diff --git a/sdk/resourcemanager/reservations/armreservations/CHANGELOG.md b/sdk/resourcemanager/reservations/armreservations/CHANGELOG.md index 5ca7d6a3d111..c7b88a9b668d 100644 --- a/sdk/resourcemanager/reservations/armreservations/CHANGELOG.md +++ b/sdk/resourcemanager/reservations/armreservations/CHANGELOG.md @@ -1,5 +1,119 @@ # Release History +## 2.0.0 (2022-11-19) +### Breaking Changes + +- Type of `PurchaseRequest.Location` has been changed from `*string` to `*Location` +- Type of `Properties.UserFriendlyAppliedScopeType` has been changed from `*string` to `*UserFriendlyAppliedScopeType` +- Type of `Properties.UserFriendlyRenewState` has been changed from `*string` to `*UserFriendlyRenewState` +- Type of `Properties.Capabilities` has been changed from `*string` to `*Capabilities` +- Type of `Properties.ProvisioningSubState` has been changed from `*string` to `*ProvisioningSubState` +- Type of `Properties.DisplayProvisioningState` has been changed from `*string` to `*DisplayProvisioningState` +- Type of `ReservationResponse.Location` has been changed from `*string` to `*Location` +- Function `*CalculateRefundClient.Post` has been removed +- Function `NewCalculateRefundClient` has been removed +- Function `*CalculateExchangeClient.BeginPost` has been removed +- Function `*ReturnClient.Post` has been removed +- Function `NewExchangeClient` has been removed +- Function `NewReturnClient` has been removed +- Function `*ExchangeClient.BeginPost` has been removed +- Function `NewCalculateExchangeClient` has been removed +- Function `*ReservationOrderClient.Calculate` has been removed +- Struct `CalculateExchangeClient` has been removed +- Struct `CalculateExchangeClientBeginPostOptions` has been removed +- Struct `CalculateExchangeClientPostResponse` has been removed +- Struct `CalculateRefundClient` has been removed +- Struct `CalculateRefundClientPostOptions` has been removed +- Struct `CalculateRefundClientPostResponse` has been removed +- Struct `ExchangeClient` has been removed +- Struct `ExchangeClientBeginPostOptions` has been removed +- Struct `ExchangeClientPostResponse` has been removed +- Struct `ReservationOrderClientCalculateOptions` has been removed +- Struct `ReservationOrderClientCalculateResponse` has been removed +- Struct `ReturnClient` has been removed +- Struct `ReturnClientPostOptions` has been removed +- Struct `ReturnClientPostResponse` has been removed +- Field `ExpiryDate` of struct `Properties` has been removed +- Field `PurchaseDate` of struct `Properties` has been removed +- Field `OfferID` of struct `AzureReservationAPIClientGetCatalogOptions` has been removed +- Field `PlanID` of struct `AzureReservationAPIClientGetCatalogOptions` has been removed +- Field `PublisherID` of struct `AzureReservationAPIClientGetCatalogOptions` has been removed +- Field `CatalogArray` of struct `AzureReservationAPIClientGetCatalogResponse` has been removed +- Field `ExpiryDate` of struct `ReservationOrderProperties` has been removed + +### Features Added + +- New const `ProvisioningSubStatePending` +- New const `CapabilitiesNone` +- New const `ProvisioningSubStateOrphaned` +- New const `ProvisioningSubStateAppliedBenefits` +- New const `BillingPlanP1M` +- New const `ProvisioningSubStateNone` +- New const `SavingsPlanTermP1Y` +- New const `ProvisioningSubStateWarning` +- New const `CapabilitiesAPIExchangeEnabled` +- New const `SavingsPlanTermP3Y` +- New const `DisplayProvisioningStateNoBenefit` +- New const `CapabilitiesAPIReturnEnabled` +- New const `ProvisioningSubStateActive` +- New const `AppliedScopeTypeManagementGroup` +- New const `DisplayProvisioningStateWarning` +- New const `CommitmentGrainHourly` +- New type alias `CommitmentGrain` +- New type alias `BillingPlan` +- New type alias `Capabilities` +- New type alias `SavingsPlanTerm` +- New type alias `ProvisioningSubState` +- New function `PossibleCommitmentGrainValues() []CommitmentGrain` +- New function `*ReservationOrderClient.Return(context.Context, string, RefundRequest, *ReservationOrderClientReturnOptions) (ReservationOrderClientReturnResponse, error)` +- New function `PossibleProvisioningSubStateValues() []ProvisioningSubState` +- New function `PossibleSavingsPlanTermValues() []SavingsPlanTerm` +- New function `*ReservationOrderClient.CalculatePrice(context.Context, PurchaseRequest, *ReservationOrderClientCalculatePriceOptions) (ReservationOrderClientCalculatePriceResponse, error)` +- New function `*AzureReservationAPIClient.BeginCalculateExchange(context.Context, CalculateExchangeRequest, *AzureReservationAPIClientBeginCalculateExchangeOptions) (*runtime.Poller[AzureReservationAPIClientCalculateExchangeResponse], error)` +- New function `*AzureReservationAPIClient.BeginExchange(context.Context, ExchangeRequest, *AzureReservationAPIClientBeginExchangeOptions) (*runtime.Poller[AzureReservationAPIClientExchangeResponse], error)` +- New function `*ReservationOrderClient.CalculateRefund(context.Context, string, CalculateRefundRequest, *ReservationOrderClientCalculateRefundOptions) (ReservationOrderClientCalculateRefundResponse, error)` +- New function `PossibleCapabilitiesValues() []Capabilities` +- New function `PossibleBillingPlanValues() []BillingPlan` +- New struct `AppliedScopeProperties` +- New struct `AzureReservationAPIClientBeginCalculateExchangeOptions` +- New struct `AzureReservationAPIClientBeginExchangeOptions` +- New struct `AzureReservationAPIClientCalculateExchangeResponse` +- New struct `AzureReservationAPIClientExchangeResponse` +- New struct `CatalogsResult` +- New struct `Commitment` +- New struct `ReservationOrderClientCalculatePriceOptions` +- New struct `ReservationOrderClientCalculatePriceResponse` +- New struct `ReservationOrderClientCalculateRefundOptions` +- New struct `ReservationOrderClientCalculateRefundResponse` +- New struct `ReservationOrderClientReturnOptions` +- New struct `ReservationOrderClientReturnResponse` +- New struct `ReservationSwapProperties` +- New struct `SavingsPlanPurchaseRequest` +- New struct `SavingsPlanPurchaseRequestProperties` +- New struct `SavingsPlanToPurchaseCalculateExchange` +- New struct `SavingsPlanToPurchaseExchange` +- New field `SavingsPlansToPurchase` in struct `CalculateExchangeRequestProperties` +- New field `ReviewDateTime` in struct `PurchaseRequestProperties` +- New field `AppliedScopeProperties` in struct `PurchaseRequestProperties` +- New field `AppliedScopeProperties` in struct `Properties` +- New field `PurchaseDateTime` in struct `Properties` +- New field `SwapProperties` in struct `Properties` +- New field `ReviewDateTime` in struct `Properties` +- New field `ExpiryDateTime` in struct `Properties` +- New field `AppliedScopeProperties` in struct `PatchProperties` +- New field `ReviewDateTime` in struct `PatchProperties` +- New field `SavingsPlansToPurchase` in struct `CalculateExchangeResponseProperties` +- New field `ExpiryDateTime` in struct `ReservationOrderProperties` +- New field `ReviewDateTime` in struct `ReservationOrderProperties` +- New field `NoBenefitCount` in struct `ReservationSummary` +- New field `WarningCount` in struct `ReservationSummary` +- New anonymous field `CatalogsResult` in struct `AzureReservationAPIClientGetCatalogResponse` +- New field `SavingsPlansToPurchase` in struct `ExchangeResponseProperties` +- New field `Take` in struct `AzureReservationAPIClientGetCatalogOptions` +- New field `Filter` in struct `AzureReservationAPIClientGetCatalogOptions` +- New field `Skip` in struct `AzureReservationAPIClientGetCatalogOptions` + + ## 1.1.0 (2022-09-16) ### Features Added diff --git a/sdk/resourcemanager/reservations/armreservations/autorest.md b/sdk/resourcemanager/reservations/armreservations/autorest.md index 618f8033fa82..cc25fefbc2c3 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/0507c3d410681049bb5cd9545b49a7578a91d3d0/specification/reservations/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/0507c3d410681049bb5cd9545b49a7578a91d3d0/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: 1.1.0 +module-version: 2.0.0 ``` \ 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 3f2e6950939e..a84ba5ae5a47 100644 --- a/sdk/resourcemanager/reservations/armreservations/azurereservationapi_client.go +++ b/sdk/resourcemanager/reservations/armreservations/azurereservationapi_client.go @@ -20,6 +20,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" "net/url" + "strconv" "strings" ) @@ -52,10 +53,114 @@ func NewAzureReservationAPIClient(credential azcore.TokenCredential, options *ar return client, nil } +// BeginCalculateExchange - Calculates price for exchanging Reservations if there are no policy errors. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-11-01 +// body - Request containing purchases and refunds that need to be executed. +// options - AzureReservationAPIClientBeginCalculateExchangeOptions contains the optional parameters for the AzureReservationAPIClient.BeginCalculateExchange +// method. +func (client *AzureReservationAPIClient) BeginCalculateExchange(ctx context.Context, body CalculateExchangeRequest, options *AzureReservationAPIClientBeginCalculateExchangeOptions) (*runtime.Poller[AzureReservationAPIClientCalculateExchangeResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.calculateExchange(ctx, body, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[AzureReservationAPIClientCalculateExchangeResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[AzureReservationAPIClientCalculateExchangeResponse](options.ResumeToken, client.pl, nil) + } +} + +// CalculateExchange - Calculates price for exchanging Reservations if there are no policy errors. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-11-01 +func (client *AzureReservationAPIClient) calculateExchange(ctx context.Context, body CalculateExchangeRequest, options *AzureReservationAPIClientBeginCalculateExchangeOptions) (*http.Response, error) { + req, err := client.calculateExchangeCreateRequest(ctx, body, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// calculateExchangeCreateRequest creates the CalculateExchange request. +func (client *AzureReservationAPIClient) calculateExchangeCreateRequest(ctx context.Context, body CalculateExchangeRequest, options *AzureReservationAPIClientBeginCalculateExchangeOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Capacity/calculateExchange" + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, body) +} + +// BeginExchange - Returns one or more Reservations in exchange for one or more Reservation purchases. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-11-01 +// body - Request containing the refunds and purchases that need to be executed. +// options - AzureReservationAPIClientBeginExchangeOptions contains the optional parameters for the AzureReservationAPIClient.BeginExchange +// method. +func (client *AzureReservationAPIClient) BeginExchange(ctx context.Context, body ExchangeRequest, options *AzureReservationAPIClientBeginExchangeOptions) (*runtime.Poller[AzureReservationAPIClientExchangeResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.exchange(ctx, body, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[AzureReservationAPIClientExchangeResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[AzureReservationAPIClientExchangeResponse](options.ResumeToken, client.pl, nil) + } +} + +// Exchange - Returns one or more Reservations in exchange for one or more Reservation purchases. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-11-01 +func (client *AzureReservationAPIClient) exchange(ctx context.Context, body ExchangeRequest, options *AzureReservationAPIClientBeginExchangeOptions) (*http.Response, error) { + req, err := client.exchangeCreateRequest(ctx, body, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// exchangeCreateRequest creates the Exchange request. +func (client *AzureReservationAPIClient) exchangeCreateRequest(ctx context.Context, body ExchangeRequest, options *AzureReservationAPIClientBeginExchangeOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Capacity/exchange" + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, body) +} + // GetAppliedReservationList - Get applicable Reservations that are applied to this subscription or a resource group under // this subscription. // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-01 +// Generated from API version 2022-11-01 // subscriptionID - Id of the subscription // options - AzureReservationAPIClientGetAppliedReservationListOptions contains the optional parameters for the AzureReservationAPIClient.GetAppliedReservationList // method. @@ -86,7 +191,7 @@ func (client *AzureReservationAPIClient) getAppliedReservationListCreateRequest( return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-01") + reqQP.Set("api-version", "2022-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -103,7 +208,7 @@ func (client *AzureReservationAPIClient) getAppliedReservationListHandleResponse // GetCatalog - Get the regions and skus that are available for RI purchase for the specified Azure subscription. // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-01 +// Generated from API version 2022-11-01 // subscriptionID - Id of the subscription // options - AzureReservationAPIClientGetCatalogOptions contains the optional parameters for the AzureReservationAPIClient.GetCatalog // method. @@ -134,21 +239,21 @@ func (client *AzureReservationAPIClient) getCatalogCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-01") + reqQP.Set("api-version", "2022-11-01") if options != nil && options.ReservedResourceType != nil { reqQP.Set("reservedResourceType", *options.ReservedResourceType) } if options != nil && options.Location != nil { reqQP.Set("location", *options.Location) } - if options != nil && options.PublisherID != nil { - reqQP.Set("publisherId", *options.PublisherID) + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) } - if options != nil && options.OfferID != nil { - reqQP.Set("offerId", *options.OfferID) + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatFloat(float64(*options.Skip), 'f', -1, 32)) } - if options != nil && options.PlanID != nil { - reqQP.Set("planId", *options.PlanID) + if options != nil && options.Take != nil { + reqQP.Set("$take", strconv.FormatFloat(float64(*options.Take), 'f', -1, 32)) } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} @@ -158,7 +263,7 @@ func (client *AzureReservationAPIClient) getCatalogCreateRequest(ctx context.Con // getCatalogHandleResponse handles the GetCatalog response. func (client *AzureReservationAPIClient) getCatalogHandleResponse(resp *http.Response) (AzureReservationAPIClientGetCatalogResponse, error) { result := AzureReservationAPIClientGetCatalogResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.CatalogArray); err != nil { + if err := runtime.UnmarshalAsJSON(resp, &result.CatalogsResult); err != nil { return AzureReservationAPIClientGetCatalogResponse{}, err } return result, nil 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 b44945c929bf..000000000000 --- a/sdk/resourcemanager/reservations/armreservations/azurereservationapi_client_example_test.go +++ /dev/null @@ -1,61 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package 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" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-03-01/examples/GetCatalog.json -func ExampleAzureReservationAPIClient_GetCatalog() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armreservations.NewAzureReservationAPIClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetCatalog(ctx, "23bc208b-083f-4901-ae85-4f98c0c3b4b6", &armreservations.AzureReservationAPIClientGetCatalogOptions{ReservedResourceType: to.Ptr("VirtualMachines"), - Location: to.Ptr("eastus"), - PublisherID: nil, - OfferID: nil, - PlanID: nil, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-03-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() - client, err := armreservations.NewAzureReservationAPIClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetAppliedReservationList(ctx, "23bc208b-083f-4901-ae85-4f98c0c3b4b6", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/reservations/armreservations/calculateexchange_client.go b/sdk/resourcemanager/reservations/armreservations/calculateexchange_client.go deleted file mode 100644 index 8bc2907980a0..000000000000 --- a/sdk/resourcemanager/reservations/armreservations/calculateexchange_client.go +++ /dev/null @@ -1,102 +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 - -import ( - "context" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" -) - -// CalculateExchangeClient contains the methods for the CalculateExchange group. -// Don't use this type directly, use NewCalculateExchangeClient() instead. -type CalculateExchangeClient struct { - host string - pl runtime.Pipeline -} - -// NewCalculateExchangeClient creates a new instance of CalculateExchangeClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. -func NewCalculateExchangeClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*CalculateExchangeClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) - if err != nil { - return nil, err - } - client := &CalculateExchangeClient{ - host: ep, - pl: pl, - } - return client, nil -} - -// BeginPost - Calculates price for exchanging Reservations if there are no policy errors. -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-01 -// body - Request containing purchases and refunds that need to be executed. -// options - CalculateExchangeClientBeginPostOptions contains the optional parameters for the CalculateExchangeClient.BeginPost -// method. -func (client *CalculateExchangeClient) BeginPost(ctx context.Context, body CalculateExchangeRequest, options *CalculateExchangeClientBeginPostOptions) (*runtime.Poller[CalculateExchangeClientPostResponse], error) { - if options == nil || options.ResumeToken == "" { - resp, err := client.post(ctx, body, options) - if err != nil { - return nil, err - } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[CalculateExchangeClientPostResponse]{ - FinalStateVia: runtime.FinalStateViaAzureAsyncOp, - }) - } else { - return runtime.NewPollerFromResumeToken[CalculateExchangeClientPostResponse](options.ResumeToken, client.pl, nil) - } -} - -// Post - Calculates price for exchanging Reservations if there are no policy errors. -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-01 -func (client *CalculateExchangeClient) post(ctx context.Context, body CalculateExchangeRequest, options *CalculateExchangeClientBeginPostOptions) (*http.Response, error) { - req, err := client.postCreateRequest(ctx, body, options) - if err != nil { - return nil, err - } - resp, err := client.pl.Do(req) - if err != nil { - return nil, err - } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) - } - return resp, nil -} - -// postCreateRequest creates the Post request. -func (client *CalculateExchangeClient) postCreateRequest(ctx context.Context, body CalculateExchangeRequest, options *CalculateExchangeClientBeginPostOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Capacity/calculateExchange" - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-01") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) -} 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 d3dbfd6bbf4e..000000000000 --- a/sdk/resourcemanager/reservations/armreservations/calculateexchange_client_example_test.go +++ /dev/null @@ -1,69 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package 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" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-03-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() - client, err := armreservations.NewCalculateExchangeClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.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"), - }, - }}, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/reservations/armreservations/calculaterefund_client.go b/sdk/resourcemanager/reservations/armreservations/calculaterefund_client.go deleted file mode 100644 index b095ae5fcb34..000000000000 --- a/sdk/resourcemanager/reservations/armreservations/calculaterefund_client.go +++ /dev/null @@ -1,101 +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 - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strings" -) - -// CalculateRefundClient contains the methods for the CalculateRefund group. -// Don't use this type directly, use NewCalculateRefundClient() instead. -type CalculateRefundClient struct { - host string - pl runtime.Pipeline -} - -// NewCalculateRefundClient creates a new instance of CalculateRefundClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. -func NewCalculateRefundClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*CalculateRefundClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) - if err != nil { - return nil, err - } - client := &CalculateRefundClient{ - host: ep, - pl: pl, - } - return client, nil -} - -// Post - Calculate price for returning Reservations if there are no policy errors. -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-01 -// reservationOrderID - Order Id of the reservation -// 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) { - req, err := client.postCreateRequest(ctx, reservationOrderID, body, options) - if err != nil { - return CalculateRefundClientPostResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return CalculateRefundClientPostResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return CalculateRefundClientPostResponse{}, runtime.NewResponseError(resp) - } - return client.postHandleResponse(resp) -} - -// postCreateRequest creates the Post request. -func (client *CalculateRefundClient) postCreateRequest(ctx context.Context, reservationOrderID string, body CalculateRefundRequest, options *CalculateRefundClientPostOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/calculateRefund" - if reservationOrderID == "" { - return nil, errors.New("parameter reservationOrderID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{reservationOrderId}", url.PathEscape(reservationOrderID)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-01") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) -} - -// postHandleResponse handles the Post response. -func (client *CalculateRefundClient) postHandleResponse(resp *http.Response) (CalculateRefundClientPostResponse, error) { - result := CalculateRefundClientPostResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.CalculateRefundResponse); err != nil { - return CalculateRefundClientPostResponse{}, err - } - return result, nil -} 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 752dd02e1daa..000000000000 --- a/sdk/resourcemanager/reservations/armreservations/calculaterefund_client_example_test.go +++ /dev/null @@ -1,46 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package 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" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-03-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() - client, err := armreservations.NewCalculateRefundClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.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) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/reservations/armreservations/constants.go b/sdk/resourcemanager/reservations/armreservations/constants.go index 5c6ee01bc836..dd23ddf56893 100644 --- a/sdk/resourcemanager/reservations/armreservations/constants.go +++ b/sdk/resourcemanager/reservations/armreservations/constants.go @@ -11,25 +11,41 @@ package armreservations const ( moduleName = "armreservations" - moduleVersion = "v1.1.0" + moduleVersion = "v2.0.0" ) // AppliedScopeType - Type of the Applied Scope. type AppliedScopeType string const ( - AppliedScopeTypeShared AppliedScopeType = "Shared" - AppliedScopeTypeSingle AppliedScopeType = "Single" + AppliedScopeTypeManagementGroup AppliedScopeType = "ManagementGroup" + AppliedScopeTypeShared AppliedScopeType = "Shared" + AppliedScopeTypeSingle AppliedScopeType = "Single" ) // PossibleAppliedScopeTypeValues returns the possible values for the AppliedScopeType const type. func PossibleAppliedScopeTypeValues() []AppliedScopeType { return []AppliedScopeType{ + AppliedScopeTypeManagementGroup, AppliedScopeTypeShared, AppliedScopeTypeSingle, } } +// BillingPlan - Represents the billing plan in ISO 8601 format. Required only for monthly billing plans. +type BillingPlan string + +const ( + BillingPlanP1M BillingPlan = "P1M" +) + +// PossibleBillingPlanValues returns the possible values for the BillingPlan const type. +func PossibleBillingPlanValues() []BillingPlan { + return []BillingPlan{ + BillingPlanP1M, + } +} + // CalculateExchangeOperationResultStatus - Status of the operation. type CalculateExchangeOperationResultStatus string @@ -50,6 +66,38 @@ func PossibleCalculateExchangeOperationResultStatusValues() []CalculateExchangeO } } +// Capabilities - Capabilities of the reservation +type Capabilities string + +const ( + CapabilitiesAPIExchangeEnabled Capabilities = "ApiExchangeEnabled" + CapabilitiesAPIReturnEnabled Capabilities = "ApiReturnEnabled" + CapabilitiesNone Capabilities = "None" +) + +// PossibleCapabilitiesValues returns the possible values for the Capabilities const type. +func PossibleCapabilitiesValues() []Capabilities { + return []Capabilities{ + CapabilitiesAPIExchangeEnabled, + CapabilitiesAPIReturnEnabled, + CapabilitiesNone, + } +} + +// CommitmentGrain - Commitment grain. +type CommitmentGrain string + +const ( + CommitmentGrainHourly CommitmentGrain = "Hourly" +) + +// PossibleCommitmentGrainValues returns the possible values for the CommitmentGrain const type. +func PossibleCommitmentGrainValues() []CommitmentGrain { + return []CommitmentGrain{ + CommitmentGrainHourly, + } +} + // CreatedByType - The type of identity that created the resource. type CreatedByType string @@ -78,9 +126,11 @@ const ( DisplayProvisioningStateExpired DisplayProvisioningState = "Expired" DisplayProvisioningStateExpiring DisplayProvisioningState = "Expiring" DisplayProvisioningStateFailed DisplayProvisioningState = "Failed" + DisplayProvisioningStateNoBenefit DisplayProvisioningState = "NoBenefit" DisplayProvisioningStatePending DisplayProvisioningState = "Pending" DisplayProvisioningStateProcessing DisplayProvisioningState = "Processing" DisplayProvisioningStateSucceeded DisplayProvisioningState = "Succeeded" + DisplayProvisioningStateWarning DisplayProvisioningState = "Warning" ) // PossibleDisplayProvisioningStateValues returns the possible values for the DisplayProvisioningState const type. @@ -90,9 +140,11 @@ func PossibleDisplayProvisioningStateValues() []DisplayProvisioningState { DisplayProvisioningStateExpired, DisplayProvisioningStateExpiring, DisplayProvisioningStateFailed, + DisplayProvisioningStateNoBenefit, DisplayProvisioningStatePending, DisplayProvisioningStateProcessing, DisplayProvisioningStateSucceeded, + DisplayProvisioningStateWarning, } } @@ -262,7 +314,7 @@ func PossibleInstanceFlexibilityValues() []InstanceFlexibility { } } -// Location - Location in which the Resources needs to be reserved. It cannot be changed after the resource has been created. +// Location - The Azure Region where the reserved resource lives. type Location string const ( @@ -400,6 +452,30 @@ func PossibleProvisioningStateValues() []ProvisioningState { } } +// ProvisioningSubState - Represent the current sub state of the Reservation. +type ProvisioningSubState string + +const ( + ProvisioningSubStateActive ProvisioningSubState = "Active" + ProvisioningSubStateAppliedBenefits ProvisioningSubState = "AppliedBenefits" + ProvisioningSubStateNone ProvisioningSubState = "None" + ProvisioningSubStateOrphaned ProvisioningSubState = "Orphaned" + ProvisioningSubStatePending ProvisioningSubState = "Pending" + ProvisioningSubStateWarning ProvisioningSubState = "Warning" +) + +// PossibleProvisioningSubStateValues returns the possible values for the ProvisioningSubState const type. +func PossibleProvisioningSubStateValues() []ProvisioningSubState { + return []ProvisioningSubState{ + ProvisioningSubStateActive, + ProvisioningSubStateAppliedBenefits, + ProvisioningSubStateNone, + ProvisioningSubStateOrphaned, + ProvisioningSubStatePending, + ProvisioningSubStateWarning, + } +} + // QuotaRequestState - The quota request status. type QuotaRequestState string @@ -573,6 +649,22 @@ func PossibleResourceTypeValues() []ResourceType { } } +// SavingsPlanTerm - Represent SavingsPlan term in ISO 8601 format. +type SavingsPlanTerm string + +const ( + SavingsPlanTermP1Y SavingsPlanTerm = "P1Y" + SavingsPlanTermP3Y SavingsPlanTerm = "P3Y" +) + +// PossibleSavingsPlanTermValues returns the possible values for the SavingsPlanTerm const type. +func PossibleSavingsPlanTermValues() []SavingsPlanTerm { + return []SavingsPlanTerm{ + SavingsPlanTermP1Y, + SavingsPlanTermP3Y, + } +} + // UserFriendlyAppliedScopeType - The applied scope type type UserFriendlyAppliedScopeType string diff --git a/sdk/resourcemanager/reservations/armreservations/exchange_client.go b/sdk/resourcemanager/reservations/armreservations/exchange_client.go deleted file mode 100644 index cd1b8890cd3d..000000000000 --- a/sdk/resourcemanager/reservations/armreservations/exchange_client.go +++ /dev/null @@ -1,101 +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 - -import ( - "context" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" -) - -// ExchangeClient contains the methods for the Exchange group. -// Don't use this type directly, use NewExchangeClient() instead. -type ExchangeClient struct { - host string - pl runtime.Pipeline -} - -// NewExchangeClient creates a new instance of ExchangeClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. -func NewExchangeClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*ExchangeClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) - if err != nil { - return nil, err - } - client := &ExchangeClient{ - host: ep, - pl: pl, - } - return client, nil -} - -// BeginPost - Returns one or more Reservations in exchange for one or more Reservation purchases. -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-01 -// body - Request containing the refunds and purchases that need to be executed. -// options - ExchangeClientBeginPostOptions contains the optional parameters for the ExchangeClient.BeginPost method. -func (client *ExchangeClient) BeginPost(ctx context.Context, body ExchangeRequest, options *ExchangeClientBeginPostOptions) (*runtime.Poller[ExchangeClientPostResponse], error) { - if options == nil || options.ResumeToken == "" { - resp, err := client.post(ctx, body, options) - if err != nil { - return nil, err - } - return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[ExchangeClientPostResponse]{ - FinalStateVia: runtime.FinalStateViaAzureAsyncOp, - }) - } else { - return runtime.NewPollerFromResumeToken[ExchangeClientPostResponse](options.ResumeToken, client.pl, nil) - } -} - -// Post - Returns one or more Reservations in exchange for one or more Reservation purchases. -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-01 -func (client *ExchangeClient) post(ctx context.Context, body ExchangeRequest, options *ExchangeClientBeginPostOptions) (*http.Response, error) { - req, err := client.postCreateRequest(ctx, body, options) - if err != nil { - return nil, err - } - resp, err := client.pl.Do(req) - if err != nil { - return nil, err - } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) - } - return resp, nil -} - -// postCreateRequest creates the Post request. -func (client *ExchangeClient) postCreateRequest(ctx context.Context, body ExchangeRequest, options *ExchangeClientBeginPostOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Capacity/exchange" - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-01") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) -} 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 d508fad686a4..000000000000 --- a/sdk/resourcemanager/reservations/armreservations/exchange_client_example_test.go +++ /dev/null @@ -1,45 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package 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" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-03-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() - client, err := armreservations.NewExchangeClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.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) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/reservations/armreservations/go.mod b/sdk/resourcemanager/reservations/armreservations/go.mod index af4f14ce0411..975dc5ab7d92 100644 --- a/sdk/resourcemanager/reservations/armreservations/go.mod +++ b/sdk/resourcemanager/reservations/armreservations/go.mod @@ -1,21 +1,13 @@ -module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/reservations/armreservations +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/reservations/armreservations/v2 go 1.18 -require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1 // indirect - github.com/golang-jwt/jwt v3.2.1+incompatible // indirect - github.com/google/uuid v1.1.1 // indirect - github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect - golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect - golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect golang.org/x/text v0.3.7 // indirect + 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 8828b17b1853..3afb578030a5 100644 --- a/sdk/resourcemanager/reservations/armreservations/go.sum +++ b/sdk/resourcemanager/reservations/armreservations/go.sum @@ -1,33 +1,15 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 h1:sVPhtT2qjO86rTUaWMr4WoES4TkjGnzcioXcnHV9s5k= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0 h1:QkAcEIAKbNL4KoFr4SathZPhDhF4mVwpBMFlYjyAqy8= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0/go.mod h1:bhXu1AjYL+wutSL/kpSq6s7733q2Rb0yuot9Zgfqa/0= github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1 h1:BWe8a+f/t+7KY7zH2mqygeUD0t8hNFXe08p1Pb3/jKE= -github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= -github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c= -github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= -github.com/golang-jwt/jwt/v4 v4.2.0 h1:besgBTC8w8HjP6NzQdxwKH9Z5oQMZ24ThTrHp3cZ8eU= -github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ= +github.com/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.0.0-20220511200225-c6db032c6c88 h1:Tgea0cVUD0ivh5ADBX4WwuI12DUd2to3nCYe2eayMIw= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +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 00c9ee3c7684..7f1167a1a928 100644 --- a/sdk/resourcemanager/reservations/armreservations/models.go +++ b/sdk/resourcemanager/reservations/armreservations/models.go @@ -34,6 +34,24 @@ type AppliedReservationsProperties struct { ReservationOrderIDs *AppliedReservationList `json:"reservationOrderIds,omitempty"` } +// AppliedScopeProperties - Properties specific to applied scope type. Not required if not applicable. +type AppliedScopeProperties struct { + // Display name + DisplayName *string `json:"displayName,omitempty"` + + // Fully-qualified identifier of the management group where the benefit must be applied. + ManagementGroupID *string `json:"managementGroupId,omitempty"` + + // Fully-qualified identifier of the resource group. + ResourceGroupID *string `json:"resourceGroupId,omitempty"` + + // Fully-qualified identifier of the subscription. + SubscriptionID *string `json:"subscriptionId,omitempty"` + + // Tenant ID where the savings plan should apply benefit. + TenantID *string `json:"tenantId,omitempty"` +} + type AvailableScopeProperties struct { Properties *SubscriptionScopeProperties `json:"properties,omitempty"` } @@ -49,6 +67,20 @@ type AvailableScopeRequestProperties struct { Scopes []*string `json:"scopes,omitempty"` } +// AzureReservationAPIClientBeginCalculateExchangeOptions contains the optional parameters for the AzureReservationAPIClient.BeginCalculateExchange +// method. +type AzureReservationAPIClientBeginCalculateExchangeOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// AzureReservationAPIClientBeginExchangeOptions contains the optional parameters for the AzureReservationAPIClient.BeginExchange +// method. +type AzureReservationAPIClientBeginExchangeOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + // AzureReservationAPIClientGetAppliedReservationListOptions contains the optional parameters for the AzureReservationAPIClient.GetAppliedReservationList // method. type AzureReservationAPIClientGetAppliedReservationListOptions struct { @@ -58,16 +90,16 @@ type AzureReservationAPIClientGetAppliedReservationListOptions struct { // AzureReservationAPIClientGetCatalogOptions contains the optional parameters for the AzureReservationAPIClient.GetCatalog // 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 @@ -77,12 +109,6 @@ type BillingInformation struct { BillingCurrencyTotalPaidAmount *Price `json:"billingCurrencyTotalPaidAmount,omitempty"` } -// 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. @@ -114,6 +140,9 @@ type CalculateExchangeRequestProperties struct { // List of reservations that are being purchased in this exchange. ReservationsToPurchase []*PurchaseRequest `json:"reservationsToPurchase,omitempty"` + + // List of savings plans that are being purchased in this exchange. + SavingsPlansToPurchase []*SavingsPlanPurchaseRequest `json:"savingsPlansToPurchase,omitempty"` } // CalculateExchangeResponseProperties - CalculateExchange response properties @@ -131,6 +160,9 @@ type CalculateExchangeResponseProperties struct { // Details of the reservations being purchased ReservationsToPurchase []*ReservationToPurchaseCalculateExchange `json:"reservationsToPurchase,omitempty"` + // Details of the savings plans being purchased + SavingsPlansToPurchase []*SavingsPlanToPurchaseCalculateExchange `json:"savingsPlansToPurchase,omitempty"` + // Exchange session identifier SessionID *string `json:"sessionId,omitempty"` } @@ -191,11 +223,6 @@ type CalculatePriceResponsePropertiesPricingCurrencyTotal struct { CurrencyCode *string `json:"currencyCode,omitempty"` } -// CalculateRefundClientPostOptions contains the optional parameters for the CalculateRefundClient.Post method. -type CalculateRefundClientPostOptions struct { - // placeholder for future optional parameters -} - type CalculateRefundRequest struct { // Fully qualified identifier of the reservation order being returned ID *string `json:"id,omitempty"` @@ -257,6 +284,18 @@ type CatalogMsrp struct { P1Y *Price `json:"p1Y,omitempty"` } +// CatalogsResult - The list of catalogs and pagination information. +type CatalogsResult struct { + // The total amount of catalog items. + TotalItems *int64 `json:"totalItems,omitempty"` + + // READ-ONLY; The link (url) to the next page of results. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; The list of catalogs. + Value []*Catalog `json:"value,omitempty" azure:"ro"` +} + type ChangeDirectoryRequest struct { // Tenant id GUID that reservation order is to be transferred to DestinationTenantID *string `json:"destinationTenantId,omitempty"` @@ -284,6 +323,17 @@ type ChangeDirectoryResult struct { Name *string `json:"name,omitempty"` } +// Commitment towards the benefit. +type Commitment struct { + Amount *float64 `json:"amount,omitempty"` + + // The ISO 4217 3-letter currency code for the currency used by this purchase record. + CurrencyCode *string `json:"currencyCode,omitempty"` + + // Commitment grain. + Grain *CommitmentGrain `json:"grain,omitempty"` +} + // CreateGenericQuotaRequestParameters - Quota change requests information. type CreateGenericQuotaRequestParameters struct { // Quota change requests. @@ -343,12 +393,6 @@ type ExceptionResponse struct { Error *ServiceError `json:"error,omitempty"` } -// 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. @@ -406,6 +450,9 @@ type ExchangeResponseProperties struct { // Details of the reservations being purchased ReservationsToPurchase []*ReservationToPurchaseExchange `json:"reservationsToPurchase,omitempty"` + // Details of the savings plans being purchased + SavingsPlansToPurchase []*SavingsPlanToPurchaseExchange `json:"savingsPlansToPurchase,omitempty"` + // Exchange session identifier SessionID *string `json:"sessionId,omitempty"` } @@ -493,6 +540,9 @@ type Patch struct { } type PatchProperties struct { + // Properties specific to applied scope type. Not required if not applicable. + AppliedScopeProperties *AppliedScopeProperties `json:"appliedScopeProperties,omitempty"` + // Type of the Applied Scope. AppliedScopeType *AppliedScopeType `json:"appliedScopeType,omitempty"` @@ -509,6 +559,9 @@ type PatchProperties struct { // Setting this to true will automatically purchase a new reservation on the expiration date time. Renew *bool `json:"renew,omitempty"` RenewProperties *PatchPropertiesRenewProperties `json:"renewProperties,omitempty"` + + // This is the date-time when the Azure Hybrid Benefit needs to be reviewed. + ReviewDateTime *time.Time `json:"reviewDateTime,omitempty"` } type PatchPropertiesRenewProperties struct { @@ -546,6 +599,9 @@ type Price struct { // Properties - The properties of the reservations type Properties struct { + // Properties specific to applied scope type. Not required if not applicable. + AppliedScopeProperties *AppliedScopeProperties `json:"appliedScopeProperties,omitempty"` + // The applied scope type AppliedScopeType *AppliedScopeType `json:"appliedScopeType,omitempty"` @@ -561,11 +617,11 @@ type Properties struct { // The billing plan options available for this SKU. BillingPlan *ReservationBillingPlan `json:"billingPlan,omitempty"` - // Subscription that will be charged for purchasing Reservation + // Subscription that will be charged for purchasing Reservation or Savings Plan BillingScopeID *string `json:"billingScopeId,omitempty"` // Capabilities of the reservation - Capabilities *string `json:"capabilities,omitempty"` + Capabilities *Capabilities `json:"capabilities,omitempty"` // Friendly name for user to easily identify the reservation DisplayName *string `json:"displayName,omitempty"` @@ -574,7 +630,7 @@ type Properties struct { EffectiveDateTime *time.Time `json:"effectiveDateTime,omitempty"` // This is the date when the Reservation will expire. - ExpiryDate *time.Time `json:"expiryDate,omitempty"` + ExpiryDateTime *time.Time `json:"expiryDateTime,omitempty"` // The message giving detailed information about the status code. ExtendedStatusInfo *ExtendedStatusInfo `json:"extendedStatusInfo,omitempty"` @@ -588,7 +644,7 @@ type Properties struct { ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` // This is the date when the Reservation was purchased. - PurchaseDate *time.Time `json:"purchaseDate,omitempty"` + PurchaseDateTime *time.Time `json:"purchaseDateTime,omitempty"` // Quantity of the SKUs that are part of the Reservation. Quantity *int32 `json:"quantity,omitempty"` @@ -607,27 +663,31 @@ type Properties struct { // The type of the resource that is being reserved. ReservedResourceType *ReservedResourceType `json:"reservedResourceType,omitempty"` + // This is the date-time when the Azure Hybrid Benefit needs to be reviewed. + ReviewDateTime *time.Time `json:"reviewDateTime,omitempty"` + // Description of the SKU in english. SKUDescription *string `json:"skuDescription,omitempty"` SplitProperties *ReservationSplitProperties `json:"splitProperties,omitempty"` + SwapProperties *ReservationSwapProperties `json:"swapProperties,omitempty"` // Represent the term of Reservation. Term *ReservationTerm `json:"term,omitempty"` - // READ-ONLY; The provisioning state of the reservation for display, e.g. Succeeded - DisplayProvisioningState *string `json:"displayProvisioningState,omitempty" azure:"ro"` + // READ-ONLY; Represent the current display state of the Reservation. + DisplayProvisioningState *DisplayProvisioningState `json:"displayProvisioningState,omitempty" azure:"ro"` // READ-ONLY; DateTime of the last time the Reservation was updated. LastUpdatedDateTime *time.Time `json:"lastUpdatedDateTime,omitempty" azure:"ro"` - // READ-ONLY; The provisioning state of the reservation, e.g. Succeeded - ProvisioningSubState *string `json:"provisioningSubState,omitempty" azure:"ro"` + // READ-ONLY; Represent the current sub state of the Reservation. + ProvisioningSubState *ProvisioningSubState `json:"provisioningSubState,omitempty" azure:"ro"` - // READ-ONLY; The applied scope type of the reservation for display, e.g. Shared - UserFriendlyAppliedScopeType *string `json:"userFriendlyAppliedScopeType,omitempty" azure:"ro"` + // READ-ONLY; The applied scope type + UserFriendlyAppliedScopeType *UserFriendlyAppliedScopeType `json:"userFriendlyAppliedScopeType,omitempty" azure:"ro"` - // READ-ONLY; The renew state of the reservation for display, e.g. On - UserFriendlyRenewState *string `json:"userFriendlyRenewState,omitempty" azure:"ro"` + // READ-ONLY; The renew state of the reservation + UserFriendlyRenewState *UserFriendlyRenewState `json:"userFriendlyRenewState,omitempty" azure:"ro"` // READ-ONLY; Reservation utilization Utilization *PropertiesUtilization `json:"utilization,omitempty" azure:"ro"` @@ -638,18 +698,21 @@ type PropertiesUtilization struct { // The array of aggregates of a reservation's utilization Aggregates []*ReservationUtilizationAggregates `json:"aggregates,omitempty"` - // READ-ONLY; The number of days trend for a reservation + // READ-ONLY; last 7 day utilization trend for a reservation Trend *string `json:"trend,omitempty" azure:"ro"` } type PurchaseRequest struct { // The Azure Region where the reserved resource lives. - Location *string `json:"location,omitempty"` + Location *Location `json:"location,omitempty"` Properties *PurchaseRequestProperties `json:"properties,omitempty"` SKU *SKUName `json:"sku,omitempty"` } type PurchaseRequestProperties struct { + // Properties specific to applied scope type. Not required if not applicable. + AppliedScopeProperties *AppliedScopeProperties `json:"appliedScopeProperties,omitempty"` + // Type of the Applied Scope. AppliedScopeType *AppliedScopeType `json:"appliedScopeType,omitempty"` @@ -659,7 +722,7 @@ type PurchaseRequestProperties struct { // Represent the billing plans. BillingPlan *ReservationBillingPlan `json:"billingPlan,omitempty"` - // Subscription that will be charged for purchasing Reservation + // Subscription that will be charged for purchasing Reservation or Savings Plan BillingScopeID *string `json:"billingScopeId,omitempty"` // Friendly name of the Reservation @@ -677,6 +740,9 @@ type PurchaseRequestProperties struct { // The type of the resource that is being reserved. ReservedResourceType *ReservedResourceType `json:"reservedResourceType,omitempty"` + // This is the date-time when the Azure Hybrid Benefit needs to be reviewed. + ReviewDateTime *time.Time `json:"reviewDateTime,omitempty"` + // Represent the term of Reservation. Term *ReservationTerm `json:"term,omitempty"` } @@ -1028,7 +1094,7 @@ type ReservationClientGetOptions struct { 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, provisioningState, + // properties/{appliedScopeType, archived, displayName, displayProvisioningState, effectiveDateTime, expiryDateTime, provisioningState, // quantity, renew, reservedResourceType, term, // userFriendlyAppliedScopeType, userFriendlyRenewState} Filter *string @@ -1093,8 +1159,15 @@ type ReservationOrderClientBeginPurchaseOptions struct { ResumeToken string } -// ReservationOrderClientCalculateOptions contains the optional parameters for the ReservationOrderClient.Calculate method. -type ReservationOrderClientCalculateOptions struct { +// ReservationOrderClientCalculatePriceOptions contains the optional parameters for the ReservationOrderClient.CalculatePrice +// method. +type ReservationOrderClientCalculatePriceOptions struct { + // placeholder for future optional parameters +} + +// ReservationOrderClientCalculateRefundOptions contains the optional parameters for the ReservationOrderClient.CalculateRefund +// method. +type ReservationOrderClientCalculateRefundOptions struct { // placeholder for future optional parameters } @@ -1115,6 +1188,11 @@ type ReservationOrderClientListOptions struct { // placeholder for future optional parameters } +// ReservationOrderClientReturnOptions contains the optional parameters for the ReservationOrderClient.Return method. +type ReservationOrderClientReturnOptions struct { + // placeholder for future optional parameters +} + type ReservationOrderList struct { // Url to get the next page of reservationOrders. NextLink *string `json:"nextLink,omitempty"` @@ -1135,7 +1213,7 @@ type ReservationOrderProperties struct { DisplayName *string `json:"displayName,omitempty"` // This is the date when the Reservation will expire. - ExpiryDate *time.Time `json:"expiryDate,omitempty"` + ExpiryDateTime *time.Time `json:"expiryDateTime,omitempty"` // Total Quantity of the SKUs purchased in the Reservation. OriginalQuantity *int32 `json:"originalQuantity,omitempty"` @@ -1150,6 +1228,9 @@ type ReservationOrderProperties struct { RequestDateTime *time.Time `json:"requestDateTime,omitempty"` Reservations []*ReservationResponse `json:"reservations,omitempty"` + // This is the date-time when the Azure Hybrid Benefit needs to be reviewed. + ReviewDateTime *time.Time `json:"reviewDateTime,omitempty"` + // Represent the term of Reservation. Term *ReservationTerm `json:"term,omitempty"` } @@ -1179,7 +1260,7 @@ type ReservationResponse struct { Kind *string `json:"kind,omitempty"` // The Azure Region where the reserved resource lives. - Location *string `json:"location,omitempty"` + Location *Location `json:"location,omitempty"` // The properties associated to this reservation Properties *Properties `json:"properties,omitempty"` @@ -1222,6 +1303,9 @@ type ReservationSummary struct { // READ-ONLY; The number of reservation in Failed state FailedCount *float32 `json:"failedCount,omitempty" azure:"ro"` + // READ-ONLY; The number of reservation in NoBenefit state + NoBenefitCount *float32 `json:"noBenefitCount,omitempty" azure:"ro"` + // READ-ONLY; The number of reservation in Pending state PendingCount *float32 `json:"pendingCount,omitempty" azure:"ro"` @@ -1230,6 +1314,17 @@ type ReservationSummary struct { // READ-ONLY; The number of reservation in Succeeded state SucceededCount *float32 `json:"succeededCount,omitempty" azure:"ro"` + + // READ-ONLY; The number of reservation in Warning state + WarningCount *float32 `json:"warningCount,omitempty" azure:"ro"` +} + +type ReservationSwapProperties struct { + // Reservation Resource Id that the original resource gets swapped to. Format of the resource Id is /providers/microsoft.capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId} + SwapDestination *string `json:"swapDestination,omitempty"` + + // Resource Id of the Source Reservation that gets swapped. Format of the resource Id is /providers/microsoft.capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId} + SwapSource *string `json:"swapSource,omitempty"` } // ReservationToExchange - Reservation refund details @@ -1316,11 +1411,6 @@ type ResourceName struct { LocalizedValue *string `json:"localizedValue,omitempty" azure:"ro"` } -// ReturnClientPostOptions contains the optional parameters for the ReturnClient.Post method. -type ReturnClientPostOptions struct { - // placeholder for future optional parameters -} - type SKUCapability struct { // An invariant to describe the feature. Name *string `json:"name,omitempty"` @@ -1353,6 +1443,56 @@ type SKURestriction struct { Values []*string `json:"values,omitempty"` } +type SavingsPlanPurchaseRequest struct { + Properties *SavingsPlanPurchaseRequestProperties `json:"properties,omitempty"` + SKU *SKUName `json:"sku,omitempty"` +} + +type SavingsPlanPurchaseRequestProperties struct { + // Properties specific to applied scope type. Not required if not applicable. + AppliedScopeProperties *AppliedScopeProperties `json:"appliedScopeProperties,omitempty"` + + // Type of the Applied Scope. + AppliedScopeType *AppliedScopeType `json:"appliedScopeType,omitempty"` + + // Represents the billing plan in ISO 8601 format. Required only for monthly billing plans. + BillingPlan *BillingPlan `json:"billingPlan,omitempty"` + + // Subscription that will be charged for purchasing Reservation or Savings Plan + BillingScopeID *string `json:"billingScopeId,omitempty"` + + // Commitment towards the benefit. + Commitment *Commitment `json:"commitment,omitempty"` + + // Friendly name of the Savings Plan + DisplayName *string `json:"displayName,omitempty"` + + // Represent SavingsPlan term in ISO 8601 format. + Term *SavingsPlanTerm `json:"term,omitempty"` +} + +// SavingsPlanToPurchaseCalculateExchange - Savings Plan purchase details +type SavingsPlanToPurchaseCalculateExchange struct { + BillingCurrencyTotal *Price `json:"billingCurrencyTotal,omitempty"` + Properties *SavingsPlanPurchaseRequest `json:"properties,omitempty"` +} + +// SavingsPlanToPurchaseExchange - Savings Plan purchase details +type SavingsPlanToPurchaseExchange struct { + BillingCurrencyTotal *Price `json:"billingCurrencyTotal,omitempty"` + Properties *SavingsPlanPurchaseRequest `json:"properties,omitempty"` + + // Fully qualified id of the Savings Plan being purchased. This value is only guaranteed to be non-null if the purchase is + // successful. + SavingsPlanID *string `json:"savingsPlanId,omitempty"` + + // Fully qualified id of the Savings Plan order being purchased + SavingsPlanOrderID *string `json:"savingsPlanOrderId,omitempty"` + + // Status of the individual operation. + Status *OperationStatus `json:"status,omitempty"` +} + type ScopeProperties struct { Scope *string `json:"scope,omitempty"` Valid *bool `json:"valid,omitempty"` diff --git a/sdk/resourcemanager/reservations/armreservations/models_serde.go b/sdk/resourcemanager/reservations/armreservations/models_serde.go index c42ad5582ca1..0257dfa06d6c 100644 --- a/sdk/resourcemanager/reservations/armreservations/models_serde.go +++ b/sdk/resourcemanager/reservations/armreservations/models_serde.go @@ -113,6 +113,49 @@ func (a *AppliedReservationsProperties) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type AppliedScopeProperties. +func (a AppliedScopeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "displayName", a.DisplayName) + populate(objectMap, "managementGroupId", a.ManagementGroupID) + populate(objectMap, "resourceGroupId", a.ResourceGroupID) + populate(objectMap, "subscriptionId", a.SubscriptionID) + populate(objectMap, "tenantId", a.TenantID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AppliedScopeProperties. +func (a *AppliedScopeProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "displayName": + err = unpopulate(val, "DisplayName", &a.DisplayName) + delete(rawMsg, key) + case "managementGroupId": + err = unpopulate(val, "ManagementGroupID", &a.ManagementGroupID) + delete(rawMsg, key) + case "resourceGroupId": + err = unpopulate(val, "ResourceGroupID", &a.ResourceGroupID) + delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, "SubscriptionID", &a.SubscriptionID) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &a.TenantID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type AvailableScopeProperties. func (a AvailableScopeProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) @@ -304,6 +347,7 @@ func (c CalculateExchangeRequestProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) populate(objectMap, "reservationsToExchange", c.ReservationsToExchange) populate(objectMap, "reservationsToPurchase", c.ReservationsToPurchase) + populate(objectMap, "savingsPlansToPurchase", c.SavingsPlansToPurchase) return json.Marshal(objectMap) } @@ -322,6 +366,9 @@ func (c *CalculateExchangeRequestProperties) UnmarshalJSON(data []byte) error { case "reservationsToPurchase": err = unpopulate(val, "ReservationsToPurchase", &c.ReservationsToPurchase) delete(rawMsg, key) + case "savingsPlansToPurchase": + err = unpopulate(val, "SavingsPlansToPurchase", &c.SavingsPlansToPurchase) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", c, err) @@ -339,6 +386,7 @@ func (c CalculateExchangeResponseProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "refundsTotal", c.RefundsTotal) populate(objectMap, "reservationsToExchange", c.ReservationsToExchange) populate(objectMap, "reservationsToPurchase", c.ReservationsToPurchase) + populate(objectMap, "savingsPlansToPurchase", c.SavingsPlansToPurchase) populate(objectMap, "sessionId", c.SessionID) return json.Marshal(objectMap) } @@ -370,6 +418,9 @@ func (c *CalculateExchangeResponseProperties) UnmarshalJSON(data []byte) error { case "reservationsToPurchase": err = unpopulate(val, "ReservationsToPurchase", &c.ReservationsToPurchase) delete(rawMsg, key) + case "savingsPlansToPurchase": + err = unpopulate(val, "SavingsPlansToPurchase", &c.SavingsPlansToPurchase) + delete(rawMsg, key) case "sessionId": err = unpopulate(val, "SessionID", &c.SessionID) delete(rawMsg, key) @@ -724,6 +775,41 @@ func (c *CatalogMsrp) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type CatalogsResult. +func (c CatalogsResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "totalItems", c.TotalItems) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CatalogsResult. +func (c *CatalogsResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &c.NextLink) + delete(rawMsg, key) + case "totalItems": + err = unpopulate(val, "TotalItems", &c.TotalItems) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &c.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type ChangeDirectoryRequest. func (c ChangeDirectoryRequest) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) @@ -821,6 +907,41 @@ func (c *ChangeDirectoryResult) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type Commitment. +func (c Commitment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "amount", c.Amount) + populate(objectMap, "currencyCode", c.CurrencyCode) + populate(objectMap, "grain", c.Grain) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Commitment. +func (c *Commitment) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "amount": + err = unpopulate(val, "Amount", &c.Amount) + delete(rawMsg, key) + case "currencyCode": + err = unpopulate(val, "CurrencyCode", &c.CurrencyCode) + delete(rawMsg, key) + case "grain": + err = unpopulate(val, "Grain", &c.Grain) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type CreateGenericQuotaRequestParameters. func (c CreateGenericQuotaRequestParameters) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) @@ -1198,6 +1319,7 @@ func (e ExchangeResponseProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "refundsTotal", e.RefundsTotal) populate(objectMap, "reservationsToExchange", e.ReservationsToExchange) populate(objectMap, "reservationsToPurchase", e.ReservationsToPurchase) + populate(objectMap, "savingsPlansToPurchase", e.SavingsPlansToPurchase) populate(objectMap, "sessionId", e.SessionID) return json.Marshal(objectMap) } @@ -1229,6 +1351,9 @@ func (e *ExchangeResponseProperties) UnmarshalJSON(data []byte) error { case "reservationsToPurchase": err = unpopulate(val, "ReservationsToPurchase", &e.ReservationsToPurchase) delete(rawMsg, key) + case "savingsPlansToPurchase": + err = unpopulate(val, "SavingsPlansToPurchase", &e.SavingsPlansToPurchase) + delete(rawMsg, key) case "sessionId": err = unpopulate(val, "SessionID", &e.SessionID) delete(rawMsg, key) @@ -1565,12 +1690,14 @@ func (p *Patch) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PatchProperties. func (p PatchProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) + populate(objectMap, "appliedScopeProperties", p.AppliedScopeProperties) populate(objectMap, "appliedScopeType", p.AppliedScopeType) populate(objectMap, "appliedScopes", p.AppliedScopes) populate(objectMap, "instanceFlexibility", p.InstanceFlexibility) populate(objectMap, "name", p.Name) populate(objectMap, "renew", p.Renew) populate(objectMap, "renewProperties", p.RenewProperties) + populateTimeRFC3339(objectMap, "reviewDateTime", p.ReviewDateTime) return json.Marshal(objectMap) } @@ -1583,6 +1710,9 @@ func (p *PatchProperties) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "appliedScopeProperties": + err = unpopulate(val, "AppliedScopeProperties", &p.AppliedScopeProperties) + delete(rawMsg, key) case "appliedScopeType": err = unpopulate(val, "AppliedScopeType", &p.AppliedScopeType) delete(rawMsg, key) @@ -1601,6 +1731,9 @@ func (p *PatchProperties) UnmarshalJSON(data []byte) error { case "renewProperties": err = unpopulate(val, "RenewProperties", &p.RenewProperties) delete(rawMsg, key) + case "reviewDateTime": + err = unpopulateTimeRFC3339(val, "ReviewDateTime", &p.ReviewDateTime) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", p, err) @@ -1721,6 +1854,7 @@ func (p *Price) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type Properties. func (p Properties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) + populate(objectMap, "appliedScopeProperties", p.AppliedScopeProperties) populate(objectMap, "appliedScopeType", p.AppliedScopeType) populate(objectMap, "appliedScopes", p.AppliedScopes) populate(objectMap, "archived", p.Archived) @@ -1731,22 +1865,24 @@ func (p Properties) MarshalJSON() ([]byte, error) { populate(objectMap, "displayName", p.DisplayName) populate(objectMap, "displayProvisioningState", p.DisplayProvisioningState) populateTimeRFC3339(objectMap, "effectiveDateTime", p.EffectiveDateTime) - populateDateType(objectMap, "expiryDate", p.ExpiryDate) + populateTimeRFC3339(objectMap, "expiryDateTime", p.ExpiryDateTime) populate(objectMap, "extendedStatusInfo", p.ExtendedStatusInfo) populate(objectMap, "instanceFlexibility", p.InstanceFlexibility) populateTimeRFC3339(objectMap, "lastUpdatedDateTime", p.LastUpdatedDateTime) populate(objectMap, "mergeProperties", p.MergeProperties) populate(objectMap, "provisioningState", p.ProvisioningState) populate(objectMap, "provisioningSubState", p.ProvisioningSubState) - populateDateType(objectMap, "purchaseDate", p.PurchaseDate) + populateTimeRFC3339(objectMap, "purchaseDateTime", p.PurchaseDateTime) populate(objectMap, "quantity", p.Quantity) populate(objectMap, "renew", p.Renew) populate(objectMap, "renewDestination", p.RenewDestination) populate(objectMap, "renewProperties", p.RenewProperties) populate(objectMap, "renewSource", p.RenewSource) populate(objectMap, "reservedResourceType", p.ReservedResourceType) + populateTimeRFC3339(objectMap, "reviewDateTime", p.ReviewDateTime) populate(objectMap, "skuDescription", p.SKUDescription) populate(objectMap, "splitProperties", p.SplitProperties) + populate(objectMap, "swapProperties", p.SwapProperties) populate(objectMap, "term", p.Term) populate(objectMap, "userFriendlyAppliedScopeType", p.UserFriendlyAppliedScopeType) populate(objectMap, "userFriendlyRenewState", p.UserFriendlyRenewState) @@ -1763,6 +1899,9 @@ func (p *Properties) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "appliedScopeProperties": + err = unpopulate(val, "AppliedScopeProperties", &p.AppliedScopeProperties) + delete(rawMsg, key) case "appliedScopeType": err = unpopulate(val, "AppliedScopeType", &p.AppliedScopeType) delete(rawMsg, key) @@ -1793,8 +1932,8 @@ func (p *Properties) UnmarshalJSON(data []byte) error { case "effectiveDateTime": err = unpopulateTimeRFC3339(val, "EffectiveDateTime", &p.EffectiveDateTime) delete(rawMsg, key) - case "expiryDate": - err = unpopulateDateType(val, "ExpiryDate", &p.ExpiryDate) + case "expiryDateTime": + err = unpopulateTimeRFC3339(val, "ExpiryDateTime", &p.ExpiryDateTime) delete(rawMsg, key) case "extendedStatusInfo": err = unpopulate(val, "ExtendedStatusInfo", &p.ExtendedStatusInfo) @@ -1814,8 +1953,8 @@ func (p *Properties) UnmarshalJSON(data []byte) error { case "provisioningSubState": err = unpopulate(val, "ProvisioningSubState", &p.ProvisioningSubState) delete(rawMsg, key) - case "purchaseDate": - err = unpopulateDateType(val, "PurchaseDate", &p.PurchaseDate) + case "purchaseDateTime": + err = unpopulateTimeRFC3339(val, "PurchaseDateTime", &p.PurchaseDateTime) delete(rawMsg, key) case "quantity": err = unpopulate(val, "Quantity", &p.Quantity) @@ -1835,12 +1974,18 @@ func (p *Properties) UnmarshalJSON(data []byte) error { case "reservedResourceType": err = unpopulate(val, "ReservedResourceType", &p.ReservedResourceType) delete(rawMsg, key) + case "reviewDateTime": + err = unpopulateTimeRFC3339(val, "ReviewDateTime", &p.ReviewDateTime) + delete(rawMsg, key) case "skuDescription": err = unpopulate(val, "SKUDescription", &p.SKUDescription) delete(rawMsg, key) case "splitProperties": err = unpopulate(val, "SplitProperties", &p.SplitProperties) delete(rawMsg, key) + case "swapProperties": + err = unpopulate(val, "SwapProperties", &p.SwapProperties) + delete(rawMsg, key) case "term": err = unpopulate(val, "Term", &p.Term) delete(rawMsg, key) @@ -1930,6 +2075,7 @@ func (p *PurchaseRequest) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type PurchaseRequestProperties. func (p PurchaseRequestProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) + populate(objectMap, "appliedScopeProperties", p.AppliedScopeProperties) populate(objectMap, "appliedScopeType", p.AppliedScopeType) populate(objectMap, "appliedScopes", p.AppliedScopes) populate(objectMap, "billingPlan", p.BillingPlan) @@ -1939,6 +2085,7 @@ func (p PurchaseRequestProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "renew", p.Renew) populate(objectMap, "reservedResourceProperties", p.ReservedResourceProperties) populate(objectMap, "reservedResourceType", p.ReservedResourceType) + populateTimeRFC3339(objectMap, "reviewDateTime", p.ReviewDateTime) populate(objectMap, "term", p.Term) return json.Marshal(objectMap) } @@ -1952,6 +2099,9 @@ func (p *PurchaseRequestProperties) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "appliedScopeProperties": + err = unpopulate(val, "AppliedScopeProperties", &p.AppliedScopeProperties) + delete(rawMsg, key) case "appliedScopeType": err = unpopulate(val, "AppliedScopeType", &p.AppliedScopeType) delete(rawMsg, key) @@ -1979,6 +2129,9 @@ func (p *PurchaseRequestProperties) UnmarshalJSON(data []byte) error { case "reservedResourceType": err = unpopulate(val, "ReservedResourceType", &p.ReservedResourceType) delete(rawMsg, key) + case "reviewDateTime": + err = unpopulateTimeRFC3339(val, "ReviewDateTime", &p.ReviewDateTime) + delete(rawMsg, key) case "term": err = unpopulate(val, "Term", &p.Term) delete(rawMsg, key) @@ -2946,12 +3099,13 @@ func (r ReservationOrderProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "billingPlan", r.BillingPlan) populateTimeRFC3339(objectMap, "createdDateTime", r.CreatedDateTime) populate(objectMap, "displayName", r.DisplayName) - populateDateType(objectMap, "expiryDate", r.ExpiryDate) + populateTimeRFC3339(objectMap, "expiryDateTime", r.ExpiryDateTime) populate(objectMap, "originalQuantity", r.OriginalQuantity) populate(objectMap, "planInformation", r.PlanInformation) populate(objectMap, "provisioningState", r.ProvisioningState) populateTimeRFC3339(objectMap, "requestDateTime", r.RequestDateTime) populate(objectMap, "reservations", r.Reservations) + populateTimeRFC3339(objectMap, "reviewDateTime", r.ReviewDateTime) populate(objectMap, "term", r.Term) return json.Marshal(objectMap) } @@ -2977,8 +3131,8 @@ func (r *ReservationOrderProperties) UnmarshalJSON(data []byte) error { case "displayName": err = unpopulate(val, "DisplayName", &r.DisplayName) delete(rawMsg, key) - case "expiryDate": - err = unpopulateDateType(val, "ExpiryDate", &r.ExpiryDate) + case "expiryDateTime": + err = unpopulateTimeRFC3339(val, "ExpiryDateTime", &r.ExpiryDateTime) delete(rawMsg, key) case "originalQuantity": err = unpopulate(val, "OriginalQuantity", &r.OriginalQuantity) @@ -2995,6 +3149,9 @@ func (r *ReservationOrderProperties) UnmarshalJSON(data []byte) error { case "reservations": err = unpopulate(val, "Reservations", &r.Reservations) delete(rawMsg, key) + case "reviewDateTime": + err = unpopulateTimeRFC3339(val, "ReviewDateTime", &r.ReviewDateTime) + delete(rawMsg, key) case "term": err = unpopulate(val, "Term", &r.Term) delete(rawMsg, key) @@ -3150,9 +3307,11 @@ func (r ReservationSummary) MarshalJSON() ([]byte, error) { populate(objectMap, "expiredCount", r.ExpiredCount) populate(objectMap, "expiringCount", r.ExpiringCount) populate(objectMap, "failedCount", r.FailedCount) + populate(objectMap, "noBenefitCount", r.NoBenefitCount) populate(objectMap, "pendingCount", r.PendingCount) populate(objectMap, "processingCount", r.ProcessingCount) populate(objectMap, "succeededCount", r.SucceededCount) + populate(objectMap, "warningCount", r.WarningCount) return json.Marshal(objectMap) } @@ -3177,6 +3336,9 @@ func (r *ReservationSummary) UnmarshalJSON(data []byte) error { case "failedCount": err = unpopulate(val, "FailedCount", &r.FailedCount) delete(rawMsg, key) + case "noBenefitCount": + err = unpopulate(val, "NoBenefitCount", &r.NoBenefitCount) + delete(rawMsg, key) case "pendingCount": err = unpopulate(val, "PendingCount", &r.PendingCount) delete(rawMsg, key) @@ -3186,6 +3348,40 @@ func (r *ReservationSummary) UnmarshalJSON(data []byte) error { case "succeededCount": err = unpopulate(val, "SucceededCount", &r.SucceededCount) delete(rawMsg, key) + case "warningCount": + err = unpopulate(val, "WarningCount", &r.WarningCount) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReservationSwapProperties. +func (r ReservationSwapProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "swapDestination", r.SwapDestination) + populate(objectMap, "swapSource", r.SwapSource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReservationSwapProperties. +func (r *ReservationSwapProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "swapDestination": + err = unpopulate(val, "SwapDestination", &r.SwapDestination) + delete(rawMsg, key) + case "swapSource": + err = unpopulate(val, "SwapSource", &r.SwapSource) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", r, err) @@ -3575,6 +3771,162 @@ func (s *SKURestriction) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type SavingsPlanPurchaseRequest. +func (s SavingsPlanPurchaseRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "sku", s.SKU) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SavingsPlanPurchaseRequest. +func (s *SavingsPlanPurchaseRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &s.SKU) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SavingsPlanPurchaseRequestProperties. +func (s SavingsPlanPurchaseRequestProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "appliedScopeProperties", s.AppliedScopeProperties) + populate(objectMap, "appliedScopeType", s.AppliedScopeType) + populate(objectMap, "billingPlan", s.BillingPlan) + populate(objectMap, "billingScopeId", s.BillingScopeID) + populate(objectMap, "commitment", s.Commitment) + populate(objectMap, "displayName", s.DisplayName) + populate(objectMap, "term", s.Term) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SavingsPlanPurchaseRequestProperties. +func (s *SavingsPlanPurchaseRequestProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "appliedScopeProperties": + err = unpopulate(val, "AppliedScopeProperties", &s.AppliedScopeProperties) + delete(rawMsg, key) + case "appliedScopeType": + err = unpopulate(val, "AppliedScopeType", &s.AppliedScopeType) + delete(rawMsg, key) + case "billingPlan": + err = unpopulate(val, "BillingPlan", &s.BillingPlan) + delete(rawMsg, key) + case "billingScopeId": + err = unpopulate(val, "BillingScopeID", &s.BillingScopeID) + delete(rawMsg, key) + case "commitment": + err = unpopulate(val, "Commitment", &s.Commitment) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &s.DisplayName) + delete(rawMsg, key) + case "term": + err = unpopulate(val, "Term", &s.Term) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SavingsPlanToPurchaseCalculateExchange. +func (s SavingsPlanToPurchaseCalculateExchange) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "billingCurrencyTotal", s.BillingCurrencyTotal) + populate(objectMap, "properties", s.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SavingsPlanToPurchaseCalculateExchange. +func (s *SavingsPlanToPurchaseCalculateExchange) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "billingCurrencyTotal": + err = unpopulate(val, "BillingCurrencyTotal", &s.BillingCurrencyTotal) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SavingsPlanToPurchaseExchange. +func (s SavingsPlanToPurchaseExchange) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "billingCurrencyTotal", s.BillingCurrencyTotal) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "savingsPlanId", s.SavingsPlanID) + populate(objectMap, "savingsPlanOrderId", s.SavingsPlanOrderID) + populate(objectMap, "status", s.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SavingsPlanToPurchaseExchange. +func (s *SavingsPlanToPurchaseExchange) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "billingCurrencyTotal": + err = unpopulate(val, "BillingCurrencyTotal", &s.BillingCurrencyTotal) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + case "savingsPlanId": + err = unpopulate(val, "SavingsPlanID", &s.SavingsPlanID) + delete(rawMsg, key) + case "savingsPlanOrderId": + err = unpopulate(val, "SavingsPlanOrderID", &s.SavingsPlanOrderID) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &s.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type ScopeProperties. func (s ScopeProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) diff --git a/sdk/resourcemanager/reservations/armreservations/operation_client.go b/sdk/resourcemanager/reservations/armreservations/operation_client.go index d11ad25936ce..bd8618d358f2 100644 --- a/sdk/resourcemanager/reservations/armreservations/operation_client.go +++ b/sdk/resourcemanager/reservations/armreservations/operation_client.go @@ -50,7 +50,7 @@ func NewOperationClient(credential azcore.TokenCredential, options *arm.ClientOp } // NewListPager - List all the operations. -// Generated from API version 2022-03-01 +// Generated from API version 2022-11-01 // options - OperationClientListOptions contains the optional parameters for the OperationClient.List method. func (client *OperationClient) NewListPager(options *OperationClientListOptions) *runtime.Pager[OperationClientListResponse] { return runtime.NewPager(runtime.PagingHandler[OperationClientListResponse]{ @@ -88,7 +88,7 @@ func (client *OperationClient) listCreateRequest(ctx context.Context, options *O return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-01") + reqQP.Set("api-version", "2022-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil 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 4081ead15252..000000000000 --- a/sdk/resourcemanager/reservations/armreservations/operation_client_example_test.go +++ /dev/null @@ -1,41 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package 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" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-03-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() - client, err := armreservations.NewOperationClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/reservations/armreservations/quota_client_example_test.go b/sdk/resourcemanager/reservations/armreservations/quota_client_example_test.go deleted file mode 100644 index 954b39cfe57c..000000000000 --- a/sdk/resourcemanager/reservations/armreservations/quota_client_example_test.go +++ /dev/null @@ -1,211 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package 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" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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() - client, err := armreservations.NewQuotaClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "00000000-0000-0000-0000-000000000000", "Microsoft.Compute", "eastus", "standardNDSFamily", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/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() - client, err := armreservations.NewQuotaClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.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) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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() - client, err := armreservations.NewQuotaClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.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) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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() - client, err := armreservations.NewQuotaClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.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) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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() - client, err := armreservations.NewQuotaClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.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) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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() - client, err := armreservations.NewQuotaClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("00000000-0000-0000-0000-000000000000", "Microsoft.Compute", "eastus", nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/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() - client, err := armreservations.NewQuotaClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("00000000-0000-0000-0000-000000000000", "Microsoft.MachineLearningServices", "eastus", nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/reservations/armreservations/quotarequeststatus_client_example_test.go b/sdk/resourcemanager/reservations/armreservations/quotarequeststatus_client_example_test.go deleted file mode 100644 index 5ad51d51194f..000000000000 --- a/sdk/resourcemanager/reservations/armreservations/quotarequeststatus_client_example_test.go +++ /dev/null @@ -1,101 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package 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" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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() - client, err := armreservations.NewQuotaRequestStatusClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.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) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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() - client, err := armreservations.NewQuotaRequestStatusClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.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) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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() - client, err := armreservations.NewQuotaRequestStatusClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.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) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/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() - client, err := armreservations.NewQuotaRequestStatusClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("3f75fdf7-977e-44ad-990d-99f14f0f299f", "Microsoft.Compute", "eastus", &armreservations.QuotaRequestStatusClientListOptions{Filter: nil, - Top: nil, - Skiptoken: nil, - }) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/reservations/armreservations/reservation_client.go b/sdk/resourcemanager/reservations/armreservations/reservation_client.go index 6cc8b3c93e35..518423fedb31 100644 --- a/sdk/resourcemanager/reservations/armreservations/reservation_client.go +++ b/sdk/resourcemanager/reservations/armreservations/reservation_client.go @@ -55,7 +55,7 @@ func NewReservationClient(credential azcore.TokenCredential, options *arm.Client // Archive - Archiving a Reservation moves it to Archived state. // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-01 +// Generated from API version 2022-11-01 // reservationOrderID - Order Id of the reservation // reservationID - Id of the Reservation Item // options - ReservationClientArchiveOptions contains the optional parameters for the ReservationClient.Archive method. @@ -90,7 +90,7 @@ func (client *ReservationClient) archiveCreateRequest(ctx context.Context, reser return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-01") + reqQP.Set("api-version", "2022-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -98,7 +98,7 @@ func (client *ReservationClient) archiveCreateRequest(ctx context.Context, reser // BeginAvailableScopes - Get Available Scopes for Reservation. // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-01 +// Generated from API version 2022-11-01 // reservationOrderID - Order Id of the reservation // reservationID - Id of the Reservation Item // options - ReservationClientBeginAvailableScopesOptions contains the optional parameters for the ReservationClient.BeginAvailableScopes @@ -117,7 +117,7 @@ func (client *ReservationClient) BeginAvailableScopes(ctx context.Context, reser // AvailableScopes - Get Available Scopes for Reservation. // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-01 +// 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) { req, err := client.availableScopesCreateRequest(ctx, reservationOrderID, reservationID, body, options) if err != nil { @@ -149,7 +149,7 @@ func (client *ReservationClient) availableScopesCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-01") + 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) @@ -157,7 +157,7 @@ func (client *ReservationClient) availableScopesCreateRequest(ctx context.Contex // Get - Get specific Reservation details. // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-01 +// Generated from API version 2022-11-01 // reservationID - Id of the Reservation Item // reservationOrderID - Order Id of the reservation // options - ReservationClientGetOptions contains the optional parameters for the ReservationClient.Get method. @@ -192,7 +192,7 @@ func (client *ReservationClient) getCreateRequest(ctx context.Context, reservati return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-01") + reqQP.Set("api-version", "2022-11-01") if options != nil && options.Expand != nil { reqQP.Set("expand", *options.Expand) } @@ -211,7 +211,7 @@ func (client *ReservationClient) getHandleResponse(resp *http.Response) (Reserva } // NewListPager - List Reservations within a single ReservationOrder. -// Generated from API version 2022-03-01 +// Generated from API version 2022-11-01 // reservationOrderID - Order Id of the reservation // options - ReservationClientListOptions contains the optional parameters for the ReservationClient.List method. func (client *ReservationClient) NewListPager(reservationOrderID string, options *ReservationClientListOptions) *runtime.Pager[ReservationClientListResponse] { @@ -254,7 +254,7 @@ func (client *ReservationClient) listCreateRequest(ctx context.Context, reservat return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-01") + reqQP.Set("api-version", "2022-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -271,7 +271,7 @@ func (client *ReservationClient) listHandleResponse(resp *http.Response) (Reserv // NewListAllPager - List the reservations and the roll up counts of reservations group by provisioning states that the user // has access to in the current tenant. -// Generated from API version 2022-03-01 +// Generated from API version 2022-11-01 // options - ReservationClientListAllOptions contains the optional parameters for the ReservationClient.ListAll method. func (client *ReservationClient) NewListAllPager(options *ReservationClientListAllOptions) *runtime.Pager[ReservationClientListAllResponse] { return runtime.NewPager(runtime.PagingHandler[ReservationClientListAllResponse]{ @@ -309,7 +309,7 @@ func (client *ReservationClient) listAllCreateRequest(ctx context.Context, optio return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-01") + reqQP.Set("api-version", "2022-11-01") if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } @@ -343,7 +343,7 @@ func (client *ReservationClient) listAllHandleResponse(resp *http.Response) (Res } // NewListRevisionsPager - List of all the revisions for the Reservation. -// Generated from API version 2022-03-01 +// Generated from API version 2022-11-01 // reservationID - Id of the Reservation Item // reservationOrderID - Order Id of the reservation // options - ReservationClientListRevisionsOptions contains the optional parameters for the ReservationClient.ListRevisions @@ -392,7 +392,7 @@ func (client *ReservationClient) listRevisionsCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-01") + reqQP.Set("api-version", "2022-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -410,7 +410,7 @@ func (client *ReservationClient) listRevisionsHandleResponse(resp *http.Response // BeginMerge - Merge the specified Reservations into a new Reservation. The two Reservations being merged must have same // properties. // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-01 +// Generated from API version 2022-11-01 // reservationOrderID - Order Id of the reservation // body - Information needed for commercial request for a reservation // options - ReservationClientBeginMergeOptions contains the optional parameters for the ReservationClient.BeginMerge method. @@ -430,7 +430,7 @@ func (client *ReservationClient) BeginMerge(ctx context.Context, reservationOrde // Merge - Merge the specified Reservations into a new Reservation. The two Reservations being merged must have same properties. // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-01 +// Generated from API version 2022-11-01 func (client *ReservationClient) merge(ctx context.Context, reservationOrderID string, body MergeRequest, options *ReservationClientBeginMergeOptions) (*http.Response, error) { req, err := client.mergeCreateRequest(ctx, reservationOrderID, body, options) if err != nil { @@ -458,7 +458,7 @@ func (client *ReservationClient) mergeCreateRequest(ctx context.Context, reserva return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-01") + 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) @@ -466,7 +466,7 @@ func (client *ReservationClient) mergeCreateRequest(ctx context.Context, reserva // BeginSplit - Split a Reservation into two Reservations with specified quantity distribution. // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-01 +// Generated from API version 2022-11-01 // reservationOrderID - Order Id of the reservation // body - Information needed to Split a reservation item // options - ReservationClientBeginSplitOptions contains the optional parameters for the ReservationClient.BeginSplit method. @@ -486,7 +486,7 @@ func (client *ReservationClient) BeginSplit(ctx context.Context, reservationOrde // Split - Split a Reservation into two Reservations with specified quantity distribution. // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-01 +// Generated from API version 2022-11-01 func (client *ReservationClient) split(ctx context.Context, reservationOrderID string, body SplitRequest, options *ReservationClientBeginSplitOptions) (*http.Response, error) { req, err := client.splitCreateRequest(ctx, reservationOrderID, body, options) if err != nil { @@ -514,7 +514,7 @@ func (client *ReservationClient) splitCreateRequest(ctx context.Context, reserva return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-01") + 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) @@ -522,7 +522,7 @@ func (client *ReservationClient) splitCreateRequest(ctx context.Context, reserva // Unarchive - Unarchiving a Reservation moves it to the state it was before archiving. // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-01 +// Generated from API version 2022-11-01 // reservationOrderID - Order Id of the reservation // reservationID - Id of the Reservation Item // options - ReservationClientUnarchiveOptions contains the optional parameters for the ReservationClient.Unarchive method. @@ -557,7 +557,7 @@ func (client *ReservationClient) unarchiveCreateRequest(ctx context.Context, res return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-01") + reqQP.Set("api-version", "2022-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -565,7 +565,7 @@ func (client *ReservationClient) unarchiveCreateRequest(ctx context.Context, res // BeginUpdate - Updates the applied scopes of the Reservation. // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-01 +// Generated from API version 2022-11-01 // reservationOrderID - Order Id of the reservation // reservationID - Id of the Reservation Item // parameters - Information needed to patch a reservation item @@ -584,7 +584,7 @@ func (client *ReservationClient) BeginUpdate(ctx context.Context, reservationOrd // Update - Updates the applied scopes of the Reservation. // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-01 +// 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) { req, err := client.updateCreateRequest(ctx, reservationOrderID, reservationID, parameters, options) if err != nil { @@ -616,7 +616,7 @@ func (client *ReservationClient) updateCreateRequest(ctx context.Context, reserv return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-01") + 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) 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 70c63958cffe..000000000000 --- a/sdk/resourcemanager/reservations/armreservations/reservation_client_example_test.go +++ /dev/null @@ -1,264 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package 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" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-03-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() - client, err := armreservations.NewReservationClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.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) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-03-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() - client, err := armreservations.NewReservationClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.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) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-03-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() - client, err := armreservations.NewReservationClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.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) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-03-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() - client, err := armreservations.NewReservationClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("276e7ae4-84d0-4da6-ab4b-d6b94f3557da", nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-03-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() - client, err := armreservations.NewReservationClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "6ef59113-3482-40da-8d79-787f823e34bc", "276e7ae4-84d0-4da6-ab4b-d6b94f3557da", &armreservations.ReservationClientGetOptions{Expand: to.Ptr("renewProperties")}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-03-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() - client, err := armreservations.NewReservationClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.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) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-03-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() - client, err := armreservations.NewReservationClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.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/tree/main/specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-03-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() - client, err := armreservations.NewReservationClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.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/tree/main/specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-03-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() - client, err := armreservations.NewReservationClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListRevisionsPager("6ef59113-3482-40da-8d79-787f823e34bc", "276e7ae4-84d0-4da6-ab4b-d6b94f3557da", nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-03-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() - client, err := armreservations.NewReservationClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.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() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/reservations/armreservations/reservationorder_client.go b/sdk/resourcemanager/reservations/armreservations/reservationorder_client.go index 9e9154f91a0b..a379fd57aa20 100644 --- a/sdk/resourcemanager/reservations/armreservations/reservationorder_client.go +++ b/sdk/resourcemanager/reservations/armreservations/reservationorder_client.go @@ -52,53 +52,102 @@ func NewReservationOrderClient(credential azcore.TokenCredential, options *arm.C return client, nil } -// Calculate - Calculate price for placing a ReservationOrder. +// CalculatePrice - Calculate price for placing a ReservationOrder. // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-01 +// Generated from API version 2022-11-01 // body - Information needed for calculate or purchase reservation -// options - ReservationOrderClientCalculateOptions contains the optional parameters for the ReservationOrderClient.Calculate +// options - ReservationOrderClientCalculatePriceOptions contains the optional parameters for the ReservationOrderClient.CalculatePrice // method. -func (client *ReservationOrderClient) Calculate(ctx context.Context, body PurchaseRequest, options *ReservationOrderClientCalculateOptions) (ReservationOrderClientCalculateResponse, error) { - req, err := client.calculateCreateRequest(ctx, body, options) +func (client *ReservationOrderClient) CalculatePrice(ctx context.Context, body PurchaseRequest, options *ReservationOrderClientCalculatePriceOptions) (ReservationOrderClientCalculatePriceResponse, error) { + req, err := client.calculatePriceCreateRequest(ctx, body, options) if err != nil { - return ReservationOrderClientCalculateResponse{}, err + return ReservationOrderClientCalculatePriceResponse{}, err } resp, err := client.pl.Do(req) if err != nil { - return ReservationOrderClientCalculateResponse{}, err + return ReservationOrderClientCalculatePriceResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return ReservationOrderClientCalculateResponse{}, runtime.NewResponseError(resp) + return ReservationOrderClientCalculatePriceResponse{}, runtime.NewResponseError(resp) } - return client.calculateHandleResponse(resp) + return client.calculatePriceHandleResponse(resp) } -// calculateCreateRequest creates the Calculate request. -func (client *ReservationOrderClient) calculateCreateRequest(ctx context.Context, body PurchaseRequest, options *ReservationOrderClientCalculateOptions) (*policy.Request, error) { +// calculatePriceCreateRequest creates the CalculatePrice request. +func (client *ReservationOrderClient) calculatePriceCreateRequest(ctx context.Context, body PurchaseRequest, options *ReservationOrderClientCalculatePriceOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Capacity/calculatePrice" req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-01") + 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) } -// calculateHandleResponse handles the Calculate response. -func (client *ReservationOrderClient) calculateHandleResponse(resp *http.Response) (ReservationOrderClientCalculateResponse, error) { - result := ReservationOrderClientCalculateResponse{} +// calculatePriceHandleResponse handles the CalculatePrice response. +func (client *ReservationOrderClient) calculatePriceHandleResponse(resp *http.Response) (ReservationOrderClientCalculatePriceResponse, error) { + result := ReservationOrderClientCalculatePriceResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.CalculatePriceResponse); err != nil { - return ReservationOrderClientCalculateResponse{}, err + return ReservationOrderClientCalculatePriceResponse{}, err + } + return result, nil +} + +// CalculateRefund - Calculate price for returning Reservations if there are no policy errors. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-11-01 +// reservationOrderID - Order Id of the reservation +// body - Information needed for calculating refund of a reservation. +// options - ReservationOrderClientCalculateRefundOptions contains the optional parameters for the ReservationOrderClient.CalculateRefund +// method. +func (client *ReservationOrderClient) CalculateRefund(ctx context.Context, reservationOrderID string, body CalculateRefundRequest, options *ReservationOrderClientCalculateRefundOptions) (ReservationOrderClientCalculateRefundResponse, error) { + req, err := client.calculateRefundCreateRequest(ctx, reservationOrderID, body, options) + if err != nil { + return ReservationOrderClientCalculateRefundResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ReservationOrderClientCalculateRefundResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ReservationOrderClientCalculateRefundResponse{}, runtime.NewResponseError(resp) + } + return client.calculateRefundHandleResponse(resp) +} + +// calculateRefundCreateRequest creates the CalculateRefund request. +func (client *ReservationOrderClient) calculateRefundCreateRequest(ctx context.Context, reservationOrderID string, body CalculateRefundRequest, options *ReservationOrderClientCalculateRefundOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/calculateRefund" + if reservationOrderID == "" { + return nil, errors.New("parameter reservationOrderID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reservationOrderId}", url.PathEscape(reservationOrderID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, body) +} + +// calculateRefundHandleResponse handles the CalculateRefund response. +func (client *ReservationOrderClient) calculateRefundHandleResponse(resp *http.Response) (ReservationOrderClientCalculateRefundResponse, error) { + result := ReservationOrderClientCalculateRefundResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CalculateRefundResponse); err != nil { + return ReservationOrderClientCalculateRefundResponse{}, err } return result, nil } // ChangeDirectory - Change directory (tenant) of ReservationOrder and all Reservation under it to specified tenant id // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-01 +// Generated from API version 2022-11-01 // reservationOrderID - Order Id of the reservation // body - Information needed to change directory of reservation order // options - ReservationOrderClientChangeDirectoryOptions contains the optional parameters for the ReservationOrderClient.ChangeDirectory @@ -130,7 +179,7 @@ func (client *ReservationOrderClient) changeDirectoryCreateRequest(ctx context.C return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-01") + 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) @@ -147,7 +196,7 @@ func (client *ReservationOrderClient) changeDirectoryHandleResponse(resp *http.R // Get - Get the details of the ReservationOrder. // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-01 +// Generated from API version 2022-11-01 // 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) { @@ -177,7 +226,7 @@ func (client *ReservationOrderClient) getCreateRequest(ctx context.Context, rese return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-01") + reqQP.Set("api-version", "2022-11-01") if options != nil && options.Expand != nil { reqQP.Set("$expand", *options.Expand) } @@ -196,7 +245,7 @@ func (client *ReservationOrderClient) getHandleResponse(resp *http.Response) (Re } // NewListPager - List of all the ReservationOrders that the user has access to in the current tenant. -// Generated from API version 2022-03-01 +// Generated from API version 2022-11-01 // options - ReservationOrderClientListOptions contains the optional parameters for the ReservationOrderClient.List method. func (client *ReservationOrderClient) NewListPager(options *ReservationOrderClientListOptions) *runtime.Pager[ReservationOrderClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ReservationOrderClientListResponse]{ @@ -234,7 +283,7 @@ func (client *ReservationOrderClient) listCreateRequest(ctx context.Context, opt return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-01") + reqQP.Set("api-version", "2022-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -251,7 +300,7 @@ func (client *ReservationOrderClient) listHandleResponse(resp *http.Response) (R // BeginPurchase - Purchase ReservationOrder and create resource under the specified URI. // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-01 +// Generated from API version 2022-11-01 // reservationOrderID - Order Id of the reservation // body - Information needed for calculate or purchase reservation // options - ReservationOrderClientBeginPurchaseOptions contains the optional parameters for the ReservationOrderClient.BeginPurchase @@ -272,7 +321,7 @@ func (client *ReservationOrderClient) BeginPurchase(ctx context.Context, reserva // Purchase - Purchase ReservationOrder and create resource under the specified URI. // If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-01 +// Generated from API version 2022-11-01 func (client *ReservationOrderClient) purchase(ctx context.Context, reservationOrderID string, body PurchaseRequest, options *ReservationOrderClientBeginPurchaseOptions) (*http.Response, error) { req, err := client.purchaseCreateRequest(ctx, reservationOrderID, body, options) if err != nil { @@ -300,8 +349,59 @@ func (client *ReservationOrderClient) purchaseCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-01") + 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) } + +// Return - Return a reservation. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-11-01 +// reservationOrderID - Order Id of the reservation +// body - Information needed for returning reservation. +// options - ReservationOrderClientReturnOptions contains the optional parameters for the ReservationOrderClient.Return method. +func (client *ReservationOrderClient) Return(ctx context.Context, reservationOrderID string, body RefundRequest, options *ReservationOrderClientReturnOptions) (ReservationOrderClientReturnResponse, error) { + req, err := client.returnCreateRequest(ctx, reservationOrderID, body, options) + if err != nil { + return ReservationOrderClientReturnResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return ReservationOrderClientReturnResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusAccepted) { + return ReservationOrderClientReturnResponse{}, runtime.NewResponseError(resp) + } + return client.returnHandleResponse(resp) +} + +// returnCreateRequest creates the Return request. +func (client *ReservationOrderClient) returnCreateRequest(ctx context.Context, reservationOrderID string, body RefundRequest, options *ReservationOrderClientReturnOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/return" + if reservationOrderID == "" { + return nil, errors.New("parameter reservationOrderID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reservationOrderId}", url.PathEscape(reservationOrderID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, body) +} + +// returnHandleResponse handles the Return response. +func (client *ReservationOrderClient) returnHandleResponse(resp *http.Response) (ReservationOrderClientReturnResponse, error) { + result := ReservationOrderClientReturnResponse{} + if val := resp.Header.Get("Location"); val != "" { + result.Location = &val + } + if err := runtime.UnmarshalAsJSON(resp, &result.RefundResponse); err != nil { + return ReservationOrderClientReturnResponse{}, err + } + return result, 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 7d2faa89561a..000000000000 --- a/sdk/resourcemanager/reservations/armreservations/reservationorder_client_example_test.go +++ /dev/null @@ -1,178 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package 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" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-03-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() - client, err := armreservations.NewReservationOrderClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.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) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-03-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() - client, err := armreservations.NewReservationOrderClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-03-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() - client, err := armreservations.NewReservationOrderClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.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) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-03-01/examples/GetReservationOrderDetails.json -func ExampleReservationOrderClient_Get_getReservation() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armreservations.NewReservationOrderClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, "a075419f-44cc-497f-b68a-14ee811d48b9", &armreservations.ReservationOrderClientGetOptions{Expand: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-03-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() - client, err := armreservations.NewReservationOrderClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.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) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-03-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() - client, err := armreservations.NewReservationOrderClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.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) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/reservations/armreservations/response_types.go b/sdk/resourcemanager/reservations/armreservations/response_types.go index 9792a3d47b63..eede9bbdc666 100644 --- a/sdk/resourcemanager/reservations/armreservations/response_types.go +++ b/sdk/resourcemanager/reservations/armreservations/response_types.go @@ -11,6 +11,16 @@ package armreservations import "encoding/json" +// AzureReservationAPIClientCalculateExchangeResponse contains the response from method AzureReservationAPIClient.CalculateExchange. +type AzureReservationAPIClientCalculateExchangeResponse struct { + CalculateExchangeOperationResultResponse +} + +// AzureReservationAPIClientExchangeResponse contains the response from method AzureReservationAPIClient.Exchange. +type AzureReservationAPIClientExchangeResponse struct { + ExchangeOperationResultResponse +} + // AzureReservationAPIClientGetAppliedReservationListResponse contains the response from method AzureReservationAPIClient.GetAppliedReservationList. type AzureReservationAPIClientGetAppliedReservationListResponse struct { AppliedReservations @@ -18,23 +28,7 @@ type AzureReservationAPIClientGetAppliedReservationListResponse struct { // AzureReservationAPIClientGetCatalogResponse contains the response from method AzureReservationAPIClient.GetCatalog. type AzureReservationAPIClientGetCatalogResponse struct { - // Array of Catalog - CatalogArray []*Catalog -} - -// CalculateExchangeClientPostResponse contains the response from method CalculateExchangeClient.Post. -type CalculateExchangeClientPostResponse struct { - CalculateExchangeOperationResultResponse -} - -// CalculateRefundClientPostResponse contains the response from method CalculateRefundClient.Post. -type CalculateRefundClientPostResponse struct { - CalculateRefundResponse -} - -// ExchangeClientPostResponse contains the response from method ExchangeClient.Post. -type ExchangeClientPostResponse struct { - ExchangeOperationResultResponse + CatalogsResult } // OperationClientListResponse contains the response from method OperationClient.List. @@ -138,11 +132,16 @@ type ReservationClientUpdateResponse struct { ReservationResponse } -// ReservationOrderClientCalculateResponse contains the response from method ReservationOrderClient.Calculate. -type ReservationOrderClientCalculateResponse struct { +// ReservationOrderClientCalculatePriceResponse contains the response from method ReservationOrderClient.CalculatePrice. +type ReservationOrderClientCalculatePriceResponse struct { CalculatePriceResponse } +// ReservationOrderClientCalculateRefundResponse contains the response from method ReservationOrderClient.CalculateRefund. +type ReservationOrderClientCalculateRefundResponse struct { + CalculateRefundResponse +} + // ReservationOrderClientChangeDirectoryResponse contains the response from method ReservationOrderClient.ChangeDirectory. type ReservationOrderClientChangeDirectoryResponse struct { ChangeDirectoryResponse @@ -163,8 +162,8 @@ type ReservationOrderClientPurchaseResponse struct { ReservationOrderResponse } -// ReturnClientPostResponse contains the response from method ReturnClient.Post. -type ReturnClientPostResponse struct { +// ReservationOrderClientReturnResponse contains the response from method ReservationOrderClient.Return. +type ReservationOrderClientReturnResponse struct { RefundResponse // Location contains the information returned from the Location header response. Location *string diff --git a/sdk/resourcemanager/reservations/armreservations/return_client.go b/sdk/resourcemanager/reservations/armreservations/return_client.go deleted file mode 100644 index 4b90d1163e21..000000000000 --- a/sdk/resourcemanager/reservations/armreservations/return_client.go +++ /dev/null @@ -1,104 +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 - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strings" -) - -// ReturnClient contains the methods for the Return group. -// Don't use this type directly, use NewReturnClient() instead. -type ReturnClient struct { - host string - pl runtime.Pipeline -} - -// NewReturnClient creates a new instance of ReturnClient with the specified values. -// credential - used to authorize requests. Usually a credential from azidentity. -// options - pass nil to accept the default values. -func NewReturnClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*ReturnClient, error) { - if options == nil { - options = &arm.ClientOptions{} - } - ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint - if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { - ep = c.Endpoint - } - pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) - if err != nil { - return nil, err - } - client := &ReturnClient{ - host: ep, - pl: pl, - } - return client, nil -} - -// Post - Return a reservation. -// If the operation fails it returns an *azcore.ResponseError type. -// Generated from API version 2022-03-01 -// reservationOrderID - Order Id of the reservation -// body - Information needed for returning reservation. -// options - ReturnClientPostOptions contains the optional parameters for the ReturnClient.Post method. -func (client *ReturnClient) Post(ctx context.Context, reservationOrderID string, body RefundRequest, options *ReturnClientPostOptions) (ReturnClientPostResponse, error) { - req, err := client.postCreateRequest(ctx, reservationOrderID, body, options) - if err != nil { - return ReturnClientPostResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return ReturnClientPostResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusAccepted) { - return ReturnClientPostResponse{}, runtime.NewResponseError(resp) - } - return client.postHandleResponse(resp) -} - -// postCreateRequest creates the Post request. -func (client *ReturnClient) postCreateRequest(ctx context.Context, reservationOrderID string, body RefundRequest, options *ReturnClientPostOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/return" - if reservationOrderID == "" { - return nil, errors.New("parameter reservationOrderID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{reservationOrderId}", url.PathEscape(reservationOrderID)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-03-01") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) -} - -// postHandleResponse handles the Post response. -func (client *ReturnClient) postHandleResponse(resp *http.Response) (ReturnClientPostResponse, error) { - result := ReturnClientPostResponse{} - if val := resp.Header.Get("Location"); val != "" { - result.Location = &val - } - if err := runtime.UnmarshalAsJSON(resp, &result.RefundResponse); err != nil { - return ReturnClientPostResponse{}, err - } - return result, 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 62a4427ab6f6..000000000000 --- a/sdk/resourcemanager/reservations/armreservations/return_client_example_test.go +++ /dev/null @@ -1,45 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package 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" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-03-01/examples/Return.json -func ExampleReturnClient_Post() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armreservations.NewReturnClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.Post(ctx, "276e7ae4-84d0-4da6-ab4b-d6b94f3557da", 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) - } -}