From 9a4984a90f897c3c6f86751f6bddb00f6d62fd9b Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Fri, 9 Dec 2022 22:40:47 +0000 Subject: [PATCH] CodeGen from PR 21565 in Azure/azure-rest-api-specs Merge 2921c73fed787e1335302caaf9bea1220a867f8e into 23b62d4e4dab07dccda851cfe50f6c6afb705a3b --- .../reservations/armreservations/CHANGELOG.md | 41 ++ .../reservations/armreservations/autorest.md | 6 +- .../azurereservationapi_client.go | 62 ++- ...azurereservationapi_client_example_test.go | 61 --- .../calculateexchange_client.go | 6 +- .../calculateexchange_client_example_test.go | 69 ---- .../armreservations/calculaterefund_client.go | 4 +- .../calculaterefund_client_example_test.go | 46 --- .../reservations/armreservations/constants.go | 56 ++- .../armreservations/exchange_client.go | 6 +- .../exchange_client_example_test.go | 45 --- .../reservations/armreservations/go.mod | 16 +- .../reservations/armreservations/go.sum | 24 +- .../reservations/armreservations/models.go | 165 +++++++- .../armreservations/models_serde.go | 364 ++++++++++++++++++ .../armreservations/operation_client.go | 4 +- .../operation_client_example_test.go | 41 -- .../quota_client_example_test.go | 211 ---------- .../quotarequeststatus_client_example_test.go | 101 ----- .../armreservations/reservation_client.go | 52 +-- .../reservation_client_example_test.go | 264 ------------- .../reservationorder_client.go | 22 +- .../reservationorder_client_example_test.go | 178 --------- .../armreservations/response_types.go | 3 +- .../armreservations/return_client.go | 4 +- .../return_client_example_test.go | 45 --- 26 files changed, 718 insertions(+), 1178 deletions(-) delete mode 100644 sdk/resourcemanager/reservations/armreservations/azurereservationapi_client_example_test.go delete mode 100644 sdk/resourcemanager/reservations/armreservations/calculateexchange_client_example_test.go delete mode 100644 sdk/resourcemanager/reservations/armreservations/calculaterefund_client_example_test.go delete mode 100644 sdk/resourcemanager/reservations/armreservations/exchange_client_example_test.go delete mode 100644 sdk/resourcemanager/reservations/armreservations/operation_client_example_test.go delete mode 100644 sdk/resourcemanager/reservations/armreservations/quota_client_example_test.go delete mode 100644 sdk/resourcemanager/reservations/armreservations/quotarequeststatus_client_example_test.go delete mode 100644 sdk/resourcemanager/reservations/armreservations/reservation_client_example_test.go delete mode 100644 sdk/resourcemanager/reservations/armreservations/reservationorder_client_example_test.go delete mode 100644 sdk/resourcemanager/reservations/armreservations/return_client_example_test.go diff --git a/sdk/resourcemanager/reservations/armreservations/CHANGELOG.md b/sdk/resourcemanager/reservations/armreservations/CHANGELOG.md index 5ca7d6a3d111..8baec3887e4b 100644 --- a/sdk/resourcemanager/reservations/armreservations/CHANGELOG.md +++ b/sdk/resourcemanager/reservations/armreservations/CHANGELOG.md @@ -1,5 +1,46 @@ # Release History +## 2.0.0 (2022-12-09) +### Breaking Changes + +- Function `*AzureReservationAPIClient.GetCatalog` has been removed +- Field `CatalogArray` of struct `AzureReservationAPIClientGetCatalogResponse` has been removed + +### Features Added + +- New value `AppliedScopeTypeManagementGroup` added to type alias `AppliedScopeType` +- New value `DisplayProvisioningStateNoBenefit`, `DisplayProvisioningStateWarning` added to type alias `DisplayProvisioningState` +- New type alias `BillingPlan` with values `BillingPlanP1M` +- New type alias `CommitmentGrain` with values `CommitmentGrainHourly` +- New type alias `SavingsPlanTerm` with values `SavingsPlanTermP1Y`, `SavingsPlanTermP3Y` +- New function `*AzureReservationAPIClient.NewGetCatalogPager(string, *AzureReservationAPIClientGetCatalogOptions) *runtime.Pager[AzureReservationAPIClientGetCatalogResponse]` +- New struct `AppliedScopeProperties` +- New struct `CatalogsResult` +- New struct `Commitment` +- New struct `ReservationSwapProperties` +- New struct `SavingsPlanPurchaseRequest` +- New struct `SavingsPlanPurchaseRequestProperties` +- New struct `SavingsPlanToPurchaseCalculateExchange` +- New struct `SavingsPlanToPurchaseExchange` +- New anonymous field `CatalogsResult` in struct `AzureReservationAPIClientGetCatalogResponse` +- New field `SavingsPlansToPurchase` in struct `CalculateExchangeRequestProperties` +- New field `SavingsPlansToPurchase` in struct `CalculateExchangeResponseProperties` +- New field `SavingsPlansToPurchase` in struct `ExchangeResponseProperties` +- New field `AppliedScopeProperties` in struct `PatchProperties` +- New field `ReviewDateTime` in struct `PatchProperties` +- New field `AppliedScopeProperties` in struct `Properties` +- New field `ExpiryDateTime` in struct `Properties` +- New field `PurchaseDateTime` in struct `Properties` +- New field `ReviewDateTime` in struct `Properties` +- New field `SwapProperties` in struct `Properties` +- New field `AppliedScopeProperties` in struct `PurchaseRequestProperties` +- New field `ReviewDateTime` in struct `PurchaseRequestProperties` +- New field `ExpiryDateTime` in struct `ReservationOrderProperties` +- New field `ReviewDateTime` in struct `ReservationOrderProperties` +- New field `NoBenefitCount` in struct `ReservationSummary` +- New field `WarningCount` in struct `ReservationSummary` + + ## 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..a3de75400b8f 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" ) @@ -55,7 +56,7 @@ func NewAzureReservationAPIClient(credential azcore.TokenCredential, options *ar // 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 +87,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 @@ -101,25 +102,37 @@ func (client *AzureReservationAPIClient) getAppliedReservationListHandleResponse return result, nil } -// 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 +// NewGetCatalogPager - Get the regions and skus that are available for RI purchase for the specified Azure subscription. +// Generated from API version 2022-11-01 // subscriptionID - Id of the subscription // options - AzureReservationAPIClientGetCatalogOptions contains the optional parameters for the AzureReservationAPIClient.GetCatalog // method. -func (client *AzureReservationAPIClient) GetCatalog(ctx context.Context, subscriptionID string, options *AzureReservationAPIClientGetCatalogOptions) (AzureReservationAPIClientGetCatalogResponse, error) { - req, err := client.getCatalogCreateRequest(ctx, subscriptionID, options) - if err != nil { - return AzureReservationAPIClientGetCatalogResponse{}, err - } - resp, err := client.pl.Do(req) - if err != nil { - return AzureReservationAPIClientGetCatalogResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return AzureReservationAPIClientGetCatalogResponse{}, runtime.NewResponseError(resp) - } - return client.getCatalogHandleResponse(resp) +func (client *AzureReservationAPIClient) NewGetCatalogPager(subscriptionID string, options *AzureReservationAPIClientGetCatalogOptions) *runtime.Pager[AzureReservationAPIClientGetCatalogResponse] { + return runtime.NewPager(runtime.PagingHandler[AzureReservationAPIClientGetCatalogResponse]{ + More: func(page AzureReservationAPIClientGetCatalogResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *AzureReservationAPIClientGetCatalogResponse) (AzureReservationAPIClientGetCatalogResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.getCatalogCreateRequest(ctx, subscriptionID, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return AzureReservationAPIClientGetCatalogResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AzureReservationAPIClientGetCatalogResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AzureReservationAPIClientGetCatalogResponse{}, runtime.NewResponseError(resp) + } + return client.getCatalogHandleResponse(resp) + }, + }) } // getCatalogCreateRequest creates the GetCatalog request. @@ -134,7 +147,7 @@ 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) } @@ -150,6 +163,15 @@ func (client *AzureReservationAPIClient) getCatalogCreateRequest(ctx context.Con if options != nil && options.PlanID != nil { reqQP.Set("planId", *options.PlanID) } + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.Skip != nil { + reqQP.Set("$skip", strconv.FormatFloat(float64(*options.Skip), 'f', -1, 32)) + } + 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"} return req, nil @@ -158,7 +180,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 index 8bc2907980a0..651eb1975700 100644 --- a/sdk/resourcemanager/reservations/armreservations/calculateexchange_client.go +++ b/sdk/resourcemanager/reservations/armreservations/calculateexchange_client.go @@ -51,7 +51,7 @@ func NewCalculateExchangeClient(credential azcore.TokenCredential, options *arm. // 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 +// Generated from API version 2022-11-01 // body - Request containing purchases and refunds that need to be executed. // options - CalculateExchangeClientBeginPostOptions contains the optional parameters for the CalculateExchangeClient.BeginPost // method. @@ -71,7 +71,7 @@ func (client *CalculateExchangeClient) BeginPost(ctx context.Context, body Calcu // 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 +// Generated from API version 2022-11-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 { @@ -95,7 +95,7 @@ func (client *CalculateExchangeClient) postCreateRequest(ctx context.Context, bo 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) 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 index b095ae5fcb34..e1516f0432df 100644 --- a/sdk/resourcemanager/reservations/armreservations/calculaterefund_client.go +++ b/sdk/resourcemanager/reservations/armreservations/calculaterefund_client.go @@ -54,7 +54,7 @@ func NewCalculateRefundClient(credential azcore.TokenCredential, options *arm.Cl // 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 +// Generated from API version 2022-11-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. @@ -85,7 +85,7 @@ func (client *CalculateRefundClient) postCreateRequest(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") 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/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..3415f07e01f3 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,20 @@ func PossibleCalculateExchangeOperationResultStatusValues() []CalculateExchangeO } } +// 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 +108,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 +122,11 @@ func PossibleDisplayProvisioningStateValues() []DisplayProvisioningState { DisplayProvisioningStateExpired, DisplayProvisioningStateExpiring, DisplayProvisioningStateFailed, + DisplayProvisioningStateNoBenefit, DisplayProvisioningStatePending, DisplayProvisioningStateProcessing, DisplayProvisioningStateSucceeded, + DisplayProvisioningStateWarning, } } @@ -573,6 +607,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 index cd1b8890cd3d..f599425b2fc3 100644 --- a/sdk/resourcemanager/reservations/armreservations/exchange_client.go +++ b/sdk/resourcemanager/reservations/armreservations/exchange_client.go @@ -51,7 +51,7 @@ func NewExchangeClient(credential azcore.TokenCredential, options *arm.ClientOpt // 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 +// Generated from API version 2022-11-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) { @@ -70,7 +70,7 @@ func (client *ExchangeClient) BeginPost(ctx context.Context, body ExchangeReques // 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 +// Generated from API version 2022-11-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 { @@ -94,7 +94,7 @@ func (client *ExchangeClient) postCreateRequest(ctx context.Context, body Exchan 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) 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..95ddc83d899a 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"` } @@ -58,6 +76,8 @@ 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 @@ -68,6 +88,10 @@ type AzureReservationAPIClientGetCatalogOptions struct { 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 @@ -114,6 +138,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 +158,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"` } @@ -257,6 +287,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 +326,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. @@ -406,6 +459,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 +549,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 +568,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 +608,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,7 +626,7 @@ 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 @@ -576,10 +641,13 @@ type Properties struct { // This is the date when the Reservation will expire. ExpiryDate *time.Time `json:"expiryDate,omitempty"` + // This is the date-time when the Reservation will expire. + ExpiryDateTime *time.Time `json:"expiryDateTime,omitempty"` + // The message giving detailed information about the status code. ExtendedStatusInfo *ExtendedStatusInfo `json:"extendedStatusInfo,omitempty"` - // Allows reservation discount to be applied across skus within the same Autofit group. Not all skus support instance size + // Allows reservation discount to be applied across skus within the same auto fit group. Not all skus support instance size // flexibility. InstanceFlexibility *InstanceFlexibility `json:"instanceFlexibility,omitempty"` MergeProperties *ReservationMergeProperties `json:"mergeProperties,omitempty"` @@ -590,6 +658,9 @@ type Properties struct { // This is the date when the Reservation was purchased. PurchaseDate *time.Time `json:"purchaseDate,omitempty"` + // This is the date-time when the Reservation was purchased. + PurchaseDateTime *time.Time `json:"purchaseDateTime,omitempty"` + // Quantity of the SKUs that are part of the Reservation. Quantity *int32 `json:"quantity,omitempty"` @@ -607,9 +678,13 @@ 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"` @@ -620,7 +695,7 @@ type Properties struct { // 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 + // READ-ONLY; The provisioning sub state of the reservation, e.g. Succeeded ProvisioningSubState *string `json:"provisioningSubState,omitempty" azure:"ro"` // READ-ONLY; The applied scope type of the reservation for display, e.g. Shared @@ -638,7 +713,7 @@ 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"` } @@ -650,6 +725,9 @@ type PurchaseRequest struct { } 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 +737,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 +755,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,8 +1109,8 @@ 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, - // quantity, renew, reservedResourceType, term, + // properties/{appliedScopeType, archived, displayName, displayProvisioningState, effectiveDateTime, expiryDate, expiryDateTime, + // provisioningState, quantity, renew, reservedResourceType, term, // userFriendlyAppliedScopeType, userFriendlyRenewState} Filter *string // May be used to sort order by reservation properties. @@ -1137,6 +1218,9 @@ type ReservationOrderProperties struct { // This is the date when the Reservation will expire. ExpiryDate *time.Time `json:"expiryDate,omitempty"` + // This is the date-time when the Reservation will expire. + ExpiryDateTime *time.Time `json:"expiryDateTime,omitempty"` + // Total Quantity of the SKUs purchased in the Reservation. OriginalQuantity *int32 `json:"originalQuantity,omitempty"` @@ -1150,6 +1234,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"` } @@ -1222,6 +1309,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 +1320,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 @@ -1353,6 +1454,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..304b039ee3e6 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) @@ -1732,6 +1866,7 @@ func (p Properties) MarshalJSON() ([]byte, error) { 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) @@ -1739,14 +1874,17 @@ func (p Properties) MarshalJSON() ([]byte, error) { 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 +1901,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) @@ -1796,6 +1937,9 @@ func (p *Properties) UnmarshalJSON(data []byte) error { case "expiryDate": err = unpopulateDateType(val, "ExpiryDate", &p.ExpiryDate) delete(rawMsg, key) + case "expiryDateTime": + err = unpopulateTimeRFC3339(val, "ExpiryDateTime", &p.ExpiryDateTime) + delete(rawMsg, key) case "extendedStatusInfo": err = unpopulate(val, "ExtendedStatusInfo", &p.ExtendedStatusInfo) delete(rawMsg, key) @@ -1817,6 +1961,9 @@ func (p *Properties) UnmarshalJSON(data []byte) error { case "purchaseDate": err = unpopulateDateType(val, "PurchaseDate", &p.PurchaseDate) delete(rawMsg, key) + case "purchaseDateTime": + err = unpopulateTimeRFC3339(val, "PurchaseDateTime", &p.PurchaseDateTime) + delete(rawMsg, key) case "quantity": err = unpopulate(val, "Quantity", &p.Quantity) delete(rawMsg, key) @@ -1835,12 +1982,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 +2083,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 +2093,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 +2107,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 +2137,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) @@ -2947,11 +3108,13 @@ func (r ReservationOrderProperties) MarshalJSON() ([]byte, error) { 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) } @@ -2980,6 +3143,9 @@ func (r *ReservationOrderProperties) UnmarshalJSON(data []byte) error { case "expiryDate": err = unpopulateDateType(val, "ExpiryDate", &r.ExpiryDate) delete(rawMsg, key) + case "expiryDateTime": + err = unpopulateTimeRFC3339(val, "ExpiryDateTime", &r.ExpiryDateTime) + delete(rawMsg, key) case "originalQuantity": err = unpopulate(val, "OriginalQuantity", &r.OriginalQuantity) delete(rawMsg, key) @@ -2995,6 +3161,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 +3319,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 +3348,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 +3360,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 +3783,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..56b15dbe9beb 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,9 +192,9 @@ 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) + reqQP.Set("$expand", *options.Expand) } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} @@ -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,15 +514,15 @@ 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) } -// Unarchive - Unarchiving a Reservation moves it to the state it was before archiving. +// Unarchive - Moves a Reservation 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..ae0c6307fe14 100644 --- a/sdk/resourcemanager/reservations/armreservations/reservationorder_client.go +++ b/sdk/resourcemanager/reservations/armreservations/reservationorder_client.go @@ -54,7 +54,7 @@ func NewReservationOrderClient(credential azcore.TokenCredential, options *arm.C // Calculate - 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 // method. @@ -81,7 +81,7 @@ func (client *ReservationOrderClient) calculateCreateRequest(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) @@ -98,7 +98,7 @@ func (client *ReservationOrderClient) calculateHandleResponse(resp *http.Respons // 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 +130,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 +147,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 +177,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 +196,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 +234,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 +251,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 +272,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,7 +300,7 @@ 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) 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..e6739ef1b924 100644 --- a/sdk/resourcemanager/reservations/armreservations/response_types.go +++ b/sdk/resourcemanager/reservations/armreservations/response_types.go @@ -18,8 +18,7 @@ type AzureReservationAPIClientGetAppliedReservationListResponse struct { // AzureReservationAPIClientGetCatalogResponse contains the response from method AzureReservationAPIClient.GetCatalog. type AzureReservationAPIClientGetCatalogResponse struct { - // Array of Catalog - CatalogArray []*Catalog + CatalogsResult } // CalculateExchangeClientPostResponse contains the response from method CalculateExchangeClient.Post. diff --git a/sdk/resourcemanager/reservations/armreservations/return_client.go b/sdk/resourcemanager/reservations/armreservations/return_client.go index 4b90d1163e21..6ebeaad3c123 100644 --- a/sdk/resourcemanager/reservations/armreservations/return_client.go +++ b/sdk/resourcemanager/reservations/armreservations/return_client.go @@ -54,7 +54,7 @@ func NewReturnClient(credential azcore.TokenCredential, options *arm.ClientOptio // Post - Return a 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 // body - Information needed for returning reservation. // options - ReturnClientPostOptions contains the optional parameters for the ReturnClient.Post method. @@ -85,7 +85,7 @@ func (client *ReturnClient) postCreateRequest(ctx context.Context, reservationOr 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) 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) - } -}