From 0cf357313bc9edb9fca6fc76bb002eb9768195b9 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Sat, 5 Aug 2023 01:37:25 +0000 Subject: [PATCH] CodeGen from PR 25192 in Azure/azure-rest-api-specs Merge 8e6fe97eb2cd166f8f164a41f3046d41daa67e0f into 0baf811c3c76c87b3c127d098519bd97141222dd --- .../reservations/armreservations/CHANGELOG.md | 4 + .../reservations/armreservations/autorest.md | 6 +- .../azurereservationapi_client.go | 14 +- ...azurereservationapi_client_example_test.go | 235 ----- .../calculateexchange_client.go | 21 +- .../calculateexchange_client_example_test.go | 188 ---- .../armreservations/calculaterefund_client.go | 19 +- .../calculaterefund_client_example_test.go | 97 -- .../armreservations/client_factory.go | 43 +- .../reservations/armreservations/constants.go | 5 +- .../reservations/armreservations/date_type.go | 3 +- .../armreservations/exchange_client.go | 21 +- .../exchange_client_example_test.go | 151 --- .../reservations/armreservations/go.mod | 20 +- .../reservations/armreservations/go.sum | 38 +- .../reservations/armreservations/models.go | 199 +--- .../armreservations/models_serde.go | 3 +- .../armreservations/operation_client.go | 3 +- .../operation_client_example_test.go | 136 --- .../reservations/armreservations/options.go | 219 ++++ .../armreservations/quota_client.go | 50 +- .../quota_client_example_test.go | 449 -------- .../quotarequeststatus_client.go | 14 +- .../quotarequeststatus_client_example_test.go | 284 ----- .../armreservations/reservation_client.go | 102 +- .../reservation_client_example_test.go | 997 ------------------ .../reservationorder_client.go | 64 +- .../reservationorder_client_example_test.go | 472 --------- .../armreservations/response_types.go | 29 +- .../armreservations/return_client.go | 21 +- .../return_client_example_test.go | 74 -- .../armreservations/time_rfc3339.go | 3 +- 32 files changed, 505 insertions(+), 3479 deletions(-) delete mode 100644 sdk/resourcemanager/reservations/armreservations/azurereservationapi_client_example_test.go delete mode 100644 sdk/resourcemanager/reservations/armreservations/calculateexchange_client_example_test.go delete mode 100644 sdk/resourcemanager/reservations/armreservations/calculaterefund_client_example_test.go delete mode 100644 sdk/resourcemanager/reservations/armreservations/exchange_client_example_test.go delete mode 100644 sdk/resourcemanager/reservations/armreservations/operation_client_example_test.go create mode 100644 sdk/resourcemanager/reservations/armreservations/options.go delete mode 100644 sdk/resourcemanager/reservations/armreservations/quota_client_example_test.go delete mode 100644 sdk/resourcemanager/reservations/armreservations/quotarequeststatus_client_example_test.go delete mode 100644 sdk/resourcemanager/reservations/armreservations/reservation_client_example_test.go delete mode 100644 sdk/resourcemanager/reservations/armreservations/reservationorder_client_example_test.go delete mode 100644 sdk/resourcemanager/reservations/armreservations/return_client_example_test.go diff --git a/sdk/resourcemanager/reservations/armreservations/CHANGELOG.md b/sdk/resourcemanager/reservations/armreservations/CHANGELOG.md index 0f77c9054444..98f2d2a9f6bd 100644 --- a/sdk/resourcemanager/reservations/armreservations/CHANGELOG.md +++ b/sdk/resourcemanager/reservations/armreservations/CHANGELOG.md @@ -1,5 +1,9 @@ # Release History +## 3.0.2 (2023-08-05) +### Other Changes + + ## 3.0.1 (2023-04-14) ### Bug Fixes diff --git a/sdk/resourcemanager/reservations/armreservations/autorest.md b/sdk/resourcemanager/reservations/armreservations/autorest.md index be7e544187f8..d64e22a2b507 100644 --- a/sdk/resourcemanager/reservations/armreservations/autorest.md +++ b/sdk/resourcemanager/reservations/armreservations/autorest.md @@ -5,9 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/1e7b408f3323e7f5424745718fe62c7a043a2337/specification/reservations/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/1e7b408f3323e7f5424745718fe62c7a043a2337/specification/reservations/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/reservations/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/reservations/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 3.0.1 +module-version: 3.0.2 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/reservations/armreservations/azurereservationapi_client.go b/sdk/resourcemanager/reservations/armreservations/azurereservationapi_client.go index b0e7daac84f1..1a0017f67d86 100644 --- a/sdk/resourcemanager/reservations/armreservations/azurereservationapi_client.go +++ b/sdk/resourcemanager/reservations/armreservations/azurereservationapi_client.go @@ -3,9 +3,8 @@ // 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. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armreservations @@ -51,18 +50,21 @@ func NewAzureReservationAPIClient(credential azcore.TokenCredential, options *ar // - options - AzureReservationAPIClientGetAppliedReservationListOptions contains the optional parameters for the AzureReservationAPIClient.GetAppliedReservationList // method. func (client *AzureReservationAPIClient) GetAppliedReservationList(ctx context.Context, subscriptionID string, options *AzureReservationAPIClientGetAppliedReservationListOptions) (AzureReservationAPIClientGetAppliedReservationListResponse, error) { + var err error req, err := client.getAppliedReservationListCreateRequest(ctx, subscriptionID, options) if err != nil { return AzureReservationAPIClientGetAppliedReservationListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return AzureReservationAPIClientGetAppliedReservationListResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return AzureReservationAPIClientGetAppliedReservationListResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AzureReservationAPIClientGetAppliedReservationListResponse{}, err } - return client.getAppliedReservationListHandleResponse(resp) + resp, err := client.getAppliedReservationListHandleResponse(httpResp) + return resp, err } // getAppliedReservationListCreateRequest creates the GetAppliedReservationList request. diff --git a/sdk/resourcemanager/reservations/armreservations/azurereservationapi_client_example_test.go b/sdk/resourcemanager/reservations/armreservations/azurereservationapi_client_example_test.go deleted file mode 100644 index dc1390b5567b..000000000000 --- a/sdk/resourcemanager/reservations/armreservations/azurereservationapi_client_example_test.go +++ /dev/null @@ -1,235 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armreservations_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/reservations/armreservations/v3" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/1e7b408f3323e7f5424745718fe62c7a043a2337/specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/GetCatalog.json -func ExampleAzureReservationAPIClient_NewGetCatalogPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armreservations.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewAzureReservationAPIClient().NewGetCatalogPager("23bc208b-083f-4901-ae85-4f98c0c3b4b6", &armreservations.AzureReservationAPIClientGetCatalogOptions{ReservedResourceType: to.Ptr("VirtualMachines"), - Location: to.Ptr("eastus"), - PublisherID: nil, - OfferID: nil, - PlanID: nil, - Filter: nil, - Skip: nil, - Take: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.CatalogsResult = armreservations.CatalogsResult{ - // TotalItems: to.Ptr[int64](1000), - // Value: []*armreservations.Catalog{ - // { - // Name: to.Ptr("Standard_DS5_v2"), - // BillingPlans: map[string][]*armreservations.ReservationBillingPlan{ - // "P1Y": []*armreservations.ReservationBillingPlan{ - // to.Ptr(armreservations.ReservationBillingPlanUpfront), - // to.Ptr(armreservations.ReservationBillingPlanMonthly)}, - // "P3Y": []*armreservations.ReservationBillingPlan{ - // to.Ptr(armreservations.ReservationBillingPlanUpfront), - // to.Ptr(armreservations.ReservationBillingPlanMonthly)}, - // }, - // Locations: []*string{ - // to.Ptr("eastus")}, - // ResourceType: to.Ptr("VirtualMachines"), - // Restrictions: []*armreservations.SKURestriction{ - // }, - // SKUProperties: []*armreservations.SKUProperty{ - // { - // Name: to.Ptr("Cores"), - // Value: to.Ptr("16"), - // }, - // { - // Name: to.Ptr("ProductTitle"), - // Value: to.Ptr("DSv2 Series, DS5"), - // }, - // { - // Name: to.Ptr("ProductShortName"), - // Value: to.Ptr("DSv2 Series"), - // }, - // { - // Name: to.Ptr("SKUName"), - // Value: to.Ptr("DS5 v2"), - // }, - // { - // Name: to.Ptr("MeterId"), - // Value: to.Ptr("12bc208b-083f-4901-ae85-4f98c0c3b4b8"), - // }}, - // Terms: []*armreservations.ReservationTerm{ - // to.Ptr(armreservations.ReservationTermP1Y), - // to.Ptr(armreservations.ReservationTermP3Y)}, - // }, - // { - // Name: to.Ptr("Standard_D1"), - // BillingPlans: map[string][]*armreservations.ReservationBillingPlan{ - // "P1Y": []*armreservations.ReservationBillingPlan{ - // to.Ptr(armreservations.ReservationBillingPlanUpfront), - // to.Ptr(armreservations.ReservationBillingPlanMonthly)}, - // "P3Y": []*armreservations.ReservationBillingPlan{ - // to.Ptr(armreservations.ReservationBillingPlanUpfront), - // to.Ptr(armreservations.ReservationBillingPlanMonthly)}, - // }, - // Locations: []*string{ - // to.Ptr("eastus")}, - // ResourceType: to.Ptr("VirtualMachines"), - // Restrictions: []*armreservations.SKURestriction{ - // { - // Type: to.Ptr("Term"), - // ReasonCode: to.Ptr("NotAvailableForSubscription"), - // Values: []*string{ - // to.Ptr("P1Y")}, - // }, - // { - // Type: to.Ptr("Term"), - // ReasonCode: to.Ptr("NotAvailableForSubscription"), - // Values: []*string{ - // to.Ptr("P3Y")}, - // }}, - // SKUProperties: []*armreservations.SKUProperty{ - // { - // Name: to.Ptr("Cores"), - // Value: to.Ptr("1"), - // }, - // { - // Name: to.Ptr("ProductTitle"), - // Value: to.Ptr("D Series, D1"), - // }, - // { - // Name: to.Ptr("ProductShortName"), - // Value: to.Ptr("D Series"), - // }, - // { - // Name: to.Ptr("SKUName"), - // Value: to.Ptr("D1"), - // }, - // { - // Name: to.Ptr("MeterId"), - // Value: to.Ptr("12bc208b-083f-4901-ae85-4f98c0c3b4b8"), - // }}, - // Terms: []*armreservations.ReservationTerm{ - // to.Ptr(armreservations.ReservationTermP1Y), - // to.Ptr(armreservations.ReservationTermP3Y)}, - // }, - // { - // Name: to.Ptr("Standard_F2"), - // BillingPlans: map[string][]*armreservations.ReservationBillingPlan{ - // "P1Y": []*armreservations.ReservationBillingPlan{ - // to.Ptr(armreservations.ReservationBillingPlanUpfront), - // to.Ptr(armreservations.ReservationBillingPlanMonthly)}, - // "P3Y": []*armreservations.ReservationBillingPlan{ - // to.Ptr(armreservations.ReservationBillingPlanUpfront), - // to.Ptr(armreservations.ReservationBillingPlanMonthly)}, - // }, - // Locations: []*string{ - // to.Ptr("eastus")}, - // ResourceType: to.Ptr("VirtualMachines"), - // Restrictions: []*armreservations.SKURestriction{ - // { - // Type: to.Ptr("Location"), - // ReasonCode: to.Ptr("NotAvailableForSubscription"), - // Values: []*string{ - // to.Ptr("eastus")}, - // }}, - // SKUProperties: []*armreservations.SKUProperty{ - // { - // Name: to.Ptr("Cores"), - // Value: to.Ptr("2"), - // }, - // { - // Name: to.Ptr("ProductTitle"), - // Value: to.Ptr("F Series, F2"), - // }, - // { - // Name: to.Ptr("ProductShortName"), - // Value: to.Ptr("F Series"), - // }, - // { - // Name: to.Ptr("SKUName"), - // Value: to.Ptr("F2"), - // }, - // { - // Name: to.Ptr("MeterId"), - // Value: to.Ptr("12bc208b-083f-4901-ae85-4f98c0c3b4b8"), - // }}, - // Terms: []*armreservations.ReservationTerm{ - // to.Ptr(armreservations.ReservationTermP1Y), - // to.Ptr(armreservations.ReservationTermP3Y)}, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/1e7b408f3323e7f5424745718fe62c7a043a2337/specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/GetAppliedReservations.json -func ExampleAzureReservationAPIClient_GetAppliedReservationList() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armreservations.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAzureReservationAPIClient().GetAppliedReservationList(ctx, "23bc208b-083f-4901-ae85-4f98c0c3b4b6", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.AppliedReservations = armreservations.AppliedReservations{ - // Name: to.Ptr("default"), - // Type: to.Ptr("Microsoft.Capacity/AppliedReservations"), - // ID: to.Ptr("/subscriptions/23bc208b-083f-4901-ae85-4f98c0c3b4b6/providers/microsoft.capacity/AppliedReservations/default"), - // Properties: &armreservations.AppliedReservationsProperties{ - // ReservationOrderIDs: &armreservations.AppliedReservationList{ - // Value: []*string{ - // to.Ptr("/providers/Microsoft.Capacity/reservationorders/e1eccf0b-2db4-4e84-97e7-98b50e9d46f7"), - // to.Ptr("/providers/Microsoft.Capacity/reservationorders/741a32eb-6158-4cee-9642-a0243ae79fac"), - // to.Ptr("/providers/Microsoft.Capacity/reservationorders/e061223d-fcff-4d10-bd49-56a740cfb96a"), - // to.Ptr("/providers/Microsoft.Capacity/reservationorders/2eeb7234-970e-4663-b60b-85241b515901"), - // to.Ptr("/providers/Microsoft.Capacity/reservationorders/9db2f4c5-b1c5-42a8-bd79-ee56cdde2c7f"), - // to.Ptr("/providers/Microsoft.Capacity/reservationorders/5da7a877-6d6e-44af-8880-ed3f533bf928"), - // to.Ptr("/providers/Microsoft.Capacity/reservationorders/f65b0d0a-f945-4105-821c-d00bc8bacde8"), - // to.Ptr("/providers/Microsoft.Capacity/reservationorders/51304124-e477-4b07-b9fa-03b05c8b924b"), - // to.Ptr("/providers/Microsoft.Capacity/reservationorders/f5409b98-8a42-4dc6-be0a-cc59bef4d0db"), - // to.Ptr("/providers/Microsoft.Capacity/reservationorders/a495550a-80a4-46f8-8843-34d4df46f9a6"), - // to.Ptr("/providers/Microsoft.Capacity/reservationorders/1a966e18-c272-4ce1-a0c2-d4e1039023c3"), - // to.Ptr("/providers/Microsoft.Capacity/reservationorders/939310b4-f9de-4645-9569-ab5b6cfe958e"), - // to.Ptr("/providers/Microsoft.Capacity/reservationorders/4193a889-7c3b-44dc-8b7b-bfd7aad6c723")}, - // }, - // }, - // } -} diff --git a/sdk/resourcemanager/reservations/armreservations/calculateexchange_client.go b/sdk/resourcemanager/reservations/armreservations/calculateexchange_client.go index b96eefa7ddca..baff5c3414ff 100644 --- a/sdk/resourcemanager/reservations/armreservations/calculateexchange_client.go +++ b/sdk/resourcemanager/reservations/armreservations/calculateexchange_client.go @@ -3,9 +3,8 @@ // 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. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armreservations @@ -51,9 +50,10 @@ func (client *CalculateExchangeClient) BeginPost(ctx context.Context, body Calcu if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CalculateExchangeClientPostResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[CalculateExchangeClientPostResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[CalculateExchangeClientPostResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -64,18 +64,20 @@ func (client *CalculateExchangeClient) BeginPost(ctx context.Context, body Calcu // // Generated from API version 2022-11-01 func (client *CalculateExchangeClient) post(ctx context.Context, body CalculateExchangeRequest, options *CalculateExchangeClientBeginPostOptions) (*http.Response, error) { + var err error req, err := client.postCreateRequest(ctx, body, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // postCreateRequest creates the Post request. @@ -89,5 +91,8 @@ func (client *CalculateExchangeClient) postCreateRequest(ctx context.Context, bo reqQP.Set("api-version", "2022-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil } diff --git a/sdk/resourcemanager/reservations/armreservations/calculateexchange_client_example_test.go b/sdk/resourcemanager/reservations/armreservations/calculateexchange_client_example_test.go deleted file mode 100644 index 7ab668404e6b..000000000000 --- a/sdk/resourcemanager/reservations/armreservations/calculateexchange_client_example_test.go +++ /dev/null @@ -1,188 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armreservations_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/reservations/armreservations/v3" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/1e7b408f3323e7f5424745718fe62c7a043a2337/specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/CalculateExchange.json -func ExampleCalculateExchangeClient_BeginPost() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armreservations.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewCalculateExchangeClient().BeginPost(ctx, armreservations.CalculateExchangeRequest{ - Properties: &armreservations.CalculateExchangeRequestProperties{ - ReservationsToExchange: []*armreservations.ReservationToReturn{ - { - Quantity: to.Ptr[int32](1), - ReservationID: to.Ptr("/providers/microsoft.capacity/reservationOrders/1f14354c-dc12-4c8d-8090-6f295a3a34aa/reservations/c8c926bd-fc5d-4e29-9d43-b68340ac23a6"), - }}, - ReservationsToPurchase: []*armreservations.PurchaseRequest{ - { - Location: to.Ptr("westus"), - Properties: &armreservations.PurchaseRequestProperties{ - AppliedScopeType: to.Ptr(armreservations.AppliedScopeTypeShared), - BillingPlan: to.Ptr(armreservations.ReservationBillingPlanUpfront), - BillingScopeID: to.Ptr("/subscriptions/ed3a1871-612d-abcd-a849-c2542a68be83"), - DisplayName: to.Ptr("testDisplayName"), - Quantity: to.Ptr[int32](1), - Renew: to.Ptr(false), - ReservedResourceProperties: &armreservations.PurchaseRequestPropertiesReservedResourceProperties{ - InstanceFlexibility: to.Ptr(armreservations.InstanceFlexibilityOn), - }, - ReservedResourceType: to.Ptr(armreservations.ReservedResourceTypeVirtualMachines), - Term: to.Ptr(armreservations.ReservationTermP1Y), - }, - SKU: &armreservations.SKUName{ - Name: to.Ptr("Standard_B1ls"), - }, - }}, - SavingsPlansToPurchase: []*armreservations.SavingsPlanPurchaseRequest{ - { - Properties: &armreservations.SavingsPlanPurchaseRequestProperties{ - AppliedScopeProperties: &armreservations.AppliedScopeProperties{ - ResourceGroupID: to.Ptr("/subscriptions/10000000-0000-0000-0000-000000000000/resourceGroups/testrg"), - }, - AppliedScopeType: to.Ptr(armreservations.AppliedScopeTypeSingle), - BillingScopeID: to.Ptr("/subscriptions/10000000-0000-0000-0000-000000000000"), - Commitment: &armreservations.Commitment{ - Amount: to.Ptr[float64](15.23), - CurrencyCode: to.Ptr("USD"), - Grain: to.Ptr(armreservations.CommitmentGrainHourly), - }, - DisplayName: to.Ptr("ComputeSavingsPlan"), - Term: to.Ptr(armreservations.SavingsPlanTermP1Y), - }, - SKU: &armreservations.SKUName{ - Name: to.Ptr("Compute_Savings_Plan"), - }, - }}, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.CalculateExchangeOperationResultResponse = armreservations.CalculateExchangeOperationResultResponse{ - // Name: to.Ptr("4e2ffff7-b331-4fcb-ab11-b5fa49368188"), - // ID: to.Ptr("/providers/microsoft.capacity/operationResults/4e2ffff7-b331-4fcb-ab11-b5fa49368188"), - // Properties: &armreservations.CalculateExchangeResponseProperties{ - // NetPayable: &armreservations.Price{ - // Amount: to.Ptr[float64](149254.8), - // CurrencyCode: to.Ptr("USD"), - // }, - // PolicyResult: &armreservations.ExchangePolicyErrors{ - // }, - // PurchasesTotal: &armreservations.Price{ - // Amount: to.Ptr[float64](153214.8), - // CurrencyCode: to.Ptr("USD"), - // }, - // RefundsTotal: &armreservations.Price{ - // Amount: to.Ptr[float64](3960), - // CurrencyCode: to.Ptr("USD"), - // }, - // ReservationsToExchange: []*armreservations.ReservationToExchange{ - // { - // BillingInformation: &armreservations.BillingInformation{ - // BillingCurrencyProratedAmount: &armreservations.Price{ - // Amount: to.Ptr[float64](149254.8), - // CurrencyCode: to.Ptr("USD"), - // }, - // BillingCurrencyRemainingCommitmentAmount: &armreservations.Price{ - // Amount: to.Ptr[float64](0), - // CurrencyCode: to.Ptr("USD"), - // }, - // BillingCurrencyTotalPaidAmount: &armreservations.Price{ - // Amount: to.Ptr[float64](153214.8), - // CurrencyCode: to.Ptr("USD"), - // }, - // }, - // BillingRefundAmount: &armreservations.Price{ - // Amount: to.Ptr[float64](3960), - // CurrencyCode: to.Ptr("USD"), - // }, - // Quantity: to.Ptr[int32](1), - // ReservationID: to.Ptr("/providers/microsoft.capacity/reservationOrders/1f14354c-dc12-4c8d-8090-6f295a3a34aa/reservations/c8c926bd-fc5d-4e29-9d43-b68340ac23a6"), - // }}, - // ReservationsToPurchase: []*armreservations.ReservationToPurchaseCalculateExchange{ - // { - // BillingCurrencyTotal: &armreservations.Price{ - // Amount: to.Ptr[float64](19800), - // CurrencyCode: to.Ptr("USD"), - // }, - // Properties: &armreservations.PurchaseRequest{ - // Location: to.Ptr("westus"), - // Properties: &armreservations.PurchaseRequestProperties{ - // AppliedScopeType: to.Ptr(armreservations.AppliedScopeTypeShared), - // BillingPlan: to.Ptr(armreservations.ReservationBillingPlanUpfront), - // BillingScopeID: to.Ptr("/subscriptions/ed3a1871-612d-abcd-a849-c2542a68be83"), - // DisplayName: to.Ptr("testDisplayName"), - // Quantity: to.Ptr[int32](1), - // Renew: to.Ptr(false), - // ReservedResourceProperties: &armreservations.PurchaseRequestPropertiesReservedResourceProperties{ - // InstanceFlexibility: to.Ptr(armreservations.InstanceFlexibilityOn), - // }, - // ReservedResourceType: to.Ptr(armreservations.ReservedResourceTypeVirtualMachines), - // Term: to.Ptr(armreservations.ReservationTermP1Y), - // }, - // SKU: &armreservations.SKUName{ - // Name: to.Ptr("Standard_B1ls"), - // }, - // }, - // }}, - // SavingsPlansToPurchase: []*armreservations.SavingsPlanToPurchaseCalculateExchange{ - // { - // BillingCurrencyTotal: &armreservations.Price{ - // Amount: to.Ptr[float64](133414.8), - // CurrencyCode: to.Ptr("USD"), - // }, - // Properties: &armreservations.SavingsPlanPurchaseRequest{ - // Properties: &armreservations.SavingsPlanPurchaseRequestProperties{ - // AppliedScopeProperties: &armreservations.AppliedScopeProperties{ - // ResourceGroupID: to.Ptr("/subscriptions/10000000-0000-0000-0000-000000000000/resourceGroups/testrg"), - // }, - // AppliedScopeType: to.Ptr(armreservations.AppliedScopeTypeSingle), - // BillingScopeID: to.Ptr("/subscriptions/10000000-0000-0000-0000-000000000000"), - // Commitment: &armreservations.Commitment{ - // Amount: to.Ptr[float64](15.23), - // CurrencyCode: to.Ptr("USD"), - // Grain: to.Ptr(armreservations.CommitmentGrainHourly), - // }, - // DisplayName: to.Ptr("ComputeSavingsPlan"), - // Term: to.Ptr(armreservations.SavingsPlanTermP1Y), - // }, - // SKU: &armreservations.SKUName{ - // Name: to.Ptr("Compute_Savings_Plan"), - // }, - // }, - // }}, - // SessionID: to.Ptr("66e2ac8f-439e-4345-8235-6fef07608081"), - // }, - // Status: to.Ptr(armreservations.CalculateExchangeOperationResultStatusSucceeded), - // } -} diff --git a/sdk/resourcemanager/reservations/armreservations/calculaterefund_client.go b/sdk/resourcemanager/reservations/armreservations/calculaterefund_client.go index 31140fda3a77..f25089448afa 100644 --- a/sdk/resourcemanager/reservations/armreservations/calculaterefund_client.go +++ b/sdk/resourcemanager/reservations/armreservations/calculaterefund_client.go @@ -3,9 +3,8 @@ // 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. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armreservations @@ -49,18 +48,21 @@ func NewCalculateRefundClient(credential azcore.TokenCredential, options *arm.Cl // - body - Information needed for calculating refund of a reservation. // - options - CalculateRefundClientPostOptions contains the optional parameters for the CalculateRefundClient.Post method. func (client *CalculateRefundClient) Post(ctx context.Context, reservationOrderID string, body CalculateRefundRequest, options *CalculateRefundClientPostOptions) (CalculateRefundClientPostResponse, error) { + var err error req, err := client.postCreateRequest(ctx, reservationOrderID, body, options) if err != nil { return CalculateRefundClientPostResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return CalculateRefundClientPostResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return CalculateRefundClientPostResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return CalculateRefundClientPostResponse{}, err } - return client.postHandleResponse(resp) + resp, err := client.postHandleResponse(httpResp) + return resp, err } // postCreateRequest creates the Post request. @@ -78,7 +80,10 @@ func (client *CalculateRefundClient) postCreateRequest(ctx context.Context, rese reqQP.Set("api-version", "2022-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil } // postHandleResponse handles the Post response. diff --git a/sdk/resourcemanager/reservations/armreservations/calculaterefund_client_example_test.go b/sdk/resourcemanager/reservations/armreservations/calculaterefund_client_example_test.go deleted file mode 100644 index 99929502e8c9..000000000000 --- a/sdk/resourcemanager/reservations/armreservations/calculaterefund_client_example_test.go +++ /dev/null @@ -1,97 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armreservations_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/reservations/armreservations/v3" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/1e7b408f3323e7f5424745718fe62c7a043a2337/specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/CalculateRefund.json -func ExampleCalculateRefundClient_Post() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armreservations.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewCalculateRefundClient().Post(ctx, "276e7ae4-84d0-4da6-ab4b-d6b94f3557da", armreservations.CalculateRefundRequest{ - ID: to.Ptr("/providers/microsoft.capacity/reservationOrders/50000000-aaaa-bbbb-cccc-100000000004"), - Properties: &armreservations.CalculateRefundRequestProperties{ - ReservationToReturn: &armreservations.ReservationToReturn{ - Quantity: to.Ptr[int32](1), - ReservationID: to.Ptr("/providers/microsoft.capacity/reservationOrders/50000000-aaaa-bbbb-cccc-100000000004/reservations/40000000-aaaa-bbbb-cccc-100000000000"), - }, - Scope: to.Ptr("Reservation"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.CalculateRefundResponse = armreservations.CalculateRefundResponse{ - // ID: to.Ptr("/providers/Microsoft.Capacity/reservationOrders/50000000-aaaa-bbbb-cccc-100000000004/reservations/40000000-aaaa-bbbb-cccc-100000000000"), - // Properties: &armreservations.RefundResponseProperties{ - // BillingInformation: &armreservations.RefundBillingInformation{ - // BillingCurrencyProratedAmount: &armreservations.Price{ - // Amount: to.Ptr[float64](3.28), - // CurrencyCode: to.Ptr("GBP"), - // }, - // BillingCurrencyRemainingCommitmentAmount: &armreservations.Price{ - // Amount: to.Ptr[float64](0), - // CurrencyCode: to.Ptr("GBP"), - // }, - // BillingCurrencyTotalPaidAmount: &armreservations.Price{ - // Amount: to.Ptr[float64](24), - // CurrencyCode: to.Ptr("GBP"), - // }, - // BillingPlan: to.Ptr(armreservations.ReservationBillingPlanUpfront), - // CompletedTransactions: to.Ptr[int32](1), - // TotalTransactions: to.Ptr[int32](1), - // }, - // BillingRefundAmount: &armreservations.Price{ - // Amount: to.Ptr[float64](20.72), - // CurrencyCode: to.Ptr("GBP"), - // }, - // PolicyResult: &armreservations.RefundPolicyResult{ - // Properties: &armreservations.RefundPolicyResultProperty{ - // ConsumedRefundsTotal: &armreservations.Price{ - // Amount: to.Ptr[float64](83.69), - // CurrencyCode: to.Ptr("USD"), - // }, - // MaxRefundLimit: &armreservations.Price{ - // Amount: to.Ptr[float64](50000), - // CurrencyCode: to.Ptr("USD"), - // }, - // PolicyErrors: []*armreservations.RefundPolicyError{ - // { - // Code: to.Ptr(armreservations.ErrorResponseCodeSelfServiceRefundNotSupported), - // Message: to.Ptr("Self Service refunds are currently not supported for this resource, please contact support."), - // }}, - // }, - // }, - // PricingRefundAmount: &armreservations.Price{ - // Amount: to.Ptr[float64](24.92), - // CurrencyCode: to.Ptr("USD"), - // }, - // Quantity: to.Ptr[int32](1), - // SessionID: to.Ptr("10000000-aaaa-bbbb-cccc-200000000000"), - // }, - // } -} diff --git a/sdk/resourcemanager/reservations/armreservations/client_factory.go b/sdk/resourcemanager/reservations/armreservations/client_factory.go index 40dca0094b3a..4cc06fc0d941 100644 --- a/sdk/resourcemanager/reservations/armreservations/client_factory.go +++ b/sdk/resourcemanager/reservations/armreservations/client_factory.go @@ -3,9 +3,8 @@ // 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. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armreservations @@ -36,52 +35,52 @@ func NewClientFactory(credential azcore.TokenCredential, options *arm.ClientOpti }, nil } -func (c *ClientFactory) NewReservationClient() *ReservationClient { - subClient, _ := NewReservationClient(c.credential, c.options) +func (c *ClientFactory) NewAzureReservationAPIClient() *AzureReservationAPIClient { + subClient, _ := NewAzureReservationAPIClient(c.credential, c.options) return subClient } -func (c *ClientFactory) NewAzureReservationAPIClient() *AzureReservationAPIClient { - subClient, _ := NewAzureReservationAPIClient(c.credential, c.options) +func (c *ClientFactory) NewCalculateExchangeClient() *CalculateExchangeClient { + subClient, _ := NewCalculateExchangeClient(c.credential, c.options) return subClient } -func (c *ClientFactory) NewReservationOrderClient() *ReservationOrderClient { - subClient, _ := NewReservationOrderClient(c.credential, c.options) +func (c *ClientFactory) NewCalculateRefundClient() *CalculateRefundClient { + subClient, _ := NewCalculateRefundClient(c.credential, c.options) return subClient } -func (c *ClientFactory) NewOperationClient() *OperationClient { - subClient, _ := NewOperationClient(c.credential, c.options) +func (c *ClientFactory) NewExchangeClient() *ExchangeClient { + subClient, _ := NewExchangeClient(c.credential, c.options) return subClient } -func (c *ClientFactory) NewCalculateRefundClient() *CalculateRefundClient { - subClient, _ := NewCalculateRefundClient(c.credential, c.options) +func (c *ClientFactory) NewOperationClient() *OperationClient { + subClient, _ := NewOperationClient(c.credential, c.options) return subClient } -func (c *ClientFactory) NewReturnClient() *ReturnClient { - subClient, _ := NewReturnClient(c.credential, c.options) +func (c *ClientFactory) NewQuotaClient() *QuotaClient { + subClient, _ := NewQuotaClient(c.credential, c.options) return subClient } -func (c *ClientFactory) NewCalculateExchangeClient() *CalculateExchangeClient { - subClient, _ := NewCalculateExchangeClient(c.credential, c.options) +func (c *ClientFactory) NewQuotaRequestStatusClient() *QuotaRequestStatusClient { + subClient, _ := NewQuotaRequestStatusClient(c.credential, c.options) return subClient } -func (c *ClientFactory) NewExchangeClient() *ExchangeClient { - subClient, _ := NewExchangeClient(c.credential, c.options) +func (c *ClientFactory) NewReservationClient() *ReservationClient { + subClient, _ := NewReservationClient(c.credential, c.options) return subClient } -func (c *ClientFactory) NewQuotaClient() *QuotaClient { - subClient, _ := NewQuotaClient(c.credential, c.options) +func (c *ClientFactory) NewReservationOrderClient() *ReservationOrderClient { + subClient, _ := NewReservationOrderClient(c.credential, c.options) return subClient } -func (c *ClientFactory) NewQuotaRequestStatusClient() *QuotaRequestStatusClient { - subClient, _ := NewQuotaRequestStatusClient(c.credential, c.options) +func (c *ClientFactory) NewReturnClient() *ReturnClient { + subClient, _ := NewReturnClient(c.credential, c.options) return subClient } diff --git a/sdk/resourcemanager/reservations/armreservations/constants.go b/sdk/resourcemanager/reservations/armreservations/constants.go index aa32bfe0071e..c29faf1a8780 100644 --- a/sdk/resourcemanager/reservations/armreservations/constants.go +++ b/sdk/resourcemanager/reservations/armreservations/constants.go @@ -3,15 +3,14 @@ // 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. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armreservations const ( moduleName = "armreservations" - moduleVersion = "v3.0.1" + moduleVersion = "v3.0.2" ) // AppliedScopeType - Type of the Applied Scope. diff --git a/sdk/resourcemanager/reservations/armreservations/date_type.go b/sdk/resourcemanager/reservations/armreservations/date_type.go index dc1137638a16..e9f4b6f6e095 100644 --- a/sdk/resourcemanager/reservations/armreservations/date_type.go +++ b/sdk/resourcemanager/reservations/armreservations/date_type.go @@ -3,9 +3,8 @@ // 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. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armreservations diff --git a/sdk/resourcemanager/reservations/armreservations/exchange_client.go b/sdk/resourcemanager/reservations/armreservations/exchange_client.go index 3176386a3e25..c2741d8ec4ee 100644 --- a/sdk/resourcemanager/reservations/armreservations/exchange_client.go +++ b/sdk/resourcemanager/reservations/armreservations/exchange_client.go @@ -3,9 +3,8 @@ // 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. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armreservations @@ -50,9 +49,10 @@ func (client *ExchangeClient) BeginPost(ctx context.Context, body ExchangeReques if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ExchangeClientPostResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ExchangeClientPostResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[ExchangeClientPostResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -63,18 +63,20 @@ func (client *ExchangeClient) BeginPost(ctx context.Context, body ExchangeReques // // Generated from API version 2022-11-01 func (client *ExchangeClient) post(ctx context.Context, body ExchangeRequest, options *ExchangeClientBeginPostOptions) (*http.Response, error) { + var err error req, err := client.postCreateRequest(ctx, body, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // postCreateRequest creates the Post request. @@ -88,5 +90,8 @@ func (client *ExchangeClient) postCreateRequest(ctx context.Context, body Exchan reqQP.Set("api-version", "2022-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil } diff --git a/sdk/resourcemanager/reservations/armreservations/exchange_client_example_test.go b/sdk/resourcemanager/reservations/armreservations/exchange_client_example_test.go deleted file mode 100644 index 12510814ecad..000000000000 --- a/sdk/resourcemanager/reservations/armreservations/exchange_client_example_test.go +++ /dev/null @@ -1,151 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armreservations_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/reservations/armreservations/v3" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/1e7b408f3323e7f5424745718fe62c7a043a2337/specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/Exchange.json -func ExampleExchangeClient_BeginPost() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armreservations.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewExchangeClient().BeginPost(ctx, armreservations.ExchangeRequest{ - Properties: &armreservations.ExchangeRequestProperties{ - SessionID: to.Ptr("66e2ac8f-439e-4345-8235-6fef07608081"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ExchangeOperationResultResponse = armreservations.ExchangeOperationResultResponse{ - // Name: to.Ptr("4e2ffff7-b331-4fcb-ab11-b5fa49368188"), - // ID: to.Ptr("/providers/microsoft.capacity/operationResults/4e2ffff7-b331-4fcb-ab11-b5fa49368188"), - // Properties: &armreservations.ExchangeResponseProperties{ - // NetPayable: &armreservations.Price{ - // Amount: to.Ptr[float64](149254.8), - // CurrencyCode: to.Ptr("USD"), - // }, - // PolicyResult: &armreservations.ExchangePolicyErrors{ - // }, - // PurchasesTotal: &armreservations.Price{ - // Amount: to.Ptr[float64](153214.8), - // CurrencyCode: to.Ptr("USD"), - // }, - // RefundsTotal: &armreservations.Price{ - // Amount: to.Ptr[float64](3960), - // CurrencyCode: to.Ptr("USD"), - // }, - // ReservationsToExchange: []*armreservations.ReservationToReturnForExchange{ - // { - // BillingInformation: &armreservations.BillingInformation{ - // BillingCurrencyProratedAmount: &armreservations.Price{ - // Amount: to.Ptr[float64](149254.8), - // CurrencyCode: to.Ptr("USD"), - // }, - // BillingCurrencyRemainingCommitmentAmount: &armreservations.Price{ - // Amount: to.Ptr[float64](0), - // CurrencyCode: to.Ptr("USD"), - // }, - // BillingCurrencyTotalPaidAmount: &armreservations.Price{ - // Amount: to.Ptr[float64](153214.8), - // CurrencyCode: to.Ptr("USD"), - // }, - // }, - // BillingRefundAmount: &armreservations.Price{ - // Amount: to.Ptr[float64](3960), - // CurrencyCode: to.Ptr("USD"), - // }, - // Quantity: to.Ptr[int32](1), - // ReservationID: to.Ptr("/providers/microsoft.capacity/reservationOrders/1f14354c-dc12-4c8d-8090-6f295a3a34aa/reservations/c8c926bd-fc5d-4e29-9d43-b68340ac23a6"), - // Status: to.Ptr(armreservations.OperationStatusSucceeded), - // }}, - // ReservationsToPurchase: []*armreservations.ReservationToPurchaseExchange{ - // { - // BillingCurrencyTotal: &armreservations.Price{ - // Amount: to.Ptr[float64](19800), - // CurrencyCode: to.Ptr("USD"), - // }, - // Properties: &armreservations.PurchaseRequest{ - // Location: to.Ptr("westus"), - // Properties: &armreservations.PurchaseRequestProperties{ - // AppliedScopeType: to.Ptr(armreservations.AppliedScopeTypeShared), - // BillingPlan: to.Ptr(armreservations.ReservationBillingPlanUpfront), - // BillingScopeID: to.Ptr("/subscriptions/ed3a1871-612d-abcd-a849-c2542a68be83"), - // DisplayName: to.Ptr("testDisplayName"), - // Quantity: to.Ptr[int32](1), - // Renew: to.Ptr(false), - // ReservedResourceProperties: &armreservations.PurchaseRequestPropertiesReservedResourceProperties{ - // InstanceFlexibility: to.Ptr(armreservations.InstanceFlexibilityOn), - // }, - // ReservedResourceType: to.Ptr(armreservations.ReservedResourceTypeVirtualMachines), - // Term: to.Ptr(armreservations.ReservationTermP1Y), - // }, - // SKU: &armreservations.SKUName{ - // Name: to.Ptr("Standard_B1ls"), - // }, - // }, - // ReservationID: to.Ptr("/providers/microsoft.capacity/reservationOrders/1e85c519-b815-4169-8d79-62fc460c608f/reservations/0c80fceb-305c-40a8-b5a6-11445807bbb3"), - // ReservationOrderID: to.Ptr("/providers/microsoft.capacity/reservationOrders/1e85c519-b815-4169-8d79-62fc460c608f"), - // Status: to.Ptr(armreservations.OperationStatusSucceeded), - // }}, - // SavingsPlansToPurchase: []*armreservations.SavingsPlanToPurchaseExchange{ - // { - // BillingCurrencyTotal: &armreservations.Price{ - // Amount: to.Ptr[float64](133414.8), - // CurrencyCode: to.Ptr("USD"), - // }, - // Properties: &armreservations.SavingsPlanPurchaseRequest{ - // Properties: &armreservations.SavingsPlanPurchaseRequestProperties{ - // AppliedScopeProperties: &armreservations.AppliedScopeProperties{ - // ResourceGroupID: to.Ptr("/subscriptions/10000000-0000-0000-0000-000000000000/resourceGroups/testrg"), - // }, - // AppliedScopeType: to.Ptr(armreservations.AppliedScopeTypeSingle), - // BillingScopeID: to.Ptr("/subscriptions/10000000-0000-0000-0000-000000000000"), - // Commitment: &armreservations.Commitment{ - // Amount: to.Ptr[float64](15.23), - // CurrencyCode: to.Ptr("USD"), - // Grain: to.Ptr(armreservations.CommitmentGrainHourly), - // }, - // DisplayName: to.Ptr("ComputeSavingsPlan"), - // Term: to.Ptr(armreservations.SavingsPlanTermP1Y), - // }, - // SKU: &armreservations.SKUName{ - // Name: to.Ptr("Compute_Savings_Plan"), - // }, - // }, - // SavingsPlanID: to.Ptr("/providers/Microsoft.BillingBenefits/savingsPlanOrders/20000000-0000-0000-0000-000000000000/savingsPlans/30000000-0000-0000-0000-000000000000"), - // SavingsPlanOrderID: to.Ptr("/providers/Microsoft.BillingBenefits/savingsPlanOrders/20000000-0000-0000-0000-000000000000"), - // Status: to.Ptr(armreservations.OperationStatusSucceeded), - // }}, - // SessionID: to.Ptr("66e2ac8f-439e-4345-8235-6fef07608081"), - // }, - // Status: to.Ptr(armreservations.ExchangeOperationResultStatusSucceeded), - // } -} diff --git a/sdk/resourcemanager/reservations/armreservations/go.mod b/sdk/resourcemanager/reservations/armreservations/go.mod index 5385830d54f9..7503d54ddd40 100644 --- a/sdk/resourcemanager/reservations/armreservations/go.mod +++ b/sdk/resourcemanager/reservations/armreservations/go.mod @@ -2,20 +2,12 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/reservations/armres go 1.18 -require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1 require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect - github.com/golang-jwt/jwt/v4 v4.5.0 // indirect - github.com/google/uuid v1.3.0 // indirect - github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect - golang.org/x/crypto v0.6.0 // indirect - golang.org/x/net v0.7.0 // indirect - golang.org/x/sys v0.5.0 // indirect - golang.org/x/text v0.7.0 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + golang.org/x/net v0.8.0 // indirect + golang.org/x/text v0.8.0 // indirect + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect ) diff --git a/sdk/resourcemanager/reservations/armreservations/go.sum b/sdk/resourcemanager/reservations/armreservations/go.sum index 8ba445a8c4da..5c6bee428364 100644 --- a/sdk/resourcemanager/reservations/armreservations/go.sum +++ b/sdk/resourcemanager/reservations/armreservations/go.sum @@ -1,31 +1,15 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= -github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1 h1:SEy2xmstIphdPwNBUi7uhvjyjhVKISfwjfOJmuy7kg4= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 h1:sXr+ck84g/ZlZUOZiNELInmMgOsuGwdjjVkEIde0OtY= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0/go.mod h1:okt5dMMTOFjX/aovMlrjvvXoPMBVSPzk9185BT0+eZM= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= -github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= -github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= -github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= -golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= -golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= -golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= +golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= +golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= +golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/reservations/armreservations/models.go b/sdk/resourcemanager/reservations/armreservations/models.go index 33bc60932867..8f3bf5201ac3 100644 --- a/sdk/resourcemanager/reservations/armreservations/models.go +++ b/sdk/resourcemanager/reservations/armreservations/models.go @@ -3,9 +3,8 @@ // 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. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armreservations @@ -75,33 +74,6 @@ type AvailableScopeRequestProperties struct { Scopes []*string } -// AzureReservationAPIClientGetAppliedReservationListOptions contains the optional parameters for the AzureReservationAPIClient.GetAppliedReservationList -// method. -type AzureReservationAPIClientGetAppliedReservationListOptions struct { - // placeholder for future optional parameters -} - -// AzureReservationAPIClientGetCatalogOptions contains the optional parameters for the AzureReservationAPIClient.NewGetCatalogPager -// method. -type AzureReservationAPIClientGetCatalogOptions struct { - // May be used to filter by Catalog properties. The filter supports 'eq', 'or', and 'and'. - Filter *string - // Filters the skus based on the location specified in this parameter. This can be an Azure region or global - Location *string - // Offer id used to get the third party products - OfferID *string - // Plan id used to get the third party products - PlanID *string - // Publisher id used to get the third party products - PublisherID *string - // The type of the resource for which the skus should be provided. - ReservedResourceType *string - // The number of reservations to skip from the list before returning results - Skip *float32 - // To number of reservations to return - Take *float32 -} - // BillingInformation - billing information type BillingInformation struct { // Pricing information containing the amount and the currency code @@ -114,12 +86,6 @@ type BillingInformation struct { BillingCurrencyTotalPaidAmount *Price } -// CalculateExchangeClientBeginPostOptions contains the optional parameters for the CalculateExchangeClient.BeginPost method. -type CalculateExchangeClientBeginPostOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - // CalculateExchangeOperationResultResponse - CalculateExchange operation result type CalculateExchangeOperationResultResponse struct { // Required if status == failed or status == canceled. @@ -242,11 +208,6 @@ type CalculatePriceResponsePropertiesPricingCurrencyTotal struct { CurrencyCode *string } -// CalculateRefundClientPostOptions contains the optional parameters for the CalculateRefundClient.Post method. -type CalculateRefundClientPostOptions struct { - // placeholder for future optional parameters -} - // CalculateRefundRequest - Request containing information needed for calculating refund. type CalculateRefundRequest struct { // Fully qualified identifier of the reservation order being returned @@ -435,12 +396,6 @@ type ExceptionResponse struct { Error *ServiceError } -// ExchangeClientBeginPostOptions contains the optional parameters for the ExchangeClient.BeginPost method. -type ExchangeClientBeginPostOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - // ExchangeOperationResultResponse - Exchange operation result type ExchangeOperationResultResponse struct { // Required if status == failed or status == canceled. @@ -547,11 +502,6 @@ type MergeRequest struct { Properties *MergeProperties } -// OperationClientListOptions contains the optional parameters for the OperationClient.NewListPager method. -type OperationClientListOptions struct { - // placeholder for future optional parameters -} - // OperationDisplay - Information about an operation type OperationDisplay struct { Description *string @@ -864,28 +814,6 @@ type PurchaseRequestPropertiesReservedResourceProperties struct { InstanceFlexibility *InstanceFlexibility } -// QuotaClientBeginCreateOrUpdateOptions contains the optional parameters for the QuotaClient.BeginCreateOrUpdate method. -type QuotaClientBeginCreateOrUpdateOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// QuotaClientBeginUpdateOptions contains the optional parameters for the QuotaClient.BeginUpdate method. -type QuotaClientBeginUpdateOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// QuotaClientGetOptions contains the optional parameters for the QuotaClient.Get method. -type QuotaClientGetOptions struct { - // placeholder for future optional parameters -} - -// QuotaClientListOptions contains the optional parameters for the QuotaClient.NewListPager method. -type QuotaClientListOptions struct { - // placeholder for future optional parameters -} - // QuotaLimits - Quota limits. type QuotaLimits struct { // The URI for fetching the next page of quotas (service limits). When no more pages exist, the value is null. @@ -1001,24 +929,6 @@ type QuotaRequestProperties struct { RequestSubmitTime *time.Time } -// QuotaRequestStatusClientGetOptions contains the optional parameters for the QuotaRequestStatusClient.Get method. -type QuotaRequestStatusClientGetOptions struct { - // placeholder for future optional parameters -} - -// QuotaRequestStatusClientListOptions contains the optional parameters for the QuotaRequestStatusClient.NewListPager method. -type QuotaRequestStatusClientListOptions struct { - // FIELD SUPPORTED OPERATORS - // requestSubmitTime ge, le, eq, gt, lt - Filter *string - // Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, - // the value of the nextLink element includes a skiptoken parameter that - // specifies a starting point to use for subsequent calls. - Skiptoken *string - // Number of records to return. - Top *int32 -} - // QuotaRequestStatusDetails - Quota request status details. type QuotaRequestStatusDetails struct { // READ-ONLY; A user friendly message. @@ -1188,78 +1098,6 @@ type RenewPropertiesResponsePricingCurrencyTotal struct { CurrencyCode *string } -// ReservationClientArchiveOptions contains the optional parameters for the ReservationClient.Archive method. -type ReservationClientArchiveOptions struct { - // placeholder for future optional parameters -} - -// ReservationClientBeginAvailableScopesOptions contains the optional parameters for the ReservationClient.BeginAvailableScopes -// method. -type ReservationClientBeginAvailableScopesOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// ReservationClientBeginMergeOptions contains the optional parameters for the ReservationClient.BeginMerge method. -type ReservationClientBeginMergeOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// ReservationClientBeginSplitOptions contains the optional parameters for the ReservationClient.BeginSplit method. -type ReservationClientBeginSplitOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// ReservationClientBeginUpdateOptions contains the optional parameters for the ReservationClient.BeginUpdate method. -type ReservationClientBeginUpdateOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// ReservationClientGetOptions contains the optional parameters for the ReservationClient.Get method. -type ReservationClientGetOptions struct { - // Supported value of this query is renewProperties - Expand *string -} - -// ReservationClientListAllOptions contains the optional parameters for the ReservationClient.NewListAllPager method. -type ReservationClientListAllOptions struct { - // May be used to filter by reservation properties. The filter supports 'eq', 'or', and 'and'. It does not currently support - // 'ne', 'gt', 'le', 'ge', or 'not'. Reservation properties include sku/name, - // properties/{appliedScopeType, archived, displayName, displayProvisioningState, effectiveDateTime, expiryDate, expiryDateTime, - // provisioningState, quantity, renew, reservedResourceType, term, - // userFriendlyAppliedScopeType, userFriendlyRenewState} - Filter *string - // May be used to sort order by reservation properties. - Orderby *string - // To indicate whether to refresh the roll up counts of the reservations group by provisioning states - RefreshSummary *string - // The selected provisioning state - SelectedState *string - // The number of reservations to skip from the list before returning results - Skiptoken *float32 - // To number of reservations to return - Take *float32 -} - -// ReservationClientListOptions contains the optional parameters for the ReservationClient.NewListPager method. -type ReservationClientListOptions struct { - // placeholder for future optional parameters -} - -// ReservationClientListRevisionsOptions contains the optional parameters for the ReservationClient.NewListRevisionsPager -// method. -type ReservationClientListRevisionsOptions struct { - // placeholder for future optional parameters -} - -// ReservationClientUnarchiveOptions contains the optional parameters for the ReservationClient.Unarchive method. -type ReservationClientUnarchiveOptions struct { - // placeholder for future optional parameters -} - // ReservationList - List of Reservations type ReservationList struct { // Url to get the next page of reservations. @@ -1289,35 +1127,6 @@ type ReservationOrderBillingPlanInformation struct { Transactions []*PaymentDetail } -// ReservationOrderClientBeginPurchaseOptions contains the optional parameters for the ReservationOrderClient.BeginPurchase -// method. -type ReservationOrderClientBeginPurchaseOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// ReservationOrderClientCalculateOptions contains the optional parameters for the ReservationOrderClient.Calculate method. -type ReservationOrderClientCalculateOptions struct { - // placeholder for future optional parameters -} - -// ReservationOrderClientChangeDirectoryOptions contains the optional parameters for the ReservationOrderClient.ChangeDirectory -// method. -type ReservationOrderClientChangeDirectoryOptions struct { - // placeholder for future optional parameters -} - -// ReservationOrderClientGetOptions contains the optional parameters for the ReservationOrderClient.Get method. -type ReservationOrderClientGetOptions struct { - // May be used to expand the planInformation. - Expand *string -} - -// ReservationOrderClientListOptions contains the optional parameters for the ReservationOrderClient.NewListPager method. -type ReservationOrderClientListOptions struct { - // placeholder for future optional parameters -} - // ReservationOrderList - List of ReservationOrders type ReservationOrderList struct { // Url to get the next page of reservationOrders. @@ -1571,12 +1380,6 @@ type ResourceName struct { LocalizedValue *string } -// ReturnClientBeginPostOptions contains the optional parameters for the ReturnClient.BeginPost method. -type ReturnClientBeginPostOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - // SKUCapability - Capability of a sku. type SKUCapability struct { // An invariant to describe the feature. diff --git a/sdk/resourcemanager/reservations/armreservations/models_serde.go b/sdk/resourcemanager/reservations/armreservations/models_serde.go index 08515f942bf1..6948617485f6 100644 --- a/sdk/resourcemanager/reservations/armreservations/models_serde.go +++ b/sdk/resourcemanager/reservations/armreservations/models_serde.go @@ -3,9 +3,8 @@ // 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. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armreservations diff --git a/sdk/resourcemanager/reservations/armreservations/operation_client.go b/sdk/resourcemanager/reservations/armreservations/operation_client.go index c8f7fd473d64..e7bec202aef9 100644 --- a/sdk/resourcemanager/reservations/armreservations/operation_client.go +++ b/sdk/resourcemanager/reservations/armreservations/operation_client.go @@ -3,9 +3,8 @@ // 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. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armreservations diff --git a/sdk/resourcemanager/reservations/armreservations/operation_client_example_test.go b/sdk/resourcemanager/reservations/armreservations/operation_client_example_test.go deleted file mode 100644 index 4aed8b4ff782..000000000000 --- a/sdk/resourcemanager/reservations/armreservations/operation_client_example_test.go +++ /dev/null @@ -1,136 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armreservations_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/reservations/armreservations/v3" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/1e7b408f3323e7f5424745718fe62c7a043a2337/specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/GetOperations.json -func ExampleOperationClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armreservations.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewOperationClient().NewListPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.OperationList = armreservations.OperationList{ - // Value: []*armreservations.OperationResponse{ - // { - // Name: to.Ptr("Microsoft.Capacity/reservationorders/read"), - // Display: &armreservations.OperationDisplay{ - // Description: to.Ptr("Read All Reservations"), - // Operation: to.Ptr("Get Reservations"), - // Provider: to.Ptr("Microsoft Capacity"), - // Resource: to.Ptr("Reservations"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.Capacity/reservationorders/write"), - // Display: &armreservations.OperationDisplay{ - // Description: to.Ptr("Create any Reservation"), - // Operation: to.Ptr("Create Reservations"), - // Provider: to.Ptr("Microsoft Capacity"), - // Resource: to.Ptr("Reservations"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.Capacity/reservationorders/action"), - // Display: &armreservations.OperationDisplay{ - // Description: to.Ptr("Update any Reservation"), - // Operation: to.Ptr("Update Reservations"), - // Provider: to.Ptr("Microsoft Capacity"), - // Resource: to.Ptr("Reservations"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.Capacity/reservationorders/delete"), - // Display: &armreservations.OperationDisplay{ - // Description: to.Ptr("Delete any Reservation"), - // Operation: to.Ptr("Delete Reservations"), - // Provider: to.Ptr("Microsoft Capacity"), - // Resource: to.Ptr("Reservations"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.Capacity/reservationorders/reservations/read"), - // Display: &armreservations.OperationDisplay{ - // Description: to.Ptr("Read All Reservations"), - // Operation: to.Ptr("Get Reservations"), - // Provider: to.Ptr("Microsoft Capacity"), - // Resource: to.Ptr("Reservations"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.Capacity/reservationorders/reservations/write"), - // Display: &armreservations.OperationDisplay{ - // Description: to.Ptr("Create any Reservation"), - // Operation: to.Ptr("Create Reservations"), - // Provider: to.Ptr("Microsoft Capacity"), - // Resource: to.Ptr("Reservations"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.Capacity/reservationorders/reservations/action"), - // Display: &armreservations.OperationDisplay{ - // Description: to.Ptr("Update any Reservation"), - // Operation: to.Ptr("Update Reservations"), - // Provider: to.Ptr("Microsoft Capacity"), - // Resource: to.Ptr("Reservations"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.Capacity/reservationorders/reservations/delete"), - // Display: &armreservations.OperationDisplay{ - // Description: to.Ptr("Delete any Reservation"), - // Operation: to.Ptr("Delete Reservations"), - // Provider: to.Ptr("Microsoft Capacity"), - // Resource: to.Ptr("Reservations"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.Capacity/reservationorders/reservations/revisions/read"), - // Display: &armreservations.OperationDisplay{ - // Description: to.Ptr("Read All Reservations"), - // Operation: to.Ptr("Get Reservations"), - // Provider: to.Ptr("Microsoft Capacity"), - // Resource: to.Ptr("Reservations"), - // }, - // }, - // { - // Name: to.Ptr("Microsoft.Capacity/register/action"), - // Display: &armreservations.OperationDisplay{ - // Description: to.Ptr("Registers the Capacity resource provider and enables the creation of Capacity resources."), - // Operation: to.Ptr("Registers the Capacity Resource Provider."), - // Provider: to.Ptr("Microsoft Capacity"), - // Resource: to.Ptr("Reservations"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/reservations/armreservations/options.go b/sdk/resourcemanager/reservations/armreservations/options.go new file mode 100644 index 000000000000..6a2d1f29ad6a --- /dev/null +++ b/sdk/resourcemanager/reservations/armreservations/options.go @@ -0,0 +1,219 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armreservations + +// AzureReservationAPIClientGetAppliedReservationListOptions contains the optional parameters for the AzureReservationAPIClient.GetAppliedReservationList +// method. +type AzureReservationAPIClientGetAppliedReservationListOptions struct { + // placeholder for future optional parameters +} + +// AzureReservationAPIClientGetCatalogOptions contains the optional parameters for the AzureReservationAPIClient.NewGetCatalogPager +// method. +type AzureReservationAPIClientGetCatalogOptions struct { + // May be used to filter by Catalog properties. The filter supports 'eq', 'or', and 'and'. + Filter *string + + // Filters the skus based on the location specified in this parameter. This can be an Azure region or global + Location *string + + // Offer id used to get the third party products + OfferID *string + + // Plan id used to get the third party products + PlanID *string + + // Publisher id used to get the third party products + PublisherID *string + + // The type of the resource for which the skus should be provided. + ReservedResourceType *string + + // The number of reservations to skip from the list before returning results + Skip *float32 + + // To number of reservations to return + Take *float32 +} + +// CalculateExchangeClientBeginPostOptions contains the optional parameters for the CalculateExchangeClient.BeginPost method. +type CalculateExchangeClientBeginPostOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// CalculateRefundClientPostOptions contains the optional parameters for the CalculateRefundClient.Post method. +type CalculateRefundClientPostOptions struct { + // placeholder for future optional parameters +} + +// ExchangeClientBeginPostOptions contains the optional parameters for the ExchangeClient.BeginPost method. +type ExchangeClientBeginPostOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// OperationClientListOptions contains the optional parameters for the OperationClient.NewListPager method. +type OperationClientListOptions struct { + // placeholder for future optional parameters +} + +// QuotaClientBeginCreateOrUpdateOptions contains the optional parameters for the QuotaClient.BeginCreateOrUpdate method. +type QuotaClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// QuotaClientBeginUpdateOptions contains the optional parameters for the QuotaClient.BeginUpdate method. +type QuotaClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// QuotaClientGetOptions contains the optional parameters for the QuotaClient.Get method. +type QuotaClientGetOptions struct { + // placeholder for future optional parameters +} + +// QuotaClientListOptions contains the optional parameters for the QuotaClient.NewListPager method. +type QuotaClientListOptions struct { + // placeholder for future optional parameters +} + +// QuotaRequestStatusClientGetOptions contains the optional parameters for the QuotaRequestStatusClient.Get method. +type QuotaRequestStatusClientGetOptions struct { + // placeholder for future optional parameters +} + +// QuotaRequestStatusClientListOptions contains the optional parameters for the QuotaRequestStatusClient.NewListPager method. +type QuotaRequestStatusClientListOptions struct { + // FIELD SUPPORTED OPERATORS + // requestSubmitTime ge, le, eq, gt, lt + Filter *string + + // Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, + // the value of the nextLink element includes a skiptoken parameter that + // specifies a starting point to use for subsequent calls. + Skiptoken *string + + // Number of records to return. + Top *int32 +} + +// ReservationClientArchiveOptions contains the optional parameters for the ReservationClient.Archive method. +type ReservationClientArchiveOptions struct { + // placeholder for future optional parameters +} + +// ReservationClientBeginAvailableScopesOptions contains the optional parameters for the ReservationClient.BeginAvailableScopes +// method. +type ReservationClientBeginAvailableScopesOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ReservationClientBeginMergeOptions contains the optional parameters for the ReservationClient.BeginMerge method. +type ReservationClientBeginMergeOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ReservationClientBeginSplitOptions contains the optional parameters for the ReservationClient.BeginSplit method. +type ReservationClientBeginSplitOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ReservationClientBeginUpdateOptions contains the optional parameters for the ReservationClient.BeginUpdate method. +type ReservationClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ReservationClientGetOptions contains the optional parameters for the ReservationClient.Get method. +type ReservationClientGetOptions struct { + // Supported value of this query is renewProperties + Expand *string +} + +// ReservationClientListAllOptions contains the optional parameters for the ReservationClient.NewListAllPager method. +type ReservationClientListAllOptions struct { + // May be used to filter by reservation properties. The filter supports 'eq', 'or', and 'and'. It does not currently support + // 'ne', 'gt', 'le', 'ge', or 'not'. Reservation properties include sku/name, + // properties/{appliedScopeType, archived, displayName, displayProvisioningState, effectiveDateTime, expiryDate, expiryDateTime, + // provisioningState, quantity, renew, reservedResourceType, term, + // userFriendlyAppliedScopeType, userFriendlyRenewState} + Filter *string + + // May be used to sort order by reservation properties. + Orderby *string + + // To indicate whether to refresh the roll up counts of the reservations group by provisioning states + RefreshSummary *string + + // The selected provisioning state + SelectedState *string + + // The number of reservations to skip from the list before returning results + Skiptoken *float32 + + // To number of reservations to return + Take *float32 +} + +// ReservationClientListOptions contains the optional parameters for the ReservationClient.NewListPager method. +type ReservationClientListOptions struct { + // placeholder for future optional parameters +} + +// ReservationClientListRevisionsOptions contains the optional parameters for the ReservationClient.NewListRevisionsPager +// method. +type ReservationClientListRevisionsOptions struct { + // placeholder for future optional parameters +} + +// ReservationClientUnarchiveOptions contains the optional parameters for the ReservationClient.Unarchive method. +type ReservationClientUnarchiveOptions struct { + // placeholder for future optional parameters +} + +// ReservationOrderClientBeginPurchaseOptions contains the optional parameters for the ReservationOrderClient.BeginPurchase +// method. +type ReservationOrderClientBeginPurchaseOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ReservationOrderClientCalculateOptions contains the optional parameters for the ReservationOrderClient.Calculate method. +type ReservationOrderClientCalculateOptions struct { + // placeholder for future optional parameters +} + +// ReservationOrderClientChangeDirectoryOptions contains the optional parameters for the ReservationOrderClient.ChangeDirectory +// method. +type ReservationOrderClientChangeDirectoryOptions struct { + // placeholder for future optional parameters +} + +// ReservationOrderClientGetOptions contains the optional parameters for the ReservationOrderClient.Get method. +type ReservationOrderClientGetOptions struct { + // May be used to expand the planInformation. + Expand *string +} + +// ReservationOrderClientListOptions contains the optional parameters for the ReservationOrderClient.NewListPager method. +type ReservationOrderClientListOptions struct { + // placeholder for future optional parameters +} + +// ReturnClientBeginPostOptions contains the optional parameters for the ReturnClient.BeginPost method. +type ReturnClientBeginPostOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} diff --git a/sdk/resourcemanager/reservations/armreservations/quota_client.go b/sdk/resourcemanager/reservations/armreservations/quota_client.go index 8027368c6219..3da3fd14c6ce 100644 --- a/sdk/resourcemanager/reservations/armreservations/quota_client.go +++ b/sdk/resourcemanager/reservations/armreservations/quota_client.go @@ -3,9 +3,8 @@ // 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. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armreservations @@ -63,9 +62,10 @@ func (client *QuotaClient) BeginCreateOrUpdate(ctx context.Context, subscription if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[QuotaClientCreateOrUpdateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[QuotaClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaOriginalURI, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[QuotaClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -80,18 +80,20 @@ func (client *QuotaClient) BeginCreateOrUpdate(ctx context.Context, subscription // // Generated from API version 2020-10-25 func (client *QuotaClient) createOrUpdate(ctx context.Context, subscriptionID string, providerID string, location string, resourceName string, createQuotaRequest CurrentQuotaLimitBase, options *QuotaClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error req, err := client.createOrUpdateCreateRequest(ctx, subscriptionID, providerID, location, resourceName, createQuotaRequest, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // createOrUpdateCreateRequest creates the CreateOrUpdate request. @@ -121,7 +123,10 @@ func (client *QuotaClient) createOrUpdateCreateRequest(ctx context.Context, subs reqQP.Set("api-version", "2020-10-25") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, createQuotaRequest) + if err := runtime.MarshalAsJSON(req, createQuotaRequest); err != nil { + return nil, err + } + return req, nil } // Get - Get the current quota (service limit) and usage of a resource. You can use the response from the GET operation to @@ -136,18 +141,21 @@ func (client *QuotaClient) createOrUpdateCreateRequest(ctx context.Context, subs // for Microsoft.MachineLearningServices // - options - QuotaClientGetOptions contains the optional parameters for the QuotaClient.Get method. func (client *QuotaClient) Get(ctx context.Context, subscriptionID string, providerID string, location string, resourceName string, options *QuotaClientGetOptions) (QuotaClientGetResponse, error) { + var err error req, err := client.getCreateRequest(ctx, subscriptionID, providerID, location, resourceName, options) if err != nil { return QuotaClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return QuotaClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return QuotaClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return QuotaClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -286,9 +294,10 @@ func (client *QuotaClient) BeginUpdate(ctx context.Context, subscriptionID strin if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[QuotaClientUpdateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[QuotaClientUpdateResponse]{ FinalStateVia: runtime.FinalStateViaOriginalURI, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[QuotaClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -302,18 +311,20 @@ func (client *QuotaClient) BeginUpdate(ctx context.Context, subscriptionID strin // // Generated from API version 2020-10-25 func (client *QuotaClient) update(ctx context.Context, subscriptionID string, providerID string, location string, resourceName string, createQuotaRequest CurrentQuotaLimitBase, options *QuotaClientBeginUpdateOptions) (*http.Response, error) { + var err error req, err := client.updateCreateRequest(ctx, subscriptionID, providerID, location, resourceName, createQuotaRequest, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // updateCreateRequest creates the Update request. @@ -343,5 +354,8 @@ func (client *QuotaClient) updateCreateRequest(ctx context.Context, subscription reqQP.Set("api-version", "2020-10-25") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, createQuotaRequest) + if err := runtime.MarshalAsJSON(req, createQuotaRequest); err != nil { + return nil, err + } + return req, nil } diff --git a/sdk/resourcemanager/reservations/armreservations/quota_client_example_test.go b/sdk/resourcemanager/reservations/armreservations/quota_client_example_test.go deleted file mode 100644 index 5b952bc4c73b..000000000000 --- a/sdk/resourcemanager/reservations/armreservations/quota_client_example_test.go +++ /dev/null @@ -1,449 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armreservations_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/reservations/armreservations/v3" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/1e7b408f3323e7f5424745718fe62c7a043a2337/specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/getComputeOneSkuUsages.json -func ExampleQuotaClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armreservations.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQuotaClient().Get(ctx, "00000000-0000-0000-0000-000000000000", "Microsoft.Compute", "eastus", "standardNDSFamily", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.CurrentQuotaLimitBase = armreservations.CurrentQuotaLimitBase{ - // Properties: &armreservations.QuotaProperties{ - // Name: &armreservations.ResourceName{ - // LocalizedValue: to.Ptr("Standard NDS Family vCPUs"), - // Value: to.Ptr("standardNDSFamily"), - // }, - // CurrentValue: to.Ptr[int32](0), - // Limit: to.Ptr[int32](10), - // Unit: to.Ptr("Count"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/1e7b408f3323e7f5424745718fe62c7a043a2337/specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/putComputeOneSkuQuotaRequest.json -func ExampleQuotaClient_BeginCreateOrUpdate_quotasRequestPutForCompute() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armreservations.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewQuotaClient().BeginCreateOrUpdate(ctx, "D7EC67B3-7657-4966-BFFC-41EFD36BAAB3", "Microsoft.Compute", "eastus", "standardFSv2Family", armreservations.CurrentQuotaLimitBase{ - Properties: &armreservations.QuotaProperties{ - Name: &armreservations.ResourceName{ - Value: to.Ptr("standardFSv2Family"), - }, - Limit: to.Ptr[int32](200), - Unit: to.Ptr("Count"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.CurrentQuotaLimitBase = armreservations.CurrentQuotaLimitBase{ - // Name: to.Ptr("2B5C8515-37D8-4B6A-879B-CD641A2CF605"), - // Type: to.Ptr("Microsoft.Capacity/serviceLimits"), - // ID: to.Ptr("/subscriptions/D7EC67B3-7657-4966-BFFC-41EFD36BAAB3/providers/Microsoft.Capacity/resourceProviders/Microsoft.Compute/locations/eastus/serviceLimitsRequests/2B5C8515-37D8-4B6A-879B-CD641A2CF605"), - // Properties: &armreservations.QuotaProperties{ - // Name: &armreservations.ResourceName{ - // LocalizedValue: to.Ptr("Standard FSv2 Family vCPUs"), - // Value: to.Ptr("standardFSv2Family"), - // }, - // CurrentValue: to.Ptr[int32](160), - // Limit: to.Ptr[int32](200), - // Properties: map[string]any{ - // }, - // QuotaPeriod: to.Ptr(""), - // Unit: to.Ptr("Count"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/1e7b408f3323e7f5424745718fe62c7a043a2337/specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/putMachineLearningServicesQuotaRequestDedicated.json -func ExampleQuotaClient_BeginCreateOrUpdate_quotasRequestPutForMachineLearningServicesDedicatedResource() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armreservations.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewQuotaClient().BeginCreateOrUpdate(ctx, "D7EC67B3-7657-4966-BFFC-41EFD36BAAB3", "Microsoft.MachineLearningServices", "eastus", "StandardDv2Family", armreservations.CurrentQuotaLimitBase{ - Properties: &armreservations.QuotaProperties{ - Name: &armreservations.ResourceName{ - Value: to.Ptr("StandardDv2Family"), - }, - Limit: to.Ptr[int32](200), - ResourceType: to.Ptr(armreservations.ResourceTypeDedicated), - Unit: to.Ptr("Count"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.CurrentQuotaLimitBase = armreservations.CurrentQuotaLimitBase{ - // Name: to.Ptr("2B5C8515-37D8-4B6A-879B-CD641A2CF605"), - // Type: to.Ptr("Microsoft.Capacity/serviceLimits"), - // ID: to.Ptr("/subscriptions/D7EC67B3-7657-4966-BFFC-41EFD36BAAB3/providers/Microsoft.Capacity/resourceProviders/Microsoft.MachineLearningServices/locations/eastus/serviceLimitsRequests/2B5C8515-37D8-4B6A-879B-CD641A2CF605"), - // Properties: &armreservations.QuotaProperties{ - // Name: &armreservations.ResourceName{ - // LocalizedValue: to.Ptr("Standard Dv2 Family Cluster Dedicated vCPUs"), - // Value: to.Ptr("StandardDv2Family"), - // }, - // CurrentValue: to.Ptr[int32](160), - // Limit: to.Ptr[int32](200), - // Properties: map[string]any{ - // }, - // QuotaPeriod: to.Ptr(""), - // ResourceType: to.Ptr(armreservations.ResourceTypeDedicated), - // Unit: to.Ptr("Count"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/1e7b408f3323e7f5424745718fe62c7a043a2337/specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/putMachineLearningServicesQuotaRequestLowPriority.json -func ExampleQuotaClient_BeginCreateOrUpdate_quotasRequestPutForMachineLearningServicesLowPriorityResource() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armreservations.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewQuotaClient().BeginCreateOrUpdate(ctx, "D7EC67B3-7657-4966-BFFC-41EFD36BAAB3", "Microsoft.MachineLearningServices", "eastus", "TotalLowPriorityCores", armreservations.CurrentQuotaLimitBase{ - Properties: &armreservations.QuotaProperties{ - Name: &armreservations.ResourceName{ - Value: to.Ptr("TotalLowPriorityCores"), - }, - Limit: to.Ptr[int32](200), - ResourceType: to.Ptr(armreservations.ResourceTypeLowPriority), - Unit: to.Ptr("Count"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.CurrentQuotaLimitBase = armreservations.CurrentQuotaLimitBase{ - // Name: to.Ptr("2B5C8515-37D8-4B6A-879B-CD641A2CF605"), - // Type: to.Ptr("Microsoft.Capacity/serviceLimits"), - // ID: to.Ptr("/subscriptions/D7EC67B3-7657-4966-BFFC-41EFD36BAAB3/providers/Microsoft.Capacity/resourceProviders/Microsoft.MachineLearningServices/locations/eastus/serviceLimitsRequests/2B5C8515-37D8-4B6A-879B-CD641A2CF605"), - // Properties: &armreservations.QuotaProperties{ - // Name: &armreservations.ResourceName{ - // LocalizedValue: to.Ptr("Total Cluster Low Priority Regional vCPUs"), - // Value: to.Ptr("TotalLowPriorityCores"), - // }, - // CurrentValue: to.Ptr[int32](160), - // Limit: to.Ptr[int32](200), - // Properties: map[string]any{ - // }, - // QuotaPeriod: to.Ptr(""), - // ResourceType: to.Ptr(armreservations.ResourceTypeLowPriority), - // Unit: to.Ptr("Count"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/1e7b408f3323e7f5424745718fe62c7a043a2337/specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/patchComputeQuotaRequest.json -func ExampleQuotaClient_BeginUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armreservations.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewQuotaClient().BeginUpdate(ctx, "D7EC67B3-7657-4966-BFFC-41EFD36BAAB3", "Microsoft.Compute", "eastus", "standardFSv2Family", armreservations.CurrentQuotaLimitBase{ - Properties: &armreservations.QuotaProperties{ - Name: &armreservations.ResourceName{ - Value: to.Ptr("standardFSv2Family"), - }, - Limit: to.Ptr[int32](200), - Unit: to.Ptr("Count"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.CurrentQuotaLimitBase = armreservations.CurrentQuotaLimitBase{ - // Name: to.Ptr("2B5C8515-37D8-4B6A-879B-CD641A2CF605"), - // Type: to.Ptr("Microsoft.Capacity/serviceLimits"), - // ID: to.Ptr("/subscriptions/D7EC67B3-7657-4966-BFFC-41EFD36BAAB3/providers/Microsoft.Capacity/resourceProviders/Microsoft.Compute/locations/eastus/serviceLimitsRequests/2B5C8515-37D8-4B6A-879B-CD641A2CF605"), - // Properties: &armreservations.QuotaProperties{ - // Name: &armreservations.ResourceName{ - // LocalizedValue: to.Ptr("Standard FSv2 Family vCPUs"), - // Value: to.Ptr("standardFSv2Family"), - // }, - // CurrentValue: to.Ptr[int32](160), - // Limit: to.Ptr[int32](200), - // Properties: map[string]any{ - // }, - // QuotaPeriod: to.Ptr(""), - // Unit: to.Ptr("Count"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/1e7b408f3323e7f5424745718fe62c7a043a2337/specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/getComputeUsages.json -func ExampleQuotaClient_NewListPager_quotasListUsagesForCompute() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armreservations.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewQuotaClient().NewListPager("00000000-0000-0000-0000-000000000000", "Microsoft.Compute", "eastus", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.QuotaLimits = armreservations.QuotaLimits{ - // Value: []*armreservations.CurrentQuotaLimitBase{ - // { - // Properties: &armreservations.QuotaProperties{ - // Name: &armreservations.ResourceName{ - // LocalizedValue: to.Ptr("Standard FSv2 Family vCPUs"), - // Value: to.Ptr("standardFSv2Family"), - // }, - // CurrentValue: to.Ptr[int32](0), - // Limit: to.Ptr[int32](100), - // Unit: to.Ptr("Count"), - // }, - // }, - // { - // Properties: &armreservations.QuotaProperties{ - // Name: &armreservations.ResourceName{ - // LocalizedValue: to.Ptr("Standard NDS Family vCPUs"), - // Value: to.Ptr("standardNDSFamily"), - // }, - // CurrentValue: to.Ptr[int32](0), - // Limit: to.Ptr[int32](0), - // Unit: to.Ptr("Count"), - // }, - // }, - // { - // Properties: &armreservations.QuotaProperties{ - // Name: &armreservations.ResourceName{ - // LocalizedValue: to.Ptr("Standard NCSv2 Family vCPUs"), - // Value: to.Ptr("standardNCSv2Family"), - // }, - // CurrentValue: to.Ptr[int32](0), - // Limit: to.Ptr[int32](0), - // Unit: to.Ptr("Count"), - // }, - // }, - // { - // Properties: &armreservations.QuotaProperties{ - // Name: &armreservations.ResourceName{ - // LocalizedValue: to.Ptr("Standard NCSv3 Family vCPUs"), - // Value: to.Ptr("standardNCSv3Family"), - // }, - // CurrentValue: to.Ptr[int32](0), - // Limit: to.Ptr[int32](0), - // Unit: to.Ptr("Count"), - // }, - // }, - // { - // Properties: &armreservations.QuotaProperties{ - // Name: &armreservations.ResourceName{ - // LocalizedValue: to.Ptr("Standard LSv2 Family vCPUs"), - // Value: to.Ptr("standardLSv2Family"), - // }, - // CurrentValue: to.Ptr[int32](0), - // Limit: to.Ptr[int32](100), - // Unit: to.Ptr("Count"), - // }, - // }, - // { - // Properties: &armreservations.QuotaProperties{ - // Name: &armreservations.ResourceName{ - // LocalizedValue: to.Ptr("Standard PBS Family vCPUs"), - // Value: to.Ptr("standardPBSFamily"), - // }, - // CurrentValue: to.Ptr[int32](0), - // Limit: to.Ptr[int32](6), - // Unit: to.Ptr("Count"), - // }, - // }, - // { - // Properties: &armreservations.QuotaProperties{ - // Name: &armreservations.ResourceName{ - // LocalizedValue: to.Ptr("Standard EIv3 Family vCPUs"), - // Value: to.Ptr("standardEIv3Family"), - // }, - // CurrentValue: to.Ptr[int32](0), - // Limit: to.Ptr[int32](100), - // Unit: to.Ptr("Count"), - // }, - // }, - // { - // Properties: &armreservations.QuotaProperties{ - // Name: &armreservations.ResourceName{ - // LocalizedValue: to.Ptr("Standard EISv3 Family vCPUs"), - // Value: to.Ptr("standardEISv3Family"), - // }, - // CurrentValue: to.Ptr[int32](0), - // Limit: to.Ptr[int32](100), - // Unit: to.Ptr("Count"), - // }, - // }, - // { - // Properties: &armreservations.QuotaProperties{ - // Name: &armreservations.ResourceName{ - // LocalizedValue: to.Ptr("Standard DCS Family vCPUs"), - // Value: to.Ptr("standardDCSFamily"), - // }, - // CurrentValue: to.Ptr[int32](0), - // Limit: to.Ptr[int32](8), - // Unit: to.Ptr("Count"), - // }, - // }, - // { - // Properties: &armreservations.QuotaProperties{ - // Name: &armreservations.ResourceName{ - // LocalizedValue: to.Ptr("Standard NVSv2 Family vCPUs"), - // Value: to.Ptr("standardNVSv2Family"), - // }, - // CurrentValue: to.Ptr[int32](0), - // Limit: to.Ptr[int32](0), - // Unit: to.Ptr("Count"), - // }, - // }, - // { - // Properties: &armreservations.QuotaProperties{ - // Name: &armreservations.ResourceName{ - // LocalizedValue: to.Ptr("Standard MSv2 Family vCPUs"), - // Value: to.Ptr("standardMSv2Family"), - // }, - // CurrentValue: to.Ptr[int32](0), - // Limit: to.Ptr[int32](0), - // Unit: to.Ptr("Count"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/1e7b408f3323e7f5424745718fe62c7a043a2337/specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/getMachineLearningServicesUsages.json -func ExampleQuotaClient_NewListPager_quotasListUsagesMachineLearningServices() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armreservations.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewQuotaClient().NewListPager("00000000-0000-0000-0000-000000000000", "Microsoft.MachineLearningServices", "eastus", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.QuotaLimits = armreservations.QuotaLimits{ - // Value: []*armreservations.CurrentQuotaLimitBase{ - // { - // Properties: &armreservations.QuotaProperties{ - // Name: &armreservations.ResourceName{ - // LocalizedValue: to.Ptr("Standard Dv2 Family vCPUs"), - // Value: to.Ptr("standardDv2Family"), - // }, - // CurrentValue: to.Ptr[int32](15), - // Limit: to.Ptr[int32](20), - // ResourceType: to.Ptr(armreservations.ResourceTypeDedicated), - // }, - // }, - // { - // Properties: &armreservations.QuotaProperties{ - // Name: &armreservations.ResourceName{ - // LocalizedValue: to.Ptr("Total Regional Low-priority vCPUs"), - // Value: to.Ptr("totalLowPriorityCores"), - // }, - // CurrentValue: to.Ptr[int32](49), - // Limit: to.Ptr[int32](600), - // ResourceType: to.Ptr(armreservations.ResourceTypeLowPriority), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/reservations/armreservations/quotarequeststatus_client.go b/sdk/resourcemanager/reservations/armreservations/quotarequeststatus_client.go index aa96f65ac7c9..c426ebba1e89 100644 --- a/sdk/resourcemanager/reservations/armreservations/quotarequeststatus_client.go +++ b/sdk/resourcemanager/reservations/armreservations/quotarequeststatus_client.go @@ -3,9 +3,8 @@ // 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. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armreservations @@ -54,18 +53,21 @@ func NewQuotaRequestStatusClient(credential azcore.TokenCredential, options *arm // - id - Quota Request ID. // - options - QuotaRequestStatusClientGetOptions contains the optional parameters for the QuotaRequestStatusClient.Get method. func (client *QuotaRequestStatusClient) Get(ctx context.Context, subscriptionID string, providerID string, location string, id string, options *QuotaRequestStatusClientGetOptions) (QuotaRequestStatusClientGetResponse, error) { + var err error req, err := client.getCreateRequest(ctx, subscriptionID, providerID, location, id, options) if err != nil { return QuotaRequestStatusClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return QuotaRequestStatusClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return QuotaRequestStatusClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return QuotaRequestStatusClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. diff --git a/sdk/resourcemanager/reservations/armreservations/quotarequeststatus_client_example_test.go b/sdk/resourcemanager/reservations/armreservations/quotarequeststatus_client_example_test.go deleted file mode 100644 index 65a36026b2b4..000000000000 --- a/sdk/resourcemanager/reservations/armreservations/quotarequeststatus_client_example_test.go +++ /dev/null @@ -1,284 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armreservations_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/reservations/armreservations/v3" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/1e7b408f3323e7f5424745718fe62c7a043a2337/specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/getQuotaRequestStatusFailed.json -func ExampleQuotaRequestStatusClient_Get_quotaRequestFailed() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armreservations.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQuotaRequestStatusClient().Get(ctx, "00000000-0000-0000-0000-000000000000", "Microsoft.Compute", "eastus", "2B5C8515-37D8-4B6A-879B-CD641A2CF605", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.QuotaRequestDetails = armreservations.QuotaRequestDetails{ - // Name: to.Ptr("00000000-0000-0000-0000-000000000000/2B5C8515-37D8-4B6A-879B-CD641A2CF605"), - // Type: to.Ptr("Microsoft.Capacity/serviceLimitsRequests"), - // ID: to.Ptr("2B5C8515-37D8-4B6A-879B-CD641A2CF605"), - // Properties: &armreservations.QuotaRequestProperties{ - // Message: to.Ptr("Request failed, please contatct support."), - // ProvisioningState: to.Ptr(armreservations.QuotaRequestStateSucceeded), - // RequestSubmitTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-19T19:23:17.904Z"); return t}()), - // Value: []*armreservations.SubRequest{ - // { - // Name: &armreservations.ResourceName{ - // LocalizedValue: to.Ptr("Standard HCS Family vCPUs"), - // Value: to.Ptr("standardHCSFamily"), - // }, - // Limit: to.Ptr[int32](200), - // Message: to.Ptr("Request completed"), - // ProvisioningState: to.Ptr(armreservations.QuotaRequestStateSucceeded), - // SubRequestID: to.Ptr("AD07450A-DE86-4FD3-859B-107BEF218C4C"), - // }, - // { - // Name: &armreservations.ResourceName{ - // LocalizedValue: to.Ptr("Standard NC Promo Family vCPUs"), - // Value: to.Ptr("standardNCPromoFamily"), - // }, - // Limit: to.Ptr[int32](50), - // Message: to.Ptr("RRequest failed, please contatct support."), - // ProvisioningState: to.Ptr(armreservations.QuotaRequestStateSucceeded), - // SubRequestID: to.Ptr("AD07450A-DE86-4FD3-859B-107BEF218C4C"), - // }}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/1e7b408f3323e7f5424745718fe62c7a043a2337/specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/getQuotaRequestStatusInProgress.json -func ExampleQuotaRequestStatusClient_Get_quotaRequestInProgress() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armreservations.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQuotaRequestStatusClient().Get(ctx, "00000000-0000-0000-0000-000000000000", "Microsoft.Compute", "eastus", "2B5C8515-37D8-4B6A-879B-CD641A2CF605", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.QuotaRequestDetails = armreservations.QuotaRequestDetails{ - // Name: to.Ptr("00000000-0000-0000-0000-000000000000/2B5C8515-37D8-4B6A-879B-CD641A2CF605"), - // Type: to.Ptr("Microsoft.Capacity/serviceLimitsRequests"), - // ID: to.Ptr("2B5C8515-37D8-4B6A-879B-CD641A2CF605"), - // Properties: &armreservations.QuotaRequestProperties{ - // Message: to.Ptr("Request processing"), - // ProvisioningState: to.Ptr(armreservations.QuotaRequestStateSucceeded), - // RequestSubmitTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-19T19:23:17.904Z"); return t}()), - // Value: []*armreservations.SubRequest{ - // { - // Name: &armreservations.ResourceName{ - // LocalizedValue: to.Ptr("Standard NC Promo Family vCPUs"), - // Value: to.Ptr("standardNCPromoFamily"), - // }, - // Limit: to.Ptr[int32](50), - // Message: to.Ptr("Request processing"), - // ProvisioningState: to.Ptr(armreservations.QuotaRequestStateSucceeded), - // SubRequestID: to.Ptr("AD07450A-DE86-4FD3-859B-107BEF218C4C"), - // }}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/1e7b408f3323e7f5424745718fe62c7a043a2337/specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/getQuotaRequestStatusById.json -func ExampleQuotaRequestStatusClient_Get_quotaRequestStatus() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armreservations.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQuotaRequestStatusClient().Get(ctx, "00000000-0000-0000-0000-000000000000", "Microsoft.Compute", "eastus", "2B5C8515-37D8-4B6A-879B-CD641A2CF605", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.QuotaRequestDetails = armreservations.QuotaRequestDetails{ - // Name: to.Ptr("00000000-0000-0000-0000-000000000000/2B5C8515-37D8-4B6A-879B-CD641A2CF605"), - // Type: to.Ptr("Microsoft.Capacity/serviceLimitsRequests"), - // ID: to.Ptr("2B5C8515-37D8-4B6A-879B-CD641A2CF605"), - // Properties: &armreservations.QuotaRequestProperties{ - // Message: to.Ptr("Request completed"), - // ProvisioningState: to.Ptr(armreservations.QuotaRequestStateSucceeded), - // RequestSubmitTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-19T19:23:17.904Z"); return t}()), - // Value: []*armreservations.SubRequest{ - // { - // Name: &armreservations.ResourceName{ - // LocalizedValue: to.Ptr("Standard HCS Family vCPUs"), - // Value: to.Ptr("standardHCSFamily"), - // }, - // Limit: to.Ptr[int32](200), - // Message: to.Ptr("Request completed"), - // ProvisioningState: to.Ptr(armreservations.QuotaRequestStateSucceeded), - // SubRequestID: to.Ptr("AD07450A-DE86-4FD3-859B-107BEF218C4C"), - // }, - // { - // Name: &armreservations.ResourceName{ - // LocalizedValue: to.Ptr("Standard NC Promo Family vCPUs"), - // Value: to.Ptr("standardNCPromoFamily"), - // }, - // Limit: to.Ptr[int32](50), - // Message: to.Ptr("Request completed"), - // ProvisioningState: to.Ptr(armreservations.QuotaRequestStateSucceeded), - // }}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/1e7b408f3323e7f5424745718fe62c7a043a2337/specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/getQuotaRequestsHistory.json -func ExampleQuotaRequestStatusClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armreservations.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewQuotaRequestStatusClient().NewListPager("3f75fdf7-977e-44ad-990d-99f14f0f299f", "Microsoft.Compute", "eastus", &armreservations.QuotaRequestStatusClientListOptions{Filter: nil, - Top: nil, - Skiptoken: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.QuotaRequestDetailsList = armreservations.QuotaRequestDetailsList{ - // Value: []*armreservations.QuotaRequestDetails{ - // { - // Name: to.Ptr("00000000-0000-0000-0000-000000000000/2B5C8515-37D8-4B6A-879B-CD641A2CF605"), - // Type: to.Ptr("Microsoft.Capacity/serviceLimitsRequests"), - // ID: to.Ptr("2B5C8515-37D8-4B6A-879B-CD641A2CF605"), - // Properties: &armreservations.QuotaRequestProperties{ - // Message: to.Ptr("Request completed"), - // ProvisioningState: to.Ptr(armreservations.QuotaRequestStateSucceeded), - // RequestSubmitTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-19T19:23:17.904Z"); return t}()), - // Value: []*armreservations.SubRequest{ - // { - // Name: &armreservations.ResourceName{ - // LocalizedValue: to.Ptr("Standard HCS Family vCPUs"), - // Value: to.Ptr("standardHCSFamily"), - // }, - // Limit: to.Ptr[int32](200), - // Message: to.Ptr("Request completed"), - // ProvisioningState: to.Ptr(armreservations.QuotaRequestStateSucceeded), - // SubRequestID: to.Ptr("AD07450A-DE86-4FD3-859B-107BEF218C4C"), - // }, - // { - // Name: &armreservations.ResourceName{ - // LocalizedValue: to.Ptr("Standard NC Promo Family vCPUs"), - // Value: to.Ptr("standardNCPromoFamily"), - // }, - // Limit: to.Ptr[int32](50), - // Message: to.Ptr("Request completed"), - // ProvisioningState: to.Ptr(armreservations.QuotaRequestStateSucceeded), - // SubRequestID: to.Ptr("AD07450A-DE86-4FD3-859B-107BEF218C4C"), - // }}, - // }, - // }, - // { - // Name: to.Ptr("00000000-0000-0000-0000-000000000000/7E73A85C-83BB-4DE4-903F-076F1A2B91D6"), - // Type: to.Ptr("Microsoft.Capacity/serviceLimitsRequests"), - // ID: to.Ptr("7E73A85C-83BB-4DE4-903F-076F1A2B91D6"), - // Properties: &armreservations.QuotaRequestProperties{ - // Message: to.Ptr("Request completed"), - // ProvisioningState: to.Ptr(armreservations.QuotaRequestStateSucceeded), - // RequestSubmitTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-18T19:23:17.904Z"); return t}()), - // Value: []*armreservations.SubRequest{ - // { - // Name: &armreservations.ResourceName{ - // LocalizedValue: to.Ptr("Standard NVSv3 Family vCPUs"), - // Value: to.Ptr("standardNVSv3Family"), - // }, - // Limit: to.Ptr[int32](100), - // Message: to.Ptr("Request completed"), - // ProvisioningState: to.Ptr(armreservations.QuotaRequestStateSucceeded), - // SubRequestID: to.Ptr("AD07450A-DE86-4FD3-859B-107BEF218C4C"), - // }, - // { - // Name: &armreservations.ResourceName{ - // LocalizedValue: to.Ptr("Standard NV Promo Family vCPUs"), - // Value: to.Ptr("standardNVPromoFamily"), - // }, - // Limit: to.Ptr[int32](150), - // Message: to.Ptr("Request completed"), - // ProvisioningState: to.Ptr(armreservations.QuotaRequestStateSucceeded), - // SubRequestID: to.Ptr("AD07450A-DE86-4FD3-859B-107BEF218C4C"), - // }}, - // }, - // }, - // { - // Name: to.Ptr("00000000-0000-0000-0000-000000000000/5E460077-AB53-4802-8997-A6940E0B7649"), - // Type: to.Ptr("Microsoft.Capacity/serviceLimitsRequests"), - // ID: to.Ptr("5E460077-AB53-4802-8997-A6940E0B7649"), - // Properties: &armreservations.QuotaRequestProperties{ - // Message: to.Ptr("Request completed"), - // ProvisioningState: to.Ptr(armreservations.QuotaRequestStateSucceeded), - // RequestSubmitTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-17T19:23:17.904Z"); return t}()), - // Value: []*armreservations.SubRequest{ - // { - // Name: &armreservations.ResourceName{ - // LocalizedValue: to.Ptr("Standard NC Promo Family vCPUs"), - // Value: to.Ptr("standardNCPromoFamily"), - // }, - // Limit: to.Ptr[int32](70), - // Message: to.Ptr("Request completed"), - // ProvisioningState: to.Ptr(armreservations.QuotaRequestStateSucceeded), - // SubRequestID: to.Ptr("AD07450A-DE86-4FD3-859B-107BEF218C4C"), - // }, - // { - // Name: &armreservations.ResourceName{ - // LocalizedValue: to.Ptr("Standard HBS Family vCPUs"), - // Value: to.Ptr("standardHBSFamily"), - // }, - // Limit: to.Ptr[int32](52), - // Message: to.Ptr("Request completed"), - // ProvisioningState: to.Ptr(armreservations.QuotaRequestStateSucceeded), - // SubRequestID: to.Ptr("AD07450A-DE86-4FD3-859B-107BEF218C4C"), - // }}, - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/reservations/armreservations/reservation_client.go b/sdk/resourcemanager/reservations/armreservations/reservation_client.go index aec822469fb3..f1e08ceb2ed6 100644 --- a/sdk/resourcemanager/reservations/armreservations/reservation_client.go +++ b/sdk/resourcemanager/reservations/armreservations/reservation_client.go @@ -3,9 +3,8 @@ // 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. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armreservations @@ -50,16 +49,18 @@ func NewReservationClient(credential azcore.TokenCredential, options *arm.Client // - reservationID - Id of the reservation item // - options - ReservationClientArchiveOptions contains the optional parameters for the ReservationClient.Archive method. func (client *ReservationClient) Archive(ctx context.Context, reservationOrderID string, reservationID string, options *ReservationClientArchiveOptions) (ReservationClientArchiveResponse, error) { + var err error req, err := client.archiveCreateRequest(ctx, reservationOrderID, reservationID, options) if err != nil { return ReservationClientArchiveResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ReservationClientArchiveResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ReservationClientArchiveResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ReservationClientArchiveResponse{}, err } return ReservationClientArchiveResponse{}, nil } @@ -101,7 +102,8 @@ func (client *ReservationClient) BeginAvailableScopes(ctx context.Context, reser if err != nil { return nil, err } - return runtime.NewPoller[ReservationClientAvailableScopesResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller[ReservationClientAvailableScopesResponse](resp, client.internal.Pipeline(), nil) + return poller, err } else { return runtime.NewPollerFromResumeToken[ReservationClientAvailableScopesResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -112,18 +114,20 @@ func (client *ReservationClient) BeginAvailableScopes(ctx context.Context, reser // // Generated from API version 2022-11-01 func (client *ReservationClient) availableScopes(ctx context.Context, reservationOrderID string, reservationID string, body AvailableScopeRequest, options *ReservationClientBeginAvailableScopesOptions) (*http.Response, error) { + var err error req, err := client.availableScopesCreateRequest(ctx, reservationOrderID, reservationID, body, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // availableScopesCreateRequest creates the AvailableScopes request. @@ -145,7 +149,10 @@ func (client *ReservationClient) availableScopesCreateRequest(ctx context.Contex reqQP.Set("api-version", "2022-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil } // Get - Get specific Reservation details. @@ -156,18 +163,21 @@ func (client *ReservationClient) availableScopesCreateRequest(ctx context.Contex // - reservationID - Id of the reservation item // - options - ReservationClientGetOptions contains the optional parameters for the ReservationClient.Get method. func (client *ReservationClient) Get(ctx context.Context, reservationOrderID string, reservationID string, options *ReservationClientGetOptions) (ReservationClientGetResponse, error) { + var err error req, err := client.getCreateRequest(ctx, reservationOrderID, reservationID, options) if err != nil { return ReservationClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ReservationClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ReservationClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ReservationClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -418,9 +428,10 @@ func (client *ReservationClient) BeginMerge(ctx context.Context, reservationOrde if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ReservationClientMergeResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ReservationClientMergeResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[ReservationClientMergeResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -431,18 +442,20 @@ func (client *ReservationClient) BeginMerge(ctx context.Context, reservationOrde // // Generated from API version 2022-11-01 func (client *ReservationClient) merge(ctx context.Context, reservationOrderID string, body MergeRequest, options *ReservationClientBeginMergeOptions) (*http.Response, error) { + var err error req, err := client.mergeCreateRequest(ctx, reservationOrderID, body, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // mergeCreateRequest creates the Merge request. @@ -460,7 +473,10 @@ func (client *ReservationClient) mergeCreateRequest(ctx context.Context, reserva reqQP.Set("api-version", "2022-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil } // BeginSplit - Split a Reservation into two Reservations with specified quantity distribution. @@ -476,9 +492,10 @@ func (client *ReservationClient) BeginSplit(ctx context.Context, reservationOrde if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ReservationClientSplitResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ReservationClientSplitResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[ReservationClientSplitResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -489,18 +506,20 @@ func (client *ReservationClient) BeginSplit(ctx context.Context, reservationOrde // // Generated from API version 2022-11-01 func (client *ReservationClient) split(ctx context.Context, reservationOrderID string, body SplitRequest, options *ReservationClientBeginSplitOptions) (*http.Response, error) { + var err error req, err := client.splitCreateRequest(ctx, reservationOrderID, body, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // splitCreateRequest creates the Split request. @@ -518,7 +537,10 @@ func (client *ReservationClient) splitCreateRequest(ctx context.Context, reserva reqQP.Set("api-version", "2022-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil } // Unarchive - Restores a Reservation to the state it was before archiving. @@ -529,16 +551,18 @@ func (client *ReservationClient) splitCreateRequest(ctx context.Context, reserva // - reservationID - Id of the reservation item // - options - ReservationClientUnarchiveOptions contains the optional parameters for the ReservationClient.Unarchive method. func (client *ReservationClient) Unarchive(ctx context.Context, reservationOrderID string, reservationID string, options *ReservationClientUnarchiveOptions) (ReservationClientUnarchiveResponse, error) { + var err error req, err := client.unarchiveCreateRequest(ctx, reservationOrderID, reservationID, options) if err != nil { return ReservationClientUnarchiveResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ReservationClientUnarchiveResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ReservationClientUnarchiveResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ReservationClientUnarchiveResponse{}, err } return ReservationClientUnarchiveResponse{}, nil } @@ -579,9 +603,10 @@ func (client *ReservationClient) BeginUpdate(ctx context.Context, reservationOrd if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ReservationClientUpdateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ReservationClientUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[ReservationClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -592,18 +617,20 @@ func (client *ReservationClient) BeginUpdate(ctx context.Context, reservationOrd // // Generated from API version 2022-11-01 func (client *ReservationClient) update(ctx context.Context, reservationOrderID string, reservationID string, parameters Patch, options *ReservationClientBeginUpdateOptions) (*http.Response, error) { + var err error req, err := client.updateCreateRequest(ctx, reservationOrderID, reservationID, parameters, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // updateCreateRequest creates the Update request. @@ -625,5 +652,8 @@ func (client *ReservationClient) updateCreateRequest(ctx context.Context, reserv reqQP.Set("api-version", "2022-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, parameters) + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil } diff --git a/sdk/resourcemanager/reservations/armreservations/reservation_client_example_test.go b/sdk/resourcemanager/reservations/armreservations/reservation_client_example_test.go deleted file mode 100644 index 0b17b4992161..000000000000 --- a/sdk/resourcemanager/reservations/armreservations/reservation_client_example_test.go +++ /dev/null @@ -1,997 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armreservations_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/reservations/armreservations/v3" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/1e7b408f3323e7f5424745718fe62c7a043a2337/specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/GetAvailableScope.json -func ExampleReservationClient_BeginAvailableScopes() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armreservations.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewReservationClient().BeginAvailableScopes(ctx, "276e7ae4-84d0-4da6-ab4b-d6b94f3557da", "356e7ae4-84d0-4da6-ab4b-d6b94f3557da", armreservations.AvailableScopeRequest{ - Properties: &armreservations.AvailableScopeRequestProperties{ - Scopes: []*string{ - to.Ptr("/subscriptions/efc7c997-7700-4a74-b731-55aec16c15e9")}, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.AvailableScopeProperties = armreservations.AvailableScopeProperties{ - // Properties: &armreservations.SubscriptionScopeProperties{ - // Scopes: []*armreservations.ScopeProperties{ - // { - // Scope: to.Ptr("/subscriptions/efc7c997-7700-4a74-b731-55aec16c15e9"), - // Valid: to.Ptr(true), - // }}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/1e7b408f3323e7f5424745718fe62c7a043a2337/specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/SplitReservation.json -func ExampleReservationClient_BeginSplit() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armreservations.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewReservationClient().BeginSplit(ctx, "276e7ae4-84d0-4da6-ab4b-d6b94f3557da", armreservations.SplitRequest{ - Properties: &armreservations.SplitProperties{ - Quantities: []*int32{ - to.Ptr[int32](1), - to.Ptr[int32](2)}, - ReservationID: to.Ptr("/providers/Microsoft.Capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/bcae77cd-3119-4766-919f-b50d36c75c7a"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ReservationResponseArray = []*armreservations.ReservationResponse{ - // { - // Name: to.Ptr("00238563-7312-4c20-a134-8c030bf938a7"), - // Type: to.Ptr("Microsoft.Capacity/reservationOrders/reservations"), - // ID: to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/00238563-7312-4c20-a134-8c030bf938a7"), - // Etag: to.Ptr[int32](2), - // Location: to.Ptr("eastus"), - // Properties: &armreservations.Properties{ - // AppliedScopeProperties: &armreservations.AppliedScopeProperties{ - // DisplayName: to.Ptr("Azure subscription 1"), - // SubscriptionID: to.Ptr("/subscriptions/98df3792-7962-4f18-8be2-d5576f122de3"), - // }, - // AppliedScopeType: to.Ptr(armreservations.AppliedScopeTypeSingle), - // BillingPlan: to.Ptr(armreservations.ReservationBillingPlanMonthly), - // BillingScopeID: to.Ptr("/subscriptions/19376483-64b8-49e4-a931-d5248828720a"), - // DisplayName: to.Ptr("cabri_test"), - // EffectiveDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-09-22T01:00:30.9253826Z"); return t}()), - // ExpiryDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2018-09-22"); return t}()), - // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-22T01:00:30.9253826Z"); return t}()), - // InstanceFlexibility: to.Ptr(armreservations.InstanceFlexibilityOff), - // LastUpdatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-09-22T01:00:36.3191627Z"); return t}()), - // ProvisioningState: to.Ptr(armreservations.ProvisioningStateSucceeded), - // Quantity: to.Ptr[int32](1), - // Renew: to.Ptr(false), - // ReservedResourceType: to.Ptr(armreservations.ReservedResourceTypeVirtualMachines), - // SKUDescription: to.Ptr("D1 v2"), - // SplitProperties: &armreservations.ReservationSplitProperties{ - // SplitSource: to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/bcae77cd-3119-4766-919f-b50d36c75c7a"), - // }, - // }, - // SKU: &armreservations.SKUName{ - // Name: to.Ptr("Standard_DS1_v2"), - // }, - // }, - // { - // Name: to.Ptr("e0e4b4f5-77ea-4984-9ee4-6bf9850ee6de"), - // Type: to.Ptr("Microsoft.Capacity/reservationOrders/reservations"), - // ID: to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/e0e4b4f5-77ea-4984-9ee4-6bf9850ee6de"), - // Etag: to.Ptr[int32](2), - // Location: to.Ptr("eastus"), - // Properties: &armreservations.Properties{ - // AppliedScopeProperties: &armreservations.AppliedScopeProperties{ - // DisplayName: to.Ptr("Azure subscription 1"), - // SubscriptionID: to.Ptr("/subscriptions/98df3792-7962-4f18-8be2-d5576f122de3"), - // }, - // AppliedScopeType: to.Ptr(armreservations.AppliedScopeTypeSingle), - // BillingPlan: to.Ptr(armreservations.ReservationBillingPlanMonthly), - // BillingScopeID: to.Ptr("/subscriptions/19376483-64b8-49e4-a931-d5248828720a"), - // DisplayName: to.Ptr("cabri_test"), - // EffectiveDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-09-22T01:00:30.9253826Z"); return t}()), - // ExpiryDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2018-09-22"); return t}()), - // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-22T01:00:30.9253826Z"); return t}()), - // InstanceFlexibility: to.Ptr(armreservations.InstanceFlexibilityOff), - // LastUpdatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-09-22T01:00:36.3191627Z"); return t}()), - // ProvisioningState: to.Ptr(armreservations.ProvisioningStateSucceeded), - // Quantity: to.Ptr[int32](2), - // Renew: to.Ptr(false), - // ReservedResourceType: to.Ptr(armreservations.ReservedResourceTypeVirtualMachines), - // SKUDescription: to.Ptr("D1 v2"), - // SplitProperties: &armreservations.ReservationSplitProperties{ - // SplitSource: to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/bcae77cd-3119-4766-919f-b50d36c75c7a"), - // }, - // }, - // SKU: &armreservations.SKUName{ - // Name: to.Ptr("Standard_DS1_v2"), - // }, - // }, - // { - // Name: to.Ptr("bcae77cd-3119-4766-919f-b50d36c75c7a"), - // Type: to.Ptr("Microsoft.Capacity/reservationOrders/reservations"), - // ID: to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/bcae77cd-3119-4766-919f-b50d36c75c7a"), - // Etag: to.Ptr[int32](10), - // Location: to.Ptr("eastus"), - // Properties: &armreservations.Properties{ - // AppliedScopeProperties: &armreservations.AppliedScopeProperties{ - // DisplayName: to.Ptr("Azure subscription 1"), - // SubscriptionID: to.Ptr("/subscriptions/98df3792-7962-4f18-8be2-d5576f122de3"), - // }, - // AppliedScopeType: to.Ptr(armreservations.AppliedScopeTypeSingle), - // BillingPlan: to.Ptr(armreservations.ReservationBillingPlanMonthly), - // BillingScopeID: to.Ptr("/subscriptions/19376483-64b8-49e4-a931-d5248828720a"), - // DisplayName: to.Ptr("cabri_test"), - // EffectiveDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-09-22T01:00:30.9253826Z"); return t}()), - // ExpiryDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2018-09-22"); return t}()), - // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-22T01:00:30.9253826Z"); return t}()), - // ExtendedStatusInfo: &armreservations.ExtendedStatusInfo{ - // Message: to.Ptr("This reservation was split and is no longer active."), - // StatusCode: to.Ptr(armreservations.ReservationStatusCodeSplit), - // }, - // InstanceFlexibility: to.Ptr(armreservations.InstanceFlexibilityOff), - // LastUpdatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-09-22T01:00:36.3191627Z"); return t}()), - // ProvisioningState: to.Ptr(armreservations.ProvisioningStateSucceeded), - // Quantity: to.Ptr[int32](3), - // Renew: to.Ptr(false), - // ReservedResourceType: to.Ptr(armreservations.ReservedResourceTypeVirtualMachines), - // SKUDescription: to.Ptr("D1 v2"), - // SplitProperties: &armreservations.ReservationSplitProperties{ - // SplitDestinations: []*string{ - // to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/00238563-7312-4c20-a134-8c030bf938a7"), - // to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/e0e4b4f5-77ea-4984-9ee4-6bf9850ee6de")}, - // }, - // }, - // SKU: &armreservations.SKUName{ - // Name: to.Ptr("Standard_DS1_v2"), - // }, - // }} -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/1e7b408f3323e7f5424745718fe62c7a043a2337/specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/MergeReservations.json -func ExampleReservationClient_BeginMerge() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armreservations.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewReservationClient().BeginMerge(ctx, "276e7ae4-84d0-4da6-ab4b-d6b94f3557da", armreservations.MergeRequest{ - Properties: &armreservations.MergeProperties{ - Sources: []*string{ - to.Ptr("/providers/Microsoft.Capacity/reservationOrders/c0565a8a-4491-4e77-b07b-5e6d66718e1c/reservations/cea04232-932e-47db-acb5-e29a945ecc73"), - to.Ptr("/providers/Microsoft.Capacity/reservationOrders/c0565a8a-4491-4e77-b07b-5e6d66718e1c/reservations/5bf54dc7-dacd-4f46-a16b-7b78f4a59799")}, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ReservationResponseArray = []*armreservations.ReservationResponse{ - // { - // Name: to.Ptr("00238563-7312-4c20-a134-8c030bf938a7"), - // Type: to.Ptr("Microsoft.Capacity/reservationOrders/reservations"), - // ID: to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/00238563-7312-4c20-a134-8c030bf938a7"), - // Etag: to.Ptr[int32](5), - // Location: to.Ptr("eastus"), - // Properties: &armreservations.Properties{ - // AppliedScopeProperties: &armreservations.AppliedScopeProperties{ - // DisplayName: to.Ptr("Azure subscription 1"), - // SubscriptionID: to.Ptr("/subscriptions/98df3792-7962-4f18-8be2-d5576f122de3"), - // }, - // AppliedScopeType: to.Ptr(armreservations.AppliedScopeTypeSingle), - // BillingPlan: to.Ptr(armreservations.ReservationBillingPlanMonthly), - // BillingScopeID: to.Ptr("/subscriptions/19376483-64b8-49e4-a931-d5248828720a"), - // DisplayName: to.Ptr("cabri_test"), - // EffectiveDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-09-22T22:46:32.7632798Z"); return t}()), - // ExpiryDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2018-09-22"); return t}()), - // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-22T22:46:32.7632798Z"); return t}()), - // ExtendedStatusInfo: &armreservations.ExtendedStatusInfo{ - // Message: to.Ptr("This reservation was merged and is no longer active."), - // StatusCode: to.Ptr(armreservations.ReservationStatusCodeMerged), - // }, - // InstanceFlexibility: to.Ptr(armreservations.InstanceFlexibilityOff), - // LastUpdatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-09-22T22:46:32.7632798Z"); return t}()), - // MergeProperties: &armreservations.ReservationMergeProperties{ - // MergeDestination: to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/6ef59113-3482-40da-8d79-787f823e34bc"), - // }, - // ProvisioningState: to.Ptr(armreservations.ProvisioningStateSucceeded), - // Quantity: to.Ptr[int32](1), - // Renew: to.Ptr(false), - // ReservedResourceType: to.Ptr(armreservations.ReservedResourceTypeVirtualMachines), - // SKUDescription: to.Ptr("D1 v2"), - // SplitProperties: &armreservations.ReservationSplitProperties{ - // SplitSource: to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/bcae77cd-3119-4766-919f-b50d36c75c7a"), - // }, - // }, - // SKU: &armreservations.SKUName{ - // Name: to.Ptr("Standard_DS1_v2"), - // }, - // }, - // { - // Name: to.Ptr("e0e4b4f5-77ea-4984-9ee4-6bf9850ee6de"), - // Type: to.Ptr("Microsoft.Capacity/reservationOrders/reservations"), - // ID: to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/e0e4b4f5-77ea-4984-9ee4-6bf9850ee6de"), - // Etag: to.Ptr[int32](4), - // Location: to.Ptr("eastus"), - // Properties: &armreservations.Properties{ - // AppliedScopeProperties: &armreservations.AppliedScopeProperties{ - // DisplayName: to.Ptr("Azure subscription 1"), - // SubscriptionID: to.Ptr("/subscriptions/98df3792-7962-4f18-8be2-d5576f122de3"), - // }, - // AppliedScopeType: to.Ptr(armreservations.AppliedScopeTypeSingle), - // BillingPlan: to.Ptr(armreservations.ReservationBillingPlanMonthly), - // BillingScopeID: to.Ptr("/subscriptions/19376483-64b8-49e4-a931-d5248828720a"), - // DisplayName: to.Ptr("cabri_test"), - // EffectiveDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-09-22T22:46:32.7632798Z"); return t}()), - // ExpiryDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2018-09-22"); return t}()), - // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-22T22:46:32.7632798Z"); return t}()), - // ExtendedStatusInfo: &armreservations.ExtendedStatusInfo{ - // Message: to.Ptr("This reservation was merged and is no longer active."), - // StatusCode: to.Ptr(armreservations.ReservationStatusCodeMerged), - // }, - // InstanceFlexibility: to.Ptr(armreservations.InstanceFlexibilityOff), - // LastUpdatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-09-22T22:46:32.7632798Z"); return t}()), - // MergeProperties: &armreservations.ReservationMergeProperties{ - // MergeDestination: to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/6ef59113-3482-40da-8d79-787f823e34bc"), - // }, - // ProvisioningState: to.Ptr(armreservations.ProvisioningStateSucceeded), - // Quantity: to.Ptr[int32](2), - // Renew: to.Ptr(false), - // ReservedResourceType: to.Ptr(armreservations.ReservedResourceTypeVirtualMachines), - // SKUDescription: to.Ptr("D1 v2"), - // SplitProperties: &armreservations.ReservationSplitProperties{ - // SplitSource: to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/bcae77cd-3119-4766-919f-b50d36c75c7a"), - // }, - // }, - // SKU: &armreservations.SKUName{ - // Name: to.Ptr("Standard_DS1_v2"), - // }, - // }, - // { - // Name: to.Ptr("6ef59113-3482-40da-8d79-787f823e34bc"), - // Type: to.Ptr("Microsoft.Capacity/reservationOrders/reservations"), - // ID: to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/6ef59113-3482-40da-8d79-787f823e34bc"), - // Etag: to.Ptr[int32](2), - // Location: to.Ptr("eastus"), - // Properties: &armreservations.Properties{ - // AppliedScopeProperties: &armreservations.AppliedScopeProperties{ - // DisplayName: to.Ptr("Azure subscription 1"), - // SubscriptionID: to.Ptr("/subscriptions/98df3792-7962-4f18-8be2-d5576f122de3"), - // }, - // AppliedScopeType: to.Ptr(armreservations.AppliedScopeTypeSingle), - // BillingPlan: to.Ptr(armreservations.ReservationBillingPlanMonthly), - // BillingScopeID: to.Ptr("/subscriptions/19376483-64b8-49e4-a931-d5248828720a"), - // DisplayName: to.Ptr("cabri_test"), - // EffectiveDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-09-22T22:46:32.7632798Z"); return t}()), - // ExpiryDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2018-09-22"); return t}()), - // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-22T22:46:32.7632798Z"); return t}()), - // InstanceFlexibility: to.Ptr(armreservations.InstanceFlexibilityOff), - // LastUpdatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-09-22T22:46:32.7632798Z"); return t}()), - // MergeProperties: &armreservations.ReservationMergeProperties{ - // MergeSources: []*string{ - // to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/00238563-7312-4c20-a134-8c030bf938a7"), - // to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/e0e4b4f5-77ea-4984-9ee4-6bf9850ee6de")}, - // }, - // ProvisioningState: to.Ptr(armreservations.ProvisioningStateSucceeded), - // Quantity: to.Ptr[int32](3), - // Renew: to.Ptr(false), - // ReservedResourceType: to.Ptr(armreservations.ReservedResourceTypeVirtualMachines), - // SKUDescription: to.Ptr("D1 v2"), - // }, - // SKU: &armreservations.SKUName{ - // Name: to.Ptr("Standard_DS1_v2"), - // }, - // }} -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/1e7b408f3323e7f5424745718fe62c7a043a2337/specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/GetReservationsFromOrder.json -func ExampleReservationClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armreservations.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewReservationClient().NewListPager("276e7ae4-84d0-4da6-ab4b-d6b94f3557da", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ReservationList = armreservations.ReservationList{ - // Value: []*armreservations.ReservationResponse{ - // { - // Name: to.Ptr("bcae77cd-3119-4766-919f-b50d36c75c7a"), - // Type: to.Ptr("Microsoft.Capacity/reservationOrders/reservations"), - // ID: to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/bcae77cd-3119-4766-919f-b50d36c75c7a"), - // Etag: to.Ptr[int32](10), - // Location: to.Ptr("eastus"), - // Properties: &armreservations.Properties{ - // AppliedScopeProperties: &armreservations.AppliedScopeProperties{ - // DisplayName: to.Ptr("Azure subscription 1"), - // SubscriptionID: to.Ptr("/subscriptions/98df3792-7962-4f18-8be2-d5576f122de3"), - // }, - // AppliedScopeType: to.Ptr(armreservations.AppliedScopeTypeSingle), - // BenefitStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-09-22T01:00:30.9253826Z"); return t}()), - // BillingPlan: to.Ptr(armreservations.ReservationBillingPlanMonthly), - // BillingScopeID: to.Ptr("/subscriptions/19376483-64b8-49e4-a931-d5248828720a"), - // DisplayName: to.Ptr("cabri_test"), - // EffectiveDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-09-22T01:00:30.9253826Z"); return t}()), - // ExpiryDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2018-09-22"); return t}()), - // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-22T01:00:30.9253826Z"); return t}()), - // ExtendedStatusInfo: &armreservations.ExtendedStatusInfo{ - // Message: to.Ptr("This reservation was split and is no longer active."), - // StatusCode: to.Ptr(armreservations.ReservationStatusCodeSplit), - // }, - // InstanceFlexibility: to.Ptr(armreservations.InstanceFlexibilityOn), - // LastUpdatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-09-22T01:00:36.3191627Z"); return t}()), - // ProvisioningState: to.Ptr(armreservations.ProvisioningStateSucceeded), - // Quantity: to.Ptr[int32](3), - // Renew: to.Ptr(false), - // ReservedResourceType: to.Ptr(armreservations.ReservedResourceTypeVirtualMachines), - // SKUDescription: to.Ptr("D1 v2"), - // SplitProperties: &armreservations.ReservationSplitProperties{ - // SplitDestinations: []*string{ - // to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/00238563-7312-4c20-a134-8c030bf938a7"), - // to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/e0e4b4f5-77ea-4984-9ee4-6bf9850ee6de")}, - // }, - // }, - // SKU: &armreservations.SKUName{ - // Name: to.Ptr("Standard_DS1_v2"), - // }, - // }, - // { - // Name: to.Ptr("00238563-7312-4c20-a134-8c030bf938a7"), - // Type: to.Ptr("Microsoft.Capacity/reservationOrders/reservations"), - // ID: to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/00238563-7312-4c20-a134-8c030bf938a7"), - // Etag: to.Ptr[int32](5), - // Location: to.Ptr("eastus"), - // Properties: &armreservations.Properties{ - // AppliedScopeProperties: &armreservations.AppliedScopeProperties{ - // DisplayName: to.Ptr("Azure subscription 1"), - // SubscriptionID: to.Ptr("/subscriptions/98df3792-7962-4f18-8be2-d5576f122de3"), - // }, - // AppliedScopeType: to.Ptr(armreservations.AppliedScopeTypeSingle), - // BenefitStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-09-22T22:46:32.7632798Z"); return t}()), - // BillingPlan: to.Ptr(armreservations.ReservationBillingPlanMonthly), - // BillingScopeID: to.Ptr("/subscriptions/19376483-64b8-49e4-a931-d5248828720a"), - // DisplayName: to.Ptr("cabri_test"), - // EffectiveDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-09-22T22:46:32.7632798Z"); return t}()), - // ExpiryDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2018-09-22"); return t}()), - // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-22T22:46:32.7632798Z"); return t}()), - // ExtendedStatusInfo: &armreservations.ExtendedStatusInfo{ - // Message: to.Ptr("This reservation was merged and is no longer active."), - // StatusCode: to.Ptr(armreservations.ReservationStatusCodeMerged), - // }, - // InstanceFlexibility: to.Ptr(armreservations.InstanceFlexibilityOn), - // LastUpdatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-09-22T22:46:32.7632798Z"); return t}()), - // MergeProperties: &armreservations.ReservationMergeProperties{ - // MergeDestination: to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/6ef59113-3482-40da-8d79-787f823e34bc"), - // }, - // ProvisioningState: to.Ptr(armreservations.ProvisioningStateSucceeded), - // Quantity: to.Ptr[int32](1), - // Renew: to.Ptr(false), - // ReservedResourceType: to.Ptr(armreservations.ReservedResourceTypeVirtualMachines), - // SKUDescription: to.Ptr("D1 v2"), - // SplitProperties: &armreservations.ReservationSplitProperties{ - // SplitSource: to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/bcae77cd-3119-4766-919f-b50d36c75c7a"), - // }, - // }, - // SKU: &armreservations.SKUName{ - // Name: to.Ptr("Standard_DS1_v2"), - // }, - // }, - // { - // Name: to.Ptr("e0e4b4f5-77ea-4984-9ee4-6bf9850ee6de"), - // Type: to.Ptr("Microsoft.Capacity/reservationOrders/reservations"), - // ID: to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/e0e4b4f5-77ea-4984-9ee4-6bf9850ee6de"), - // Etag: to.Ptr[int32](4), - // Location: to.Ptr("eastus"), - // Properties: &armreservations.Properties{ - // AppliedScopeProperties: &armreservations.AppliedScopeProperties{ - // DisplayName: to.Ptr("Azure subscription 1"), - // SubscriptionID: to.Ptr("/subscriptions/98df3792-7962-4f18-8be2-d5576f122de3"), - // }, - // AppliedScopeType: to.Ptr(armreservations.AppliedScopeTypeSingle), - // BenefitStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-09-22T22:46:32.7632798Z"); return t}()), - // BillingPlan: to.Ptr(armreservations.ReservationBillingPlanMonthly), - // BillingScopeID: to.Ptr("/subscriptions/19376483-64b8-49e4-a931-d5248828720a"), - // DisplayName: to.Ptr("cabri_test"), - // EffectiveDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-09-22T22:46:32.7632798Z"); return t}()), - // ExpiryDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2018-09-22"); return t}()), - // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-22T22:46:32.7632798Z"); return t}()), - // ExtendedStatusInfo: &armreservations.ExtendedStatusInfo{ - // Message: to.Ptr("This reservation was merged and is no longer active."), - // StatusCode: to.Ptr(armreservations.ReservationStatusCodeMerged), - // }, - // InstanceFlexibility: to.Ptr(armreservations.InstanceFlexibilityOn), - // LastUpdatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-09-22T22:46:32.7632798Z"); return t}()), - // MergeProperties: &armreservations.ReservationMergeProperties{ - // MergeDestination: to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/6ef59113-3482-40da-8d79-787f823e34bc"), - // }, - // ProvisioningState: to.Ptr(armreservations.ProvisioningStateSucceeded), - // Quantity: to.Ptr[int32](2), - // Renew: to.Ptr(false), - // ReservedResourceType: to.Ptr(armreservations.ReservedResourceTypeVirtualMachines), - // SKUDescription: to.Ptr("D1 v2"), - // SplitProperties: &armreservations.ReservationSplitProperties{ - // SplitSource: to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/bcae77cd-3119-4766-919f-b50d36c75c7a"), - // }, - // }, - // SKU: &armreservations.SKUName{ - // Name: to.Ptr("Standard_DS1_v2"), - // }, - // }, - // { - // Name: to.Ptr("6ef59113-3482-40da-8d79-787f823e34bc"), - // Type: to.Ptr("Microsoft.Capacity/reservationOrders/reservations"), - // ID: to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/6ef59113-3482-40da-8d79-787f823e34bc"), - // Etag: to.Ptr[int32](2), - // Location: to.Ptr("eastus"), - // Properties: &armreservations.Properties{ - // AppliedScopeProperties: &armreservations.AppliedScopeProperties{ - // DisplayName: to.Ptr("Azure subscription 1"), - // SubscriptionID: to.Ptr("/subscriptions/98df3792-7962-4f18-8be2-d5576f122de3"), - // }, - // AppliedScopeType: to.Ptr(armreservations.AppliedScopeTypeSingle), - // BenefitStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-09-22T22:46:32.7632798Z"); return t}()), - // BillingPlan: to.Ptr(armreservations.ReservationBillingPlanMonthly), - // BillingScopeID: to.Ptr("/subscriptions/19376483-64b8-49e4-a931-d5248828720a"), - // DisplayName: to.Ptr("cabri_test"), - // EffectiveDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-09-22T22:46:32.7632798Z"); return t}()), - // ExpiryDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2018-09-22"); return t}()), - // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-22T22:46:32.7632798Z"); return t}()), - // InstanceFlexibility: to.Ptr(armreservations.InstanceFlexibilityOn), - // LastUpdatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-09-22T22:46:32.7632798Z"); return t}()), - // MergeProperties: &armreservations.ReservationMergeProperties{ - // MergeSources: []*string{ - // to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/00238563-7312-4c20-a134-8c030bf938a7"), - // to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/e0e4b4f5-77ea-4984-9ee4-6bf9850ee6de")}, - // }, - // ProvisioningState: to.Ptr(armreservations.ProvisioningStateSucceeded), - // Quantity: to.Ptr[int32](3), - // Renew: to.Ptr(false), - // ReservedResourceType: to.Ptr(armreservations.ReservedResourceTypeVirtualMachines), - // SKUDescription: to.Ptr("D1 v2"), - // }, - // SKU: &armreservations.SKUName{ - // Name: to.Ptr("Standard_DS1_v2"), - // }, - // }, - // { - // Name: to.Ptr("5se63214-3382-40da-ed79-787f823e34bc"), - // Type: to.Ptr("Microsoft.Capacity/reservationOrders/reservations"), - // ID: to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/5se63214-3382-40da-ed79-787f823e34bc"), - // Etag: to.Ptr[int32](2), - // Location: to.Ptr("eastus"), - // Properties: &armreservations.Properties{ - // AppliedScopeProperties: &armreservations.AppliedScopeProperties{ - // DisplayName: to.Ptr("Azure subscription 1"), - // SubscriptionID: to.Ptr("/subscriptions/98df3792-7962-4f18-8be2-d5576f122de3"), - // }, - // AppliedScopeType: to.Ptr(armreservations.AppliedScopeTypeSingle), - // BenefitStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-09-22T22:40:32.7632798Z"); return t}()), - // BillingPlan: to.Ptr(armreservations.ReservationBillingPlanMonthly), - // BillingScopeID: to.Ptr("/subscriptions/19376483-64b8-49e4-a931-d5248828720a"), - // DisplayName: to.Ptr("cabri_test"), - // EffectiveDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-09-22T22:46:32.7632798Z"); return t}()), - // ExpiryDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2018-09-22"); return t}()), - // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-22T22:46:32.7632798Z"); return t}()), - // InstanceFlexibility: to.Ptr(armreservations.InstanceFlexibilityOn), - // LastUpdatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-09-22T22:46:32.7632798Z"); return t}()), - // ProvisioningState: to.Ptr(armreservations.ProvisioningStateSucceeded), - // Quantity: to.Ptr[int32](3), - // Renew: to.Ptr(false), - // ReservedResourceType: to.Ptr(armreservations.ReservedResourceTypeVirtualMachines), - // SKUDescription: to.Ptr("D1 v2"), - // SwapProperties: &armreservations.ReservationSwapProperties{ - // SwapDestination: to.Ptr("/providers/microsoft.capacity/reservationOrders/63027ae3-389a-4716-ad77-04f42ce93c06/reservations/4jf50113-3382-40da-ed79-787f823e34bc"), - // }, - // }, - // SKU: &armreservations.SKUName{ - // Name: to.Ptr("Standard_D1_v2"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/1e7b408f3323e7f5424745718fe62c7a043a2337/specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/GetReservationDetails.json -func ExampleReservationClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armreservations.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewReservationClient().Get(ctx, "276e7ae4-84d0-4da6-ab4b-d6b94f3557da", "6ef59113-3482-40da-8d79-787f823e34bc", &armreservations.ReservationClientGetOptions{Expand: to.Ptr("renewProperties")}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ReservationResponse = armreservations.ReservationResponse{ - // Name: to.Ptr("6ef59113-3482-40da-8d79-787f823e34bc"), - // Type: to.Ptr("Microsoft.Capacity/reservationOrders/reservations"), - // ID: to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/6ef59113-3482-40da-8d79-787f823e34bc"), - // Etag: to.Ptr[int32](2), - // Location: to.Ptr("eastus"), - // Properties: &armreservations.Properties{ - // AppliedScopeProperties: &armreservations.AppliedScopeProperties{ - // DisplayName: to.Ptr("Azure subscription 1"), - // SubscriptionID: to.Ptr("/subscriptions/98df3792-7962-4f18-8be2-d5576f122de3"), - // }, - // AppliedScopeType: to.Ptr(armreservations.AppliedScopeTypeSingle), - // BenefitStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-09-22T22:46:32.7632798Z"); return t}()), - // BillingPlan: to.Ptr(armreservations.ReservationBillingPlanMonthly), - // BillingScopeID: to.Ptr("/subscriptions/19376483-64b8-49e4-a931-d5248828720a"), - // DisplayName: to.Ptr("cabri_test"), - // EffectiveDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-09-22T22:46:32.7632798Z"); return t}()), - // ExpiryDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2018-09-22"); return t}()), - // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-22T22:46:32.7632798Z"); return t}()), - // InstanceFlexibility: to.Ptr(armreservations.InstanceFlexibilityOff), - // LastUpdatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-09-22T22:46:32.7632798Z"); return t}()), - // MergeProperties: &armreservations.ReservationMergeProperties{ - // MergeSources: []*string{ - // to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/00238563-7312-4c20-a134-8c030bf938a7"), - // to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/e0e4b4f5-77ea-4984-9ee4-6bf9850ee6de")}, - // }, - // ProvisioningState: to.Ptr(armreservations.ProvisioningStateSucceeded), - // Quantity: to.Ptr[int32](3), - // Renew: to.Ptr(false), - // RenewDestination: to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/00238563-7312-4c20-a134-8c030bf938a7"), - // RenewProperties: &armreservations.RenewPropertiesResponse{ - // BillingCurrencyTotal: &armreservations.RenewPropertiesResponseBillingCurrencyTotal{ - // Amount: to.Ptr[float32](466), - // CurrencyCode: to.Ptr("USD"), - // }, - // PricingCurrencyTotal: &armreservations.RenewPropertiesResponsePricingCurrencyTotal{ - // Amount: to.Ptr[float32](466), - // CurrencyCode: to.Ptr("USD"), - // }, - // PurchaseProperties: &armreservations.PurchaseRequest{ - // Location: to.Ptr("westus"), - // Properties: &armreservations.PurchaseRequestProperties{ - // AppliedScopeType: to.Ptr(armreservations.AppliedScopeTypeShared), - // BillingScopeID: to.Ptr("/subscriptions/19376483-64b8-49e4-a931-d5248828720a"), - // DisplayName: to.Ptr("Renew_Test_0618"), - // Quantity: to.Ptr[int32](2), - // Renew: to.Ptr(false), - // ReservedResourceProperties: &armreservations.PurchaseRequestPropertiesReservedResourceProperties{ - // InstanceFlexibility: to.Ptr(armreservations.InstanceFlexibilityOn), - // }, - // ReservedResourceType: to.Ptr(armreservations.ReservedResourceTypeVirtualMachines), - // Term: to.Ptr(armreservations.ReservationTermP1Y), - // }, - // SKU: &armreservations.SKUName{ - // Name: to.Ptr("Standard_D1"), - // }, - // }, - // }, - // RenewSource: to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/00238563-7312-4c20-a134-8c030bf938a7"), - // ReservedResourceType: to.Ptr(armreservations.ReservedResourceTypeVirtualMachines), - // SKUDescription: to.Ptr("D1 v2"), - // SwapProperties: &armreservations.ReservationSwapProperties{ - // SwapSource: to.Ptr("/providers/microsoft.capacity/reservationOrders/63037ae3-385a-4716-ad77-02f42ce93c06/reservations/5c6383f5-3f2c-4159-ae74-j72i1c1a49bc"), - // }, - // Term: to.Ptr(armreservations.ReservationTermP1Y), - // }, - // SKU: &armreservations.SKUName{ - // Name: to.Ptr("Standard_DS1_v2"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/1e7b408f3323e7f5424745718fe62c7a043a2337/specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/UpdateReservation.json -func ExampleReservationClient_BeginUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armreservations.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewReservationClient().BeginUpdate(ctx, "276e7ae4-84d0-4da6-ab4b-d6b94f3557da", "6ef59113-3482-40da-8d79-787f823e34bc", armreservations.Patch{ - Properties: &armreservations.PatchProperties{ - AppliedScopeType: to.Ptr(armreservations.AppliedScopeTypeShared), - InstanceFlexibility: to.Ptr(armreservations.InstanceFlexibilityOff), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ReservationResponse = armreservations.ReservationResponse{ - // Name: to.Ptr("6ef59113-3482-40da-8d79-787f823e34bc"), - // Type: to.Ptr("Microsoft.Capacity/reservationOrders/reservations"), - // ID: to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/6ef59113-3482-40da-8d79-787f823e34bc"), - // Etag: to.Ptr[int32](4), - // Location: to.Ptr("eastus"), - // Properties: &armreservations.Properties{ - // AppliedScopeType: to.Ptr(armreservations.AppliedScopeTypeShared), - // BillingPlan: to.Ptr(armreservations.ReservationBillingPlanMonthly), - // BillingScopeID: to.Ptr("/subscriptions/19376483-64b8-49e4-a931-d5248828720a"), - // DisplayName: to.Ptr("cabri_test"), - // EffectiveDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-09-22T23:57:48.1891638Z"); return t}()), - // ExpiryDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2018-09-22"); return t}()), - // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-22T23:57:48.1891638Z"); return t}()), - // InstanceFlexibility: to.Ptr(armreservations.InstanceFlexibilityOff), - // LastUpdatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-09-22T23:57:54.3768768Z"); return t}()), - // MergeProperties: &armreservations.ReservationMergeProperties{ - // MergeSources: []*string{ - // to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/00238563-7312-4c20-a134-8c030bf938a7"), - // to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/e0e4b4f5-77ea-4984-9ee4-6bf9850ee6de")}, - // }, - // ProvisioningState: to.Ptr(armreservations.ProvisioningStateSucceeded), - // Quantity: to.Ptr[int32](3), - // Renew: to.Ptr(false), - // ReservedResourceType: to.Ptr(armreservations.ReservedResourceTypeVirtualMachines), - // SKUDescription: to.Ptr("D1 v2"), - // }, - // SKU: &armreservations.SKUName{ - // Name: to.Ptr("Standard_DS1_v2"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/1e7b408f3323e7f5424745718fe62c7a043a2337/specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/Archive.json -func ExampleReservationClient_Archive() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armreservations.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewReservationClient().Archive(ctx, "276e7ae4-84d0-4da6-ab4b-d6b94f3557da", "356e7ae4-84d0-4da6-ab4b-d6b94f3557da", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/1e7b408f3323e7f5424745718fe62c7a043a2337/specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/Unarchive.json -func ExampleReservationClient_Unarchive() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armreservations.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewReservationClient().Unarchive(ctx, "276e7ae4-84d0-4da6-ab4b-d6b94f3557da", "356e7ae4-84d0-4da6-ab4b-d6b94f3557da", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/1e7b408f3323e7f5424745718fe62c7a043a2337/specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/GetReservationRevisions.json -func ExampleReservationClient_NewListRevisionsPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armreservations.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewReservationClient().NewListRevisionsPager("276e7ae4-84d0-4da6-ab4b-d6b94f3557da", "6ef59113-3482-40da-8d79-787f823e34bc", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ReservationList = armreservations.ReservationList{ - // Value: []*armreservations.ReservationResponse{ - // { - // Name: to.Ptr("4"), - // Type: to.Ptr("Microsoft.Capacity/reservationOrders/reservations/revisions"), - // ID: to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/6ef59113-3482-40da-8d79-787f823e34bc/revisions/4"), - // Etag: to.Ptr[int32](4), - // Location: to.Ptr("eastus"), - // Properties: &armreservations.Properties{ - // AppliedScopeType: to.Ptr(armreservations.AppliedScopeTypeShared), - // BillingPlan: to.Ptr(armreservations.ReservationBillingPlanMonthly), - // DisplayName: to.Ptr("cabri_test"), - // EffectiveDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-09-22T23:57:48.1891638Z"); return t}()), - // ExpiryDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2018-09-22"); return t}()), - // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-22T23:57:48.1891638Z"); return t}()), - // InstanceFlexibility: to.Ptr(armreservations.InstanceFlexibilityOn), - // LastUpdatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-09-22T23:57:54.3768768Z"); return t}()), - // MergeProperties: &armreservations.ReservationMergeProperties{ - // MergeSources: []*string{ - // to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/00238563-7312-4c20-a134-8c030bf938a7"), - // to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/e0e4b4f5-77ea-4984-9ee4-6bf9850ee6de")}, - // }, - // ProvisioningState: to.Ptr(armreservations.ProvisioningStateSucceeded), - // Quantity: to.Ptr[int32](3), - // ReservedResourceType: to.Ptr(armreservations.ReservedResourceTypeVirtualMachines), - // SKUDescription: to.Ptr("D1 v2"), - // }, - // SKU: &armreservations.SKUName{ - // Name: to.Ptr("Standard_DS1_v2"), - // }, - // }, - // { - // Name: to.Ptr("3"), - // Type: to.Ptr("Microsoft.Capacity/reservationOrders/reservations/revisions"), - // ID: to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/6ef59113-3482-40da-8d79-787f823e34bc/revisions/3"), - // Etag: to.Ptr[int32](3), - // Location: to.Ptr("eastus"), - // Properties: &armreservations.Properties{ - // AppliedScopeProperties: &armreservations.AppliedScopeProperties{ - // DisplayName: to.Ptr("Azure subscription 1"), - // SubscriptionID: to.Ptr("/subscriptions/98df3792-7962-4f18-8be2-d5576f122de3"), - // }, - // AppliedScopeType: to.Ptr(armreservations.AppliedScopeTypeSingle), - // BillingPlan: to.Ptr(armreservations.ReservationBillingPlanMonthly), - // DisplayName: to.Ptr("cabri_test"), - // EffectiveDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-09-22T22:46:32.7632798Z"); return t}()), - // ExpiryDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2018-09-22"); return t}()), - // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-22T22:46:32.7632798Z"); return t}()), - // ExtendedStatusInfo: &armreservations.ExtendedStatusInfo{ - // Message: to.Ptr("An operation is in progress on your reservation. Please wait for operation to complete before taking further action"), - // StatusCode: to.Ptr(armreservations.ReservationStatusCodePending), - // }, - // InstanceFlexibility: to.Ptr(armreservations.InstanceFlexibilityOn), - // LastUpdatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-09-22T23:57:47.488284Z"); return t}()), - // MergeProperties: &armreservations.ReservationMergeProperties{ - // MergeSources: []*string{ - // to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/00238563-7312-4c20-a134-8c030bf938a7"), - // to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/e0e4b4f5-77ea-4984-9ee4-6bf9850ee6de")}, - // }, - // ProvisioningState: to.Ptr(armreservations.ProvisioningStateSucceeded), - // Quantity: to.Ptr[int32](3), - // ReservedResourceType: to.Ptr(armreservations.ReservedResourceTypeVirtualMachines), - // SKUDescription: to.Ptr("D1 v2"), - // }, - // SKU: &armreservations.SKUName{ - // Name: to.Ptr("Standard_DS1_v2"), - // }, - // }, - // { - // Name: to.Ptr("2"), - // Type: to.Ptr("Microsoft.Capacity/reservationOrders/reservations/revisions"), - // ID: to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/6ef59113-3482-40da-8d79-787f823e34bc/revisions/2"), - // Etag: to.Ptr[int32](2), - // Location: to.Ptr("eastus"), - // Properties: &armreservations.Properties{ - // AppliedScopeProperties: &armreservations.AppliedScopeProperties{ - // DisplayName: to.Ptr("Azure subscription 1"), - // SubscriptionID: to.Ptr("/subscriptions/98df3792-7962-4f18-8be2-d5576f122de3"), - // }, - // AppliedScopeType: to.Ptr(armreservations.AppliedScopeTypeSingle), - // BillingPlan: to.Ptr(armreservations.ReservationBillingPlanMonthly), - // DisplayName: to.Ptr("cabri_test"), - // EffectiveDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-09-22T22:46:32.7632798Z"); return t}()), - // ExpiryDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2018-09-22"); return t}()), - // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-22T22:46:32.7632798Z"); return t}()), - // InstanceFlexibility: to.Ptr(armreservations.InstanceFlexibilityOn), - // LastUpdatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-09-22T22:46:32.7632798Z"); return t}()), - // MergeProperties: &armreservations.ReservationMergeProperties{ - // MergeSources: []*string{ - // to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/00238563-7312-4c20-a134-8c030bf938a7"), - // to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/e0e4b4f5-77ea-4984-9ee4-6bf9850ee6de")}, - // }, - // ProvisioningState: to.Ptr(armreservations.ProvisioningStateSucceeded), - // Quantity: to.Ptr[int32](3), - // ReservedResourceType: to.Ptr(armreservations.ReservedResourceTypeVirtualMachines), - // SKUDescription: to.Ptr("D1 v2"), - // SwapProperties: &armreservations.ReservationSwapProperties{ - // SwapDestination: to.Ptr("/providers/microsoft.capacity/reservationOrders/afadf486-3432-4254-b297-4db8ef055f38/reservations/317efb41-b3ef-3706-8447-c2c045ab3ef5"), - // }, - // }, - // SKU: &armreservations.SKUName{ - // Name: to.Ptr("Standard_DS1_v2"), - // }, - // }, - // { - // Name: to.Ptr("1"), - // Type: to.Ptr("Microsoft.Capacity/reservationOrders/reservations/revisions"), - // ID: to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/6ef59113-3482-40da-8d79-787f823e34bc/revisions/1"), - // Etag: to.Ptr[int32](1), - // Location: to.Ptr("eastus"), - // Properties: &armreservations.Properties{ - // AppliedScopeProperties: &armreservations.AppliedScopeProperties{ - // DisplayName: to.Ptr("Azure subscription 1"), - // SubscriptionID: to.Ptr("/subscriptions/98df3792-7962-4f18-8be2-d5576f122de3"), - // }, - // AppliedScopeType: to.Ptr(armreservations.AppliedScopeTypeSingle), - // DisplayName: to.Ptr("cabri_test"), - // EffectiveDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-09-22T22:46:27.3313607Z"); return t}()), - // ExpiryDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2018-09-22"); return t}()), - // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-22T22:46:27.3313607Z"); return t}()), - // InstanceFlexibility: to.Ptr(armreservations.InstanceFlexibilityOn), - // LastUpdatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-09-22T22:46:27.3313607Z"); return t}()), - // MergeProperties: &armreservations.ReservationMergeProperties{ - // MergeSources: []*string{ - // to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/00238563-7312-4c20-a134-8c030bf938a7"), - // to.Ptr("/providers/microsoft.capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/e0e4b4f5-77ea-4984-9ee4-6bf9850ee6de")}, - // }, - // ProvisioningState: to.Ptr(armreservations.ProvisioningStateSucceeded), - // Quantity: to.Ptr[int32](3), - // ReservedResourceType: to.Ptr(armreservations.ReservedResourceTypeVirtualMachines), - // SKUDescription: to.Ptr("D1 v2"), - // }, - // SKU: &armreservations.SKUName{ - // Name: to.Ptr("Standard_DS1_v2"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/1e7b408f3323e7f5424745718fe62c7a043a2337/specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/GetReservations.json -func ExampleReservationClient_NewListAllPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armreservations.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewReservationClient().NewListAllPager(&armreservations.ReservationClientListAllOptions{Filter: to.Ptr("(properties%2farchived+eq+false)"), - Orderby: to.Ptr("properties/displayName asc"), - RefreshSummary: nil, - Skiptoken: to.Ptr[float32](50), - SelectedState: nil, - Take: to.Ptr[float32](1), - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ListResult = armreservations.ListResult{ - // Summary: &armreservations.ReservationSummary{ - // CancelledCount: to.Ptr[float32](0), - // ExpiredCount: to.Ptr[float32](0), - // ExpiringCount: to.Ptr[float32](0), - // FailedCount: to.Ptr[float32](0), - // PendingCount: to.Ptr[float32](0), - // SucceededCount: to.Ptr[float32](1), - // }, - // Value: []*armreservations.ReservationResponse{ - // { - // Name: to.Ptr("00000000-0000-0000-0000-000000000001/00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.Capacity/reservationOrders/reservations"), - // ID: to.Ptr("/providers/microsoft.capacity/reservationOrders/00000000-0000-0000-0000-000000000001/reservations/00000000-0000-0000-0000-000000000000"), - // Location: to.Ptr("westus"), - // Properties: &armreservations.Properties{ - // AppliedScopeType: to.Ptr(armreservations.AppliedScopeTypeShared), - // DisplayName: to.Ptr("VM_RI_07-21-2020_12-06"), - // DisplayProvisioningState: to.Ptr("Succeeded"), - // EffectiveDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-09-22T22:46:32.7632798Z"); return t}()), - // ExpiryDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2023-07-21"); return t}()), - // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-07-21T22:46:32.7632798Z"); return t}()), - // ProvisioningState: to.Ptr(armreservations.ProvisioningStateSucceeded), - // PurchaseDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2021-04-22"); return t}()), - // PurchaseDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-22T22:46:32.7632798Z"); return t}()), - // Quantity: to.Ptr[int32](2), - // Renew: to.Ptr(false), - // RenewSource: to.Ptr("/providers/Microsoft.Capacity/reservationorders/00000000-0000-0000-0000-000000000002/reservations/00000000-0000-0000-0000-000000000003"), - // ReservedResourceType: to.Ptr(armreservations.ReservedResourceTypeVirtualMachines), - // Term: to.Ptr(armreservations.ReservationTermP3Y), - // UserFriendlyAppliedScopeType: to.Ptr("Shared"), - // UserFriendlyRenewState: to.Ptr("Off"), - // Utilization: &armreservations.PropertiesUtilization{ - // Aggregates: []*armreservations.ReservationUtilizationAggregates{ - // { - // Grain: to.Ptr[float32](1), - // GrainUnit: to.Ptr("days"), - // Value: to.Ptr[float32](0.05), - // ValueUnit: to.Ptr("percentage"), - // }, - // { - // Grain: to.Ptr[float32](7), - // GrainUnit: to.Ptr("days"), - // Value: to.Ptr[float32](0.05), - // ValueUnit: to.Ptr("percentage"), - // }, - // { - // Grain: to.Ptr[float32](30), - // GrainUnit: to.Ptr("days"), - // Value: to.Ptr[float32](0.05), - // ValueUnit: to.Ptr("percentage"), - // }}, - // Trend: to.Ptr("UP"), - // }, - // }, - // SKU: &armreservations.SKUName{ - // Name: to.Ptr("Standard_D1"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/reservations/armreservations/reservationorder_client.go b/sdk/resourcemanager/reservations/armreservations/reservationorder_client.go index c9b146649fac..7a3ad43de68e 100644 --- a/sdk/resourcemanager/reservations/armreservations/reservationorder_client.go +++ b/sdk/resourcemanager/reservations/armreservations/reservationorder_client.go @@ -3,9 +3,8 @@ // 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. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armreservations @@ -49,18 +48,21 @@ func NewReservationOrderClient(credential azcore.TokenCredential, options *arm.C // - options - ReservationOrderClientCalculateOptions contains the optional parameters for the ReservationOrderClient.Calculate // method. func (client *ReservationOrderClient) Calculate(ctx context.Context, body PurchaseRequest, options *ReservationOrderClientCalculateOptions) (ReservationOrderClientCalculateResponse, error) { + var err error req, err := client.calculateCreateRequest(ctx, body, options) if err != nil { return ReservationOrderClientCalculateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ReservationOrderClientCalculateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ReservationOrderClientCalculateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ReservationOrderClientCalculateResponse{}, err } - return client.calculateHandleResponse(resp) + resp, err := client.calculateHandleResponse(httpResp) + return resp, err } // calculateCreateRequest creates the Calculate request. @@ -74,7 +76,10 @@ func (client *ReservationOrderClient) calculateCreateRequest(ctx context.Context reqQP.Set("api-version", "2022-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil } // calculateHandleResponse handles the Calculate response. @@ -95,18 +100,21 @@ func (client *ReservationOrderClient) calculateHandleResponse(resp *http.Respons // - options - ReservationOrderClientChangeDirectoryOptions contains the optional parameters for the ReservationOrderClient.ChangeDirectory // method. func (client *ReservationOrderClient) ChangeDirectory(ctx context.Context, reservationOrderID string, body ChangeDirectoryRequest, options *ReservationOrderClientChangeDirectoryOptions) (ReservationOrderClientChangeDirectoryResponse, error) { + var err error req, err := client.changeDirectoryCreateRequest(ctx, reservationOrderID, body, options) if err != nil { return ReservationOrderClientChangeDirectoryResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ReservationOrderClientChangeDirectoryResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ReservationOrderClientChangeDirectoryResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ReservationOrderClientChangeDirectoryResponse{}, err } - return client.changeDirectoryHandleResponse(resp) + resp, err := client.changeDirectoryHandleResponse(httpResp) + return resp, err } // changeDirectoryCreateRequest creates the ChangeDirectory request. @@ -124,7 +132,10 @@ func (client *ReservationOrderClient) changeDirectoryCreateRequest(ctx context.C reqQP.Set("api-version", "2022-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil } // changeDirectoryHandleResponse handles the ChangeDirectory response. @@ -143,18 +154,21 @@ func (client *ReservationOrderClient) changeDirectoryHandleResponse(resp *http.R // - reservationOrderID - Order Id of the reservation // - options - ReservationOrderClientGetOptions contains the optional parameters for the ReservationOrderClient.Get method. func (client *ReservationOrderClient) Get(ctx context.Context, reservationOrderID string, options *ReservationOrderClientGetOptions) (ReservationOrderClientGetResponse, error) { + var err error req, err := client.getCreateRequest(ctx, reservationOrderID, options) if err != nil { return ReservationOrderClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ReservationOrderClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ReservationOrderClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ReservationOrderClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -257,9 +271,10 @@ func (client *ReservationOrderClient) BeginPurchase(ctx context.Context, reserva if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ReservationOrderClientPurchaseResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ReservationOrderClientPurchaseResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[ReservationOrderClientPurchaseResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -270,18 +285,20 @@ func (client *ReservationOrderClient) BeginPurchase(ctx context.Context, reserva // // Generated from API version 2022-11-01 func (client *ReservationOrderClient) purchase(ctx context.Context, reservationOrderID string, body PurchaseRequest, options *ReservationOrderClientBeginPurchaseOptions) (*http.Response, error) { + var err error req, err := client.purchaseCreateRequest(ctx, reservationOrderID, body, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // purchaseCreateRequest creates the Purchase request. @@ -299,5 +316,8 @@ func (client *ReservationOrderClient) purchaseCreateRequest(ctx context.Context, reqQP.Set("api-version", "2022-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil } diff --git a/sdk/resourcemanager/reservations/armreservations/reservationorder_client_example_test.go b/sdk/resourcemanager/reservations/armreservations/reservationorder_client_example_test.go deleted file mode 100644 index 01d000237d2c..000000000000 --- a/sdk/resourcemanager/reservations/armreservations/reservationorder_client_example_test.go +++ /dev/null @@ -1,472 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armreservations_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/reservations/armreservations/v3" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/1e7b408f3323e7f5424745718fe62c7a043a2337/specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/CalculateReservationOrder.json -func ExampleReservationOrderClient_Calculate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armreservations.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewReservationOrderClient().Calculate(ctx, armreservations.PurchaseRequest{ - Location: to.Ptr("westus"), - Properties: &armreservations.PurchaseRequestProperties{ - AppliedScopeType: to.Ptr(armreservations.AppliedScopeTypeShared), - BillingPlan: to.Ptr(armreservations.ReservationBillingPlanMonthly), - BillingScopeID: to.Ptr("/subscriptions/ed3a1871-612d-abcd-a849-c2542a68be83"), - DisplayName: to.Ptr("TestReservationOrder"), - Quantity: to.Ptr[int32](1), - ReservedResourceProperties: &armreservations.PurchaseRequestPropertiesReservedResourceProperties{ - InstanceFlexibility: to.Ptr(armreservations.InstanceFlexibilityOn), - }, - ReservedResourceType: to.Ptr(armreservations.ReservedResourceTypeVirtualMachines), - Term: to.Ptr(armreservations.ReservationTermP1Y), - }, - SKU: &armreservations.SKUName{ - Name: to.Ptr("standard_D1"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.CalculatePriceResponse = armreservations.CalculatePriceResponse{ - // Properties: &armreservations.CalculatePriceResponseProperties{ - // BillingCurrencyTotal: &armreservations.CalculatePriceResponsePropertiesBillingCurrencyTotal{ - // Amount: to.Ptr[float64](46), - // CurrencyCode: to.Ptr("USD"), - // }, - // PaymentSchedule: []*armreservations.PaymentDetail{ - // { - // BillingCurrencyTotal: &armreservations.Price{ - // Amount: to.Ptr[float64](40), - // CurrencyCode: to.Ptr("EUR"), - // }, - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2019-05-14"); return t}()), - // PricingCurrencyTotal: &armreservations.Price{ - // Amount: to.Ptr[float64](46), - // CurrencyCode: to.Ptr("USD"), - // }, - // }, - // { - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2019-06-14"); return t}()), - // PricingCurrencyTotal: &armreservations.Price{ - // Amount: to.Ptr[float64](46), - // CurrencyCode: to.Ptr("USD"), - // }, - // }, - // { - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2019-07-14"); return t}()), - // PricingCurrencyTotal: &armreservations.Price{ - // Amount: to.Ptr[float64](46), - // CurrencyCode: to.Ptr("USD"), - // }, - // }}, - // PricingCurrencyTotal: &armreservations.CalculatePriceResponsePropertiesPricingCurrencyTotal{ - // Amount: to.Ptr[float32](46), - // CurrencyCode: to.Ptr("USD"), - // }, - // ReservationOrderID: to.Ptr("6d9cec54-7de8-abcd-9de7-80f5d634f2d2"), - // SKUDescription: to.Ptr("standard_D1"), - // SKUTitle: to.Ptr("Reserved VM Instance, Standard_D1, US West, 1 Year"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/1e7b408f3323e7f5424745718fe62c7a043a2337/specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/GetReservationOrders.json -func ExampleReservationOrderClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armreservations.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewReservationOrderClient().NewListPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ReservationOrderList = armreservations.ReservationOrderList{ - // Value: []*armreservations.ReservationOrderResponse{ - // { - // Name: to.Ptr("1e6407ba-37a5-499f-80ed-a3f0f338e443"), - // Type: to.Ptr("Microsoft.Capacity/reservationOrders"), - // Etag: to.Ptr[int32](7), - // ID: to.Ptr("/providers/microsoft.capacity/reservationOrders/1e6407ba-37a5-499f-80ed-a3f0f338e443"), - // Properties: &armreservations.ReservationOrderProperties{ - // BenefitStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-29T21:20:23.8134834Z"); return t}()), - // BillingPlan: to.Ptr(armreservations.ReservationBillingPlanMonthly), - // CreatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-29T21:22:56.8541664Z"); return t}()), - // DisplayName: to.Ptr("cabri"), - // ExpiryDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2018-08-29"); return t}()), - // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-29T21:20:23.8134834Z"); return t}()), - // OriginalQuantity: to.Ptr[int32](1), - // ProvisioningState: to.Ptr(armreservations.ProvisioningStateSucceeded), - // RequestDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-29T21:20:23.8134834Z"); return t}()), - // Reservations: []*armreservations.ReservationResponse{ - // { - // ID: to.Ptr("/providers/microsoft.capacity/reservationOrders/1e6407ba-37a5-499f-80ed-a3f0f338e443/reservations/cae5924e-7a15-419f-a369-124f52d4a106"), - // }}, - // Term: to.Ptr(armreservations.ReservationTermP1Y), - // }, - // }, - // { - // Name: to.Ptr("1ea6e203-288e-4732-b9e1-da8bbe10c614"), - // Type: to.Ptr("Microsoft.Capacity/reservationOrders"), - // Etag: to.Ptr[int32](7), - // ID: to.Ptr("/providers/microsoft.capacity/reservationOrders/1ea6e203-288e-4732-b9e1-da8bbe10c614"), - // Properties: &armreservations.ReservationOrderProperties{ - // BenefitStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-30T12:55:40.2799114Z"); return t}()), - // BillingPlan: to.Ptr(armreservations.ReservationBillingPlanMonthly), - // CreatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-30T12:58:20.526Z"); return t}()), - // DisplayName: to.Ptr("cabri"), - // ExpiryDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2018-08-30"); return t}()), - // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-30T12:58:20.526Z"); return t}()), - // OriginalQuantity: to.Ptr[int32](9), - // ProvisioningState: to.Ptr(armreservations.ProvisioningStateSucceeded), - // RequestDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-30T12:55:40.2799114Z"); return t}()), - // Reservations: []*armreservations.ReservationResponse{ - // { - // ID: to.Ptr("/providers/microsoft.capacity/reservationOrders/1ea6e203-288e-4732-b9e1-da8bbe10c614/reservations/d04fd48d-e3f6-42a3-a8f6-1ad0b7513e48"), - // }}, - // Term: to.Ptr(armreservations.ReservationTermP1Y), - // }, - // }, - // { - // Name: to.Ptr("1f14354c-dc12-4c8d-8090-6f295a3a34aa"), - // Type: to.Ptr("Microsoft.Capacity/reservationOrders"), - // Etag: to.Ptr[int32](7), - // ID: to.Ptr("/providers/microsoft.capacity/reservationOrders/1f14354c-dc12-4c8d-8090-6f295a3a34aa"), - // Properties: &armreservations.ReservationOrderProperties{ - // BenefitStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-30T03:49:19.0252126Z"); return t}()), - // BillingPlan: to.Ptr(armreservations.ReservationBillingPlanMonthly), - // CreatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-30T03:51:49.8083758Z"); return t}()), - // DisplayName: to.Ptr("cabri"), - // ExpiryDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2018-08-30"); return t}()), - // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-30T03:51:49.8083758Z"); return t}()), - // OriginalQuantity: to.Ptr[int32](7), - // ProvisioningState: to.Ptr(armreservations.ProvisioningStateSucceeded), - // RequestDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-30T03:49:19.0252126Z"); return t}()), - // Reservations: []*armreservations.ReservationResponse{ - // { - // ID: to.Ptr("/providers/microsoft.capacity/reservationOrders/1f14354c-dc12-4c8d-8090-6f295a3a34aa/reservations/c8c926bd-fc5d-4e29-9d43-b68340ac23a6"), - // }}, - // Term: to.Ptr(armreservations.ReservationTermP1Y), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/1e7b408f3323e7f5424745718fe62c7a043a2337/specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/PurchaseReservationOrder.json -func ExampleReservationOrderClient_BeginPurchase() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armreservations.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewReservationOrderClient().BeginPurchase(ctx, "a075419f-44cc-497f-b68a-14ee811d48b9", armreservations.PurchaseRequest{ - Location: to.Ptr("westus"), - Properties: &armreservations.PurchaseRequestProperties{ - AppliedScopeType: to.Ptr(armreservations.AppliedScopeTypeShared), - BillingPlan: to.Ptr(armreservations.ReservationBillingPlanMonthly), - BillingScopeID: to.Ptr("/subscriptions/ed3a1871-612d-abcd-a849-c2542a68be83"), - DisplayName: to.Ptr("TestReservationOrder"), - Quantity: to.Ptr[int32](1), - Renew: to.Ptr(false), - ReservedResourceProperties: &armreservations.PurchaseRequestPropertiesReservedResourceProperties{ - InstanceFlexibility: to.Ptr(armreservations.InstanceFlexibilityOn), - }, - ReservedResourceType: to.Ptr(armreservations.ReservedResourceTypeVirtualMachines), - Term: to.Ptr(armreservations.ReservationTermP1Y), - }, - SKU: &armreservations.SKUName{ - Name: to.Ptr("standard_D1"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ReservationOrderResponse = armreservations.ReservationOrderResponse{ - // Name: to.Ptr("1f14354c-dc12-4c8d-8090-6f295a3a34aa"), - // Type: to.Ptr("Microsoft.Capacity/reservationOrders"), - // Etag: to.Ptr[int32](7), - // ID: to.Ptr("/providers/microsoft.capacity/reservationOrders/1f14354c-dc12-4c8d-8090-6f295a3a34aa"), - // Properties: &armreservations.ReservationOrderProperties{ - // BillingPlan: to.Ptr(armreservations.ReservationBillingPlanMonthly), - // CreatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-30T03:51:49.8083758Z"); return t}()), - // DisplayName: to.Ptr("cabri"), - // ExpiryDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2018-08-30"); return t}()), - // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-30T03:51:49.8083758Z"); return t}()), - // OriginalQuantity: to.Ptr[int32](7), - // ProvisioningState: to.Ptr(armreservations.ProvisioningStateSucceeded), - // RequestDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-30T03:49:19.0252126Z"); return t}()), - // Reservations: []*armreservations.ReservationResponse{ - // { - // ID: to.Ptr("/providers/microsoft.capacity/reservationOrders/1f14354c-dc12-4c8d-8090-6f295a3a34aa/reservations/c8c926bd-fc5d-4e29-9d43-b68340ac23a6"), - // }}, - // Term: to.Ptr(armreservations.ReservationTermP1Y), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/1e7b408f3323e7f5424745718fe62c7a043a2337/specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/GetReservationOrderDetails.json -func ExampleReservationOrderClient_Get_getReservationOrder() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armreservations.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewReservationOrderClient().Get(ctx, "a075419f-44cc-497f-b68a-14ee811d48b9", &armreservations.ReservationOrderClientGetOptions{Expand: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ReservationOrderResponse = armreservations.ReservationOrderResponse{ - // Name: to.Ptr("1f14354c-dc12-4c8d-8090-6f295a3a34aa"), - // Type: to.Ptr("Microsoft.Capacity/reservationOrders"), - // Etag: to.Ptr[int32](7), - // ID: to.Ptr("/providers/microsoft.capacity/reservationOrders/1f14354c-dc12-4c8d-8090-6f295a3a34aa"), - // Properties: &armreservations.ReservationOrderProperties{ - // BenefitStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-30T03:49:19.0252126Z"); return t}()), - // BillingPlan: to.Ptr(armreservations.ReservationBillingPlanMonthly), - // CreatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-30T03:51:49.8083758Z"); return t}()), - // DisplayName: to.Ptr("cabri"), - // ExpiryDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2018-08-30"); return t}()), - // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-30T03:51:49.8083758Z"); return t}()), - // OriginalQuantity: to.Ptr[int32](7), - // ProvisioningState: to.Ptr(armreservations.ProvisioningStateSucceeded), - // RequestDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-30T03:49:19.0252126Z"); return t}()), - // Reservations: []*armreservations.ReservationResponse{ - // { - // ID: to.Ptr("/providers/microsoft.capacity/reservationOrders/1f14354c-dc12-4c8d-8090-6f295a3a34aa/reservations/c8c926bd-fc5d-4e29-9d43-b68340ac23a6"), - // }}, - // Term: to.Ptr(armreservations.ReservationTermP1Y), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/1e7b408f3323e7f5424745718fe62c7a043a2337/specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/GetReservationOrderDetailsWithExpandPlanInformation.json -func ExampleReservationOrderClient_Get_getReservationWithExpandPayments() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armreservations.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewReservationOrderClient().Get(ctx, "a075419f-44cc-497f-b68a-14ee811d48b9", &armreservations.ReservationOrderClientGetOptions{Expand: to.Ptr("schedule")}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ReservationOrderResponse = armreservations.ReservationOrderResponse{ - // Name: to.Ptr("1f14354c-dc12-4c8d-8090-6f295a3a34aa"), - // Type: to.Ptr("Microsoft.Capacity/reservationOrders"), - // Etag: to.Ptr[int32](7), - // ID: to.Ptr("/providers/microsoft.capacity/reservationOrders/1f14354c-dc12-4c8d-8090-6f295a3a34aa"), - // Properties: &armreservations.ReservationOrderProperties{ - // BenefitStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-30T03:51:49Z"); return t}()), - // BillingPlan: to.Ptr(armreservations.ReservationBillingPlanMonthly), - // CreatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-30T03:51:49Z"); return t}()), - // DisplayName: to.Ptr("cabri"), - // ExpiryDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2018-08-30"); return t}()), - // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-30T03:51:49Z"); return t}()), - // OriginalQuantity: to.Ptr[int32](7), - // PlanInformation: &armreservations.ReservationOrderBillingPlanInformation{ - // NextPaymentDueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2019-09-30"); return t}()), - // PricingCurrencyTotal: &armreservations.Price{ - // Amount: to.Ptr[float64](466), - // CurrencyCode: to.Ptr("USD"), - // }, - // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2019-08-30"); return t}()), - // Transactions: []*armreservations.PaymentDetail{ - // { - // BillingAccount: to.Ptr("23456"), - // BillingCurrencyTotal: &armreservations.Price{ - // Amount: to.Ptr[float64](466), - // CurrencyCode: to.Ptr("USD"), - // }, - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2019-09-30"); return t}()), - // PaymentDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2019-09-30"); return t}()), - // PricingCurrencyTotal: &armreservations.Price{ - // Amount: to.Ptr[float64](466), - // CurrencyCode: to.Ptr("USD"), - // }, - // Status: to.Ptr(armreservations.PaymentStatusSucceeded), - // }, - // { - // BillingAccount: to.Ptr("23456"), - // BillingCurrencyTotal: &armreservations.Price{ - // Amount: to.Ptr[float64](466), - // CurrencyCode: to.Ptr("USD"), - // }, - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2019-10-30"); return t}()), - // ExtendedStatusInfo: &armreservations.ExtendedStatusInfo{ - // Message: to.Ptr("Credit card charge failed."), - // StatusCode: to.Ptr(armreservations.ReservationStatusCode("PaymentDeclined")), - // }, - // PaymentDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2019-10-30"); return t}()), - // PricingCurrencyTotal: &armreservations.Price{ - // Amount: to.Ptr[float64](466), - // CurrencyCode: to.Ptr("USD"), - // }, - // Status: to.Ptr(armreservations.PaymentStatusFailed), - // }, - // { - // BillingAccount: to.Ptr("23456"), - // BillingCurrencyTotal: &armreservations.Price{ - // Amount: to.Ptr[float64](466), - // CurrencyCode: to.Ptr("USD"), - // }, - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2019-10-31"); return t}()), - // PaymentDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2019-10-31"); return t}()), - // PricingCurrencyTotal: &armreservations.Price{ - // Amount: to.Ptr[float64](466), - // CurrencyCode: to.Ptr("USD"), - // }, - // Status: to.Ptr(armreservations.PaymentStatusSucceeded), - // }, - // { - // BillingAccount: to.Ptr("23456"), - // BillingCurrencyTotal: &armreservations.Price{ - // Amount: to.Ptr[float64](466), - // CurrencyCode: to.Ptr("USD"), - // }, - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2019-11-30"); return t}()), - // PaymentDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2019-11-30"); return t}()), - // PricingCurrencyTotal: &armreservations.Price{ - // Amount: to.Ptr[float64](466), - // CurrencyCode: to.Ptr("USD"), - // }, - // Status: to.Ptr(armreservations.PaymentStatusSucceeded), - // }, - // { - // BillingAccount: to.Ptr("23456"), - // BillingCurrencyTotal: &armreservations.Price{ - // Amount: to.Ptr[float64](466), - // CurrencyCode: to.Ptr("USD"), - // }, - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2019-07-14"); return t}()), - // PaymentDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2019-06-14"); return t}()), - // PricingCurrencyTotal: &armreservations.Price{ - // Amount: to.Ptr[float64](466), - // CurrencyCode: to.Ptr("USD"), - // }, - // Status: to.Ptr(armreservations.PaymentStatusScheduled), - // }, - // { - // BillingAccount: to.Ptr("23456"), - // BillingCurrencyTotal: &armreservations.Price{ - // Amount: to.Ptr[float64](466), - // CurrencyCode: to.Ptr("USD"), - // }, - // DueDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2019-06-14"); return t}()), - // PaymentDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2019-08-14"); return t}()), - // PricingCurrencyTotal: &armreservations.Price{ - // Amount: to.Ptr[float64](466), - // CurrencyCode: to.Ptr("USD"), - // }, - // Status: to.Ptr(armreservations.PaymentStatusScheduled), - // }}, - // }, - // ProvisioningState: to.Ptr(armreservations.ProvisioningStateSucceeded), - // RequestDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-30T03:49:19Z"); return t}()), - // Reservations: []*armreservations.ReservationResponse{ - // { - // ID: to.Ptr("/providers/microsoft.capacity/reservationOrders/1f14354c-dc12-4c8d-8090-6f295a3a34aa/reservations/c8c926bd-fc5d-4e29-9d43-b68340ac23a6"), - // }}, - // Term: to.Ptr(armreservations.ReservationTermP1Y), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/1e7b408f3323e7f5424745718fe62c7a043a2337/specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/ChangeDirectoryReservationOrder.json -func ExampleReservationOrderClient_ChangeDirectory() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armreservations.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewReservationOrderClient().ChangeDirectory(ctx, "a075419f-44cc-497f-b68a-14ee811d48b9", armreservations.ChangeDirectoryRequest{ - DestinationTenantID: to.Ptr("906655ea-30be-4587-9d12-b50e077b0f32"), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ChangeDirectoryResponse = armreservations.ChangeDirectoryResponse{ - // ReservationOrder: &armreservations.ChangeDirectoryResult{ - // Name: to.Ptr("VM_RI_10-02-2020_15-21"), - // Error: to.Ptr("error string"), - // ID: to.Ptr("a075419f-44cc-497f-b68a-14ee811d48b9"), - // IsSucceeded: to.Ptr(true), - // }, - // Reservations: []*armreservations.ChangeDirectoryResult{ - // { - // Name: to.Ptr("VM_RI_10-02-2020_15-21"), - // Error: to.Ptr("error string"), - // ID: to.Ptr("1f14354c-dc12-4c8d-8090-6f295a3a34aa"), - // IsSucceeded: to.Ptr(true), - // }}, - // } -} diff --git a/sdk/resourcemanager/reservations/armreservations/response_types.go b/sdk/resourcemanager/reservations/armreservations/response_types.go index 6a74444f86b0..77f11e4dc660 100644 --- a/sdk/resourcemanager/reservations/armreservations/response_types.go +++ b/sdk/resourcemanager/reservations/armreservations/response_types.go @@ -3,9 +3,8 @@ // 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. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armreservations @@ -13,65 +12,79 @@ import "encoding/json" // AzureReservationAPIClientGetAppliedReservationListResponse contains the response from method AzureReservationAPIClient.GetAppliedReservationList. type AzureReservationAPIClientGetAppliedReservationListResponse struct { + // The response for applied reservations api AppliedReservations } // AzureReservationAPIClientGetCatalogResponse contains the response from method AzureReservationAPIClient.NewGetCatalogPager. type AzureReservationAPIClientGetCatalogResponse struct { + // The list of catalogs and pagination information. CatalogsResult } // CalculateExchangeClientPostResponse contains the response from method CalculateExchangeClient.BeginPost. type CalculateExchangeClientPostResponse struct { + // CalculateExchange operation result CalculateExchangeOperationResultResponse } // CalculateRefundClientPostResponse contains the response from method CalculateRefundClient.Post. type CalculateRefundClientPostResponse struct { + // The response of calculate refund containing refund information of reservation CalculateRefundResponse } // ExchangeClientPostResponse contains the response from method ExchangeClient.BeginPost. type ExchangeClientPostResponse struct { + // Exchange operation result ExchangeOperationResultResponse } // OperationClientListResponse contains the response from method OperationClient.NewListPager. type OperationClientListResponse struct { + // Paginated list of operations OperationList } // QuotaClientCreateOrUpdateResponse contains the response from method QuotaClient.BeginCreateOrUpdate. type QuotaClientCreateOrUpdateResponse struct { + // Quota properties. CurrentQuotaLimitBase } // QuotaClientGetResponse contains the response from method QuotaClient.Get. type QuotaClientGetResponse struct { + // Quota properties. CurrentQuotaLimitBase + // ETag contains the information returned from the ETag header response. ETag *string } // QuotaClientListResponse contains the response from method QuotaClient.NewListPager. type QuotaClientListResponse struct { + // Quota limits. QuotaLimits + // ETag contains the information returned from the ETag header response. ETag *string } // QuotaClientUpdateResponse contains the response from method QuotaClient.BeginUpdate. type QuotaClientUpdateResponse struct { + // Quota properties. CurrentQuotaLimitBase } // QuotaRequestStatusClientGetResponse contains the response from method QuotaRequestStatusClient.Get. type QuotaRequestStatusClientGetResponse struct { + // Quota request details. QuotaRequestDetails } // QuotaRequestStatusClientListResponse contains the response from method QuotaRequestStatusClient.NewListPager. type QuotaRequestStatusClientListResponse struct { + // Quota request details. QuotaRequestDetailsList } @@ -82,26 +95,31 @@ type ReservationClientArchiveResponse struct { // ReservationClientAvailableScopesResponse contains the response from method ReservationClient.BeginAvailableScopes. type ReservationClientAvailableScopesResponse struct { + // The response of available scope api containing scopes and their eligibilities. AvailableScopeProperties } // ReservationClientGetResponse contains the response from method ReservationClient.Get. type ReservationClientGetResponse struct { + // The definition of the reservation. ReservationResponse } // ReservationClientListAllResponse contains the response from method ReservationClient.NewListAllPager. type ReservationClientListAllResponse struct { + // The list of reservations and summary of roll out count of reservations in each state. ListResult } // ReservationClientListResponse contains the response from method ReservationClient.NewListPager. type ReservationClientListResponse struct { + // List of `Reservation`s ReservationList } // ReservationClientListRevisionsResponse contains the response from method ReservationClient.NewListRevisionsPager. type ReservationClientListRevisionsResponse struct { + // List of `Reservation`s ReservationList } @@ -134,35 +152,42 @@ type ReservationClientUnarchiveResponse struct { // ReservationClientUpdateResponse contains the response from method ReservationClient.BeginUpdate. type ReservationClientUpdateResponse struct { + // The definition of the reservation. ReservationResponse } // ReservationOrderClientCalculateResponse contains the response from method ReservationOrderClient.Calculate. type ReservationOrderClientCalculateResponse struct { + // The response of calculate price for reservation. CalculatePriceResponse } // ReservationOrderClientChangeDirectoryResponse contains the response from method ReservationOrderClient.ChangeDirectory. type ReservationOrderClientChangeDirectoryResponse struct { + // Change directory response ChangeDirectoryResponse } // ReservationOrderClientGetResponse contains the response from method ReservationOrderClient.Get. type ReservationOrderClientGetResponse struct { + // Details of a reservation order being returned. ReservationOrderResponse } // ReservationOrderClientListResponse contains the response from method ReservationOrderClient.NewListPager. type ReservationOrderClientListResponse struct { + // List of `ReservationOrder`s ReservationOrderList } // ReservationOrderClientPurchaseResponse contains the response from method ReservationOrderClient.BeginPurchase. type ReservationOrderClientPurchaseResponse struct { + // Details of a reservation order being returned. ReservationOrderResponse } // ReturnClientPostResponse contains the response from method ReturnClient.BeginPost. type ReturnClientPostResponse struct { + // Details of a reservation order being returned. ReservationOrderResponse } diff --git a/sdk/resourcemanager/reservations/armreservations/return_client.go b/sdk/resourcemanager/reservations/armreservations/return_client.go index 7363b0b8e633..ed4fe984d744 100644 --- a/sdk/resourcemanager/reservations/armreservations/return_client.go +++ b/sdk/resourcemanager/reservations/armreservations/return_client.go @@ -3,9 +3,8 @@ // 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. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armreservations @@ -54,9 +53,10 @@ func (client *ReturnClient) BeginPost(ctx context.Context, reservationOrderID st if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ReturnClientPostResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ReturnClientPostResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[ReturnClientPostResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -67,18 +67,20 @@ func (client *ReturnClient) BeginPost(ctx context.Context, reservationOrderID st // // Generated from API version 2022-11-01 func (client *ReturnClient) post(ctx context.Context, reservationOrderID string, body RefundRequest, options *ReturnClientBeginPostOptions) (*http.Response, error) { + var err error req, err := client.postCreateRequest(ctx, reservationOrderID, body, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // postCreateRequest creates the Post request. @@ -96,5 +98,8 @@ func (client *ReturnClient) postCreateRequest(ctx context.Context, reservationOr reqQP.Set("api-version", "2022-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil } diff --git a/sdk/resourcemanager/reservations/armreservations/return_client_example_test.go b/sdk/resourcemanager/reservations/armreservations/return_client_example_test.go deleted file mode 100644 index f721ea8045e5..000000000000 --- a/sdk/resourcemanager/reservations/armreservations/return_client_example_test.go +++ /dev/null @@ -1,74 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armreservations_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/reservations/armreservations/v3" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/1e7b408f3323e7f5424745718fe62c7a043a2337/specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/Return.json -func ExampleReturnClient_BeginPost() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armreservations.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewReturnClient().BeginPost(ctx, "50000000-aaaa-bbbb-cccc-100000000004", armreservations.RefundRequest{ - Properties: &armreservations.RefundRequestProperties{ - ReservationToReturn: &armreservations.ReservationToReturn{ - Quantity: to.Ptr[int32](1), - ReservationID: to.Ptr("/providers/microsoft.capacity/reservationOrders/50000000-aaaa-bbbb-cccc-100000000004/reservations/40000000-aaaa-bbbb-cccc-100000000000"), - }, - ReturnReason: to.Ptr("PurchasedWrongProduct"), - Scope: to.Ptr("Reservation"), - SessionID: to.Ptr("10000000-aaaa-bbbb-cccc-200000000000"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ReservationOrderResponse = armreservations.ReservationOrderResponse{ - // Name: to.Ptr("50000000-aaaa-bbbb-cccc-100000000004"), - // Type: to.Ptr("Microsoft.Capacity/reservationOrders"), - // Etag: to.Ptr[int32](7), - // ID: to.Ptr("/providers/microsoft.capacity/reservationOrders/50000000-aaaa-bbbb-cccc-100000000004"), - // Properties: &armreservations.ReservationOrderProperties{ - // BillingPlan: to.Ptr(armreservations.ReservationBillingPlanMonthly), - // CreatedDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-30T03:51:49.8083758Z"); return t}()), - // DisplayName: to.Ptr("cabri"), - // ExpiryDate: to.Ptr(func() time.Time { t, _ := time.Parse("2006-01-02", "2018-08-30"); return t}()), - // ExpiryDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-30T03:51:49.8083758Z"); return t}()), - // OriginalQuantity: to.Ptr[int32](7), - // ProvisioningState: to.Ptr(armreservations.ProvisioningStateSucceeded), - // RequestDateTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-08-30T03:49:19.0252126Z"); return t}()), - // Reservations: []*armreservations.ReservationResponse{ - // { - // ID: to.Ptr("/providers/microsoft.capacity/reservationOrders/50000000-aaaa-bbbb-cccc-100000000004/reservations/40000000-aaaa-bbbb-cccc-100000000000"), - // }}, - // Term: to.Ptr(armreservations.ReservationTermP1Y), - // }, - // } -} diff --git a/sdk/resourcemanager/reservations/armreservations/time_rfc3339.go b/sdk/resourcemanager/reservations/armreservations/time_rfc3339.go index 8cc0ea56c97b..cb5dc1d33880 100644 --- a/sdk/resourcemanager/reservations/armreservations/time_rfc3339.go +++ b/sdk/resourcemanager/reservations/armreservations/time_rfc3339.go @@ -3,9 +3,8 @@ // 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. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armreservations