diff --git a/sdk/resourcemanager/consumption/armconsumption/CHANGELOG.md b/sdk/resourcemanager/consumption/armconsumption/CHANGELOG.md index 259b594fb26c..65d606e63307 100644 --- a/sdk/resourcemanager/consumption/armconsumption/CHANGELOG.md +++ b/sdk/resourcemanager/consumption/armconsumption/CHANGELOG.md @@ -1,5 +1,42 @@ # Release History +## 2.0.0 (2025-05-12) +### Breaking Changes + +- Type of `ModernReservationRecommendation.Properties` has been changed from `*ModernReservationRecommendationProperties` to `ModernReservationRecommendationPropertiesClassification` +- Field `Etag`, `Tags` of struct `CreditSummary` has been removed +- Field `MarketplaceCharges` of struct `LegacyChargeSummaryProperties` has been removed + +### Features Added + +- New value `EventTypeCreditExpired` added to enum type `EventType` +- New value `TermP1M` added to enum type `Term` +- New enum type `OperationStatusType` with values `OperationStatusTypeCompleted`, `OperationStatusTypeFailed`, `OperationStatusTypeRunning` +- New enum type `OrganizationType` with values `OrganizationTypeContributorOrganizationType`, `OrganizationTypePrimaryOrganizationType` +- New function `*ModernReservationRecommendationProperties.GetModernReservationRecommendationProperties() *ModernReservationRecommendationProperties` +- New function `*ModernSharedScopeReservationRecommendationProperties.GetModernReservationRecommendationProperties() *ModernReservationRecommendationProperties` +- New function `*ModernSingleScopeReservationRecommendationProperties.GetModernReservationRecommendationProperties() *ModernReservationRecommendationProperties` +- New function `*PriceSheetClient.BeginDownloadByBillingAccountPeriod(context.Context, string, string, *PriceSheetClientBeginDownloadByBillingAccountPeriodOptions) (*runtime.Poller[PriceSheetClientDownloadByBillingAccountPeriodResponse], error)` +- New struct `ModernSharedScopeReservationRecommendationProperties` +- New struct `ModernSingleScopeReservationRecommendationProperties` +- New struct `OperationStatus` +- New struct `PricesheetDownloadProperties` +- New struct `SavingsPlan` +- New field `OverageRefund` in struct `BalanceProperties` +- New field `ETag` in struct `CreditSummary` +- New field `IsEstimatedBalance` in struct `CreditSummaryProperties` +- New field `BillingAccountDisplayName`, `BillingAccountID`, `ChargesInLotCurrency`, `ClosedBalanceInLotCurrency`, `IsEstimatedBalance` in struct `EventProperties` +- New field `AzureMarketplaceCharges` in struct `LegacyChargeSummaryProperties` +- New field `LastUsageDate`, `TotalHours` in struct `LegacyReservationRecommendationProperties` +- New field `LastUsageDate`, `TotalHours` in struct `LegacySharedScopeReservationRecommendationProperties` +- New field `LastUsageDate`, `TotalHours` in struct `LegacySingleScopeReservationRecommendationProperties` +- New field `IsEstimatedBalance`, `OrganizationType`, `UsedAmount` in struct `LotProperties` +- New field `SubscriptionID` in struct `ModernChargeSummaryProperties` +- New field `SavingsPlan` in struct `PriceSheetProperties` +- New field `Filter` in struct `ReservationRecommendationDetailsClientGetOptions` +- New field `PreviewMarkupPercentage`, `UseMarkupIfPartner` in struct `ReservationTransactionsClientListOptions` + + ## 1.2.0 (2023-11-24) ### Features Added diff --git a/sdk/resourcemanager/consumption/armconsumption/README.md b/sdk/resourcemanager/consumption/armconsumption/README.md index 571bd0d116f7..0d52a8376200 100644 --- a/sdk/resourcemanager/consumption/armconsumption/README.md +++ b/sdk/resourcemanager/consumption/armconsumption/README.md @@ -18,7 +18,7 @@ This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for ve Install the Azure Consumption module: ```sh -go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2 ``` ## Authorization diff --git a/sdk/resourcemanager/consumption/armconsumption/aggregatedcost_client.go b/sdk/resourcemanager/consumption/armconsumption/aggregatedcost_client.go index eddd67945404..decb69d212ea 100644 --- a/sdk/resourcemanager/consumption/armconsumption/aggregatedcost_client.go +++ b/sdk/resourcemanager/consumption/armconsumption/aggregatedcost_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -44,7 +41,7 @@ func NewAggregatedCostClient(credential azcore.TokenCredential, options *arm.Cli // period. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-10-01 +// Generated from API version 2025-04-01 // - managementGroupID - Azure Management Group ID. // - options - AggregatedCostClientGetByManagementGroupOptions contains the optional parameters for the AggregatedCostClient.GetByManagementGroup // method. @@ -82,10 +79,10 @@ func (client *AggregatedCostClient) getByManagementGroupCreateRequest(ctx contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-10-01") if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -104,7 +101,7 @@ func (client *AggregatedCostClient) getByManagementGroupHandleResponse(resp *htt // by specified billing period // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-10-01 +// Generated from API version 2025-04-01 // - managementGroupID - Azure Management Group ID. // - billingPeriodName - Billing Period Name. // - options - AggregatedCostClientGetForBillingPeriodByManagementGroupOptions contains the optional parameters for the AggregatedCostClient.GetForBillingPeriodByManagementGroup @@ -132,7 +129,7 @@ func (client *AggregatedCostClient) GetForBillingPeriodByManagementGroup(ctx con } // getForBillingPeriodByManagementGroupCreateRequest creates the GetForBillingPeriodByManagementGroup request. -func (client *AggregatedCostClient) getForBillingPeriodByManagementGroupCreateRequest(ctx context.Context, managementGroupID string, billingPeriodName string, options *AggregatedCostClientGetForBillingPeriodByManagementGroupOptions) (*policy.Request, error) { +func (client *AggregatedCostClient) getForBillingPeriodByManagementGroupCreateRequest(ctx context.Context, managementGroupID string, billingPeriodName string, _ *AggregatedCostClientGetForBillingPeriodByManagementGroupOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/aggregatedCost" if managementGroupID == "" { return nil, errors.New("parameter managementGroupID cannot be empty") @@ -147,7 +144,7 @@ func (client *AggregatedCostClient) getForBillingPeriodByManagementGroupCreateRe return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-10-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/consumption/armconsumption/aggregatedcost_client_example_test.go b/sdk/resourcemanager/consumption/armconsumption/aggregatedcost_client_example_test.go deleted file mode 100644 index 1b05c010cf89..000000000000 --- a/sdk/resourcemanager/consumption/armconsumption/aggregatedcost_client_example_test.go +++ /dev/null @@ -1,182 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armconsumption_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/consumption/armconsumption" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/AggregatedCostByManagementGroup.json -func ExampleAggregatedCostClient_GetByManagementGroup_aggregatedCostByManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAggregatedCostClient().GetByManagementGroup(ctx, "managementGroupForTest", &armconsumption.AggregatedCostClientGetByManagementGroupOptions{Filter: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ManagementGroupAggregatedCostResult = armconsumption.ManagementGroupAggregatedCostResult{ - // Name: to.Ptr("aggregatedcostId1"), - // Type: to.Ptr("Microsoft.Consumption/aggregatedcost"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/managementGroupForTest/providers/Microsoft.Consumption/aggregatedcostId1"), - // Properties: &armconsumption.ManagementGroupAggregatedCostProperties{ - // AzureCharges: to.Ptr[float64](250.9876), - // ChargesBilledSeparately: to.Ptr[float64](120.345), - // Children: []*armconsumption.ManagementGroupAggregatedCostResult{ - // { - // Name: to.Ptr("aggregatedcostId2"), - // Type: to.Ptr("Microsoft.Consumption/aggregatedcost"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/managementGroupChildForTest/providers/Microsoft.Consumption/aggregatedcostId2"), - // Properties: &armconsumption.ManagementGroupAggregatedCostProperties{ - // AzureCharges: to.Ptr[float64](150), - // ChargesBilledSeparately: to.Ptr[float64](30.345), - // Children: []*armconsumption.ManagementGroupAggregatedCostResult{ - // }, - // Currency: to.Ptr("USD"), - // ExcludedSubscriptions: []*string{ - // }, - // IncludedSubscriptions: []*string{ - // to.Ptr("c349567d-c83a-48c9-ab0e-578c69dc97a4")}, - // MarketplaceCharges: to.Ptr[float64](50.786), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-31T00:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-10-01T00:00:00.000Z"); return t}()), - // }, - // }}, - // Currency: to.Ptr("USD"), - // ExcludedSubscriptions: []*string{ - // }, - // IncludedSubscriptions: []*string{ - // to.Ptr("1caaa5a3-2b66-438e-8ab4-bce37d518c5d")}, - // MarketplaceCharges: to.Ptr[float64](150.786), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-31T00:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-10-01T00:00:00.000Z"); return t}()), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/AggregatedCostByManagementGroupFilterByDate.json -func ExampleAggregatedCostClient_GetByManagementGroup_aggregatedCostByManagementGroupFilterByDate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAggregatedCostClient().GetByManagementGroup(ctx, "managementGroupForTest", &armconsumption.AggregatedCostClientGetByManagementGroupOptions{Filter: to.Ptr("usageStart ge '2018-08-15' and properties/usageStart le '2018-08-31'")}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ManagementGroupAggregatedCostResult = armconsumption.ManagementGroupAggregatedCostResult{ - // Name: to.Ptr("aggregatedcostId1"), - // Type: to.Ptr("Microsoft.Consumption/aggregatedcost"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/managementGroupForTest/providers/Microsoft.Consumption/aggregatedcostId1"), - // Properties: &armconsumption.ManagementGroupAggregatedCostProperties{ - // AzureCharges: to.Ptr[float64](150.9876), - // ChargesBilledSeparately: to.Ptr[float64](90.345), - // Children: []*armconsumption.ManagementGroupAggregatedCostResult{ - // { - // Name: to.Ptr("aggregatedcostId2"), - // Type: to.Ptr("Microsoft.Consumption/aggregatedcost"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/managementGroupChildForTest/providers/Microsoft.Consumption/aggregatedcostId2"), - // Properties: &armconsumption.ManagementGroupAggregatedCostProperties{ - // AzureCharges: to.Ptr[float64](50), - // ChargesBilledSeparately: to.Ptr[float64](30.345), - // Children: []*armconsumption.ManagementGroupAggregatedCostResult{ - // }, - // Currency: to.Ptr("USD"), - // ExcludedSubscriptions: []*string{ - // }, - // IncludedSubscriptions: []*string{ - // to.Ptr("c349567d-c83a-48c9-ab0e-578c69dc97a4")}, - // MarketplaceCharges: to.Ptr[float64](10.786), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-31T00:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-15T00:00:00.000Z"); return t}()), - // }, - // }}, - // Currency: to.Ptr("USD"), - // ExcludedSubscriptions: []*string{ - // }, - // IncludedSubscriptions: []*string{ - // to.Ptr("1caaa5a3-2b66-438e-8ab4-bce37d518c5d")}, - // MarketplaceCharges: to.Ptr[float64](80.786), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-31T00:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-15T00:00:00.000Z"); return t}()), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/AggregatedCostForBillingPeriodByManagementGroup.json -func ExampleAggregatedCostClient_GetForBillingPeriodByManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAggregatedCostClient().GetForBillingPeriodByManagementGroup(ctx, "managementGroupForTest", "201807", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ManagementGroupAggregatedCostResult = armconsumption.ManagementGroupAggregatedCostResult{ - // Name: to.Ptr("aggregatedcostId1"), - // Type: to.Ptr("Microsoft.Consumption/aggregatedcost"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/managementGroupForTest/providers/Microsoft.Consumption/aggregatedcostId1"), - // Properties: &armconsumption.ManagementGroupAggregatedCostProperties{ - // AzureCharges: to.Ptr[float64](250.9876), - // ChargesBilledSeparately: to.Ptr[float64](120.345), - // Children: []*armconsumption.ManagementGroupAggregatedCostResult{ - // { - // Name: to.Ptr("aggregatedcostId2"), - // Type: to.Ptr("Microsoft.Consumption/aggregatedcost"), - // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/managementGroupChildForTest/providers/Microsoft.Consumption/aggregatedcostId2"), - // Properties: &armconsumption.ManagementGroupAggregatedCostProperties{ - // AzureCharges: to.Ptr[float64](150), - // ChargesBilledSeparately: to.Ptr[float64](30.345), - // Children: []*armconsumption.ManagementGroupAggregatedCostResult{ - // }, - // Currency: to.Ptr("USD"), - // MarketplaceCharges: to.Ptr[float64](50.786), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-07-31T00:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-07-01T00:00:00.000Z"); return t}()), - // }, - // }}, - // Currency: to.Ptr("USD"), - // MarketplaceCharges: to.Ptr[float64](150.786), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-07-31T00:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-07-01T00:00:00.000Z"); return t}()), - // }, - // } -} diff --git a/sdk/resourcemanager/consumption/armconsumption/autorest.md b/sdk/resourcemanager/consumption/armconsumption/autorest.md index 58aa145c9249..acc8c3dfe68b 100644 --- a/sdk/resourcemanager/consumption/armconsumption/autorest.md +++ b/sdk/resourcemanager/consumption/armconsumption/autorest.md @@ -5,8 +5,8 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/consumption/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/consumption/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.2.0 +module-version: 2.0.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/consumption/armconsumption/balances_client.go b/sdk/resourcemanager/consumption/armconsumption/balances_client.go index 1dca3b8a7a0e..f33f75bc85b1 100644 --- a/sdk/resourcemanager/consumption/armconsumption/balances_client.go +++ b/sdk/resourcemanager/consumption/armconsumption/balances_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -44,7 +41,7 @@ func NewBalancesClient(credential azcore.TokenCredential, options *arm.ClientOpt // 1, 2014 or later. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-10-01 +// Generated from API version 2025-04-01 // - billingAccountID - BillingAccount ID // - options - BalancesClientGetByBillingAccountOptions contains the optional parameters for the BalancesClient.GetByBillingAccount // method. @@ -71,7 +68,7 @@ func (client *BalancesClient) GetByBillingAccount(ctx context.Context, billingAc } // getByBillingAccountCreateRequest creates the GetByBillingAccount request. -func (client *BalancesClient) getByBillingAccountCreateRequest(ctx context.Context, billingAccountID string, options *BalancesClientGetByBillingAccountOptions) (*policy.Request, error) { +func (client *BalancesClient) getByBillingAccountCreateRequest(ctx context.Context, billingAccountID string, _ *BalancesClientGetByBillingAccountOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/balances" if billingAccountID == "" { return nil, errors.New("parameter billingAccountID cannot be empty") @@ -82,7 +79,7 @@ func (client *BalancesClient) getByBillingAccountCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-10-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -101,7 +98,7 @@ func (client *BalancesClient) getByBillingAccountHandleResponse(resp *http.Respo // available via this API only for May 1, 2014 or later. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-10-01 +// Generated from API version 2025-04-01 // - billingAccountID - BillingAccount ID // - billingPeriodName - Billing Period Name. // - options - BalancesClientGetForBillingPeriodByBillingAccountOptions contains the optional parameters for the BalancesClient.GetForBillingPeriodByBillingAccount @@ -129,7 +126,7 @@ func (client *BalancesClient) GetForBillingPeriodByBillingAccount(ctx context.Co } // getForBillingPeriodByBillingAccountCreateRequest creates the GetForBillingPeriodByBillingAccount request. -func (client *BalancesClient) getForBillingPeriodByBillingAccountCreateRequest(ctx context.Context, billingAccountID string, billingPeriodName string, options *BalancesClientGetForBillingPeriodByBillingAccountOptions) (*policy.Request, error) { +func (client *BalancesClient) getForBillingPeriodByBillingAccountCreateRequest(ctx context.Context, billingAccountID string, billingPeriodName string, _ *BalancesClientGetForBillingPeriodByBillingAccountOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/balances" if billingAccountID == "" { return nil, errors.New("parameter billingAccountID cannot be empty") @@ -144,7 +141,7 @@ func (client *BalancesClient) getForBillingPeriodByBillingAccountCreateRequest(c return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-10-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/consumption/armconsumption/balances_client_example_test.go b/sdk/resourcemanager/consumption/armconsumption/balances_client_example_test.go deleted file mode 100644 index fc9aad9bb97c..000000000000 --- a/sdk/resourcemanager/consumption/armconsumption/balances_client_example_test.go +++ /dev/null @@ -1,126 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armconsumption_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/BalancesByBillingAccount.json -func ExampleBalancesClient_GetByBillingAccount() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewBalancesClient().GetByBillingAccount(ctx, "123456", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Balance = armconsumption.Balance{ - // Name: to.Ptr("balanceId1"), - // Type: to.Ptr("Microsoft.Consumption/balances"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.Billing/billingPeriods/201702/providers/Microsoft.Consumption/balances/balanceId1"), - // Properties: &armconsumption.BalanceProperties{ - // AdjustmentDetails: []*armconsumption.BalancePropertiesAdjustmentDetailsItem{ - // { - // Name: to.Ptr("Promo Credit"), - // Value: to.Ptr[float64](1.1), - // }, - // { - // Name: to.Ptr("SIE Credit"), - // Value: to.Ptr[float64](1), - // }}, - // Adjustments: to.Ptr[float64](0), - // AzureMarketplaceServiceCharges: to.Ptr[float64](609.82), - // BeginningBalance: to.Ptr[float64](3396469.19), - // BillingFrequency: to.Ptr(armconsumption.BillingFrequencyMonth), - // ChargesBilledSeparately: to.Ptr[float64](0), - // Currency: to.Ptr("USD "), - // EndingBalance: to.Ptr[float64](2922371.02), - // NewPurchases: to.Ptr[float64](0), - // NewPurchasesDetails: []*armconsumption.BalancePropertiesNewPurchasesDetailsItem{ - // { - // Name: to.Ptr("Promo Purchase"), - // Value: to.Ptr[float64](1), - // }}, - // PriceHidden: to.Ptr(false), - // ServiceOverage: to.Ptr[float64](0), - // TotalOverage: to.Ptr[float64](0), - // TotalUsage: to.Ptr[float64](474098.17), - // Utilized: to.Ptr[float64](474098.17), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/BalancesByBillingAccountForBillingPeriod.json -func ExampleBalancesClient_GetForBillingPeriodByBillingAccount() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewBalancesClient().GetForBillingPeriodByBillingAccount(ctx, "123456", "201702", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Balance = armconsumption.Balance{ - // Name: to.Ptr("balanceId1"), - // Type: to.Ptr("Microsoft.Consumption/balances"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.Billing/billingPeriods/201702/providers/Microsoft.Consumption/balances/balanceId1"), - // Properties: &armconsumption.BalanceProperties{ - // AdjustmentDetails: []*armconsumption.BalancePropertiesAdjustmentDetailsItem{ - // { - // Name: to.Ptr("Promo Credit"), - // Value: to.Ptr[float64](1.1), - // }, - // { - // Name: to.Ptr("SIE Credit"), - // Value: to.Ptr[float64](1), - // }}, - // Adjustments: to.Ptr[float64](0), - // AzureMarketplaceServiceCharges: to.Ptr[float64](609.82), - // BeginningBalance: to.Ptr[float64](3396469.19), - // BillingFrequency: to.Ptr(armconsumption.BillingFrequencyMonth), - // ChargesBilledSeparately: to.Ptr[float64](0), - // Currency: to.Ptr("USD "), - // EndingBalance: to.Ptr[float64](2922371.02), - // NewPurchases: to.Ptr[float64](0), - // NewPurchasesDetails: []*armconsumption.BalancePropertiesNewPurchasesDetailsItem{ - // { - // Name: to.Ptr("Promo Purchase"), - // Value: to.Ptr[float64](1), - // }}, - // PriceHidden: to.Ptr(false), - // ServiceOverage: to.Ptr[float64](0), - // TotalOverage: to.Ptr[float64](0), - // TotalUsage: to.Ptr[float64](474098.17), - // Utilized: to.Ptr[float64](474098.17), - // }, - // } -} diff --git a/sdk/resourcemanager/consumption/armconsumption/budgets_client.go b/sdk/resourcemanager/consumption/armconsumption/budgets_client.go index 1a09515b459e..e4415b5114f4 100644 --- a/sdk/resourcemanager/consumption/armconsumption/budgets_client.go +++ b/sdk/resourcemanager/consumption/armconsumption/budgets_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -45,7 +42,7 @@ func NewBudgetsClient(credential azcore.TokenCredential, options *arm.ClientOpti // to your put operation. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-10-01 +// Generated from API version 2025-04-01 // - scope - The scope associated with budget operations. This includes '/subscriptions/{subscriptionId}/' for subscription // scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for // resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, @@ -53,7 +50,7 @@ func NewBudgetsClient(credential azcore.TokenCredential, options *arm.ClientOpti // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount // scope, // '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' -// for billingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' +// for billingProfile scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' // for invoiceSection scope. // - budgetName - Budget Name. // - parameters - Parameters supplied to the Create Budget operation. @@ -81,7 +78,7 @@ func (client *BudgetsClient) CreateOrUpdate(ctx context.Context, scope string, b } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *BudgetsClient) createOrUpdateCreateRequest(ctx context.Context, scope string, budgetName string, parameters Budget, options *BudgetsClientCreateOrUpdateOptions) (*policy.Request, error) { +func (client *BudgetsClient) createOrUpdateCreateRequest(ctx context.Context, scope string, budgetName string, parameters Budget, _ *BudgetsClientCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.Consumption/budgets/{budgetName}" urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) if budgetName == "" { @@ -93,7 +90,7 @@ func (client *BudgetsClient) createOrUpdateCreateRequest(ctx context.Context, sc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-10-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -114,7 +111,7 @@ func (client *BudgetsClient) createOrUpdateHandleResponse(resp *http.Response) ( // Delete - The operation to delete a budget. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-10-01 +// Generated from API version 2025-04-01 // - scope - The scope associated with budget operations. This includes '/subscriptions/{subscriptionId}/' for subscription // scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for // resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, @@ -122,7 +119,7 @@ func (client *BudgetsClient) createOrUpdateHandleResponse(resp *http.Response) ( // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount // scope, // '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' -// for billingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' +// for billingProfile scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' // for invoiceSection scope. // - budgetName - Budget Name. // - options - BudgetsClientDeleteOptions contains the optional parameters for the BudgetsClient.Delete method. @@ -148,7 +145,7 @@ func (client *BudgetsClient) Delete(ctx context.Context, scope string, budgetNam } // deleteCreateRequest creates the Delete request. -func (client *BudgetsClient) deleteCreateRequest(ctx context.Context, scope string, budgetName string, options *BudgetsClientDeleteOptions) (*policy.Request, error) { +func (client *BudgetsClient) deleteCreateRequest(ctx context.Context, scope string, budgetName string, _ *BudgetsClientDeleteOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.Consumption/budgets/{budgetName}" urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) if budgetName == "" { @@ -160,7 +157,7 @@ func (client *BudgetsClient) deleteCreateRequest(ctx context.Context, scope stri return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-10-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -169,7 +166,7 @@ func (client *BudgetsClient) deleteCreateRequest(ctx context.Context, scope stri // Get - Gets the budget for the scope by budget name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-10-01 +// Generated from API version 2025-04-01 // - scope - The scope associated with budget operations. This includes '/subscriptions/{subscriptionId}/' for subscription // scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for // resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, @@ -177,7 +174,7 @@ func (client *BudgetsClient) deleteCreateRequest(ctx context.Context, scope stri // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount // scope, // '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' -// for billingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' +// for billingProfile scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' // for invoiceSection scope. // - budgetName - Budget Name. // - options - BudgetsClientGetOptions contains the optional parameters for the BudgetsClient.Get method. @@ -204,7 +201,7 @@ func (client *BudgetsClient) Get(ctx context.Context, scope string, budgetName s } // getCreateRequest creates the Get request. -func (client *BudgetsClient) getCreateRequest(ctx context.Context, scope string, budgetName string, options *BudgetsClientGetOptions) (*policy.Request, error) { +func (client *BudgetsClient) getCreateRequest(ctx context.Context, scope string, budgetName string, _ *BudgetsClientGetOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.Consumption/budgets/{budgetName}" urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) if budgetName == "" { @@ -216,7 +213,7 @@ func (client *BudgetsClient) getCreateRequest(ctx context.Context, scope string, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-10-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -233,7 +230,7 @@ func (client *BudgetsClient) getHandleResponse(resp *http.Response) (BudgetsClie // NewListPager - Lists all budgets for the defined scope. // -// Generated from API version 2021-10-01 +// Generated from API version 2025-04-01 // - scope - The scope associated with budget operations. This includes '/subscriptions/{subscriptionId}/' for subscription // scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for // resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, @@ -241,7 +238,7 @@ func (client *BudgetsClient) getHandleResponse(resp *http.Response) (BudgetsClie // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount // scope, // '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' -// for billingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' +// for billingProfile scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' // for invoiceSection scope. // - options - BudgetsClientListOptions contains the optional parameters for the BudgetsClient.NewListPager method. func (client *BudgetsClient) NewListPager(scope string, options *BudgetsClientListOptions) *runtime.Pager[BudgetsClientListResponse] { @@ -268,7 +265,7 @@ func (client *BudgetsClient) NewListPager(scope string, options *BudgetsClientLi } // listCreateRequest creates the List request. -func (client *BudgetsClient) listCreateRequest(ctx context.Context, scope string, options *BudgetsClientListOptions) (*policy.Request, error) { +func (client *BudgetsClient) listCreateRequest(ctx context.Context, scope string, _ *BudgetsClientListOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.Consumption/budgets" urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) @@ -276,7 +273,7 @@ func (client *BudgetsClient) listCreateRequest(ctx context.Context, scope string return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-10-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/consumption/armconsumption/budgets_client_example_test.go b/sdk/resourcemanager/consumption/armconsumption/budgets_client_example_test.go deleted file mode 100644 index fce2a968f340..000000000000 --- a/sdk/resourcemanager/consumption/armconsumption/budgets_client_example_test.go +++ /dev/null @@ -1,448 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armconsumption_test - -import ( - "context" - "log" - - "time" - - "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/consumption/armconsumption" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/BudgetsList.json -func ExampleBudgetsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewBudgetsClient().NewListPager("subscriptions/00000000-0000-0000-0000-000000000000", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.BudgetsListResult = armconsumption.BudgetsListResult{ - // Value: []*armconsumption.Budget{ - // { - // Name: to.Ptr("TestBudget"), - // Type: to.Ptr("Microsoft.Consumption/budgets"), - // ETag: to.Ptr("\"1d34d012214157f\""), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Consumption/budgets/TestBudget"), - // Properties: &armconsumption.BudgetProperties{ - // Amount: to.Ptr[float64](100.65), - // Category: to.Ptr(armconsumption.CategoryTypeCost), - // CurrentSpend: &armconsumption.CurrentSpend{ - // Amount: to.Ptr[float64](80.89), - // Unit: to.Ptr("USD"), - // }, - // Filter: &armconsumption.BudgetFilter{ - // And: []*armconsumption.BudgetFilterProperties{ - // { - // Dimensions: &armconsumption.BudgetComparisonExpression{ - // Name: to.Ptr("ResourceId"), - // Operator: to.Ptr(armconsumption.BudgetOperatorTypeIn), - // Values: []*string{ - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Compute/virtualMachines/MSVM2"), - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Compute/virtualMachines/platformcloudplatformGeneric1")}, - // }, - // }, - // { - // Tags: &armconsumption.BudgetComparisonExpression{ - // Name: to.Ptr("category"), - // Operator: to.Ptr(armconsumption.BudgetOperatorTypeIn), - // Values: []*string{ - // to.Ptr("Dev"), - // to.Ptr("Prod")}, - // }, - // }, - // { - // Tags: &armconsumption.BudgetComparisonExpression{ - // Name: to.Ptr("department"), - // Operator: to.Ptr(armconsumption.BudgetOperatorTypeIn), - // Values: []*string{ - // to.Ptr("engineering"), - // to.Ptr("sales")}, - // }, - // }}, - // }, - // Notifications: map[string]*armconsumption.Notification{ - // "Actual_GreaterThanOrEqualTo_90_Percent": &armconsumption.Notification{ - // ContactEmails: []*string{ - // to.Ptr("johndoe@contoso.com"), - // to.Ptr("janesmith@contoso.com")}, - // ContactGroups: []*string{ - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/microsoft.insights/actionGroups/SampleActionGroup")}, - // ContactRoles: []*string{ - // to.Ptr("Contributor"), - // to.Ptr("Reader")}, - // Enabled: to.Ptr(true), - // Operator: to.Ptr(armconsumption.OperatorTypeGreaterThanOrEqualTo), - // Threshold: to.Ptr[float64](90), - // }, - // "Actual_GreaterThan_80_Percent": &armconsumption.Notification{ - // ContactEmails: []*string{ - // to.Ptr("johndoe@contoso.com"), - // to.Ptr("janesmith@contoso.com")}, - // ContactRoles: []*string{ - // to.Ptr("Contributor"), - // to.Ptr("Reader")}, - // Enabled: to.Ptr(true), - // Operator: to.Ptr(armconsumption.OperatorTypeGreaterThan), - // Threshold: to.Ptr[float64](80), - // }, - // "thresholdType": &armconsumption.Notification{ - // }, - // }, - // TimeGrain: to.Ptr(armconsumption.TimeGrainTypeMonthly), - // TimePeriod: &armconsumption.BudgetTimePeriod{ - // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-31T00:00:00.000Z"); return t}()), - // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-10-01T00:00:00.000Z"); return t}()), - // }, - // }, - // }, - // { - // Name: to.Ptr("TestBudget"), - // Type: to.Ptr("Microsoft.Consumption/budgets"), - // ETag: to.Ptr("\"1d34d012214157f\""), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/budgets/TestBudget"), - // Properties: &armconsumption.BudgetProperties{ - // Amount: to.Ptr[float64](600.65), - // Category: to.Ptr(armconsumption.CategoryTypeCost), - // CurrentSpend: &armconsumption.CurrentSpend{ - // Amount: to.Ptr[float64](120.89), - // Unit: to.Ptr("USD"), - // }, - // Filter: &armconsumption.BudgetFilter{ - // And: []*armconsumption.BudgetFilterProperties{ - // { - // Dimensions: &armconsumption.BudgetComparisonExpression{ - // Name: to.Ptr("ResourceId"), - // Operator: to.Ptr(armconsumption.BudgetOperatorTypeIn), - // Values: []*string{ - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Compute/virtualMachines/MSVM2"), - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Compute/virtualMachines/platformcloudplatformGeneric1")}, - // }, - // }, - // { - // Tags: &armconsumption.BudgetComparisonExpression{ - // Name: to.Ptr("category"), - // Operator: to.Ptr(armconsumption.BudgetOperatorTypeIn), - // Values: []*string{ - // to.Ptr("Dev"), - // to.Ptr("Prod")}, - // }, - // }, - // { - // Tags: &armconsumption.BudgetComparisonExpression{ - // Name: to.Ptr("department"), - // Operator: to.Ptr(armconsumption.BudgetOperatorTypeIn), - // Values: []*string{ - // to.Ptr("engineering"), - // to.Ptr("sales")}, - // }, - // }}, - // }, - // Notifications: map[string]*armconsumption.Notification{ - // "Actual_GreaterThanOrEqualTo_60_Percent": &armconsumption.Notification{ - // ContactEmails: []*string{ - // to.Ptr("johndoe@contoso.com"), - // to.Ptr("janesmith@contoso.com")}, - // ContactGroups: []*string{ - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/microsoft.insights/actionGroups/SampleActionGroup")}, - // ContactRoles: []*string{ - // to.Ptr("Contributor"), - // to.Ptr("Reader")}, - // Enabled: to.Ptr(true), - // Operator: to.Ptr(armconsumption.OperatorTypeGreaterThanOrEqualTo), - // Threshold: to.Ptr[float64](60), - // ThresholdType: to.Ptr(armconsumption.ThresholdTypeActual), - // }, - // "Actual_GreaterThan_40_Percent": &armconsumption.Notification{ - // ContactEmails: []*string{ - // to.Ptr("johndoe@contoso.com"), - // to.Ptr("janesmith@contoso.com")}, - // ContactRoles: []*string{ - // to.Ptr("Contributor"), - // to.Ptr("Reader")}, - // Enabled: to.Ptr(true), - // Operator: to.Ptr(armconsumption.OperatorTypeGreaterThan), - // Threshold: to.Ptr[float64](40), - // }, - // }, - // TimeGrain: to.Ptr(armconsumption.TimeGrainTypeMonthly), - // TimePeriod: &armconsumption.BudgetTimePeriod{ - // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-31T00:00:00.000Z"); return t}()), - // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-10-01T00:00:00.000Z"); return t}()), - // }, - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/Budget.json -func ExampleBudgetsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewBudgetsClient().Get(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", "TestBudget", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Budget = armconsumption.Budget{ - // Name: to.Ptr("TestBudget"), - // Type: to.Ptr("Microsoft.Consumption/budgets"), - // ETag: to.Ptr("\"1d34d012214157f\""), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Consumption/budgets/TestBudget"), - // Properties: &armconsumption.BudgetProperties{ - // Amount: to.Ptr[float64](100.65), - // Category: to.Ptr(armconsumption.CategoryTypeCost), - // CurrentSpend: &armconsumption.CurrentSpend{ - // Amount: to.Ptr[float64](80.89), - // Unit: to.Ptr("USD"), - // }, - // Filter: &armconsumption.BudgetFilter{ - // And: []*armconsumption.BudgetFilterProperties{ - // { - // Dimensions: &armconsumption.BudgetComparisonExpression{ - // Name: to.Ptr("ResourceId"), - // Operator: to.Ptr(armconsumption.BudgetOperatorTypeIn), - // Values: []*string{ - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Compute/virtualMachines/MSVM2"), - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Compute/virtualMachines/platformcloudplatformGeneric1")}, - // }, - // }, - // { - // Tags: &armconsumption.BudgetComparisonExpression{ - // Name: to.Ptr("category"), - // Operator: to.Ptr(armconsumption.BudgetOperatorTypeIn), - // Values: []*string{ - // to.Ptr("Dev"), - // to.Ptr("Prod")}, - // }, - // }, - // { - // Tags: &armconsumption.BudgetComparisonExpression{ - // Name: to.Ptr("department"), - // Operator: to.Ptr(armconsumption.BudgetOperatorTypeIn), - // Values: []*string{ - // to.Ptr("engineering"), - // to.Ptr("sales")}, - // }, - // }}, - // }, - // Notifications: map[string]*armconsumption.Notification{ - // "Actual_GreaterThan_80_Percent": &armconsumption.Notification{ - // ContactEmails: []*string{ - // to.Ptr("johndoe@contoso.com"), - // to.Ptr("janesmith@contoso.com")}, - // ContactGroups: []*string{ - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/microsoft.insights/actionGroups/SampleActionGroup")}, - // ContactRoles: []*string{ - // to.Ptr("Contributor"), - // to.Ptr("Reader")}, - // Enabled: to.Ptr(true), - // Operator: to.Ptr(armconsumption.OperatorTypeGreaterThan), - // Threshold: to.Ptr[float64](80), - // ThresholdType: to.Ptr(armconsumption.ThresholdTypeActual), - // }, - // }, - // TimeGrain: to.Ptr(armconsumption.TimeGrainTypeMonthly), - // TimePeriod: &armconsumption.BudgetTimePeriod{ - // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-31T00:00:00.000Z"); return t}()), - // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-10-01T00:00:00.000Z"); return t}()), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/CreateOrUpdateBudget.json -func ExampleBudgetsClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewBudgetsClient().CreateOrUpdate(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", "TestBudget", armconsumption.Budget{ - ETag: to.Ptr("\"1d34d016a593709\""), - Properties: &armconsumption.BudgetProperties{ - Amount: to.Ptr[float64](100.65), - Category: to.Ptr(armconsumption.CategoryTypeCost), - Filter: &armconsumption.BudgetFilter{ - And: []*armconsumption.BudgetFilterProperties{ - { - Dimensions: &armconsumption.BudgetComparisonExpression{ - Name: to.Ptr("ResourceId"), - Operator: to.Ptr(armconsumption.BudgetOperatorTypeIn), - Values: []*string{ - to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Compute/virtualMachines/MSVM2"), - to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Compute/virtualMachines/platformcloudplatformGeneric1")}, - }, - }, - { - Tags: &armconsumption.BudgetComparisonExpression{ - Name: to.Ptr("category"), - Operator: to.Ptr(armconsumption.BudgetOperatorTypeIn), - Values: []*string{ - to.Ptr("Dev"), - to.Ptr("Prod")}, - }, - }, - { - Tags: &armconsumption.BudgetComparisonExpression{ - Name: to.Ptr("department"), - Operator: to.Ptr(armconsumption.BudgetOperatorTypeIn), - Values: []*string{ - to.Ptr("engineering"), - to.Ptr("sales")}, - }, - }}, - }, - Notifications: map[string]*armconsumption.Notification{ - "Actual_GreaterThan_80_Percent": { - ContactEmails: []*string{ - to.Ptr("johndoe@contoso.com"), - to.Ptr("janesmith@contoso.com")}, - ContactGroups: []*string{ - to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/microsoft.insights/actionGroups/SampleActionGroup")}, - ContactRoles: []*string{ - to.Ptr("Contributor"), - to.Ptr("Reader")}, - Enabled: to.Ptr(true), - Locale: to.Ptr(armconsumption.CultureCodeEnUs), - Operator: to.Ptr(armconsumption.OperatorTypeGreaterThan), - Threshold: to.Ptr[float64](80), - ThresholdType: to.Ptr(armconsumption.ThresholdTypeActual), - }, - }, - TimeGrain: to.Ptr(armconsumption.TimeGrainTypeMonthly), - TimePeriod: &armconsumption.BudgetTimePeriod{ - EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-31T00:00:00.000Z"); return t }()), - StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-10-01T00:00:00.000Z"); return t }()), - }, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Budget = armconsumption.Budget{ - // Name: to.Ptr("TestBudget"), - // Type: to.Ptr("Microsoft.Consumption/budgets"), - // ETag: to.Ptr("\"1d34d012214157f\""), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/budgets/TestBudget"), - // Properties: &armconsumption.BudgetProperties{ - // Amount: to.Ptr[float64](100.65), - // Category: to.Ptr(armconsumption.CategoryTypeCost), - // CurrentSpend: &armconsumption.CurrentSpend{ - // Amount: to.Ptr[float64](80.89), - // Unit: to.Ptr("USD"), - // }, - // Filter: &armconsumption.BudgetFilter{ - // And: []*armconsumption.BudgetFilterProperties{ - // { - // Dimensions: &armconsumption.BudgetComparisonExpression{ - // Name: to.Ptr("ResourceId"), - // Operator: to.Ptr(armconsumption.BudgetOperatorTypeIn), - // Values: []*string{ - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Compute/virtualMachines/MSVM2"), - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Compute/virtualMachines/platformcloudplatformGeneric1")}, - // }, - // }, - // { - // Tags: &armconsumption.BudgetComparisonExpression{ - // Name: to.Ptr("category"), - // Operator: to.Ptr(armconsumption.BudgetOperatorTypeIn), - // Values: []*string{ - // to.Ptr("Dev"), - // to.Ptr("Prod")}, - // }, - // }, - // { - // Tags: &armconsumption.BudgetComparisonExpression{ - // Name: to.Ptr("department"), - // Operator: to.Ptr(armconsumption.BudgetOperatorTypeIn), - // Values: []*string{ - // to.Ptr("engineering"), - // to.Ptr("sales")}, - // }, - // }}, - // }, - // Notifications: map[string]*armconsumption.Notification{ - // "Actual_GreaterThan_80_Percent": &armconsumption.Notification{ - // ContactEmails: []*string{ - // to.Ptr("johndoe@contoso.com"), - // to.Ptr("janesmith@contoso.com")}, - // ContactGroups: []*string{ - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/microsoft.insights/actionGroups/SampleActionGroup")}, - // ContactRoles: []*string{ - // to.Ptr("Contributor"), - // to.Ptr("Reader")}, - // Enabled: to.Ptr(true), - // Locale: to.Ptr(armconsumption.CultureCodeEnUs), - // Operator: to.Ptr(armconsumption.OperatorTypeGreaterThan), - // Threshold: to.Ptr[float64](80), - // ThresholdType: to.Ptr(armconsumption.ThresholdTypeActual), - // }, - // }, - // TimeGrain: to.Ptr(armconsumption.TimeGrainTypeMonthly), - // TimePeriod: &armconsumption.BudgetTimePeriod{ - // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-31T00:00:00.000Z"); return t}()), - // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-10-01T00:00:00.000Z"); return t}()), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/DeleteBudget.json -func ExampleBudgetsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewBudgetsClient().Delete(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", "TestBudget", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/consumption/armconsumption/charges_client.go b/sdk/resourcemanager/consumption/armconsumption/charges_client.go index 08e60b90efc7..17e1e4660e36 100644 --- a/sdk/resourcemanager/consumption/armconsumption/charges_client.go +++ b/sdk/resourcemanager/consumption/armconsumption/charges_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -41,7 +38,7 @@ func NewChargesClient(credential azcore.TokenCredential, options *arm.ClientOpti // List - Lists the charges based for the defined scope. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-10-01 +// Generated from API version 2025-04-01 // - scope - The scope associated with charges operations. This includes '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' // for Department scope, and // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount @@ -52,9 +49,9 @@ func NewChargesClient(credential azcore.TokenCredential, options *arm.ClientOpti // Also, Modern Commerce Account scopes are // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for billingAccount scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' // for -// billingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' +// billingProfile scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' // for invoiceSection scope, and -// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for partners. +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for partners. // - options - ChargesClientListOptions contains the optional parameters for the ChargesClient.List method. func (client *ChargesClient) List(ctx context.Context, scope string, options *ChargesClientListOptions) (ChargesClientListResponse, error) { var err error @@ -87,18 +84,18 @@ func (client *ChargesClient) listCreateRequest(ctx context.Context, scope string return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-10-01") - if options != nil && options.StartDate != nil { - reqQP.Set("startDate", *options.StartDate) - } - if options != nil && options.EndDate != nil { - reqQP.Set("endDate", *options.EndDate) + if options != nil && options.Apply != nil { + reqQP.Set("$apply", *options.Apply) } if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Apply != nil { - reqQP.Set("$apply", *options.Apply) + reqQP.Set("api-version", "2025-04-01") + if options != nil && options.EndDate != nil { + reqQP.Set("endDate", *options.EndDate) + } + if options != nil && options.StartDate != nil { + reqQP.Set("startDate", *options.StartDate) } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} diff --git a/sdk/resourcemanager/consumption/armconsumption/charges_client_example_test.go b/sdk/resourcemanager/consumption/armconsumption/charges_client_example_test.go deleted file mode 100644 index 24b1ae4f4e98..000000000000 --- a/sdk/resourcemanager/consumption/armconsumption/charges_client_example_test.go +++ /dev/null @@ -1,802 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armconsumption_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/consumption/armconsumption" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/ChargesForBillingPeriodByDepartment.json -func ExampleChargesClient_List_changesForBillingPeriodByDepartmentLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewChargesClient().List(ctx, "providers/Microsoft.Billing/BillingAccounts/1234/departments/42425", &armconsumption.ChargesClientListOptions{StartDate: nil, - EndDate: nil, - Filter: nil, - Apply: nil, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ChargesListResult = armconsumption.ChargesListResult{ - // Value: []armconsumption.ChargeSummaryClassification{ - // &armconsumption.LegacyChargeSummary{ - // Name: to.Ptr("chargeSummaryId1"), - // Type: to.Ptr("Microsoft.Consumption/charges"), - // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/1234/departments/42425/providers/Microsoft.Consumption/charges/chargeSummaryId1"), - // Kind: to.Ptr(armconsumption.ChargeSummaryKindLegacy), - // Properties: &armconsumption.LegacyChargeSummaryProperties{ - // AzureCharges: to.Ptr[float64](5000), - // BillingPeriodID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/1234/providers/Microsoft.Billing/billingPeriods/201804"), - // ChargesBilledSeparately: to.Ptr[float64](60.9), - // Currency: to.Ptr("USD"), - // MarketplaceCharges: to.Ptr[float64](100), - // UsageEnd: to.Ptr("2018-04-30"), - // UsageStart: to.Ptr("2018-04-01"), - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/ChargesForBillingPeriodByEnrollmentAccount.json -func ExampleChargesClient_List_changesForBillingPeriodByEnrollmentAccountLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewChargesClient().List(ctx, "providers/Microsoft.Billing/BillingAccounts/1234/enrollmentAccounts/42425", &armconsumption.ChargesClientListOptions{StartDate: nil, - EndDate: nil, - Filter: nil, - Apply: nil, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ChargesListResult = armconsumption.ChargesListResult{ - // Value: []armconsumption.ChargeSummaryClassification{ - // &armconsumption.LegacyChargeSummary{ - // Name: to.Ptr("chargeSummaryId1"), - // Type: to.Ptr("Microsoft.Consumption/charges"), - // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/1234/enrollmentAccounts/42425/providers/Microsoft.Consumption/charges/chargeSummaryId1"), - // Kind: to.Ptr(armconsumption.ChargeSummaryKindLegacy), - // Properties: &armconsumption.LegacyChargeSummaryProperties{ - // AzureCharges: to.Ptr[float64](5000), - // BillingPeriodID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/1234/providers/Microsoft.Billing/billingPeriods/201804"), - // ChargesBilledSeparately: to.Ptr[float64](60.9), - // Currency: to.Ptr("USD"), - // MarketplaceCharges: to.Ptr[float64](100), - // UsageEnd: to.Ptr("2018-04-30"), - // UsageStart: to.Ptr("2018-04-01"), - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/ChargesListByModernBillingAccount.json -func ExampleChargesClient_List_chargesListByBillingAccountModern() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewChargesClient().List(ctx, "providers/Microsoft.Billing/billingAccounts/1234:56789", &armconsumption.ChargesClientListOptions{StartDate: to.Ptr("2019-09-01"), - EndDate: to.Ptr("2019-10-31"), - Filter: nil, - Apply: nil, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ChargesListResult = armconsumption.ChargesListResult{ - // Value: []armconsumption.ChargeSummaryClassification{ - // &armconsumption.ModernChargeSummary{ - // Name: to.Ptr("chargeSummaryId1"), - // Type: to.Ptr("Microsoft.Consumption/charges"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Consumption/charges/chargeSummaryId1"), - // Kind: to.Ptr(armconsumption.ChargeSummaryKindModern), - // Properties: &armconsumption.ModernChargeSummaryProperties{ - // AzureCharges: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](0), - // }, - // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789"), - // BillingPeriodID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Billing/billingPeriods/201910"), - // ChargesBilledSeparately: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](265.09), - // }, - // IsInvoiced: to.Ptr(false), - // MarketplaceCharges: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](0), - // }, - // UsageEnd: to.Ptr("2019-10-31"), - // UsageStart: to.Ptr("2021-10-01"), - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/ChargesListByModernBillingAccountGroupByBillingProfileId.json -func ExampleChargesClient_List_chargesListByBillingAccountGroupByBillingProfileIdModern() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewChargesClient().List(ctx, "providers/Microsoft.Billing/billingAccounts/1234:56789", &armconsumption.ChargesClientListOptions{StartDate: to.Ptr("2019-09-01"), - EndDate: to.Ptr("2019-09-30"), - Filter: nil, - Apply: to.Ptr("groupby((properties/billingProfileId))"), - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ChargesListResult = armconsumption.ChargesListResult{ - // Value: []armconsumption.ChargeSummaryClassification{ - // &armconsumption.ModernChargeSummary{ - // Name: to.Ptr("chargeSummaryId1"), - // Type: to.Ptr("Microsoft.Consumption/charges"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Consumption/charges/chargeSummaryId1"), - // Kind: to.Ptr(armconsumption.ChargeSummaryKindModern), - // Properties: &armconsumption.ModernChargeSummaryProperties{ - // AzureCharges: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](5000), - // }, - // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789"), - // BillingPeriodID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/123456/providers/Microsoft.Billing/billingPeriods/201909"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/123456"), - // ChargesBilledSeparately: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](60.9), - // }, - // IsInvoiced: to.Ptr(false), - // MarketplaceCharges: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](100), - // }, - // UsageEnd: to.Ptr("2019-09-30"), - // UsageStart: to.Ptr("2019-09-01"), - // }, - // }, - // &armconsumption.ModernChargeSummary{ - // Name: to.Ptr("chargeSummaryId2"), - // Type: to.Ptr("Microsoft.Consumption/charges"), - // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/1234:56789/billingProfiles/42425/providers/Microsoft.Consumption/charges/chargeSummaryId2"), - // Kind: to.Ptr(armconsumption.ChargeSummaryKindModern), - // Properties: &armconsumption.ModernChargeSummaryProperties{ - // AzureCharges: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](5000), - // }, - // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789"), - // BillingPeriodID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Billing/billingPeriods/201909"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425"), - // ChargesBilledSeparately: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](60.9), - // }, - // MarketplaceCharges: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](100), - // }, - // UsageEnd: to.Ptr("2019-09-30"), - // UsageStart: to.Ptr("2019-09-01"), - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/ChargesListByModernBillingAccountGroupByCustomerId.json -func ExampleChargesClient_List_chargesListByBillingAccountGroupByCustomerIdModern() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewChargesClient().List(ctx, "providers/Microsoft.Billing/billingAccounts/1234:56789", &armconsumption.ChargesClientListOptions{StartDate: to.Ptr("2019-09-01"), - EndDate: to.Ptr("2019-09-30"), - Filter: nil, - Apply: to.Ptr("groupby((properties/customerId))"), - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ChargesListResult = armconsumption.ChargesListResult{ - // Value: []armconsumption.ChargeSummaryClassification{ - // &armconsumption.ModernChargeSummary{ - // Name: to.Ptr("chargeSummaryId1"), - // Type: to.Ptr("Microsoft.Consumption/charges"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/customers/67890/providers/Microsoft.Consumption/charges/chargeSummaryId1"), - // Kind: to.Ptr(armconsumption.ChargeSummaryKindModern), - // Properties: &armconsumption.ModernChargeSummaryProperties{ - // AzureCharges: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](5000), - // }, - // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789"), - // BillingPeriodID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Billing/billingPeriods/201909"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425"), - // ChargesBilledSeparately: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](60.9), - // }, - // CustomerID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/customers/67890"), - // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/invoiceSections/67890"), - // IsInvoiced: to.Ptr(false), - // MarketplaceCharges: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](100), - // }, - // UsageEnd: to.Ptr("2019-09-30"), - // UsageStart: to.Ptr("2019-09-01"), - // }, - // }, - // &armconsumption.ModernChargeSummary{ - // Name: to.Ptr("chargeSummaryId2"), - // Type: to.Ptr("Microsoft.Consumption/charges"), - // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/1234:56789/customers/123456/providers/Microsoft.Consumption/charges/chargeSummaryId2"), - // Kind: to.Ptr(armconsumption.ChargeSummaryKindModern), - // Properties: &armconsumption.ModernChargeSummaryProperties{ - // AzureCharges: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](5000), - // }, - // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789"), - // BillingPeriodID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Billing/billingPeriods/201909"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425"), - // ChargesBilledSeparately: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](60.9), - // }, - // CustomerID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/customers/123456"), - // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/invoiceSections/67890"), - // IsInvoiced: to.Ptr(false), - // MarketplaceCharges: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](100), - // }, - // UsageEnd: to.Ptr("2019-09-30"), - // UsageStart: to.Ptr("2019-09-01"), - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/ChargesListByModernBillingAccountGroupByInvoiceSectionId.json -func ExampleChargesClient_List_chargesListByBillingAccountGroupByInvoiceSectionIdModern() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewChargesClient().List(ctx, "providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425", &armconsumption.ChargesClientListOptions{StartDate: to.Ptr("2019-09-01"), - EndDate: to.Ptr("2019-09-30"), - Filter: nil, - Apply: to.Ptr("groupby((properties/invoiceSectionId))"), - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ChargesListResult = armconsumption.ChargesListResult{ - // Value: []armconsumption.ChargeSummaryClassification{ - // &armconsumption.ModernChargeSummary{ - // Name: to.Ptr("chargeSummaryId1"), - // Type: to.Ptr("Microsoft.Consumption/charges"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425/invoiceSections/4567/providers/Microsoft.Consumption/charges/chargeSummaryId1"), - // Kind: to.Ptr(armconsumption.ChargeSummaryKindModern), - // Properties: &armconsumption.ModernChargeSummaryProperties{ - // AzureCharges: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](5000), - // }, - // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789"), - // BillingPeriodID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Billing/billingPeriods/201909"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425"), - // ChargesBilledSeparately: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](60.9), - // }, - // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/invoiceSections/4567"), - // IsInvoiced: to.Ptr(false), - // MarketplaceCharges: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](100), - // }, - // UsageEnd: to.Ptr("2019-09-30"), - // UsageStart: to.Ptr("2019-09-01"), - // }, - // }, - // &armconsumption.ModernChargeSummary{ - // Name: to.Ptr("chargeSummaryId2"), - // Type: to.Ptr("Microsoft.Consumption/charges"), - // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/1234:56789//billingProfiles/42425/invoiceSections/67890/providers/Microsoft.Consumption/charges/chargeSummaryId2"), - // Kind: to.Ptr(armconsumption.ChargeSummaryKindModern), - // Properties: &armconsumption.ModernChargeSummaryProperties{ - // AzureCharges: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](5000), - // }, - // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789"), - // BillingPeriodID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Billing/billingPeriods/201909"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425"), - // ChargesBilledSeparately: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](60.9), - // }, - // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/invoiceSections/67890"), - // IsInvoiced: to.Ptr(false), - // MarketplaceCharges: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](100), - // }, - // UsageEnd: to.Ptr("2019-09-30"), - // UsageStart: to.Ptr("2019-09-01"), - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/ChargesListByModernBillingProfile.json -func ExampleChargesClient_List_chargesListByBillingProfileModern() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewChargesClient().List(ctx, "providers/Microsoft.Billing/BillingAccounts/1234:56789/billingProfiles/2460", &armconsumption.ChargesClientListOptions{StartDate: nil, - EndDate: nil, - Filter: nil, - Apply: nil, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ChargesListResult = armconsumption.ChargesListResult{ - // Value: []armconsumption.ChargeSummaryClassification{ - // &armconsumption.ModernChargeSummary{ - // Name: to.Ptr("chargeSummaryId1"), - // Type: to.Ptr("Microsoft.Consumption/charges"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/2460/providers/Microsoft.Consumption/charges/chargeSummaryId1"), - // Kind: to.Ptr(armconsumption.ChargeSummaryKindModern), - // Properties: &armconsumption.ModernChargeSummaryProperties{ - // AzureCharges: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](0), - // }, - // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789"), - // BillingPeriodID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Billing/billingPeriods/201910"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/2460"), - // ChargesBilledSeparately: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](265.09), - // }, - // IsInvoiced: to.Ptr(false), - // MarketplaceCharges: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](0), - // }, - // UsageEnd: to.Ptr("2019-10-31"), - // UsageStart: to.Ptr("2021-10-01"), - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/ChargesListByModernBillingProfileGroupByInvoiceSectionId.json -func ExampleChargesClient_List_chargesListByBillingProfileGroupByInvoiceSectionIdModern() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewChargesClient().List(ctx, "providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425", &armconsumption.ChargesClientListOptions{StartDate: to.Ptr("2019-09-01"), - EndDate: to.Ptr("2019-09-30"), - Filter: nil, - Apply: to.Ptr("groupby((properties/invoiceSectionId))"), - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ChargesListResult = armconsumption.ChargesListResult{ - // Value: []armconsumption.ChargeSummaryClassification{ - // &armconsumption.ModernChargeSummary{ - // Name: to.Ptr("chargeSummaryId1"), - // Type: to.Ptr("Microsoft.Consumption/charges"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425/invoiceSections/4567/providers/Microsoft.Consumption/charges/chargeSummaryId1"), - // Kind: to.Ptr(armconsumption.ChargeSummaryKindModern), - // Properties: &armconsumption.ModernChargeSummaryProperties{ - // AzureCharges: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](5000), - // }, - // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789"), - // BillingPeriodID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Billing/billingPeriods/201909"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425"), - // ChargesBilledSeparately: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](60.9), - // }, - // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/invoiceSections/4567"), - // IsInvoiced: to.Ptr(false), - // MarketplaceCharges: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](100), - // }, - // UsageEnd: to.Ptr("2019-09-30"), - // UsageStart: to.Ptr("2019-09-01"), - // }, - // }, - // &armconsumption.ModernChargeSummary{ - // Name: to.Ptr("chargeSummaryId2"), - // Type: to.Ptr("Microsoft.Consumption/charges"), - // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/1234:56789//billingProfiles/42425/invoiceSections/67890/providers/Microsoft.Consumption/charges/chargeSummaryId2"), - // Kind: to.Ptr(armconsumption.ChargeSummaryKindModern), - // Properties: &armconsumption.ModernChargeSummaryProperties{ - // AzureCharges: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](5000), - // }, - // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789"), - // BillingPeriodID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Billing/billingPeriods/201909"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425"), - // ChargesBilledSeparately: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](60.9), - // }, - // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/invoiceSections/67890"), - // IsInvoiced: to.Ptr(false), - // MarketplaceCharges: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](100), - // }, - // UsageEnd: to.Ptr("2019-09-30"), - // UsageStart: to.Ptr("2019-09-01"), - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/ChargesListByModernBillingProfileInvoiceSection.json -func ExampleChargesClient_List_chargesListByBillingProfileInvoiceSectionModern() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewChargesClient().List(ctx, "providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425/invoiceSections/67890", &armconsumption.ChargesClientListOptions{StartDate: to.Ptr("2019-09-01"), - EndDate: to.Ptr("2019-10-31"), - Filter: nil, - Apply: nil, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ChargesListResult = armconsumption.ChargesListResult{ - // Value: []armconsumption.ChargeSummaryClassification{ - // &armconsumption.ModernChargeSummary{ - // Name: to.Ptr("chargeSummaryId1"), - // Type: to.Ptr("Microsoft.Consumption/charges"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425/invoiceSections/67890/providers/Microsoft.Consumption/charges/chargeSummaryId1"), - // Kind: to.Ptr(armconsumption.ChargeSummaryKindModern), - // Properties: &armconsumption.ModernChargeSummaryProperties{ - // AzureCharges: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](5000), - // }, - // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789"), - // BillingPeriodID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Billing/billingPeriods/201909"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425"), - // ChargesBilledSeparately: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](60.9), - // }, - // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425/invoiceSections/4567"), - // IsInvoiced: to.Ptr(false), - // MarketplaceCharges: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](100), - // }, - // UsageEnd: to.Ptr("2019-09-30"), - // UsageStart: to.Ptr("2019-09-01"), - // }, - // }, - // &armconsumption.ModernChargeSummary{ - // Name: to.Ptr("chargeSummaryId2"), - // Type: to.Ptr("Microsoft.Consumption/charges"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425/invoiceSections/67890/providers/Microsoft.Consumption/charges/chargeSummaryId2"), - // Kind: to.Ptr(armconsumption.ChargeSummaryKindModern), - // Properties: &armconsumption.ModernChargeSummaryProperties{ - // AzureCharges: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](5000), - // }, - // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789"), - // BillingPeriodID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Billing/billingPeriods/201910"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425"), - // ChargesBilledSeparately: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](60.9), - // }, - // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/42425/invoiceSections/4567"), - // IsInvoiced: to.Ptr(false), - // MarketplaceCharges: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](100), - // }, - // UsageEnd: to.Ptr("2019-10-31"), - // UsageStart: to.Ptr("2021-10-01"), - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/ChargesListByModernCustomer.json -func ExampleChargesClient_List_chargesListByCustomerModern() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewChargesClient().List(ctx, "providers/Microsoft.Billing/BillingAccounts/1234:56789/customers/67890", &armconsumption.ChargesClientListOptions{StartDate: nil, - EndDate: nil, - Filter: nil, - Apply: nil, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ChargesListResult = armconsumption.ChargesListResult{ - // Value: []armconsumption.ChargeSummaryClassification{ - // &armconsumption.ModernChargeSummary{ - // Name: to.Ptr("chargeSummaryId1"), - // Type: to.Ptr("Microsoft.Consumption/charges"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/customers/67890/providers/Microsoft.Consumption/charges/chargeSummaryId1"), - // Kind: to.Ptr(armconsumption.ChargeSummaryKindModern), - // Properties: &armconsumption.ModernChargeSummaryProperties{ - // AzureCharges: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](0), - // }, - // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789"), - // BillingPeriodID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Billing/billingPeriods/201910"), - // ChargesBilledSeparately: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](265.09), - // }, - // IsInvoiced: to.Ptr(false), - // MarketplaceCharges: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](0), - // }, - // UsageEnd: to.Ptr("2019-10-31"), - // UsageStart: to.Ptr("2021-10-01"), - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/ChargesListForDepartmentFilterByStartEndDate.json -func ExampleChargesClient_List_chargesListByDepartmentLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewChargesClient().List(ctx, "providers/Microsoft.Billing/BillingAccounts/1234/departments/42425", &armconsumption.ChargesClientListOptions{StartDate: nil, - EndDate: nil, - Filter: to.Ptr("usageStart eq '2018-04-01' AND usageEnd eq '2018-05-30'"), - Apply: nil, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ChargesListResult = armconsumption.ChargesListResult{ - // Value: []armconsumption.ChargeSummaryClassification{ - // &armconsumption.LegacyChargeSummary{ - // Name: to.Ptr("chargeSummaryId1"), - // Type: to.Ptr("Microsoft.Consumption/charges"), - // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/1234/departments/42425/providers/Microsoft.Consumption/charges/chargeSummaryId1"), - // Kind: to.Ptr(armconsumption.ChargeSummaryKindLegacy), - // Properties: &armconsumption.LegacyChargeSummaryProperties{ - // AzureCharges: to.Ptr[float64](5000), - // BillingPeriodID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/1234/providers/Microsoft.Billing/billingPeriods/201804"), - // ChargesBilledSeparately: to.Ptr[float64](60.9), - // Currency: to.Ptr("USD"), - // MarketplaceCharges: to.Ptr[float64](100), - // UsageEnd: to.Ptr("2018-04-30"), - // UsageStart: to.Ptr("2018-04-01"), - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/ChargesListByModernInvoiceSectionId.json -func ExampleChargesClient_List_chargesListByInvoiceSectionIdModern() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewChargesClient().List(ctx, "providers/Microsoft.Billing/BillingAccounts/1234:56789/invoiceSections/97531", &armconsumption.ChargesClientListOptions{StartDate: nil, - EndDate: nil, - Filter: nil, - Apply: nil, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ChargesListResult = armconsumption.ChargesListResult{ - // Value: []armconsumption.ChargeSummaryClassification{ - // &armconsumption.ModernChargeSummary{ - // Name: to.Ptr("chargeSummaryId1"), - // Type: to.Ptr("Microsoft.Consumption/charges"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/2460/invoiceSections/97531/providers/Microsoft.Consumption/charges/chargeSummaryId1"), - // Kind: to.Ptr(armconsumption.ChargeSummaryKindModern), - // Properties: &armconsumption.ModernChargeSummaryProperties{ - // AzureCharges: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](12), - // }, - // BillingAccountID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789"), - // BillingPeriodID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Billing/billingPeriods/201910"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/2460"), - // ChargesBilledSeparately: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](0), - // }, - // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/billingProfiles/2460/invoiceSections/97531"), - // IsInvoiced: to.Ptr(false), - // MarketplaceCharges: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](0), - // }, - // UsageEnd: to.Ptr("2019-10-31"), - // UsageStart: to.Ptr("2021-10-01"), - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/ChargesListForEnrollmentAccountFilterByStartEndDate.json -func ExampleChargesClient_List_chargesListForEnrollmentAccountLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewChargesClient().List(ctx, "providers/Microsoft.Billing/BillingAccounts/1234/enrollmentAccounts/42425", &armconsumption.ChargesClientListOptions{StartDate: nil, - EndDate: nil, - Filter: nil, - Apply: nil, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ChargesListResult = armconsumption.ChargesListResult{ - // Value: []armconsumption.ChargeSummaryClassification{ - // &armconsumption.LegacyChargeSummary{ - // Name: to.Ptr("chargeSummaryId1"), - // Type: to.Ptr("Microsoft.Consumption/charges"), - // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/1234/enrollmentAccounts/42425/providers/Microsoft.Consumption/charges/chargeSummaryId1"), - // Kind: to.Ptr(armconsumption.ChargeSummaryKindLegacy), - // Properties: &armconsumption.LegacyChargeSummaryProperties{ - // AzureCharges: to.Ptr[float64](5000), - // BillingPeriodID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/1234/providers/Microsoft.Billing/billingPeriods/201804"), - // ChargesBilledSeparately: to.Ptr[float64](60.9), - // Currency: to.Ptr("USD"), - // MarketplaceCharges: to.Ptr[float64](100), - // UsageEnd: to.Ptr("2018-04-30"), - // UsageStart: to.Ptr("2018-04-01"), - // }, - // }}, - // } -} diff --git a/sdk/resourcemanager/consumption/armconsumption/client_factory.go b/sdk/resourcemanager/consumption/armconsumption/client_factory.go index 0e07c09b15f9..239a980e8d81 100644 --- a/sdk/resourcemanager/consumption/armconsumption/client_factory.go +++ b/sdk/resourcemanager/consumption/armconsumption/client_factory.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -17,8 +14,7 @@ import ( // Don't use this type directly, use NewClientFactory instead. type ClientFactory struct { subscriptionID string - credential azcore.TokenCredential - options *arm.ClientOptions + internal *arm.Client } // NewClientFactory creates a new instance of ClientFactory with the specified values. @@ -27,114 +23,132 @@ type ClientFactory struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { - _, err := arm.NewClient(moduleName, moduleVersion, credential, options) + internal, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } return &ClientFactory{ - subscriptionID: subscriptionID, credential: credential, - options: options.Clone(), + subscriptionID: subscriptionID, + internal: internal, }, nil } // NewAggregatedCostClient creates a new instance of AggregatedCostClient. func (c *ClientFactory) NewAggregatedCostClient() *AggregatedCostClient { - subClient, _ := NewAggregatedCostClient(c.credential, c.options) - return subClient + return &AggregatedCostClient{ + internal: c.internal, + } } // NewBalancesClient creates a new instance of BalancesClient. func (c *ClientFactory) NewBalancesClient() *BalancesClient { - subClient, _ := NewBalancesClient(c.credential, c.options) - return subClient + return &BalancesClient{ + internal: c.internal, + } } // NewBudgetsClient creates a new instance of BudgetsClient. func (c *ClientFactory) NewBudgetsClient() *BudgetsClient { - subClient, _ := NewBudgetsClient(c.credential, c.options) - return subClient + return &BudgetsClient{ + internal: c.internal, + } } // NewChargesClient creates a new instance of ChargesClient. func (c *ClientFactory) NewChargesClient() *ChargesClient { - subClient, _ := NewChargesClient(c.credential, c.options) - return subClient + return &ChargesClient{ + internal: c.internal, + } } // NewCreditsClient creates a new instance of CreditsClient. func (c *ClientFactory) NewCreditsClient() *CreditsClient { - subClient, _ := NewCreditsClient(c.credential, c.options) - return subClient + return &CreditsClient{ + internal: c.internal, + } } // NewEventsClient creates a new instance of EventsClient. func (c *ClientFactory) NewEventsClient() *EventsClient { - subClient, _ := NewEventsClient(c.credential, c.options) - return subClient + return &EventsClient{ + internal: c.internal, + } } // NewLotsClient creates a new instance of LotsClient. func (c *ClientFactory) NewLotsClient() *LotsClient { - subClient, _ := NewLotsClient(c.credential, c.options) - return subClient + return &LotsClient{ + internal: c.internal, + } } // NewMarketplacesClient creates a new instance of MarketplacesClient. func (c *ClientFactory) NewMarketplacesClient() *MarketplacesClient { - subClient, _ := NewMarketplacesClient(c.credential, c.options) - return subClient + return &MarketplacesClient{ + internal: c.internal, + } } // NewOperationsClient creates a new instance of OperationsClient. func (c *ClientFactory) NewOperationsClient() *OperationsClient { - subClient, _ := NewOperationsClient(c.credential, c.options) - return subClient + return &OperationsClient{ + internal: c.internal, + } } // NewPriceSheetClient creates a new instance of PriceSheetClient. func (c *ClientFactory) NewPriceSheetClient() *PriceSheetClient { - subClient, _ := NewPriceSheetClient(c.subscriptionID, c.credential, c.options) - return subClient + return &PriceSheetClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } // NewReservationRecommendationDetailsClient creates a new instance of ReservationRecommendationDetailsClient. func (c *ClientFactory) NewReservationRecommendationDetailsClient() *ReservationRecommendationDetailsClient { - subClient, _ := NewReservationRecommendationDetailsClient(c.credential, c.options) - return subClient + return &ReservationRecommendationDetailsClient{ + internal: c.internal, + } } // NewReservationRecommendationsClient creates a new instance of ReservationRecommendationsClient. func (c *ClientFactory) NewReservationRecommendationsClient() *ReservationRecommendationsClient { - subClient, _ := NewReservationRecommendationsClient(c.credential, c.options) - return subClient + return &ReservationRecommendationsClient{ + internal: c.internal, + } } // NewReservationTransactionsClient creates a new instance of ReservationTransactionsClient. func (c *ClientFactory) NewReservationTransactionsClient() *ReservationTransactionsClient { - subClient, _ := NewReservationTransactionsClient(c.credential, c.options) - return subClient + return &ReservationTransactionsClient{ + internal: c.internal, + } } // NewReservationsDetailsClient creates a new instance of ReservationsDetailsClient. func (c *ClientFactory) NewReservationsDetailsClient() *ReservationsDetailsClient { - subClient, _ := NewReservationsDetailsClient(c.credential, c.options) - return subClient + return &ReservationsDetailsClient{ + internal: c.internal, + } } // NewReservationsSummariesClient creates a new instance of ReservationsSummariesClient. func (c *ClientFactory) NewReservationsSummariesClient() *ReservationsSummariesClient { - subClient, _ := NewReservationsSummariesClient(c.credential, c.options) - return subClient + return &ReservationsSummariesClient{ + internal: c.internal, + } } // NewTagsClient creates a new instance of TagsClient. func (c *ClientFactory) NewTagsClient() *TagsClient { - subClient, _ := NewTagsClient(c.credential, c.options) - return subClient + return &TagsClient{ + internal: c.internal, + } } // NewUsageDetailsClient creates a new instance of UsageDetailsClient. func (c *ClientFactory) NewUsageDetailsClient() *UsageDetailsClient { - subClient, _ := NewUsageDetailsClient(c.credential, c.options) - return subClient + return &UsageDetailsClient{ + internal: c.internal, + } } diff --git a/sdk/resourcemanager/consumption/armconsumption/constants.go b/sdk/resourcemanager/consumption/armconsumption/constants.go index 49dc41979a4b..d2d87de631f3 100644 --- a/sdk/resourcemanager/consumption/armconsumption/constants.go +++ b/sdk/resourcemanager/consumption/armconsumption/constants.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -10,7 +7,7 @@ package armconsumption const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption" - moduleVersion = "v1.2.0" + moduleVersion = "v2.0.0" ) // BillingFrequency - The billing frequency. @@ -150,6 +147,7 @@ func PossibleDatagrainValues() []Datagrain { type EventType string const ( + EventTypeCreditExpired EventType = "CreditExpired" EventTypeNewCredit EventType = "NewCredit" EventTypePendingAdjustments EventType = "PendingAdjustments" EventTypePendingCharges EventType = "PendingCharges" @@ -162,6 +160,7 @@ const ( // PossibleEventTypeValues returns the possible values for the EventType const type. func PossibleEventTypeValues() []EventType { return []EventType{ + EventTypeCreditExpired, EventTypeNewCredit, EventTypePendingAdjustments, EventTypePendingCharges, @@ -230,12 +229,37 @@ func PossibleMetrictypeValues() []Metrictype { } } +// OperationStatusType - The status of the long running operation. +type OperationStatusType string + +const ( + OperationStatusTypeCompleted OperationStatusType = "Completed" + OperationStatusTypeFailed OperationStatusType = "Failed" + OperationStatusTypeRunning OperationStatusType = "Running" +) + +// PossibleOperationStatusTypeValues returns the possible values for the OperationStatusType const type. +func PossibleOperationStatusTypeValues() []OperationStatusType { + return []OperationStatusType{ + OperationStatusTypeCompleted, + OperationStatusTypeFailed, + OperationStatusTypeRunning, + } +} + // OperatorType - The comparison operator. type OperatorType string const ( - OperatorTypeEqualTo OperatorType = "EqualTo" - OperatorTypeGreaterThan OperatorType = "GreaterThan" + // OperatorTypeEqualTo - Alert will be triggered if the evaluated cost is the same as threshold value. Note: It’s not recommended + // to use this OperatorType as there’s low chance of cost being exactly the same as threshold value, leading to missing of + // your alert. This OperatorType will be deprecated in future. + OperatorTypeEqualTo OperatorType = "EqualTo" + // OperatorTypeGreaterThan - Alert will be triggered if the evaluated cost is greater than the threshold value. Note: This + // is the recommended OperatorType while configuring Budget Alert. + OperatorTypeGreaterThan OperatorType = "GreaterThan" + // OperatorTypeGreaterThanOrEqualTo - Alert will be triggered if the evaluated cost is greater than or equal to the threshold + // value. OperatorTypeGreaterThanOrEqualTo OperatorType = "GreaterThanOrEqualTo" ) @@ -248,6 +272,24 @@ func PossibleOperatorTypeValues() []OperatorType { } } +// OrganizationType - The organization type of the lot. +type OrganizationType string + +const ( + // OrganizationTypeContributorOrganizationType - Contributor organization type for Multi-Entity consumption commitment. + OrganizationTypeContributorOrganizationType OrganizationType = "Contributor" + // OrganizationTypePrimaryOrganizationType - Primary organization type for Multi-Entity consumption commitment. + OrganizationTypePrimaryOrganizationType OrganizationType = "Primary" +) + +// PossibleOrganizationTypeValues returns the possible values for the OrganizationType const type. +func PossibleOrganizationTypeValues() []OrganizationType { + return []OrganizationType{ + OrganizationTypeContributorOrganizationType, + OrganizationTypePrimaryOrganizationType, + } +} + // PricingModelType - Identifier that indicates how the meter is priced. type PricingModelType string @@ -324,6 +366,8 @@ func PossibleStatusValues() []Status { type Term string const ( + // TermP1M - 1 month reservation term + TermP1M Term = "P1M" // TermP1Y - 1 year reservation term TermP1Y Term = "P1Y" // TermP3Y - 3 year reservation term @@ -333,6 +377,7 @@ const ( // PossibleTermValues returns the possible values for the Term const type. func PossibleTermValues() []Term { return []Term{ + TermP1M, TermP1Y, TermP3Y, } @@ -342,7 +387,10 @@ func PossibleTermValues() []Term { type ThresholdType string const ( - ThresholdTypeActual ThresholdType = "Actual" + // ThresholdTypeActual - Actual costs budget alerts notify when the actual accrued cost exceeds the allocated budget . + ThresholdTypeActual ThresholdType = "Actual" + // ThresholdTypeForecasted - Forecasted costs budget alerts provide advanced notification that your spending trends are likely + // to exceed your allocated budget, as it relies on forecasted cost predictions. ThresholdTypeForecasted ThresholdType = "Forecasted" ) diff --git a/sdk/resourcemanager/consumption/armconsumption/credits_client.go b/sdk/resourcemanager/consumption/armconsumption/credits_client.go index 28a7848c1e86..f05462f5760c 100644 --- a/sdk/resourcemanager/consumption/armconsumption/credits_client.go +++ b/sdk/resourcemanager/consumption/armconsumption/credits_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -43,7 +40,7 @@ func NewCreditsClient(credential azcore.TokenCredential, options *arm.ClientOpti // Get - The credit summary by billingAccountId and billingProfileId. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-10-01 +// Generated from API version 2025-04-01 // - billingAccountID - BillingAccount ID // - billingProfileID - Azure Billing Profile ID. // - options - CreditsClientGetOptions contains the optional parameters for the CreditsClient.Get method. @@ -70,7 +67,7 @@ func (client *CreditsClient) Get(ctx context.Context, billingAccountID string, b } // getCreateRequest creates the Get request. -func (client *CreditsClient) getCreateRequest(ctx context.Context, billingAccountID string, billingProfileID string, options *CreditsClientGetOptions) (*policy.Request, error) { +func (client *CreditsClient) getCreateRequest(ctx context.Context, billingAccountID string, billingProfileID string, _ *CreditsClientGetOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.Consumption/credits/balanceSummary" if billingAccountID == "" { return nil, errors.New("parameter billingAccountID cannot be empty") @@ -85,7 +82,7 @@ func (client *CreditsClient) getCreateRequest(ctx context.Context, billingAccoun return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-10-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/consumption/armconsumption/credits_client_example_test.go b/sdk/resourcemanager/consumption/armconsumption/credits_client_example_test.go deleted file mode 100644 index 06206ea75eb4..000000000000 --- a/sdk/resourcemanager/consumption/armconsumption/credits_client_example_test.go +++ /dev/null @@ -1,73 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armconsumption_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/CreditSummaryByBillingProfile.json -func ExampleCreditsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewCreditsClient().Get(ctx, "1234:5678", "2468", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.CreditSummary = armconsumption.CreditSummary{ - // Name: to.Ptr("balanceSummary1"), - // Type: to.Ptr("Microsoft.Consumption/credits/balanceSummary"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:5678/billingProfiles/2468/providers/Microsoft.Consumption/credits/balanceSummary1"), - // Properties: &armconsumption.CreditSummaryProperties{ - // BalanceSummary: &armconsumption.CreditBalanceSummary{ - // CurrentBalance: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](100), - // }, - // EstimatedBalance: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](600), - // }, - // }, - // BillingCurrency: to.Ptr("USD"), - // CreditCurrency: to.Ptr("USD"), - // ExpiredCredit: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](0), - // }, - // PendingCreditAdjustments: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](500), - // }, - // PendingEligibleCharges: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](0), - // }, - // Reseller: &armconsumption.Reseller{ - // ResellerDescription: to.Ptr("Reseller information."), - // ResellerID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:5678/billingProfiles/2468/providers/Microsoft.Consumption/reseller/reseller1"), - // }, - // }, - // } -} diff --git a/sdk/resourcemanager/consumption/armconsumption/events_client.go b/sdk/resourcemanager/consumption/armconsumption/events_client.go index ac8c6ef82117..304f3738d0f2 100644 --- a/sdk/resourcemanager/consumption/armconsumption/events_client.go +++ b/sdk/resourcemanager/consumption/armconsumption/events_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -43,7 +40,7 @@ func NewEventsClient(credential azcore.TokenCredential, options *arm.ClientOptio // NewListByBillingAccountPager - Lists the events that decrements Azure credits or Microsoft Azure consumption commitment // for a billing account or a billing profile for a given start and end date. // -// Generated from API version 2021-10-01 +// Generated from API version 2025-04-01 // - billingAccountID - BillingAccount ID // - options - EventsClientListByBillingAccountOptions contains the optional parameters for the EventsClient.NewListByBillingAccountPager // method. @@ -82,10 +79,10 @@ func (client *EventsClient) listByBillingAccountCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-10-01") if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -103,7 +100,7 @@ func (client *EventsClient) listByBillingAccountHandleResponse(resp *http.Respon // NewListByBillingProfilePager - Lists the events that decrements Azure credits or Microsoft Azure consumption commitment // for a billing account or a billing profile for a given start and end date. // -// Generated from API version 2021-10-01 +// Generated from API version 2025-04-01 // - billingAccountID - BillingAccount ID // - billingProfileID - Azure Billing Profile ID. // - startDate - Start date @@ -134,7 +131,7 @@ func (client *EventsClient) NewListByBillingProfilePager(billingAccountID string } // listByBillingProfileCreateRequest creates the ListByBillingProfile request. -func (client *EventsClient) listByBillingProfileCreateRequest(ctx context.Context, billingAccountID string, billingProfileID string, startDate string, endDate string, options *EventsClientListByBillingProfileOptions) (*policy.Request, error) { +func (client *EventsClient) listByBillingProfileCreateRequest(ctx context.Context, billingAccountID string, billingProfileID string, startDate string, endDate string, _ *EventsClientListByBillingProfileOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.Consumption/events" if billingAccountID == "" { return nil, errors.New("parameter billingAccountID cannot be empty") @@ -149,9 +146,9 @@ func (client *EventsClient) listByBillingProfileCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-10-01") - reqQP.Set("startDate", startDate) + reqQP.Set("api-version", "2025-04-01") reqQP.Set("endDate", endDate) + reqQP.Set("startDate", startDate) req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/consumption/armconsumption/events_client_example_test.go b/sdk/resourcemanager/consumption/armconsumption/events_client_example_test.go deleted file mode 100644 index 8d8f765d898a..000000000000 --- a/sdk/resourcemanager/consumption/armconsumption/events_client_example_test.go +++ /dev/null @@ -1,416 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armconsumption_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/consumption/armconsumption" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/EventsListByBillingProfile.json -func ExampleEventsClient_NewListByBillingProfilePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewEventsClient().NewListByBillingProfilePager("1234:5678", "4268", "2019-09-01", "2019-10-31", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.Events = armconsumption.Events{ - // Value: []*armconsumption.EventSummary{ - // { - // Name: to.Ptr("event1"), - // Type: to.Ptr("Microsoft.Consumption/events"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:5678/billingProfiles/4268/providers/Microsoft.Consumption/events/event1"), - // Properties: &armconsumption.EventProperties{ - // Description: to.Ptr("Settled invoice #312033"), - // Adjustments: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](0), - // }, - // AdjustmentsInBillingCurrency: &armconsumption.AmountWithExchangeRate{ - // ExchangeRate: to.Ptr[float64](5000), - // ExchangeRateMonth: to.Ptr[int32](1), - // }, - // BillingCurrency: to.Ptr("USD"), - // Charges: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](500), - // }, - // ChargesInBillingCurrency: &armconsumption.AmountWithExchangeRate{ - // ExchangeRate: to.Ptr[float64](5000), - // ExchangeRateMonth: to.Ptr[int32](1), - // }, - // ClosedBalance: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](500), - // }, - // ClosedBalanceInBillingCurrency: &armconsumption.AmountWithExchangeRate{ - // ExchangeRate: to.Ptr[float64](5000), - // ExchangeRateMonth: to.Ptr[int32](1), - // }, - // CreditCurrency: to.Ptr("USD"), - // CreditExpired: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](0), - // }, - // CreditExpiredInBillingCurrency: &armconsumption.AmountWithExchangeRate{ - // ExchangeRate: to.Ptr[float64](5000), - // ExchangeRateMonth: to.Ptr[int32](1), - // }, - // EventType: to.Ptr(armconsumption.EventTypeSettledCharges), - // InvoiceNumber: to.Ptr("3301"), - // NewCredit: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](0), - // }, - // NewCreditInBillingCurrency: &armconsumption.AmountWithExchangeRate{ - // ExchangeRate: to.Ptr[float64](5000), - // ExchangeRateMonth: to.Ptr[int32](1), - // }, - // Reseller: &armconsumption.Reseller{ - // ResellerDescription: to.Ptr("Reseller information"), - // ResellerID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:5678/billingProfiles/2468/providers/Microsoft.Consumption/reseller/reseller1"), - // }, - // TransactionDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-07-01T00:00:00.000Z"); return t}()), - // }, - // }, - // { - // Name: to.Ptr("event2"), - // Type: to.Ptr("Microsoft.Consumption/events"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:5678/billingProfiles/4268/providers/Microsoft.Consumption/events/event2"), - // Properties: &armconsumption.EventProperties{ - // Description: to.Ptr("New credits added"), - // Adjustments: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](0), - // }, - // AdjustmentsInBillingCurrency: &armconsumption.AmountWithExchangeRate{ - // ExchangeRate: to.Ptr[float64](5000), - // ExchangeRateMonth: to.Ptr[int32](1), - // }, - // BillingCurrency: to.Ptr("USD"), - // CanceledCredit: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](5000), - // }, - // Charges: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](0), - // }, - // ChargesInBillingCurrency: &armconsumption.AmountWithExchangeRate{ - // ExchangeRate: to.Ptr[float64](5000), - // ExchangeRateMonth: to.Ptr[int32](1), - // }, - // ClosedBalance: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](900), - // }, - // ClosedBalanceInBillingCurrency: &armconsumption.AmountWithExchangeRate{ - // ExchangeRate: to.Ptr[float64](5000), - // ExchangeRateMonth: to.Ptr[int32](1), - // }, - // CreditCurrency: to.Ptr("USD"), - // CreditExpired: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](0), - // }, - // CreditExpiredInBillingCurrency: &armconsumption.AmountWithExchangeRate{ - // ExchangeRate: to.Ptr[float64](5000), - // ExchangeRateMonth: to.Ptr[int32](1), - // }, - // EventType: to.Ptr(armconsumption.EventTypeNewCredit), - // InvoiceNumber: to.Ptr("3302"), - // NewCredit: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](400), - // }, - // NewCreditInBillingCurrency: &armconsumption.AmountWithExchangeRate{ - // ExchangeRate: to.Ptr[float64](5000), - // ExchangeRateMonth: to.Ptr[int32](1), - // }, - // Reseller: &armconsumption.Reseller{ - // ResellerDescription: to.Ptr("Reseller information"), - // ResellerID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:5678/billingProfiles/2468/providers/Microsoft.Consumption/reseller/reseller1"), - // }, - // TransactionDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-01T00:00:00.000Z"); return t}()), - // }, - // }, - // { - // Name: to.Ptr("event3"), - // Type: to.Ptr("Microsoft.Consumption/events"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:5678/billingProfiles/4268/providers/Microsoft.Consumption/events/event3"), - // Properties: &armconsumption.EventProperties{ - // Description: to.Ptr("Credits Expired"), - // Adjustments: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](0), - // }, - // AdjustmentsInBillingCurrency: &armconsumption.AmountWithExchangeRate{ - // ExchangeRate: to.Ptr[float64](5000), - // ExchangeRateMonth: to.Ptr[int32](1), - // }, - // BillingCurrency: to.Ptr("USD"), - // CanceledCredit: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](5000), - // }, - // Charges: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](0), - // }, - // ChargesInBillingCurrency: &armconsumption.AmountWithExchangeRate{ - // ExchangeRate: to.Ptr[float64](5000), - // ExchangeRateMonth: to.Ptr[int32](1), - // }, - // ClosedBalance: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](600), - // }, - // ClosedBalanceInBillingCurrency: &armconsumption.AmountWithExchangeRate{ - // ExchangeRate: to.Ptr[float64](5000), - // ExchangeRateMonth: to.Ptr[int32](1), - // }, - // CreditCurrency: to.Ptr("USD"), - // CreditExpired: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](300), - // }, - // CreditExpiredInBillingCurrency: &armconsumption.AmountWithExchangeRate{ - // ExchangeRate: to.Ptr[float64](5000), - // ExchangeRateMonth: to.Ptr[int32](1), - // }, - // EventType: to.Ptr(armconsumption.EventType("ExpiredCredit")), - // InvoiceNumber: to.Ptr(""), - // NewCredit: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](0), - // }, - // NewCreditInBillingCurrency: &armconsumption.AmountWithExchangeRate{ - // ExchangeRate: to.Ptr[float64](5000), - // ExchangeRateMonth: to.Ptr[int32](1), - // }, - // Reseller: &armconsumption.Reseller{ - // ResellerDescription: to.Ptr("Reseller information"), - // ResellerID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:5678/billingProfiles/2468/providers/Microsoft.Consumption/reseller/reseller1"), - // }, - // TransactionDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-01T00:00:00.000Z"); return t}()), - // }, - // }, - // { - // Name: to.Ptr("event4"), - // Type: to.Ptr("Microsoft.Consumption/events"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:5678/billingProfiles/4268/providers/Microsoft.Consumption/events/event4"), - // Properties: &armconsumption.EventProperties{ - // Description: to.Ptr("Settled invoice #212033"), - // Adjustments: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](-200), - // }, - // AdjustmentsInBillingCurrency: &armconsumption.AmountWithExchangeRate{ - // ExchangeRate: to.Ptr[float64](5000), - // ExchangeRateMonth: to.Ptr[int32](1), - // }, - // BillingCurrency: to.Ptr("USD"), - // CanceledCredit: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](5000), - // }, - // Charges: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](300), - // }, - // ChargesInBillingCurrency: &armconsumption.AmountWithExchangeRate{ - // ExchangeRate: to.Ptr[float64](5000), - // ExchangeRateMonth: to.Ptr[int32](1), - // }, - // ClosedBalance: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](700), - // }, - // ClosedBalanceInBillingCurrency: &armconsumption.AmountWithExchangeRate{ - // ExchangeRate: to.Ptr[float64](5000), - // ExchangeRateMonth: to.Ptr[int32](1), - // }, - // CreditCurrency: to.Ptr("USD"), - // CreditExpired: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](100), - // }, - // CreditExpiredInBillingCurrency: &armconsumption.AmountWithExchangeRate{ - // ExchangeRate: to.Ptr[float64](5000), - // ExchangeRateMonth: to.Ptr[int32](1), - // }, - // EventType: to.Ptr(armconsumption.EventTypeSettledCharges), - // InvoiceNumber: to.Ptr("3303"), - // NewCredit: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](300), - // }, - // NewCreditInBillingCurrency: &armconsumption.AmountWithExchangeRate{ - // ExchangeRate: to.Ptr[float64](5000), - // ExchangeRateMonth: to.Ptr[int32](1), - // }, - // Reseller: &armconsumption.Reseller{ - // ResellerDescription: to.Ptr("Reseller information"), - // ResellerID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:5678/billingProfiles/2468/providers/Microsoft.Consumption/reseller/reseller1"), - // }, - // TransactionDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-10-01T00:00:00.000Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/EventsGetByBillingAccount.json -func ExampleEventsClient_NewListByBillingAccountPager_eventsGetByBillingAccount() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewEventsClient().NewListByBillingAccountPager("1234:5678", &armconsumption.EventsClientListByBillingAccountOptions{Filter: nil}) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.Events = armconsumption.Events{ - // Value: []*armconsumption.EventSummary{ - // { - // Name: to.Ptr("eventId1"), - // Type: to.Ptr("Microsoft.Consumption/events"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Consumption/events/eventId1"), - // Properties: &armconsumption.EventProperties{ - // Description: to.Ptr("New MACC Added"), - // BillingProfileDisplayName: to.Ptr("Contoso Operations Billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/X3TD-KVTT-BG7-TGB"), - // Charges: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](500), - // }, - // ClosedBalance: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](500), - // }, - // EventType: to.Ptr(armconsumption.EventTypeNewCredit), - // InvoiceNumber: to.Ptr("3304"), - // LotID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:5678/Microsoft.Consumption/lots/G202001083926600XXXXX"), - // LotSource: to.Ptr("ConsumptionCommitment"), - // NewCredit: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](500), - // }, - // TransactionDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-07-01T00:00:00.000Z"); return t}()), - // }, - // }, - // { - // Name: to.Ptr("eventId2"), - // Type: to.Ptr("Microsoft.Consumption/events"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Consumption/events/eventId2"), - // Properties: &armconsumption.EventProperties{ - // Description: to.Ptr("Balance after invoice 3304"), - // BillingProfileDisplayName: to.Ptr("Contoso Operations Billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/X3TD-KVTT-BG7-TGB"), - // Charges: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](500), - // }, - // ClosedBalance: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](500), - // }, - // EventType: to.Ptr(armconsumption.EventTypeSettledCharges), - // InvoiceNumber: to.Ptr("3304"), - // LotID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:5678/Microsoft.Consumption/lots/7004bc39-974d-482e-8e45-caf91dba0870"), - // LotSource: to.Ptr("AzurePrepayment"), - // TransactionDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-07-01T00:00:00.000Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/EventsGetByBillingAccountWithFilters.json -func ExampleEventsClient_NewListByBillingAccountPager_eventsGetByBillingAccountWithFilters() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewEventsClient().NewListByBillingAccountPager("1234:5678", &armconsumption.EventsClientListByBillingAccountOptions{Filter: to.Ptr("lotid eq 'G202001083926600XXXXX' AND lotsource eq 'consumptioncommitment'")}) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.Events = armconsumption.Events{ - // Value: []*armconsumption.EventSummary{ - // { - // Name: to.Ptr("eventId1"), - // Type: to.Ptr("Microsoft.Consumption/events"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:56789/providers/Microsoft.Consumption/events/eventId1"), - // Properties: &armconsumption.EventProperties{ - // Description: to.Ptr("MACC Canceled"), - // BillingProfileDisplayName: to.Ptr("Contoso Operations Billing"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/X3TD-KVTT-BG7-TGB"), - // CanceledCredit: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](200), - // }, - // ClosedBalance: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](500), - // }, - // EventType: to.Ptr(armconsumption.EventType("CanceledCredit")), - // InvoiceNumber: to.Ptr("3304"), - // LotID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:5678/Microsoft.Consumption/lots/G202001083926600XXXXX"), - // LotSource: to.Ptr("ConsumptionCommitment"), - // TransactionDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-07-01T00:00:00.000Z"); return t}()), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/consumption/armconsumption/fake/aggregatedcost_server.go b/sdk/resourcemanager/consumption/armconsumption/fake/aggregatedcost_server.go index 0f52fc8cdb5d..c399171db6f0 100644 --- a/sdk/resourcemanager/consumption/armconsumption/fake/aggregatedcost_server.go +++ b/sdk/resourcemanager/consumption/armconsumption/fake/aggregatedcost_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2" "net/http" "net/url" "regexp" @@ -53,23 +50,42 @@ func (a *AggregatedCostServerTransport) Do(req *http.Request) (*http.Response, e return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return a.dispatchToMethodFake(req, method) +} - switch method { - case "AggregatedCostClient.GetByManagementGroup": - resp, err = a.dispatchGetByManagementGroup(req) - case "AggregatedCostClient.GetForBillingPeriodByManagementGroup": - resp, err = a.dispatchGetForBillingPeriodByManagementGroup(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (a *AggregatedCostServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if aggregatedCostServerTransportInterceptor != nil { + res.resp, res.err, intercepted = aggregatedCostServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "AggregatedCostClient.GetByManagementGroup": + res.resp, res.err = a.dispatchGetByManagementGroup(req) + case "AggregatedCostClient.GetForBillingPeriodByManagementGroup": + res.resp, res.err = a.dispatchGetForBillingPeriodByManagementGroup(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (a *AggregatedCostServerTransport) dispatchGetByManagementGroup(req *http.Request) (*http.Response, error) { @@ -145,3 +161,9 @@ func (a *AggregatedCostServerTransport) dispatchGetForBillingPeriodByManagementG } return resp, nil } + +// set this to conditionally intercept incoming requests to AggregatedCostServerTransport +var aggregatedCostServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/consumption/armconsumption/fake/balances_server.go b/sdk/resourcemanager/consumption/armconsumption/fake/balances_server.go index 178dc3c19cc6..319f6d49f4d6 100644 --- a/sdk/resourcemanager/consumption/armconsumption/fake/balances_server.go +++ b/sdk/resourcemanager/consumption/armconsumption/fake/balances_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2" "net/http" "net/url" "regexp" @@ -53,23 +50,42 @@ func (b *BalancesServerTransport) Do(req *http.Request) (*http.Response, error) return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return b.dispatchToMethodFake(req, method) +} - switch method { - case "BalancesClient.GetByBillingAccount": - resp, err = b.dispatchGetByBillingAccount(req) - case "BalancesClient.GetForBillingPeriodByBillingAccount": - resp, err = b.dispatchGetForBillingPeriodByBillingAccount(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (b *BalancesServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if balancesServerTransportInterceptor != nil { + res.resp, res.err, intercepted = balancesServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "BalancesClient.GetByBillingAccount": + res.resp, res.err = b.dispatchGetByBillingAccount(req) + case "BalancesClient.GetForBillingPeriodByBillingAccount": + res.resp, res.err = b.dispatchGetForBillingPeriodByBillingAccount(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (b *BalancesServerTransport) dispatchGetByBillingAccount(req *http.Request) (*http.Response, error) { @@ -133,3 +149,9 @@ func (b *BalancesServerTransport) dispatchGetForBillingPeriodByBillingAccount(re } return resp, nil } + +// set this to conditionally intercept incoming requests to BalancesServerTransport +var balancesServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/consumption/armconsumption/fake/budgets_server.go b/sdk/resourcemanager/consumption/armconsumption/fake/budgets_server.go index 5fc66ef4f274..3efae2c7b191 100644 --- a/sdk/resourcemanager/consumption/armconsumption/fake/budgets_server.go +++ b/sdk/resourcemanager/consumption/armconsumption/fake/budgets_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -16,7 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2" "net/http" "net/url" "regexp" @@ -66,27 +63,46 @@ func (b *BudgetsServerTransport) Do(req *http.Request) (*http.Response, error) { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return b.dispatchToMethodFake(req, method) +} - switch method { - case "BudgetsClient.CreateOrUpdate": - resp, err = b.dispatchCreateOrUpdate(req) - case "BudgetsClient.Delete": - resp, err = b.dispatchDelete(req) - case "BudgetsClient.Get": - resp, err = b.dispatchGet(req) - case "BudgetsClient.NewListPager": - resp, err = b.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (b *BudgetsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if budgetsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = budgetsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "BudgetsClient.CreateOrUpdate": + res.resp, res.err = b.dispatchCreateOrUpdate(req) + case "BudgetsClient.Delete": + res.resp, res.err = b.dispatchDelete(req) + case "BudgetsClient.Get": + res.resp, res.err = b.dispatchGet(req) + case "BudgetsClient.NewListPager": + res.resp, res.err = b.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (b *BudgetsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -228,3 +244,9 @@ func (b *BudgetsServerTransport) dispatchNewListPager(req *http.Request) (*http. } return resp, nil } + +// set this to conditionally intercept incoming requests to BudgetsServerTransport +var budgetsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/consumption/armconsumption/fake/charges_server.go b/sdk/resourcemanager/consumption/armconsumption/fake/charges_server.go index b5b8f5a98021..19c91d839ea4 100644 --- a/sdk/resourcemanager/consumption/armconsumption/fake/charges_server.go +++ b/sdk/resourcemanager/consumption/armconsumption/fake/charges_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2" "net/http" "net/url" "regexp" @@ -49,21 +46,40 @@ func (c *ChargesServerTransport) Do(req *http.Request) (*http.Response, error) { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return c.dispatchToMethodFake(req, method) +} - switch method { - case "ChargesClient.List": - resp, err = c.dispatchList(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (c *ChargesServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if chargesServerTransportInterceptor != nil { + res.resp, res.err, intercepted = chargesServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ChargesClient.List": + res.resp, res.err = c.dispatchList(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (c *ChargesServerTransport) dispatchList(req *http.Request) (*http.Response, error) { @@ -124,3 +140,9 @@ func (c *ChargesServerTransport) dispatchList(req *http.Request) (*http.Response } return resp, nil } + +// set this to conditionally intercept incoming requests to ChargesServerTransport +var chargesServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/consumption/armconsumption/fake/credits_server.go b/sdk/resourcemanager/consumption/armconsumption/fake/credits_server.go index b7236a1f0536..f2c9b6d67f11 100644 --- a/sdk/resourcemanager/consumption/armconsumption/fake/credits_server.go +++ b/sdk/resourcemanager/consumption/armconsumption/fake/credits_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2" "net/http" "net/url" "regexp" @@ -49,21 +46,40 @@ func (c *CreditsServerTransport) Do(req *http.Request) (*http.Response, error) { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return c.dispatchToMethodFake(req, method) +} - switch method { - case "CreditsClient.Get": - resp, err = c.dispatchGet(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (c *CreditsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if creditsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = creditsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "CreditsClient.Get": + res.resp, res.err = c.dispatchGet(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (c *CreditsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { @@ -98,3 +114,9 @@ func (c *CreditsServerTransport) dispatchGet(req *http.Request) (*http.Response, } return resp, nil } + +// set this to conditionally intercept incoming requests to CreditsServerTransport +var creditsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/consumption/armconsumption/fake/events_server.go b/sdk/resourcemanager/consumption/armconsumption/fake/events_server.go index 51d00305c1a5..f053586ecf67 100644 --- a/sdk/resourcemanager/consumption/armconsumption/fake/events_server.go +++ b/sdk/resourcemanager/consumption/armconsumption/fake/events_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2" "net/http" "net/url" "regexp" @@ -59,23 +56,42 @@ func (e *EventsServerTransport) Do(req *http.Request) (*http.Response, error) { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return e.dispatchToMethodFake(req, method) +} - switch method { - case "EventsClient.NewListByBillingAccountPager": - resp, err = e.dispatchNewListByBillingAccountPager(req) - case "EventsClient.NewListByBillingProfilePager": - resp, err = e.dispatchNewListByBillingProfilePager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (e *EventsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if eventsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = eventsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "EventsClient.NewListByBillingAccountPager": + res.resp, res.err = e.dispatchNewListByBillingAccountPager(req) + case "EventsClient.NewListByBillingProfilePager": + res.resp, res.err = e.dispatchNewListByBillingProfilePager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (e *EventsServerTransport) dispatchNewListByBillingAccountPager(req *http.Request) (*http.Response, error) { @@ -176,3 +192,9 @@ func (e *EventsServerTransport) dispatchNewListByBillingProfilePager(req *http.R } return resp, nil } + +// set this to conditionally intercept incoming requests to EventsServerTransport +var eventsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/consumption/armconsumption/fake/internal.go b/sdk/resourcemanager/consumption/armconsumption/fake/internal.go index 72f540f217a1..d186c1b38a18 100644 --- a/sdk/resourcemanager/consumption/armconsumption/fake/internal.go +++ b/sdk/resourcemanager/consumption/armconsumption/fake/internal.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,6 +12,11 @@ import ( "sync" ) +type result struct { + resp *http.Response + err error +} + type nonRetriableError struct { error } diff --git a/sdk/resourcemanager/consumption/armconsumption/fake/lots_server.go b/sdk/resourcemanager/consumption/armconsumption/fake/lots_server.go index d023ac534e84..873d056d66c9 100644 --- a/sdk/resourcemanager/consumption/armconsumption/fake/lots_server.go +++ b/sdk/resourcemanager/consumption/armconsumption/fake/lots_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2" "net/http" "net/url" "regexp" @@ -65,25 +62,44 @@ func (l *LotsServerTransport) Do(req *http.Request) (*http.Response, error) { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return l.dispatchToMethodFake(req, method) +} - switch method { - case "LotsClient.NewListByBillingAccountPager": - resp, err = l.dispatchNewListByBillingAccountPager(req) - case "LotsClient.NewListByBillingProfilePager": - resp, err = l.dispatchNewListByBillingProfilePager(req) - case "LotsClient.NewListByCustomerPager": - resp, err = l.dispatchNewListByCustomerPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (l *LotsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if lotsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = lotsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "LotsClient.NewListByBillingAccountPager": + res.resp, res.err = l.dispatchNewListByBillingAccountPager(req) + case "LotsClient.NewListByBillingProfilePager": + res.resp, res.err = l.dispatchNewListByBillingProfilePager(req) + case "LotsClient.NewListByCustomerPager": + res.resp, res.err = l.dispatchNewListByCustomerPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (l *LotsServerTransport) dispatchNewListByBillingAccountPager(req *http.Request) (*http.Response, error) { @@ -228,3 +244,9 @@ func (l *LotsServerTransport) dispatchNewListByCustomerPager(req *http.Request) } return resp, nil } + +// set this to conditionally intercept incoming requests to LotsServerTransport +var lotsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/consumption/armconsumption/fake/marketplaces_server.go b/sdk/resourcemanager/consumption/armconsumption/fake/marketplaces_server.go index 9cb655048a06..9a39ccda5cb8 100644 --- a/sdk/resourcemanager/consumption/armconsumption/fake/marketplaces_server.go +++ b/sdk/resourcemanager/consumption/armconsumption/fake/marketplaces_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2" "net/http" "net/url" "regexp" @@ -25,7 +22,7 @@ import ( // MarketplacesServer is a fake server for instances of the armconsumption.MarketplacesClient type. type MarketplacesServer struct { // NewListPager is the fake for method MarketplacesClient.NewListPager - // HTTP status codes to indicate success: http.StatusOK + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent NewListPager func(scope string, options *armconsumption.MarketplacesClientListOptions) (resp azfake.PagerResponder[armconsumption.MarketplacesClientListResponse]) } @@ -54,21 +51,40 @@ func (m *MarketplacesServerTransport) Do(req *http.Request) (*http.Response, err return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return m.dispatchToMethodFake(req, method) +} - switch method { - case "MarketplacesClient.NewListPager": - resp, err = m.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (m *MarketplacesServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if marketplacesServerTransportInterceptor != nil { + res.resp, res.err, intercepted = marketplacesServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "MarketplacesClient.NewListPager": + res.resp, res.err = m.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (m *MarketplacesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { @@ -131,12 +147,18 @@ func (m *MarketplacesServerTransport) dispatchNewListPager(req *http.Request) (* if err != nil { return nil, err } - if !contains([]int{http.StatusOK}, resp.StatusCode) { + if !contains([]int{http.StatusOK, http.StatusNoContent}, resp.StatusCode) { m.newListPager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", resp.StatusCode)} } if !server.PagerResponderMore(newListPager) { m.newListPager.remove(req) } return resp, nil } + +// set this to conditionally intercept incoming requests to MarketplacesServerTransport +var marketplacesServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/consumption/armconsumption/fake/operations_server.go b/sdk/resourcemanager/consumption/armconsumption/fake/operations_server.go index 14ebf240ffb8..879c24c21ff9 100644 --- a/sdk/resourcemanager/consumption/armconsumption/fake/operations_server.go +++ b/sdk/resourcemanager/consumption/armconsumption/fake/operations_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2" "net/http" ) @@ -51,21 +48,40 @@ func (o *OperationsServerTransport) Do(req *http.Request) (*http.Response, error return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return o.dispatchToMethodFake(req, method) +} - switch method { - case "OperationsClient.NewListPager": - resp, err = o.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (o *OperationsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if operationsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = operationsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "OperationsClient.NewListPager": + res.resp, res.err = o.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { @@ -94,3 +110,9 @@ func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*ht } return resp, nil } + +// set this to conditionally intercept incoming requests to OperationsServerTransport +var operationsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/consumption/armconsumption/fake/pricesheet_server.go b/sdk/resourcemanager/consumption/armconsumption/fake/pricesheet_server.go index e7aa4eef3132..82eaf057d53b 100644 --- a/sdk/resourcemanager/consumption/armconsumption/fake/pricesheet_server.go +++ b/sdk/resourcemanager/consumption/armconsumption/fake/pricesheet_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2" "net/http" "net/url" "regexp" @@ -24,6 +21,10 @@ import ( // PriceSheetServer is a fake server for instances of the armconsumption.PriceSheetClient type. type PriceSheetServer struct { + // BeginDownloadByBillingAccountPeriod is the fake for method PriceSheetClient.BeginDownloadByBillingAccountPeriod + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginDownloadByBillingAccountPeriod func(ctx context.Context, billingAccountID string, billingPeriodName string, options *armconsumption.PriceSheetClientBeginDownloadByBillingAccountPeriodOptions) (resp azfake.PollerResponder[armconsumption.PriceSheetClientDownloadByBillingAccountPeriodResponse], errResp azfake.ErrorResponder) + // Get is the fake for method PriceSheetClient.Get // HTTP status codes to indicate success: http.StatusOK Get func(ctx context.Context, options *armconsumption.PriceSheetClientGetOptions) (resp azfake.Responder[armconsumption.PriceSheetClientGetResponse], errResp azfake.ErrorResponder) @@ -37,13 +38,17 @@ type PriceSheetServer struct { // The returned PriceSheetServerTransport instance is connected to an instance of armconsumption.PriceSheetClient via the // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewPriceSheetServerTransport(srv *PriceSheetServer) *PriceSheetServerTransport { - return &PriceSheetServerTransport{srv: srv} + return &PriceSheetServerTransport{ + srv: srv, + beginDownloadByBillingAccountPeriod: newTracker[azfake.PollerResponder[armconsumption.PriceSheetClientDownloadByBillingAccountPeriodResponse]](), + } } // PriceSheetServerTransport connects instances of armconsumption.PriceSheetClient to instances of PriceSheetServer. // Don't use this type directly, use NewPriceSheetServerTransport instead. type PriceSheetServerTransport struct { - srv *PriceSheetServer + srv *PriceSheetServer + beginDownloadByBillingAccountPeriod *tracker[azfake.PollerResponder[armconsumption.PriceSheetClientDownloadByBillingAccountPeriodResponse]] } // Do implements the policy.Transporter interface for PriceSheetServerTransport. @@ -54,22 +59,87 @@ func (p *PriceSheetServerTransport) Do(req *http.Request) (*http.Response, error return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return p.dispatchToMethodFake(req, method) +} + +func (p *PriceSheetServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if priceSheetServerTransportInterceptor != nil { + res.resp, res.err, intercepted = priceSheetServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "PriceSheetClient.BeginDownloadByBillingAccountPeriod": + res.resp, res.err = p.dispatchBeginDownloadByBillingAccountPeriod(req) + case "PriceSheetClient.Get": + res.resp, res.err = p.dispatchGet(req) + case "PriceSheetClient.GetByBillingPeriod": + res.resp, res.err = p.dispatchGetByBillingPeriod(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() - switch method { - case "PriceSheetClient.Get": - resp, err = p.dispatchGet(req) - case "PriceSheetClient.GetByBillingPeriod": - resp, err = p.dispatchGetByBillingPeriod(req) - default: - err = fmt.Errorf("unhandled API %s", method) + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err } +} +func (p *PriceSheetServerTransport) dispatchBeginDownloadByBillingAccountPeriod(req *http.Request) (*http.Response, error) { + if p.srv.BeginDownloadByBillingAccountPeriod == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDownloadByBillingAccountPeriod not implemented")} + } + beginDownloadByBillingAccountPeriod := p.beginDownloadByBillingAccountPeriod.get(req) + if beginDownloadByBillingAccountPeriod == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingPeriods/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Consumption/pricesheets/download` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountId")]) + if err != nil { + return nil, err + } + billingPeriodNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingPeriodName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.BeginDownloadByBillingAccountPeriod(req.Context(), billingAccountIDParam, billingPeriodNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDownloadByBillingAccountPeriod = &respr + p.beginDownloadByBillingAccountPeriod.add(req, beginDownloadByBillingAccountPeriod) + } + + resp, err := server.PollerResponderNext(beginDownloadByBillingAccountPeriod, req) if err != nil { return nil, err } + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + p.beginDownloadByBillingAccountPeriod.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDownloadByBillingAccountPeriod) { + p.beginDownloadByBillingAccountPeriod.remove(req) + } + return resp, nil } @@ -192,3 +262,9 @@ func (p *PriceSheetServerTransport) dispatchGetByBillingPeriod(req *http.Request } return resp, nil } + +// set this to conditionally intercept incoming requests to PriceSheetServerTransport +var priceSheetServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/consumption/armconsumption/fake/reservationrecommendationdetails_server.go b/sdk/resourcemanager/consumption/armconsumption/fake/reservationrecommendationdetails_server.go index cca46e72a905..bdfb41d42730 100644 --- a/sdk/resourcemanager/consumption/armconsumption/fake/reservationrecommendationdetails_server.go +++ b/sdk/resourcemanager/consumption/armconsumption/fake/reservationrecommendationdetails_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2" "net/http" "net/url" "regexp" @@ -49,21 +46,40 @@ func (r *ReservationRecommendationDetailsServerTransport) Do(req *http.Request) return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return r.dispatchToMethodFake(req, method) +} - switch method { - case "ReservationRecommendationDetailsClient.Get": - resp, err = r.dispatchGet(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (r *ReservationRecommendationDetailsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if reservationRecommendationDetailsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = reservationRecommendationDetailsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ReservationRecommendationDetailsClient.Get": + res.resp, res.err = r.dispatchGet(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (r *ReservationRecommendationDetailsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { @@ -119,7 +135,18 @@ func (r *ReservationRecommendationDetailsServerTransport) dispatchGet(req *http. if err != nil { return nil, err } - respr, errRespr := r.srv.Get(req.Context(), resourceScopeParam, scopeParam, regionParam, termParam, lookBackPeriodParam, productParam, nil) + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + var options *armconsumption.ReservationRecommendationDetailsClientGetOptions + if filterParam != nil { + options = &armconsumption.ReservationRecommendationDetailsClientGetOptions{ + Filter: filterParam, + } + } + respr, errRespr := r.srv.Get(req.Context(), resourceScopeParam, scopeParam, regionParam, termParam, lookBackPeriodParam, productParam, options) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -133,3 +160,9 @@ func (r *ReservationRecommendationDetailsServerTransport) dispatchGet(req *http. } return resp, nil } + +// set this to conditionally intercept incoming requests to ReservationRecommendationDetailsServerTransport +var reservationRecommendationDetailsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/consumption/armconsumption/fake/reservationrecommendations_server.go b/sdk/resourcemanager/consumption/armconsumption/fake/reservationrecommendations_server.go index 58752173fff4..d820dec9991e 100644 --- a/sdk/resourcemanager/consumption/armconsumption/fake/reservationrecommendations_server.go +++ b/sdk/resourcemanager/consumption/armconsumption/fake/reservationrecommendations_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2" "net/http" "net/url" "regexp" @@ -53,21 +50,40 @@ func (r *ReservationRecommendationsServerTransport) Do(req *http.Request) (*http return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return r.dispatchToMethodFake(req, method) +} - switch method { - case "ReservationRecommendationsClient.NewListPager": - resp, err = r.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (r *ReservationRecommendationsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if reservationRecommendationsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = reservationRecommendationsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ReservationRecommendationsClient.NewListPager": + res.resp, res.err = r.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (r *ReservationRecommendationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { @@ -118,3 +134,9 @@ func (r *ReservationRecommendationsServerTransport) dispatchNewListPager(req *ht } return resp, nil } + +// set this to conditionally intercept incoming requests to ReservationRecommendationsServerTransport +var reservationRecommendationsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/consumption/armconsumption/fake/reservationsdetails_server.go b/sdk/resourcemanager/consumption/armconsumption/fake/reservationsdetails_server.go index aee85767826f..bfdf129cdc45 100644 --- a/sdk/resourcemanager/consumption/armconsumption/fake/reservationsdetails_server.go +++ b/sdk/resourcemanager/consumption/armconsumption/fake/reservationsdetails_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2" "net/http" "net/url" "regexp" @@ -65,25 +62,44 @@ func (r *ReservationsDetailsServerTransport) Do(req *http.Request) (*http.Respon return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return r.dispatchToMethodFake(req, method) +} - switch method { - case "ReservationsDetailsClient.NewListPager": - resp, err = r.dispatchNewListPager(req) - case "ReservationsDetailsClient.NewListByReservationOrderPager": - resp, err = r.dispatchNewListByReservationOrderPager(req) - case "ReservationsDetailsClient.NewListByReservationOrderAndReservationPager": - resp, err = r.dispatchNewListByReservationOrderAndReservationPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (r *ReservationsDetailsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if reservationsDetailsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = reservationsDetailsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ReservationsDetailsClient.NewListPager": + res.resp, res.err = r.dispatchNewListPager(req) + case "ReservationsDetailsClient.NewListByReservationOrderPager": + res.resp, res.err = r.dispatchNewListByReservationOrderPager(req) + case "ReservationsDetailsClient.NewListByReservationOrderAndReservationPager": + res.resp, res.err = r.dispatchNewListByReservationOrderAndReservationPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (r *ReservationsDetailsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { @@ -246,3 +262,9 @@ func (r *ReservationsDetailsServerTransport) dispatchNewListByReservationOrderAn } return resp, nil } + +// set this to conditionally intercept incoming requests to ReservationsDetailsServerTransport +var reservationsDetailsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/consumption/armconsumption/fake/reservationssummaries_server.go b/sdk/resourcemanager/consumption/armconsumption/fake/reservationssummaries_server.go index b88d806fbf3d..ed0591b5c913 100644 --- a/sdk/resourcemanager/consumption/armconsumption/fake/reservationssummaries_server.go +++ b/sdk/resourcemanager/consumption/armconsumption/fake/reservationssummaries_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2" "net/http" "net/url" "regexp" @@ -65,25 +62,44 @@ func (r *ReservationsSummariesServerTransport) Do(req *http.Request) (*http.Resp return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return r.dispatchToMethodFake(req, method) +} - switch method { - case "ReservationsSummariesClient.NewListPager": - resp, err = r.dispatchNewListPager(req) - case "ReservationsSummariesClient.NewListByReservationOrderPager": - resp, err = r.dispatchNewListByReservationOrderPager(req) - case "ReservationsSummariesClient.NewListByReservationOrderAndReservationPager": - resp, err = r.dispatchNewListByReservationOrderAndReservationPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (r *ReservationsSummariesServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if reservationsSummariesServerTransportInterceptor != nil { + res.resp, res.err, intercepted = reservationsSummariesServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ReservationsSummariesClient.NewListPager": + res.resp, res.err = r.dispatchNewListPager(req) + case "ReservationsSummariesClient.NewListByReservationOrderPager": + res.resp, res.err = r.dispatchNewListByReservationOrderPager(req) + case "ReservationsSummariesClient.NewListByReservationOrderAndReservationPager": + res.resp, res.err = r.dispatchNewListByReservationOrderAndReservationPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (r *ReservationsSummariesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { @@ -290,3 +306,9 @@ func (r *ReservationsSummariesServerTransport) dispatchNewListByReservationOrder } return resp, nil } + +// set this to conditionally intercept incoming requests to ReservationsSummariesServerTransport +var reservationsSummariesServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/consumption/armconsumption/fake/reservationtransactions_server.go b/sdk/resourcemanager/consumption/armconsumption/fake/reservationtransactions_server.go index 6ac68f2b9977..cf5d0cfbb269 100644 --- a/sdk/resourcemanager/consumption/armconsumption/fake/reservationtransactions_server.go +++ b/sdk/resourcemanager/consumption/armconsumption/fake/reservationtransactions_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,10 +12,11 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2" "net/http" "net/url" "regexp" + "strconv" ) // ReservationTransactionsServer is a fake server for instances of the armconsumption.ReservationTransactionsClient type. @@ -59,23 +57,42 @@ func (r *ReservationTransactionsServerTransport) Do(req *http.Request) (*http.Re return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return r.dispatchToMethodFake(req, method) +} - switch method { - case "ReservationTransactionsClient.NewListPager": - resp, err = r.dispatchNewListPager(req) - case "ReservationTransactionsClient.NewListByBillingProfilePager": - resp, err = r.dispatchNewListByBillingProfilePager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (r *ReservationTransactionsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if reservationTransactionsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = reservationTransactionsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ReservationTransactionsClient.NewListPager": + res.resp, res.err = r.dispatchNewListPager(req) + case "ReservationTransactionsClient.NewListByBillingProfilePager": + res.resp, res.err = r.dispatchNewListByBillingProfilePager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (r *ReservationTransactionsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { @@ -96,14 +113,38 @@ func (r *ReservationTransactionsServerTransport) dispatchNewListPager(req *http. return nil, err } filterParam := getOptional(filterUnescaped) + useMarkupIfPartnerUnescaped, err := url.QueryUnescape(qp.Get("useMarkupIfPartner")) + if err != nil { + return nil, err + } + useMarkupIfPartnerParam, err := parseOptional(useMarkupIfPartnerUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + previewMarkupPercentageUnescaped, err := url.QueryUnescape(qp.Get("previewMarkupPercentage")) + if err != nil { + return nil, err + } + previewMarkupPercentageParam, err := parseOptional(previewMarkupPercentageUnescaped, func(v string) (float64, error) { + p, parseErr := strconv.ParseFloat(v, 64) + if parseErr != nil { + return 0, parseErr + } + return p, nil + }) + if err != nil { + return nil, err + } billingAccountIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountId")]) if err != nil { return nil, err } var options *armconsumption.ReservationTransactionsClientListOptions - if filterParam != nil { + if filterParam != nil || useMarkupIfPartnerParam != nil || previewMarkupPercentageParam != nil { options = &armconsumption.ReservationTransactionsClientListOptions{ - Filter: filterParam, + Filter: filterParam, + UseMarkupIfPartner: useMarkupIfPartnerParam, + PreviewMarkupPercentage: previewMarkupPercentageParam, } } resp := r.srv.NewListPager(billingAccountIDParam, options) @@ -179,3 +220,9 @@ func (r *ReservationTransactionsServerTransport) dispatchNewListByBillingProfile } return resp, nil } + +// set this to conditionally intercept incoming requests to ReservationTransactionsServerTransport +var reservationTransactionsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/consumption/armconsumption/fake/server_factory.go b/sdk/resourcemanager/consumption/armconsumption/fake/server_factory.go index f36cebeb1a52..0b4364261aa9 100644 --- a/sdk/resourcemanager/consumption/armconsumption/fake/server_factory.go +++ b/sdk/resourcemanager/consumption/armconsumption/fake/server_factory.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -19,23 +16,56 @@ import ( // ServerFactory is a fake server for instances of the armconsumption.ClientFactory type. type ServerFactory struct { - AggregatedCostServer AggregatedCostServer - BalancesServer BalancesServer - BudgetsServer BudgetsServer - ChargesServer ChargesServer - CreditsServer CreditsServer - EventsServer EventsServer - LotsServer LotsServer - MarketplacesServer MarketplacesServer - OperationsServer OperationsServer - PriceSheetServer PriceSheetServer + // AggregatedCostServer contains the fakes for client AggregatedCostClient + AggregatedCostServer AggregatedCostServer + + // BalancesServer contains the fakes for client BalancesClient + BalancesServer BalancesServer + + // BudgetsServer contains the fakes for client BudgetsClient + BudgetsServer BudgetsServer + + // ChargesServer contains the fakes for client ChargesClient + ChargesServer ChargesServer + + // CreditsServer contains the fakes for client CreditsClient + CreditsServer CreditsServer + + // EventsServer contains the fakes for client EventsClient + EventsServer EventsServer + + // LotsServer contains the fakes for client LotsClient + LotsServer LotsServer + + // MarketplacesServer contains the fakes for client MarketplacesClient + MarketplacesServer MarketplacesServer + + // OperationsServer contains the fakes for client OperationsClient + OperationsServer OperationsServer + + // PriceSheetServer contains the fakes for client PriceSheetClient + PriceSheetServer PriceSheetServer + + // ReservationRecommendationDetailsServer contains the fakes for client ReservationRecommendationDetailsClient ReservationRecommendationDetailsServer ReservationRecommendationDetailsServer - ReservationRecommendationsServer ReservationRecommendationsServer - ReservationTransactionsServer ReservationTransactionsServer - ReservationsDetailsServer ReservationsDetailsServer - ReservationsSummariesServer ReservationsSummariesServer - TagsServer TagsServer - UsageDetailsServer UsageDetailsServer + + // ReservationRecommendationsServer contains the fakes for client ReservationRecommendationsClient + ReservationRecommendationsServer ReservationRecommendationsServer + + // ReservationTransactionsServer contains the fakes for client ReservationTransactionsClient + ReservationTransactionsServer ReservationTransactionsServer + + // ReservationsDetailsServer contains the fakes for client ReservationsDetailsClient + ReservationsDetailsServer ReservationsDetailsServer + + // ReservationsSummariesServer contains the fakes for client ReservationsSummariesClient + ReservationsSummariesServer ReservationsSummariesServer + + // TagsServer contains the fakes for client TagsClient + TagsServer TagsServer + + // UsageDetailsServer contains the fakes for client UsageDetailsClient + UsageDetailsServer UsageDetailsServer } // NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. diff --git a/sdk/resourcemanager/consumption/armconsumption/fake/tags_server.go b/sdk/resourcemanager/consumption/armconsumption/fake/tags_server.go index f30ca1a2a7e1..9e1bb49084a1 100644 --- a/sdk/resourcemanager/consumption/armconsumption/fake/tags_server.go +++ b/sdk/resourcemanager/consumption/armconsumption/fake/tags_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2" "net/http" "net/url" "regexp" @@ -49,21 +46,40 @@ func (t *TagsServerTransport) Do(req *http.Request) (*http.Response, error) { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return t.dispatchToMethodFake(req, method) +} - switch method { - case "TagsClient.Get": - resp, err = t.dispatchGet(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (t *TagsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if tagsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = tagsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "TagsClient.Get": + res.resp, res.err = t.dispatchGet(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (t *TagsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { @@ -94,3 +110,9 @@ func (t *TagsServerTransport) dispatchGet(req *http.Request) (*http.Response, er } return resp, nil } + +// set this to conditionally intercept incoming requests to TagsServerTransport +var tagsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/consumption/armconsumption/fake/time_rfc3339.go b/sdk/resourcemanager/consumption/armconsumption/fake/time_rfc3339.go deleted file mode 100644 index b0535a7b63e6..000000000000 --- a/sdk/resourcemanager/consumption/armconsumption/fake/time_rfc3339.go +++ /dev/null @@ -1,86 +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. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package fake - -import ( - "encoding/json" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" - "regexp" - "strings" - "time" -) - -// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. -var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) - -const ( - utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` - utcDateTime = "2006-01-02T15:04:05.999999999" - dateTimeJSON = `"` + time.RFC3339Nano + `"` -) - -type dateTimeRFC3339 time.Time - -func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { - tt := time.Time(t) - return tt.MarshalJSON() -} - -func (t dateTimeRFC3339) MarshalText() ([]byte, error) { - tt := time.Time(t) - return tt.MarshalText() -} - -func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcDateTimeJSON - if tzOffsetRegex.Match(data) { - layout = dateTimeJSON - } - return t.Parse(layout, string(data)) -} - -func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { - layout := utcDateTime - if tzOffsetRegex.Match(data) { - layout = time.RFC3339Nano - } - return t.Parse(layout, string(data)) -} - -func (t *dateTimeRFC3339) Parse(layout, value string) error { - p, err := time.Parse(layout, strings.ToUpper(value)) - *t = dateTimeRFC3339(p) - return err -} - -func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { - if t == nil { - return - } else if azcore.IsNullValue(t) { - m[k] = nil - return - } else if reflect.ValueOf(t).IsNil() { - return - } - m[k] = (*dateTimeRFC3339)(t) -} - -func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { - if data == nil || strings.EqualFold(string(data), "null") { - return nil - } - var aux dateTimeRFC3339 - if err := json.Unmarshal(data, &aux); err != nil { - return fmt.Errorf("struct field %s: %v", fn, err) - } - *t = (*time.Time)(&aux) - return nil -} diff --git a/sdk/resourcemanager/consumption/armconsumption/fake/usagedetails_server.go b/sdk/resourcemanager/consumption/armconsumption/fake/usagedetails_server.go index fd4b49758831..9e366ba3c79d 100644 --- a/sdk/resourcemanager/consumption/armconsumption/fake/usagedetails_server.go +++ b/sdk/resourcemanager/consumption/armconsumption/fake/usagedetails_server.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -15,7 +12,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2" "net/http" "net/url" "regexp" @@ -54,21 +51,40 @@ func (u *UsageDetailsServerTransport) Do(req *http.Request) (*http.Response, err return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return u.dispatchToMethodFake(req, method) +} - switch method { - case "UsageDetailsClient.NewListPager": - resp, err = u.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (u *UsageDetailsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if usageDetailsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = usageDetailsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "UsageDetailsClient.NewListPager": + res.resp, res.err = u.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (u *UsageDetailsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { @@ -152,3 +168,9 @@ func (u *UsageDetailsServerTransport) dispatchNewListPager(req *http.Request) (* } return resp, nil } + +// set this to conditionally intercept incoming requests to UsageDetailsServerTransport +var usageDetailsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/consumption/armconsumption/go.mod b/sdk/resourcemanager/consumption/armconsumption/go.mod index df1b26c227ed..b98300552cef 100644 --- a/sdk/resourcemanager/consumption/armconsumption/go.mod +++ b/sdk/resourcemanager/consumption/armconsumption/go.mod @@ -1,21 +1,11 @@ -module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2 go 1.23.0 -require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.2 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2 // indirect - github.com/golang-jwt/jwt/v5 v5.2.2 // indirect - github.com/google/uuid v1.6.0 // indirect - github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect - golang.org/x/crypto v0.36.0 // indirect golang.org/x/net v0.38.0 // indirect - golang.org/x/sys v0.31.0 // indirect golang.org/x/text v0.23.0 // indirect ) diff --git a/sdk/resourcemanager/consumption/armconsumption/go.sum b/sdk/resourcemanager/consumption/armconsumption/go.sum index 4bacf756f06c..4de695d9e23a 100644 --- a/sdk/resourcemanager/consumption/armconsumption/go.sum +++ b/sdk/resourcemanager/consumption/armconsumption/go.sum @@ -1,44 +1,15 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 h1:DSDNVxqkoXJiko6x8a90zidoYqnYYa6c1MTzDKzKkTo= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1/go.mod h1:zGqV2R4Cr/k8Uye5w+dgQ06WJtEcbQG/8J7BB6hnCr4= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.2 h1:F0gBpfdPLGsw+nsgk6aqqkZS1jiixa5WwFe3fk/T3Ys= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.2/go.mod h1:SqINnQ9lVVdRlyC8cd1lCI0SdX4n2paeABd2K8ggfnE= -github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.3.2 h1:yz1bePFlP5Vws5+8ez6T3HWXPmwOK7Yvq8QxDBD3SKY= -github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.3.2/go.mod h1:Pa9ZNPuoNu/GztvBSKk9J1cDJW6vk/n0zLtV4mgd8N8= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY= -github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1 h1:WJTmL004Abzc5wDB5VtZG2PJk5ndYDgVacGqfirKxjM= -github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1/go.mod h1:tCcJZ0uHAmvjsVYzEFivsRTN00oz5BEsRgQHu5JZ9WE= -github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2 h1:oygO0locgZJe7PpYPXT5A29ZkwJaPqcva7BVeemZOZs= -github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= -github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= -github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= -github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= -github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8= -github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/keybase/go-keychain v0.0.0-20231219164618-57a3676c3af6 h1:IsMZxCuZqKuao2vNdfD82fjjgPLfyHLpR41Z88viRWs= -github.com/keybase/go-keychain v0.0.0-20231219164618-57a3676c3af6/go.mod h1:3VeWNIJaW+O5xpRQbPp0Ybqu1vJd/pm7s2F473HRrkw= -github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= -github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/redis/go-redis/v9 v9.7.0 h1:HhLSs+B6O021gwzl+locl0zEDnyNkxMtf/Z3NNBMa9E= -github.com/redis/go-redis/v9 v9.7.0/go.mod h1:f6zhXITC7JUJIlPEiBOTXxJgPLdZcA93GewI7inzyWw= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34= -golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc= golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8= golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= -golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/consumption/armconsumption/interfaces.go b/sdk/resourcemanager/consumption/armconsumption/interfaces.go index 7acac002c845..534ab83de6cc 100644 --- a/sdk/resourcemanager/consumption/armconsumption/interfaces.go +++ b/sdk/resourcemanager/consumption/armconsumption/interfaces.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -26,6 +23,15 @@ type LegacyReservationRecommendationPropertiesClassification interface { GetLegacyReservationRecommendationProperties() *LegacyReservationRecommendationProperties } +// ModernReservationRecommendationPropertiesClassification provides polymorphic access to related types. +// Call the interface's GetModernReservationRecommendationProperties() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *ModernReservationRecommendationProperties, *ModernSharedScopeReservationRecommendationProperties, *ModernSingleScopeReservationRecommendationProperties +type ModernReservationRecommendationPropertiesClassification interface { + // GetModernReservationRecommendationProperties returns the ModernReservationRecommendationProperties content of the underlying type. + GetModernReservationRecommendationProperties() *ModernReservationRecommendationProperties +} + // ReservationRecommendationClassification provides polymorphic access to related types. // Call the interface's GetReservationRecommendation() method to access the common type. // Use a type switch to determine the concrete type. The possible types are: diff --git a/sdk/resourcemanager/consumption/armconsumption/lots_client.go b/sdk/resourcemanager/consumption/armconsumption/lots_client.go index e6f067e36756..7f14bd150062 100644 --- a/sdk/resourcemanager/consumption/armconsumption/lots_client.go +++ b/sdk/resourcemanager/consumption/armconsumption/lots_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -43,7 +40,7 @@ func NewLotsClient(credential azcore.TokenCredential, options *arm.ClientOptions // NewListByBillingAccountPager - Lists all Microsoft Azure consumption commitments for a billing account. The API is only // supported for Microsoft Customer Agreements (MCA) and Direct Enterprise Agreement (EA) billing accounts. // -// Generated from API version 2021-10-01 +// Generated from API version 2025-04-01 // - billingAccountID - BillingAccount ID // - options - LotsClientListByBillingAccountOptions contains the optional parameters for the LotsClient.NewListByBillingAccountPager // method. @@ -82,10 +79,10 @@ func (client *LotsClient) listByBillingAccountCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-10-01") if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -103,7 +100,7 @@ func (client *LotsClient) listByBillingAccountHandleResponse(resp *http.Response // NewListByBillingProfilePager - Lists all Azure credits for a billing account or a billing profile. The API is only supported // for Microsoft Customer Agreements (MCA) billing accounts. // -// Generated from API version 2021-10-01 +// Generated from API version 2025-04-01 // - billingAccountID - BillingAccount ID // - billingProfileID - Azure Billing Profile ID. // - options - LotsClientListByBillingProfileOptions contains the optional parameters for the LotsClient.NewListByBillingProfilePager @@ -132,7 +129,7 @@ func (client *LotsClient) NewListByBillingProfilePager(billingAccountID string, } // listByBillingProfileCreateRequest creates the ListByBillingProfile request. -func (client *LotsClient) listByBillingProfileCreateRequest(ctx context.Context, billingAccountID string, billingProfileID string, options *LotsClientListByBillingProfileOptions) (*policy.Request, error) { +func (client *LotsClient) listByBillingProfileCreateRequest(ctx context.Context, billingAccountID string, billingProfileID string, _ *LotsClientListByBillingProfileOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.Consumption/lots" if billingAccountID == "" { return nil, errors.New("parameter billingAccountID cannot be empty") @@ -147,7 +144,7 @@ func (client *LotsClient) listByBillingProfileCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-10-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -165,7 +162,7 @@ func (client *LotsClient) listByBillingProfileHandleResponse(resp *http.Response // NewListByCustomerPager - Lists all Azure credits for a customer. The API is only supported for Microsoft Partner Agreements // (MPA) billing accounts. // -// Generated from API version 2021-10-01 +// Generated from API version 2025-04-01 // - billingAccountID - BillingAccount ID // - customerID - Customer ID // - options - LotsClientListByCustomerOptions contains the optional parameters for the LotsClient.NewListByCustomerPager method. @@ -208,10 +205,10 @@ func (client *LotsClient) listByCustomerCreateRequest(ctx context.Context, billi return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-10-01") if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/consumption/armconsumption/lots_client_example_test.go b/sdk/resourcemanager/consumption/armconsumption/lots_client_example_test.go deleted file mode 100644 index ef5be0a336e0..000000000000 --- a/sdk/resourcemanager/consumption/armconsumption/lots_client_example_test.go +++ /dev/null @@ -1,342 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armconsumption_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/consumption/armconsumption" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/LotsListByBillingProfile.json -func ExampleLotsClient_NewListByBillingProfilePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewLotsClient().NewListByBillingProfilePager("1234:5678", "2468", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.Lots = armconsumption.Lots{ - // Value: []*armconsumption.LotSummary{ - // { - // Name: to.Ptr("lot1"), - // Type: to.Ptr("Microsoft.Consumption/lots"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:5678/billingProfiles/2468/providers/Microsoft.Consumption/lots/lot1"), - // Properties: &armconsumption.LotProperties{ - // BillingCurrency: to.Ptr("USD"), - // ClosedBalance: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](60.9), - // }, - // ClosedBalanceInBillingCurrency: &armconsumption.AmountWithExchangeRate{ - // ExchangeRate: to.Ptr[float64](5000), - // ExchangeRateMonth: to.Ptr[int32](1), - // }, - // CreditCurrency: to.Ptr("USD"), - // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-10-01T00:00:00.000Z"); return t}()), - // OriginalAmount: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](5000), - // }, - // OriginalAmountInBillingCurrency: &armconsumption.AmountWithExchangeRate{ - // ExchangeRate: to.Ptr[float64](5000), - // ExchangeRateMonth: to.Ptr[int32](1), - // }, - // PoNumber: to.Ptr("3524"), - // Reseller: &armconsumption.Reseller{ - // ResellerDescription: to.Ptr("Reseller information."), - // ResellerID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:5678/billingProfiles/2468/providers/Microsoft.Consumption/reseller/reseller1"), - // }, - // Source: to.Ptr(armconsumption.LotSourcePurchasedCredit), - // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-10-01T00:00:00.000Z"); return t}()), - // }, - // }, - // { - // Name: to.Ptr("lot2"), - // Type: to.Ptr("Microsoft.Consumption/lots"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:5678/billingProfiles/2468/providers/Microsoft.Consumption/lots/lot2"), - // Properties: &armconsumption.LotProperties{ - // BillingCurrency: to.Ptr("USD"), - // ClosedBalance: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](80.9), - // }, - // ClosedBalanceInBillingCurrency: &armconsumption.AmountWithExchangeRate{ - // ExchangeRate: to.Ptr[float64](5000), - // ExchangeRateMonth: to.Ptr[int32](1), - // }, - // CreditCurrency: to.Ptr("USD"), - // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-12-31T00:00:00.000Z"); return t}()), - // OriginalAmount: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](6000), - // }, - // OriginalAmountInBillingCurrency: &armconsumption.AmountWithExchangeRate{ - // ExchangeRate: to.Ptr[float64](5000), - // ExchangeRateMonth: to.Ptr[int32](1), - // }, - // PoNumber: to.Ptr("31224"), - // Reseller: &armconsumption.Reseller{ - // ResellerDescription: to.Ptr("Reseller information."), - // ResellerID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:5678/billingProfiles/2468/providers/Microsoft.Consumption/reseller/reseller2"), - // }, - // Source: to.Ptr(armconsumption.LotSourcePurchasedCredit), - // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-10-01T00:00:00.000Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/LotsListByBillingAccount.json -func ExampleLotsClient_NewListByBillingAccountPager_lotsListByBillingAccount() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewLotsClient().NewListByBillingAccountPager("1234:5678", &armconsumption.LotsClientListByBillingAccountOptions{Filter: nil}) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.Lots = armconsumption.Lots{ - // Value: []*armconsumption.LotSummary{ - // { - // Name: to.Ptr("lot1"), - // Type: to.Ptr("Microsoft.Consumption/lots"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:5678/billingProfiles/2468/providers/Microsoft.Consumption/lots/lot1"), - // Properties: &armconsumption.LotProperties{ - // ClosedBalance: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](60.9), - // }, - // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-11-01T00:00:00.000Z"); return t}()), - // OriginalAmount: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](5000), - // }, - // PurchasedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-01T00:00:00.000Z"); return t}()), - // Source: to.Ptr(armconsumption.LotSourceConsumptionCommitment), - // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-01T00:00:00.000Z"); return t}()), - // Status: to.Ptr(armconsumption.StatusActive), - // }, - // }, - // { - // Name: to.Ptr("lot2"), - // Type: to.Ptr("Microsoft.Consumption/lots"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:5678/billingProfiles/2468/providers/Microsoft.Consumption/lots/lot2"), - // Properties: &armconsumption.LotProperties{ - // ClosedBalance: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](80.9), - // }, - // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-12-31T00:00:00.000Z"); return t}()), - // OriginalAmount: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](6000), - // }, - // PurchasedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-01T00:00:00.000Z"); return t}()), - // Source: to.Ptr(armconsumption.LotSourceConsumptionCommitment), - // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-11-01T00:00:00.000Z"); return t}()), - // Status: to.Ptr(armconsumption.StatusExpired), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/LotsListByBillingAccountWithFilters.json -func ExampleLotsClient_NewListByBillingAccountPager_lotsListByBillingAccountWithStatusFilter() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewLotsClient().NewListByBillingAccountPager("1234:5678", &armconsumption.LotsClientListByBillingAccountOptions{Filter: to.Ptr("status eq 'active' AND source eq 'consumptioncommitment'")}) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.Lots = armconsumption.Lots{ - // Value: []*armconsumption.LotSummary{ - // { - // Name: to.Ptr("lot1"), - // Type: to.Ptr("Microsoft.Consumption/lots"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234:5678/billingProfiles/2468/providers/Microsoft.Consumption/lots/lot1"), - // Properties: &armconsumption.LotProperties{ - // ClosedBalance: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](60.9), - // }, - // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-11-01T00:00:00.000Z"); return t}()), - // OriginalAmount: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](5000), - // }, - // PurchasedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-01T00:00:00.000Z"); return t}()), - // Source: to.Ptr(armconsumption.LotSourceConsumptionCommitment), - // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-01T00:00:00.000Z"); return t}()), - // Status: to.Ptr(armconsumption.StatusActive), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/LotsListByCustomer.json -func ExampleLotsClient_NewListByCustomerPager_lotsListByCustomer() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewLotsClient().NewListByCustomerPager("1234:5678", "1234:5678", &armconsumption.LotsClientListByCustomerOptions{Filter: nil}) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.Lots = armconsumption.Lots{ - // Value: []*armconsumption.LotSummary{ - // { - // Name: to.Ptr("lot1"), - // Type: to.Ptr("Microsoft.Consumption/lots"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234/customers/456/providers/Microsoft.Consumption/lots/lot1"), - // Properties: &armconsumption.LotProperties{ - // ClosedBalance: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](60.9), - // }, - // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-01T00:00:00.000Z"); return t}()), - // OriginalAmount: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](5000), - // }, - // PoNumber: to.Ptr("3524"), - // Source: to.Ptr(armconsumption.LotSourcePurchasedCredit), - // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-01T00:00:00.000Z"); return t}()), - // }, - // }, - // { - // Name: to.Ptr("lot2"), - // Type: to.Ptr("Microsoft.Consumption/lots"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234/customers/456/providers/Microsoft.Consumption/lots/lot2"), - // Properties: &armconsumption.LotProperties{ - // ClosedBalance: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](80.9), - // }, - // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-12-31T00:00:00.000Z"); return t}()), - // OriginalAmount: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](6000), - // }, - // PoNumber: to.Ptr("31224"), - // Source: to.Ptr(armconsumption.LotSourcePurchasedCredit), - // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-01T00:00:00.000Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/LotsListByCustomerWithFilters.json -func ExampleLotsClient_NewListByCustomerPager_lotsListByCustomerWithFilter() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewLotsClient().NewListByCustomerPager("1234:5678", "1234:5678", &armconsumption.LotsClientListByCustomerOptions{Filter: to.Ptr("status eq 'active' AND source eq 'consumptioncommitment'")}) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.Lots = armconsumption.Lots{ - // Value: []*armconsumption.LotSummary{ - // { - // Name: to.Ptr("lot1"), - // Type: to.Ptr("Microsoft.Consumption/lots"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/1234/customers/456/providers/Microsoft.Consumption/lots/lot1"), - // Properties: &armconsumption.LotProperties{ - // ClosedBalance: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](60.9), - // }, - // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-01T00:00:00.000Z"); return t}()), - // OriginalAmount: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](5000), - // }, - // PoNumber: to.Ptr("3524"), - // Source: to.Ptr(armconsumption.LotSourcePurchasedCredit), - // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-01T00:00:00.000Z"); return t}()), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/consumption/armconsumption/marketplaces_client.go b/sdk/resourcemanager/consumption/armconsumption/marketplaces_client.go index bd36d316fd56..f02f583205d4 100644 --- a/sdk/resourcemanager/consumption/armconsumption/marketplaces_client.go +++ b/sdk/resourcemanager/consumption/armconsumption/marketplaces_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -42,7 +39,7 @@ func NewMarketplacesClient(credential azcore.TokenCredential, options *arm.Clien // NewListPager - Lists the marketplaces for a scope at the defined scope. Marketplaces are available via this API only for // May 1, 2014 or later. // -// Generated from API version 2021-10-01 +// Generated from API version 2025-04-01 // - scope - The scope associated with marketplace operations. This includes '/subscriptions/{subscriptionId}/' for subscription // scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing // Account scope, '/providers/Microsoft.Billing/departments/{departmentId}' for Department scope, '/providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}' @@ -88,13 +85,13 @@ func (client *MarketplacesClient) listCreateRequest(ctx context.Context, scope s if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - if options != nil && options.Top != nil { - reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) - } if options != nil && options.Skiptoken != nil { reqQP.Set("$skiptoken", *options.Skiptoken) } - reqQP.Set("api-version", "2021-10-01") + if options != nil && options.Top != nil { + reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) + } + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/consumption/armconsumption/marketplaces_client_example_test.go b/sdk/resourcemanager/consumption/armconsumption/marketplaces_client_example_test.go deleted file mode 100644 index 52813b275672..000000000000 --- a/sdk/resourcemanager/consumption/armconsumption/marketplaces_client_example_test.go +++ /dev/null @@ -1,746 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armconsumption_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/MarketplacesByBillingAccountList.json -func ExampleMarketplacesClient_NewListPager_billingAccountMarketplacesList() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewMarketplacesClient().NewListPager("providers/Microsoft.Billing/billingAccounts/123456", &armconsumption.MarketplacesClientListOptions{Filter: nil, - Top: nil, - Skiptoken: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.MarketplacesListResult = armconsumption.MarketplacesListResult{ - // Value: []*armconsumption.Marketplace{ - // { - // Name: to.Ptr("marketplaceId1"), - // Type: to.Ptr("Microsoft.Consumption/marketPlaces"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.Billing/billingPeriods/201702/providers/Microsoft.Consumption/marketplaces/marketplaceId1"), - // Tags: map[string]*string{ - // "dev": to.Ptr("tools"), - // "env": to.Ptr("newcrp"), - // }, - // Properties: &armconsumption.MarketplaceProperties{ - // AccountName: to.Ptr("Account1"), - // AdditionalProperties: to.Ptr("additionalProperties"), - // BillingPeriodID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.Billing/billingPeriods/201702"), - // ConsumedQuantity: to.Ptr[float64](0.00328), - // CostCenter: to.Ptr("Center1"), - // Currency: to.Ptr("USD"), - // DepartmentName: to.Ptr("Department1"), - // InstanceID: to.Ptr("/subscriptions/subid/resourceGroups/Default-Web-eastasia/providers/Microsoft.Web/sites/shared1"), - // InstanceName: to.Ptr("shared1"), - // IsEstimated: to.Ptr(false), - // IsRecurringCharge: to.Ptr(false), - // OfferName: to.Ptr("offer1"), - // OrderNumber: to.Ptr("00000000-0000-0000-0000-000000000000"), - // PlanName: to.Ptr("plan1"), - // PretaxCost: to.Ptr[float64](0.67), - // PublisherName: to.Ptr("xyz"), - // ResourceGroup: to.Ptr("TEST"), - // ResourceRate: to.Ptr[float64](0.24), - // SubscriptionGUID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // SubscriptionName: to.Ptr("azure subscription"), - // UnitOfMeasure: to.Ptr("10 Hours"), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-13T23:59:59.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-13T00:00:00.000Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/MarketplacesByBillingAccountListForBillingPeriod.json -func ExampleMarketplacesClient_NewListPager_billingAccountMarketplacesListForBillingPeriod() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewMarketplacesClient().NewListPager("providers/Microsoft.Billing/billingAccounts/123456", &armconsumption.MarketplacesClientListOptions{Filter: nil, - Top: nil, - Skiptoken: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.MarketplacesListResult = armconsumption.MarketplacesListResult{ - // Value: []*armconsumption.Marketplace{ - // { - // Name: to.Ptr("marketplacesId1"), - // Type: to.Ptr("Microsoft.Consumption/marketPlaces"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.Billing/billingPeriods/201702/providers/Microsoft.Consumption/marketplaces/marketplaceId1"), - // Tags: map[string]*string{ - // "dev": to.Ptr("tools"), - // "env": to.Ptr("newcrp"), - // }, - // Properties: &armconsumption.MarketplaceProperties{ - // AccountName: to.Ptr("Account1"), - // AdditionalProperties: to.Ptr("additionalProperties"), - // BillingPeriodID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.Billing/billingPeriods/201702"), - // ConsumedQuantity: to.Ptr[float64](0.00328), - // CostCenter: to.Ptr("Center1"), - // Currency: to.Ptr("USD"), - // DepartmentName: to.Ptr("Department1"), - // InstanceID: to.Ptr("/subscriptions/subid/resourceGroups/Default-Web-eastasia/providers/Microsoft.Web/sites/shared1"), - // InstanceName: to.Ptr("shared1"), - // IsEstimated: to.Ptr(false), - // IsRecurringCharge: to.Ptr(false), - // MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // OfferName: to.Ptr("offer1"), - // OrderNumber: to.Ptr("00000000-0000-0000-0000-000000000000"), - // PlanName: to.Ptr("plan2"), - // PretaxCost: to.Ptr[float64](0.67), - // PublisherName: to.Ptr("xyz"), - // ResourceGroup: to.Ptr("TEST"), - // ResourceRate: to.Ptr[float64](0.24), - // SubscriptionGUID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // SubscriptionName: to.Ptr("azure subscription"), - // UnitOfMeasure: to.Ptr("10 Hours"), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-13T23:59:59.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-13T00:00:00.000Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/MarketplacesByDepartmentList.json -func ExampleMarketplacesClient_NewListPager_departmentMarketplacesList() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewMarketplacesClient().NewListPager("providers/Microsoft.Billing/departments/123456", &armconsumption.MarketplacesClientListOptions{Filter: nil, - Top: nil, - Skiptoken: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.MarketplacesListResult = armconsumption.MarketplacesListResult{ - // Value: []*armconsumption.Marketplace{ - // { - // Name: to.Ptr("marketplacesId1"), - // Type: to.Ptr("Microsoft.Consumption/marketPlaces"), - // ID: to.Ptr("/providers/Microsoft.Billing/departments/123456/providers/Microsoft.Billing/billingPeriods/201702/providers/Microsoft.Consumption/marketplaces/marketplaceId1"), - // Tags: map[string]*string{ - // "dev": to.Ptr("tools"), - // "env": to.Ptr("newcrp"), - // }, - // Properties: &armconsumption.MarketplaceProperties{ - // AccountName: to.Ptr("Account1"), - // AdditionalProperties: to.Ptr("additionalProperties"), - // BillingPeriodID: to.Ptr("/providers/Microsoft.Billing/departments/123456/providers/Microsoft.Billing/billingPeriods/201702"), - // ConsumedQuantity: to.Ptr[float64](0.00328), - // CostCenter: to.Ptr("Center1"), - // Currency: to.Ptr("USD"), - // DepartmentName: to.Ptr("Department1"), - // InstanceID: to.Ptr("/subscriptions/subid/resourceGroups/Default-Web-eastasia/providers/Microsoft.Web/sites/shared1"), - // InstanceName: to.Ptr("shared1"), - // IsEstimated: to.Ptr(false), - // IsRecurringCharge: to.Ptr(false), - // MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // OfferName: to.Ptr("offer1"), - // OrderNumber: to.Ptr("00000000-0000-0000-0000-000000000000"), - // PlanName: to.Ptr("plan2"), - // PretaxCost: to.Ptr[float64](0.67), - // PublisherName: to.Ptr("xyz"), - // ResourceGroup: to.Ptr("TEST"), - // ResourceRate: to.Ptr[float64](0.24), - // SubscriptionGUID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // SubscriptionName: to.Ptr("azure subscription"), - // UnitOfMeasure: to.Ptr("10 Hours"), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-13T23:59:59.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-13T00:00:00.000Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/MarketplacesByDepartment_ListByBillingPeriod.json -func ExampleMarketplacesClient_NewListPager_departmentMarketplacesListForBillingPeriod() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewMarketplacesClient().NewListPager("providers/Microsoft.Billing/departments/123456", &armconsumption.MarketplacesClientListOptions{Filter: nil, - Top: nil, - Skiptoken: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.MarketplacesListResult = armconsumption.MarketplacesListResult{ - // Value: []*armconsumption.Marketplace{ - // { - // Name: to.Ptr("marketplacesId1"), - // Type: to.Ptr("Microsoft.Consumption/marketPlaces"), - // ID: to.Ptr("/providers/Microsoft.Billing/departments/123456/providers/Microsoft.Billing/billingPeriods/201702/providers/Microsoft.Consumption/marketplaces/marketplaceId1"), - // Tags: map[string]*string{ - // "dev": to.Ptr("tools"), - // "env": to.Ptr("newcrp"), - // }, - // Properties: &armconsumption.MarketplaceProperties{ - // AccountName: to.Ptr("Account1"), - // AdditionalProperties: to.Ptr("additionalProperties"), - // BillingPeriodID: to.Ptr("/providers/Microsoft.Billing/departments/123456/providers/Microsoft.Billing/billingPeriods/201702"), - // ConsumedQuantity: to.Ptr[float64](0.00328), - // CostCenter: to.Ptr("Center1"), - // Currency: to.Ptr("USD"), - // DepartmentName: to.Ptr("Department1"), - // InstanceID: to.Ptr("/subscriptions/subid/resourceGroups/Default-Web-eastasia/providers/Microsoft.Web/sites/shared1"), - // InstanceName: to.Ptr("shared1"), - // IsEstimated: to.Ptr(false), - // IsRecurringCharge: to.Ptr(false), - // MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // OfferName: to.Ptr("offer1"), - // OrderNumber: to.Ptr("00000000-0000-0000-0000-000000000000"), - // PlanName: to.Ptr("plan2"), - // PretaxCost: to.Ptr[float64](0.67), - // PublisherName: to.Ptr("xyz"), - // ResourceGroup: to.Ptr("TEST"), - // ResourceRate: to.Ptr[float64](0.24), - // SubscriptionGUID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // SubscriptionName: to.Ptr("azure subscription"), - // UnitOfMeasure: to.Ptr("10 Hours"), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-13T23:59:59.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-13T00:00:00.000Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/MarketplacesByEnrollmentAccountList.json -func ExampleMarketplacesClient_NewListPager_enrollmentAccountMarketplacesList() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewMarketplacesClient().NewListPager("providers/Microsoft.Billing/enrollmentAccounts/123456", &armconsumption.MarketplacesClientListOptions{Filter: nil, - Top: nil, - Skiptoken: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.MarketplacesListResult = armconsumption.MarketplacesListResult{ - // Value: []*armconsumption.Marketplace{ - // { - // Name: to.Ptr("marketplacesId1"), - // Type: to.Ptr("Microsoft.Consumption/marketPlaces"), - // ID: to.Ptr("/providers/Microsoft.Billing/enrollmentAccounts/123456/providers/Microsoft.Billing/billingPeriods/201702/providers/Microsoft.Consumption/marketplaces/marketplaceId1"), - // Tags: map[string]*string{ - // "dev": to.Ptr("tools"), - // "env": to.Ptr("newcrp"), - // }, - // Properties: &armconsumption.MarketplaceProperties{ - // AccountName: to.Ptr("Account1"), - // AdditionalProperties: to.Ptr("additionalProperties"), - // BillingPeriodID: to.Ptr("/providers/Microsoft.Billing/enrollmentAccounts/123456/providers/Microsoft.Billing/billingPeriods/201702"), - // ConsumedQuantity: to.Ptr[float64](0.00328), - // CostCenter: to.Ptr("Center1"), - // Currency: to.Ptr("USD"), - // DepartmentName: to.Ptr("Department1"), - // InstanceID: to.Ptr("/subscriptions/subid/resourceGroups/Default-Web-eastasia/providers/Microsoft.Web/sites/shared1"), - // InstanceName: to.Ptr("shared1"), - // IsEstimated: to.Ptr(false), - // IsRecurringCharge: to.Ptr(false), - // MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // OfferName: to.Ptr("offer1"), - // OrderNumber: to.Ptr("00000000-0000-0000-0000-000000000000"), - // PlanName: to.Ptr("plan2"), - // PretaxCost: to.Ptr[float64](0.67), - // PublisherName: to.Ptr("xyz"), - // ResourceGroup: to.Ptr("TEST"), - // ResourceRate: to.Ptr[float64](0.24), - // SubscriptionGUID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // SubscriptionName: to.Ptr("azure subscription"), - // UnitOfMeasure: to.Ptr("10 Hours"), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-13T23:59:59.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-13T00:00:00.000Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/MarketplacesByEnrollmentAccounts_ListByBillingPeriod.json -func ExampleMarketplacesClient_NewListPager_enrollmentAccountMarketplacesListForBillingPeriod() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewMarketplacesClient().NewListPager("providers/Microsoft.Billing/enrollmentAccounts/123456", &armconsumption.MarketplacesClientListOptions{Filter: nil, - Top: nil, - Skiptoken: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.MarketplacesListResult = armconsumption.MarketplacesListResult{ - // Value: []*armconsumption.Marketplace{ - // { - // Name: to.Ptr("marketplacesId1"), - // Type: to.Ptr("Microsoft.Consumption/marketPlaces"), - // ID: to.Ptr("/providers/Microsoft.Billing/enrollmentAccounts/123456/providers/Microsoft.Billing/billingPeriods/201702/providers/Microsoft.Consumption/marketplaces/marketplaceId1"), - // Tags: map[string]*string{ - // "dev": to.Ptr("tools"), - // "env": to.Ptr("newcrp"), - // }, - // Properties: &armconsumption.MarketplaceProperties{ - // AccountName: to.Ptr("Account1"), - // AdditionalProperties: to.Ptr("additionalProperties"), - // BillingPeriodID: to.Ptr("/providers/Microsoft.Billing/enrollmentAccounts/123456/providers/Microsoft.Billing/billingPeriods/201702"), - // ConsumedQuantity: to.Ptr[float64](0.00328), - // CostCenter: to.Ptr("Center1"), - // Currency: to.Ptr("USD"), - // DepartmentName: to.Ptr("Department1"), - // InstanceID: to.Ptr("/subscriptions/subid/resourceGroups/Default-Web-eastasia/providers/Microsoft.Web/sites/shared1"), - // InstanceName: to.Ptr("shared1"), - // IsEstimated: to.Ptr(false), - // IsRecurringCharge: to.Ptr(false), - // MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // OfferName: to.Ptr("offer1"), - // OrderNumber: to.Ptr("00000000-0000-0000-0000-000000000000"), - // PlanName: to.Ptr("plan2"), - // PretaxCost: to.Ptr[float64](0.67), - // PublisherName: to.Ptr("xyz"), - // ResourceGroup: to.Ptr("TEST"), - // ResourceRate: to.Ptr[float64](0.24), - // SubscriptionGUID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // SubscriptionName: to.Ptr("azure subscription"), - // UnitOfMeasure: to.Ptr("10 Hours"), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-13T23:59:59.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-13T00:00:00.000Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/MarketplacesByManagementGroupList.json -func ExampleMarketplacesClient_NewListPager_managementGroupMarketplacesList() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewMarketplacesClient().NewListPager("subscriptions/00000000-0000-0000-0000-000000000000", &armconsumption.MarketplacesClientListOptions{Filter: nil, - Top: nil, - Skiptoken: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.MarketplacesListResult = armconsumption.MarketplacesListResult{ - // Value: []*armconsumption.Marketplace{ - // { - // Name: to.Ptr("marketplacesId1"), - // Type: to.Ptr("Microsoft.Consumption/marketPlaces"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Billing/billingPeriods/201810/providers/Microsoft.Consumption/marketplaces/marketplaceId1"), - // Tags: map[string]*string{ - // "dev": to.Ptr("tools"), - // "env": to.Ptr("newcrp"), - // }, - // Properties: &armconsumption.MarketplaceProperties{ - // AccountName: to.Ptr("Account1"), - // AdditionalProperties: to.Ptr("additionalProperties"), - // BillingPeriodID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Billing/billingPeriods/201810"), - // ConsumedQuantity: to.Ptr[float64](0.00328), - // CostCenter: to.Ptr("Center1"), - // Currency: to.Ptr("USD"), - // DepartmentName: to.Ptr("Department1"), - // InstanceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Default-Web-eastasia/providers/Microsoft.Web/sites/shared1"), - // InstanceName: to.Ptr("shared1"), - // IsEstimated: to.Ptr(false), - // IsRecurringCharge: to.Ptr(false), - // MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // OfferName: to.Ptr("offer1"), - // OrderNumber: to.Ptr("00000000-0000-0000-0000-000000000000"), - // PlanName: to.Ptr("plan2"), - // PretaxCost: to.Ptr[float64](0.67), - // PublisherName: to.Ptr("xyz"), - // ResourceGroup: to.Ptr("TEST"), - // ResourceRate: to.Ptr[float64](0.24), - // SubscriptionGUID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // SubscriptionName: to.Ptr("azure subscription"), - // UnitOfMeasure: to.Ptr("10 Hours"), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-13T23:59:59.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-13T00:00:00.000Z"); return t}()), - // }, - // }, - // { - // Name: to.Ptr("marketplacesId2"), - // Type: to.Ptr("Microsoft.Consumption/marketPlaces"), - // ID: to.Ptr("/subscriptions/11111111-1111-1111-1111-111111111111/providers/Microsoft.Billing/billingPeriods/201810/providers/Microsoft.Consumption/marketplaces/marketplaceId2"), - // Tags: map[string]*string{ - // "dev": to.Ptr("tools"), - // "env": to.Ptr("newcrp"), - // }, - // Properties: &armconsumption.MarketplaceProperties{ - // AccountName: to.Ptr("Account2"), - // AdditionalProperties: to.Ptr("additionalProperties"), - // BillingPeriodID: to.Ptr("/subscriptions/11111111-1111-1111-1111-111111111111/providers/Microsoft.Billing/billingPeriods/201810"), - // ConsumedQuantity: to.Ptr[float64](0.00328), - // CostCenter: to.Ptr("Center2"), - // Currency: to.Ptr("USD"), - // DepartmentName: to.Ptr("Department2"), - // InstanceID: to.Ptr("/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/Default-Web-eastasia/providers/Microsoft.Web/sites/shared2"), - // InstanceName: to.Ptr("shared2"), - // IsEstimated: to.Ptr(false), - // IsRecurringCharge: to.Ptr(false), - // MeterID: to.Ptr("11111111-1111-1111-1111-111111111111"), - // OfferName: to.Ptr("offer1"), - // OrderNumber: to.Ptr("11111111-1111-1111-1111-111111111111"), - // PlanName: to.Ptr("plan2"), - // PretaxCost: to.Ptr[float64](0.67), - // PublisherName: to.Ptr("xyz"), - // ResourceGroup: to.Ptr("TEST"), - // ResourceRate: to.Ptr[float64](0.24), - // SubscriptionGUID: to.Ptr("11111111-1111-1111-1111-111111111111"), - // SubscriptionName: to.Ptr("azure subscription"), - // UnitOfMeasure: to.Ptr("10 Hours"), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-13T23:59:59.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-13T00:00:00.000Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/MarketplacesByManagementGroup_ListForBillingPeriod.json -func ExampleMarketplacesClient_NewListPager_managementGroupMarketplacesListForBillingPeriod() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewMarketplacesClient().NewListPager("subscriptions/00000000-0000-0000-0000-000000000000", &armconsumption.MarketplacesClientListOptions{Filter: nil, - Top: nil, - Skiptoken: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.MarketplacesListResult = armconsumption.MarketplacesListResult{ - // Value: []*armconsumption.Marketplace{ - // { - // Name: to.Ptr("marketplacesId1"), - // Type: to.Ptr("Microsoft.Consumption/marketPlaces"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Billing/billingPeriods/201808/providers/Microsoft.Consumption/marketplaces/marketplaceId1"), - // Tags: map[string]*string{ - // "dev": to.Ptr("tools"), - // "env": to.Ptr("newcrp"), - // }, - // Properties: &armconsumption.MarketplaceProperties{ - // AccountName: to.Ptr("Account1"), - // AdditionalProperties: to.Ptr("additionalProperties"), - // BillingPeriodID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Billing/billingPeriods/201808"), - // ConsumedQuantity: to.Ptr[float64](0.00328), - // CostCenter: to.Ptr("Center1"), - // Currency: to.Ptr("USD"), - // DepartmentName: to.Ptr("Department1"), - // InstanceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Default-Web-eastasia/providers/Microsoft.Web/sites/shared1"), - // InstanceName: to.Ptr("shared1"), - // IsEstimated: to.Ptr(false), - // IsRecurringCharge: to.Ptr(false), - // MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // OfferName: to.Ptr("offer1"), - // OrderNumber: to.Ptr("00000000-0000-0000-0000-000000000000"), - // PlanName: to.Ptr("plan2"), - // PretaxCost: to.Ptr[float64](0.67), - // PublisherName: to.Ptr("xyz"), - // ResourceGroup: to.Ptr("TEST"), - // ResourceRate: to.Ptr[float64](0.24), - // SubscriptionGUID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // SubscriptionName: to.Ptr("azure subscription"), - // UnitOfMeasure: to.Ptr("10 Hours"), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-13T23:59:59.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-13T00:00:00.000Z"); return t}()), - // }, - // }, - // { - // Name: to.Ptr("marketplacesId2"), - // Type: to.Ptr("Microsoft.Consumption/marketPlaces"), - // ID: to.Ptr("/subscriptions/11111111-1111-1111-1111-111111111111/providers/Microsoft.Billing/billingPeriods/201808/providers/Microsoft.Consumption/marketplaces/marketplaceId2"), - // Tags: map[string]*string{ - // "dev": to.Ptr("tools"), - // "env": to.Ptr("newcrp"), - // }, - // Properties: &armconsumption.MarketplaceProperties{ - // AccountName: to.Ptr("Account2"), - // AdditionalProperties: to.Ptr("additionalProperties"), - // BillingPeriodID: to.Ptr("/subscriptions/11111111-1111-1111-1111-111111111111/providers/Microsoft.Billing/billingPeriods/201810"), - // ConsumedQuantity: to.Ptr[float64](0.00328), - // CostCenter: to.Ptr("Center2"), - // Currency: to.Ptr("USD"), - // DepartmentName: to.Ptr("Department2"), - // InstanceID: to.Ptr("/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/Default-Web-eastasia/providers/Microsoft.Web/sites/shared2"), - // InstanceName: to.Ptr("shared2"), - // IsEstimated: to.Ptr(false), - // IsRecurringCharge: to.Ptr(false), - // MeterID: to.Ptr("11111111-1111-1111-1111-111111111111"), - // OfferName: to.Ptr("offer1"), - // OrderNumber: to.Ptr("11111111-1111-1111-1111-111111111111"), - // PlanName: to.Ptr("plan2"), - // PretaxCost: to.Ptr[float64](0.67), - // PublisherName: to.Ptr("xyz"), - // ResourceGroup: to.Ptr("TEST"), - // ResourceRate: to.Ptr[float64](0.24), - // SubscriptionGUID: to.Ptr("11111111-1111-1111-1111-111111111111"), - // SubscriptionName: to.Ptr("azure subscription"), - // UnitOfMeasure: to.Ptr("10 Hours"), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-13T23:59:59.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-13T00:00:00.000Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/MarketplacesList.json -func ExampleMarketplacesClient_NewListPager_subscriptionMarketplacesList() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewMarketplacesClient().NewListPager("subscriptions/00000000-0000-0000-0000-000000000000", &armconsumption.MarketplacesClientListOptions{Filter: nil, - Top: nil, - Skiptoken: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.MarketplacesListResult = armconsumption.MarketplacesListResult{ - // Value: []*armconsumption.Marketplace{ - // { - // Name: to.Ptr("marketplaceId1"), - // Type: to.Ptr("Microsoft.Consumption/marketPlaces"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Billing/billingPeriods/201702/providers/Microsoft.Consumption/marketPlaces/marketplaceId1"), - // Tags: map[string]*string{ - // "dev": to.Ptr("tools"), - // "env": to.Ptr("newcrp"), - // }, - // Properties: &armconsumption.MarketplaceProperties{ - // AccountName: to.Ptr("Account1"), - // AdditionalProperties: to.Ptr("additionalProperties"), - // BillingPeriodID: to.Ptr("/subscriptions/subid/providers/Microsoft.Billing/billingPeriods/201702"), - // ConsumedQuantity: to.Ptr[float64](0.00328), - // CostCenter: to.Ptr("Center1"), - // Currency: to.Ptr("USD"), - // DepartmentName: to.Ptr("Department1"), - // InstanceID: to.Ptr("/subscriptions/subid/resourceGroups/Default-Web-eastasia/providers/Microsoft.Web/sites/shared1"), - // InstanceName: to.Ptr("shared1"), - // IsEstimated: to.Ptr(false), - // IsRecurringCharge: to.Ptr(false), - // OfferName: to.Ptr("offer1"), - // OrderNumber: to.Ptr("00000000-0000-0000-0000-000000000000"), - // PlanName: to.Ptr("plan1"), - // PretaxCost: to.Ptr[float64](0.67), - // PublisherName: to.Ptr("xyz"), - // ResourceGroup: to.Ptr("TEST"), - // ResourceRate: to.Ptr[float64](0.24), - // SubscriptionGUID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // SubscriptionName: to.Ptr("azure subscription"), - // UnitOfMeasure: to.Ptr("10 Hours"), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-13T23:59:59.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-13T00:00:00.000Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/MarketplacesListForBillingPeriod.json -func ExampleMarketplacesClient_NewListPager_subscriptionMarketplacesListForBillingPeriod() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewMarketplacesClient().NewListPager("subscriptions/00000000-0000-0000-0000-000000000000", &armconsumption.MarketplacesClientListOptions{Filter: nil, - Top: nil, - Skiptoken: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.MarketplacesListResult = armconsumption.MarketplacesListResult{ - // Value: []*armconsumption.Marketplace{ - // { - // Name: to.Ptr("marketplacesId1"), - // Type: to.Ptr("Microsoft.Consumption/marketPlaces"), - // ID: to.Ptr("/subscriptions/subid/providers/Microsoft.Billing/billingPeriods/201702/providers/Microsoft.Consumption/marketPlaces/marketplacesId1"), - // Tags: map[string]*string{ - // "dev": to.Ptr("tools"), - // "env": to.Ptr("newcrp"), - // }, - // Properties: &armconsumption.MarketplaceProperties{ - // AccountName: to.Ptr("Account1"), - // AdditionalProperties: to.Ptr("additionalProperties"), - // BillingPeriodID: to.Ptr("/subscriptions/subid/providers/Microsoft.Billing/billingPeriods/201702"), - // ConsumedQuantity: to.Ptr[float64](0.00328), - // CostCenter: to.Ptr("Center1"), - // Currency: to.Ptr("USD"), - // DepartmentName: to.Ptr("Department1"), - // InstanceID: to.Ptr("/subscriptions/subid/resourceGroups/Default-Web-eastasia/providers/Microsoft.Web/sites/shared1"), - // InstanceName: to.Ptr("shared1"), - // IsEstimated: to.Ptr(false), - // IsRecurringCharge: to.Ptr(false), - // MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // OfferName: to.Ptr("offer1"), - // OrderNumber: to.Ptr("00000000-0000-0000-0000-000000000000"), - // PlanName: to.Ptr("plan2"), - // PretaxCost: to.Ptr[float64](0.67), - // PublisherName: to.Ptr("xyz"), - // ResourceGroup: to.Ptr("TEST"), - // ResourceRate: to.Ptr[float64](0.24), - // SubscriptionGUID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // SubscriptionName: to.Ptr("azure subscription"), - // UnitOfMeasure: to.Ptr("10 Hours"), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-13T23:59:59.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-13T00:00:00.000Z"); return t}()), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/consumption/armconsumption/models.go b/sdk/resourcemanager/consumption/armconsumption/models.go index ad2e627d6da8..1c6a6ceff2cd 100644 --- a/sdk/resourcemanager/consumption/armconsumption/models.go +++ b/sdk/resourcemanager/consumption/armconsumption/models.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -87,6 +84,9 @@ type BalanceProperties struct { // READ-ONLY; List of new purchases. NewPurchasesDetails []*BalancePropertiesNewPurchasesDetailsItem + // READ-ONLY; Overage Refunds + OverageRefund *float64 + // READ-ONLY; Price is hidden or not. PriceHidden *bool @@ -262,21 +262,19 @@ type CreditBalanceSummary struct { // CreditSummary - A credit summary resource. type CreditSummary struct { + // eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating + // the latest version or not. + ETag *string + // The properties of the credit summary. Properties *CreditSummaryProperties - // READ-ONLY; The etag for the resource. - Etag *string - - // READ-ONLY; The full qualified ARM ID of an event. + // READ-ONLY; Resource Id. ID *string - // READ-ONLY; The ID that uniquely identifies an event. + // READ-ONLY; Resource name. Name *string - // READ-ONLY; Resource tags. - Tags map[string]*string - // READ-ONLY; Resource type. Type *string } @@ -298,6 +296,9 @@ type CreditSummaryProperties struct { // READ-ONLY; Expired credit. ExpiredCredit *Amount + // READ-ONLY; If true, the listed details are based on an estimation and it will be subjected to change. + IsEstimatedBalance *bool + // READ-ONLY; Pending credit adjustments. PendingCreditAdjustments *Amount @@ -343,6 +344,8 @@ type ErrorDetails struct { // // * 503 ServiceUnavailable - Service is temporarily unavailable. Retry after waiting for the time specified in the "Retry-After" // header. +// +// * 504 Gateway Timeout - Service timed out while processing the request. Reduce the date range in the request, if possible. type ErrorResponse struct { // The details of the error. Error *ErrorDetails @@ -359,6 +362,12 @@ type EventProperties struct { // READ-ONLY; The amount of balance adjustment in billing currency. AdjustmentsInBillingCurrency *AmountWithExchangeRate + // READ-ONLY; Name of the billing account. + BillingAccountDisplayName *string + + // READ-ONLY; Identifier of the billing account. + BillingAccountID *string + // READ-ONLY; The billing currency of the event. BillingCurrency *string @@ -373,18 +382,27 @@ type EventProperties struct { // READ-ONLY; Amount of canceled credit. CanceledCredit *Amount - // READ-ONLY; The amount of charges for events of type SettleCharges and PendingEligibleCharges. + // READ-ONLY; The amount of charges for events of type SettleCharges and PendingEligibleCharges in Lot Currency. Charges *Amount // READ-ONLY; The amount of charges for events of type SettleCharges and PendingEligibleCharges in billing currency. ChargesInBillingCurrency *AmountWithExchangeRate - // READ-ONLY; The balance after the event. + // READ-ONLY; The amount of charges for events of type SettleCharges and PendingEligibleCharges in Lot Currency. + ChargesInLotCurrency *Amount + + // READ-ONLY; The balance after the event, Note: This will not be returned for Contributor Organization Type in Multi-Entity + // consumption commitment ClosedBalance *Amount - // READ-ONLY; The balance in billing currency after the event. + // READ-ONLY; The balance in billing currency after the event, Note: This will not be returned for Contributor Organization + // Type in Multi-Entity consumption commitment ClosedBalanceInBillingCurrency *AmountWithExchangeRate + // READ-ONLY; The balance after the event, Note: This will not be returned for Contributor Organization Type in Multi-Entity + // consumption commitment + ClosedBalanceInLotCurrency *Amount + // READ-ONLY; The credit currency of the event. CreditCurrency *string @@ -404,6 +422,9 @@ type EventProperties struct { // events. InvoiceNumber *string + // READ-ONLY; If true, the listed details are based on an estimation and it will be subjected to change. + IsEstimatedBalance *bool + // READ-ONLY; The ID that uniquely identifies the lot for which the event happened. LotID *string @@ -521,6 +542,9 @@ type LegacyChargeSummaryProperties struct { // READ-ONLY; Azure Charges. AzureCharges *float64 + // READ-ONLY; Marketplace Charges. + AzureMarketplaceCharges *float64 + // READ-ONLY; The id of the billing period resource that the charge belongs to. BillingPeriodID *string @@ -530,9 +554,6 @@ type LegacyChargeSummaryProperties struct { // READ-ONLY; Currency Code Currency *string - // READ-ONLY; Marketplace Charges. - MarketplaceCharges *float64 - // READ-ONLY; Usage end date. UsageEnd *string @@ -601,6 +622,9 @@ type LegacyReservationRecommendationProperties struct { // READ-ONLY; The instance Flexibility Ratio. InstanceFlexibilityRatio *float32 + // READ-ONLY; The last usage date used for looking back for computing the recommendation. + LastUsageDate *time.Time + // READ-ONLY; The number of days of usage to look back for recommendation. LookBackPeriod *string @@ -625,11 +649,14 @@ type LegacyReservationRecommendationProperties struct { // READ-ONLY; List of sku properties SKUProperties []*SKUProperty - // READ-ONLY; RI recommendations in one or three year terms. + // READ-ONLY; Term period of the reservation. ex: P1M, P1Y or P3Y. Term *string // READ-ONLY; The total amount of cost with reserved instances. TotalCostWithReservedInstances *float64 + + // READ-ONLY; The total hours for which the cost is covered. + TotalHours *int32 } // GetLegacyReservationRecommendationProperties implements the LegacyReservationRecommendationPropertiesClassification interface @@ -694,7 +721,7 @@ type LegacyReservationTransactionProperties struct { // READ-ONLY; The date of the transaction EventDate *time.Time - // READ-ONLY; The type of the transaction (Purchase, Cancel, etc.) + // READ-ONLY; The type of the transaction (Purchase, Cancel or Refund). EventType *string // READ-ONLY; The monetary commitment amount at the enrollment scope. @@ -748,6 +775,9 @@ type LegacySharedScopeReservationRecommendationProperties struct { // READ-ONLY; The instance Flexibility Ratio. InstanceFlexibilityRatio *float32 + // READ-ONLY; The last usage date used for looking back for computing the recommendation. + LastUsageDate *time.Time + // READ-ONLY; The number of days of usage to look back for recommendation. LookBackPeriod *string @@ -772,11 +802,14 @@ type LegacySharedScopeReservationRecommendationProperties struct { // READ-ONLY; List of sku properties SKUProperties []*SKUProperty - // READ-ONLY; RI recommendations in one or three year terms. + // READ-ONLY; Term period of the reservation. ex: P1M, P1Y or P3Y. Term *string // READ-ONLY; The total amount of cost with reserved instances. TotalCostWithReservedInstances *float64 + + // READ-ONLY; The total hours for which the cost is covered. + TotalHours *int32 } // GetLegacyReservationRecommendationProperties implements the LegacyReservationRecommendationPropertiesClassification interface @@ -787,6 +820,7 @@ func (l *LegacySharedScopeReservationRecommendationProperties) GetLegacyReservat FirstUsageDate: l.FirstUsageDate, InstanceFlexibilityGroup: l.InstanceFlexibilityGroup, InstanceFlexibilityRatio: l.InstanceFlexibilityRatio, + LastUsageDate: l.LastUsageDate, LookBackPeriod: l.LookBackPeriod, MeterID: l.MeterID, NetSavings: l.NetSavings, @@ -798,6 +832,7 @@ func (l *LegacySharedScopeReservationRecommendationProperties) GetLegacyReservat Scope: l.Scope, Term: l.Term, TotalCostWithReservedInstances: l.TotalCostWithReservedInstances, + TotalHours: l.TotalHours, } } @@ -819,6 +854,9 @@ type LegacySingleScopeReservationRecommendationProperties struct { // READ-ONLY; The instance Flexibility Ratio. InstanceFlexibilityRatio *float32 + // READ-ONLY; The last usage date used for looking back for computing the recommendation. + LastUsageDate *time.Time + // READ-ONLY; The number of days of usage to look back for recommendation. LookBackPeriod *string @@ -846,11 +884,14 @@ type LegacySingleScopeReservationRecommendationProperties struct { // READ-ONLY; Subscription id associated with single scoped recommendation. SubscriptionID *string - // READ-ONLY; RI recommendations in one or three year terms. + // READ-ONLY; Term period of the reservation. ex: P1M, P1Y or P3Y. Term *string // READ-ONLY; The total amount of cost with reserved instances. TotalCostWithReservedInstances *float64 + + // READ-ONLY; The total hours for which the cost is covered. + TotalHours *int32 } // GetLegacyReservationRecommendationProperties implements the LegacyReservationRecommendationPropertiesClassification interface @@ -861,6 +902,7 @@ func (l *LegacySingleScopeReservationRecommendationProperties) GetLegacyReservat FirstUsageDate: l.FirstUsageDate, InstanceFlexibilityGroup: l.InstanceFlexibilityGroup, InstanceFlexibilityRatio: l.InstanceFlexibilityRatio, + LastUsageDate: l.LastUsageDate, LookBackPeriod: l.LookBackPeriod, MeterID: l.MeterID, NetSavings: l.NetSavings, @@ -872,6 +914,7 @@ func (l *LegacySingleScopeReservationRecommendationProperties) GetLegacyReservat Scope: l.Scope, Term: l.Term, TotalCostWithReservedInstances: l.TotalCostWithReservedInstances, + TotalHours: l.TotalHours, } } @@ -1080,10 +1123,18 @@ type LotProperties struct { // READ-ONLY; The expiration date of a lot. ExpirationDate *time.Time - // READ-ONLY; The original amount of a lot. + // READ-ONLY; If true, the listed details are based on an estimation and it will be subjected to change. + IsEstimatedBalance *bool + + // READ-ONLY; The organization type of the lot. + OrganizationType *OrganizationType + + // READ-ONLY; The original amount of a lot, Note: This will not be returned for Contributor Organization Type in Multi-Entity + // consumption commitment OriginalAmount *Amount - // READ-ONLY; The original amount of a lot in billing currency. + // READ-ONLY; The original amount of a lot in billing currency, Note: This will not be returned for Contributor Organization + // Type in Multi-Entity consumption commitment OriginalAmountInBillingCurrency *AmountWithExchangeRate // READ-ONLY; The po number of the invoice on which the lot was added. This property is not available for ConsumptionCommitment @@ -1104,6 +1155,9 @@ type LotProperties struct { // READ-ONLY; The status of the lot. Status *Status + + // READ-ONLY; Amount consumed from the commitment. + UsedAmount *Amount } // LotSummary - A lot summary resource. @@ -1410,6 +1464,9 @@ type ModernChargeSummaryProperties struct { // READ-ONLY; Marketplace Charges. MarketplaceCharges *Amount + // READ-ONLY; Subscription guid. + SubscriptionID *string + // READ-ONLY; Usage end date. UsageEnd *string @@ -1423,7 +1480,7 @@ type ModernReservationRecommendation struct { Kind *ReservationRecommendationKind // REQUIRED; Properties for modern reservation recommendation - Properties *ModernReservationRecommendationProperties + Properties ModernReservationRecommendationPropertiesClassification // READ-ONLY; The etag for the resource. Etag *string @@ -1463,6 +1520,9 @@ func (m *ModernReservationRecommendation) GetReservationRecommendation() *Reserv // ModernReservationRecommendationProperties - The properties of the reservation recommendation. type ModernReservationRecommendationProperties struct { + // REQUIRED; Shared or single recommendation. + Scope *string + // READ-ONLY; The total amount of cost without reserved instances. CostWithNoReservedInstances *Amount @@ -1475,6 +1535,9 @@ type ModernReservationRecommendationProperties struct { // READ-ONLY; The instance Flexibility Ratio. InstanceFlexibilityRatio *float32 + // READ-ONLY; The last usage date used for looking back for computing the recommendation. + LastUsageDate *time.Time + // READ-ONLY; Resource Location. Location *string @@ -1496,20 +1559,29 @@ type ModernReservationRecommendationProperties struct { // READ-ONLY; The recommended Quantity Normalized. RecommendedQuantityNormalized *float32 + // READ-ONLY; Resource type. + ResourceType *string + // READ-ONLY; This is the ARM Sku name. SKUName *string // READ-ONLY; List of sku properties SKUProperties []*SKUProperty - // READ-ONLY; Shared or single recommendation. - Scope *string - - // READ-ONLY; RI recommendations in one or three year terms. + // READ-ONLY; Term period of the reservation. ex: P1M, P1Y or P3Y. Term *string // READ-ONLY; The total amount of cost with reserved instances. TotalCostWithReservedInstances *Amount + + // READ-ONLY; The total hours for which the cost is covered. + TotalHours *int32 +} + +// GetModernReservationRecommendationProperties implements the ModernReservationRecommendationPropertiesClassification interface +// for type ModernReservationRecommendationProperties. +func (m *ModernReservationRecommendationProperties) GetModernReservationRecommendationProperties() *ModernReservationRecommendationProperties { + return m } // ModernReservationTransaction - Modern Reservation transaction resource. @@ -1556,7 +1628,7 @@ type ModernReservationTransactionProperties struct { // READ-ONLY; The date of the transaction EventDate *time.Time - // READ-ONLY; The type of the transaction (Purchase, Cancel, etc.) + // READ-ONLY; The type of the transaction (Purchase, Cancel or Refund). EventType *string // READ-ONLY; Invoice Number @@ -1604,6 +1676,183 @@ type ModernReservationTransactionsListResult struct { Value []*ModernReservationTransaction } +// ModernSharedScopeReservationRecommendationProperties - The properties of the modern reservation recommendation for shared +// scope. +type ModernSharedScopeReservationRecommendationProperties struct { + // REQUIRED; Shared or single recommendation. + Scope *string + + // READ-ONLY; The total amount of cost without reserved instances. + CostWithNoReservedInstances *Amount + + // READ-ONLY; The usage date for looking back. + FirstUsageDate *time.Time + + // READ-ONLY; The instance Flexibility Group. + InstanceFlexibilityGroup *string + + // READ-ONLY; The instance Flexibility Ratio. + InstanceFlexibilityRatio *float32 + + // READ-ONLY; The last usage date used for looking back for computing the recommendation. + LastUsageDate *time.Time + + // READ-ONLY; Resource Location. + Location *string + + // READ-ONLY; The number of days of usage to look back for recommendation. + LookBackPeriod *int32 + + // READ-ONLY; The meter id (GUID) + MeterID *string + + // READ-ONLY; Total estimated savings with reserved instances. + NetSavings *Amount + + // READ-ONLY; The normalized Size. + NormalizedSize *string + + // READ-ONLY; Recommended quality for reserved instances. + RecommendedQuantity *float64 + + // READ-ONLY; The recommended Quantity Normalized. + RecommendedQuantityNormalized *float32 + + // READ-ONLY; Resource type. + ResourceType *string + + // READ-ONLY; This is the ARM Sku name. + SKUName *string + + // READ-ONLY; List of sku properties + SKUProperties []*SKUProperty + + // READ-ONLY; Term period of the reservation. ex: P1M, P1Y or P3Y. + Term *string + + // READ-ONLY; The total amount of cost with reserved instances. + TotalCostWithReservedInstances *Amount + + // READ-ONLY; The total hours for which the cost is covered. + TotalHours *int32 +} + +// GetModernReservationRecommendationProperties implements the ModernReservationRecommendationPropertiesClassification interface +// for type ModernSharedScopeReservationRecommendationProperties. +func (m *ModernSharedScopeReservationRecommendationProperties) GetModernReservationRecommendationProperties() *ModernReservationRecommendationProperties { + return &ModernReservationRecommendationProperties{ + CostWithNoReservedInstances: m.CostWithNoReservedInstances, + FirstUsageDate: m.FirstUsageDate, + InstanceFlexibilityGroup: m.InstanceFlexibilityGroup, + InstanceFlexibilityRatio: m.InstanceFlexibilityRatio, + LastUsageDate: m.LastUsageDate, + Location: m.Location, + LookBackPeriod: m.LookBackPeriod, + MeterID: m.MeterID, + NetSavings: m.NetSavings, + NormalizedSize: m.NormalizedSize, + RecommendedQuantity: m.RecommendedQuantity, + RecommendedQuantityNormalized: m.RecommendedQuantityNormalized, + ResourceType: m.ResourceType, + SKUName: m.SKUName, + SKUProperties: m.SKUProperties, + Scope: m.Scope, + Term: m.Term, + TotalCostWithReservedInstances: m.TotalCostWithReservedInstances, + TotalHours: m.TotalHours, + } +} + +// ModernSingleScopeReservationRecommendationProperties - The properties of the modern reservation recommendation for single +// scope. +type ModernSingleScopeReservationRecommendationProperties struct { + // REQUIRED; Shared or single recommendation. + Scope *string + + // READ-ONLY; The total amount of cost without reserved instances. + CostWithNoReservedInstances *Amount + + // READ-ONLY; The usage date for looking back. + FirstUsageDate *time.Time + + // READ-ONLY; The instance Flexibility Group. + InstanceFlexibilityGroup *string + + // READ-ONLY; The instance Flexibility Ratio. + InstanceFlexibilityRatio *float32 + + // READ-ONLY; The last usage date used for looking back for computing the recommendation. + LastUsageDate *time.Time + + // READ-ONLY; Resource Location. + Location *string + + // READ-ONLY; The number of days of usage to look back for recommendation. + LookBackPeriod *int32 + + // READ-ONLY; The meter id (GUID) + MeterID *string + + // READ-ONLY; Total estimated savings with reserved instances. + NetSavings *Amount + + // READ-ONLY; The normalized Size. + NormalizedSize *string + + // READ-ONLY; Recommended quality for reserved instances. + RecommendedQuantity *float64 + + // READ-ONLY; The recommended Quantity Normalized. + RecommendedQuantityNormalized *float32 + + // READ-ONLY; Resource type. + ResourceType *string + + // READ-ONLY; This is the ARM Sku name. + SKUName *string + + // READ-ONLY; List of sku properties + SKUProperties []*SKUProperty + + // READ-ONLY; Subscription ID associated with single scoped recommendation. + SubscriptionID *string + + // READ-ONLY; Term period of the reservation. ex: P1M, P1Y or P3Y. + Term *string + + // READ-ONLY; The total amount of cost with reserved instances. + TotalCostWithReservedInstances *Amount + + // READ-ONLY; The total hours for which the cost is covered. + TotalHours *int32 +} + +// GetModernReservationRecommendationProperties implements the ModernReservationRecommendationPropertiesClassification interface +// for type ModernSingleScopeReservationRecommendationProperties. +func (m *ModernSingleScopeReservationRecommendationProperties) GetModernReservationRecommendationProperties() *ModernReservationRecommendationProperties { + return &ModernReservationRecommendationProperties{ + CostWithNoReservedInstances: m.CostWithNoReservedInstances, + FirstUsageDate: m.FirstUsageDate, + InstanceFlexibilityGroup: m.InstanceFlexibilityGroup, + InstanceFlexibilityRatio: m.InstanceFlexibilityRatio, + LastUsageDate: m.LastUsageDate, + Location: m.Location, + LookBackPeriod: m.LookBackPeriod, + MeterID: m.MeterID, + NetSavings: m.NetSavings, + NormalizedSize: m.NormalizedSize, + RecommendedQuantity: m.RecommendedQuantity, + RecommendedQuantityNormalized: m.RecommendedQuantityNormalized, + ResourceType: m.ResourceType, + SKUName: m.SKUName, + SKUProperties: m.SKUProperties, + Scope: m.Scope, + Term: m.Term, + TotalCostWithReservedInstances: m.TotalCostWithReservedInstances, + TotalHours: m.TotalHours, + } +} + // ModernUsageDetail - Modern usage detail. type ModernUsageDetail struct { // REQUIRED; Specifies the kind of usage details. @@ -1946,6 +2195,15 @@ type OperationListResult struct { Value []*Operation } +// OperationStatus - The status of the long running operation. +type OperationStatus struct { + // The properties of the resource generated. + Properties *PricesheetDownloadProperties + + // The status of the long running operation. + Status *OperationStatusType +} + // PriceSheetModel - price sheet result. It contains the pricesheet associated with billing period type PriceSheetModel struct { // READ-ONLY; Pricesheet download details. @@ -1981,6 +2239,9 @@ type PriceSheetProperties struct { // READ-ONLY; Part Number PartNumber *string + // READ-ONLY; SavingsPlan Details + SavingsPlan *SavingsPlan + // READ-ONLY; Unit of measure UnitOfMeasure *string @@ -2009,6 +2270,15 @@ type PriceSheetResult struct { Type *string } +// PricesheetDownloadProperties - The properties of the price sheet download. +type PricesheetDownloadProperties struct { + // READ-ONLY; The link (url) to download the pricesheet. + DownloadURL *string + + // READ-ONLY; Download link validity. + ValidTill *time.Time +} + // ProxyResource - The Resource model definition. type ProxyResource struct { // eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating @@ -2137,27 +2407,28 @@ func (r *ReservationRecommendation) GetReservationRecommendation() *ReservationR return r } -// ReservationRecommendationDetailsCalculatedSavingsProperties - Details of estimated savings. +// ReservationRecommendationDetailsCalculatedSavingsProperties - Details of estimated savings. The costs and savings are estimated +// for the term. type ReservationRecommendationDetailsCalculatedSavingsProperties struct { // The number of reserved units used to calculate savings. Always 1 for virtual machines. ReservedUnitCount *float32 - // READ-ONLY; The cost without reservation. + // READ-ONLY; The cost without reservation. Includes hardware and software cost. OnDemandCost *float32 - // READ-ONLY; The difference between total reservation cost and reservation cost. + // READ-ONLY; Hardware and software cost of the resources not covered by the reservation. OverageCost *float32 // READ-ONLY; The quantity for calculated savings. Quantity *float32 - // READ-ONLY; The exact cost of the estimated usage using reservation. + // READ-ONLY; Hardware cost of the resources covered by the reservation. ReservationCost *float32 - // READ-ONLY; The amount saved by purchasing the recommended quantity of reservation. + // READ-ONLY; The amount saved by purchasing the recommended quantity of reservation. This is equal to onDemandCost - totalReservationCost. Savings *float32 - // READ-ONLY; The cost of the suggested quantity. + // READ-ONLY; Reservation cost + software cost of the resources covered by the reservation + overage cost. TotalReservationCost *float32 } @@ -2214,7 +2485,7 @@ type ReservationRecommendationDetailsResourceProperties struct { // READ-ONLY; List of subscriptions for which the reservation is applied. AppliedScopes []*string - // READ-ONLY; On demand rate of the resource. + // READ-ONLY; Hourly on-demand rate of the resource. Includes only hardware rate i.e, software rate is not included. OnDemandRate *float32 // READ-ONLY; Azure product ex: StandardE8sv3 etc. @@ -2223,7 +2494,7 @@ type ReservationRecommendationDetailsResourceProperties struct { // READ-ONLY; Azure resource region ex:EastUS, WestUS etc. Region *string - // READ-ONLY; Reservation rate of the resource. + // READ-ONLY; Hourly reservation rate of the resource. Varies based on the term. ReservationRate *float32 // READ-ONLY; The azure resource type. @@ -2241,7 +2512,7 @@ type ReservationRecommendationDetailsSavingsProperties struct { // READ-ONLY; Number of recommended units of the resource. RecommendedQuantity *float32 - // READ-ONLY; Term period of the reservation, ex: P1Y or P3Y. + // READ-ONLY; Term period of the reservation. ex: P1M, P1Y or P3Y. ReservationOrderTerm *string // READ-ONLY; Type of savings, ex: instance. @@ -2448,6 +2719,18 @@ type SKUProperty struct { Value *string } +// SavingsPlan - The properties of the SavingsPlan. +type SavingsPlan struct { + // READ-ONLY; SavingsPlan Effective Price + EffectivePrice *float64 + + // READ-ONLY; SavingsPlan Market Price + MarketPrice *float64 + + // READ-ONLY; SavingsPlan term + Term *string +} + // Tag - The tag resource. type Tag struct { // Tag key. diff --git a/sdk/resourcemanager/consumption/armconsumption/models_serde.go b/sdk/resourcemanager/consumption/armconsumption/models_serde.go index bb0d8d1f161a..a361f8449353 100644 --- a/sdk/resourcemanager/consumption/armconsumption/models_serde.go +++ b/sdk/resourcemanager/consumption/armconsumption/models_serde.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -145,6 +142,7 @@ func (b BalanceProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "endingBalance", b.EndingBalance) populate(objectMap, "newPurchases", b.NewPurchases) populate(objectMap, "newPurchasesDetails", b.NewPurchasesDetails) + populate(objectMap, "overageRefund", b.OverageRefund) populate(objectMap, "priceHidden", b.PriceHidden) populate(objectMap, "serviceOverage", b.ServiceOverage) populate(objectMap, "totalOverage", b.TotalOverage) @@ -192,6 +190,9 @@ func (b *BalanceProperties) UnmarshalJSON(data []byte) error { case "newPurchasesDetails": err = unpopulate(val, "NewPurchasesDetails", &b.NewPurchasesDetails) delete(rawMsg, key) + case "overageRefund": + err = unpopulate(val, "OverageRefund", &b.OverageRefund) + delete(rawMsg, key) case "priceHidden": err = unpopulate(val, "PriceHidden", &b.PriceHidden) delete(rawMsg, key) @@ -646,11 +647,10 @@ func (c *CreditBalanceSummary) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CreditSummary. func (c CreditSummary) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "etag", c.Etag) + populate(objectMap, "eTag", c.ETag) populate(objectMap, "id", c.ID) populate(objectMap, "name", c.Name) populate(objectMap, "properties", c.Properties) - populate(objectMap, "tags", c.Tags) populate(objectMap, "type", c.Type) return json.Marshal(objectMap) } @@ -664,8 +664,8 @@ func (c *CreditSummary) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "etag": - err = unpopulate(val, "Etag", &c.Etag) + case "eTag": + err = unpopulate(val, "ETag", &c.ETag) delete(rawMsg, key) case "id": err = unpopulate(val, "ID", &c.ID) @@ -676,9 +676,6 @@ func (c *CreditSummary) UnmarshalJSON(data []byte) error { case "properties": err = unpopulate(val, "Properties", &c.Properties) delete(rawMsg, key) - case "tags": - err = unpopulate(val, "Tags", &c.Tags) - delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &c.Type) delete(rawMsg, key) @@ -698,6 +695,7 @@ func (c CreditSummaryProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "creditCurrency", c.CreditCurrency) populate(objectMap, "eTag", c.ETag) populate(objectMap, "expiredCredit", c.ExpiredCredit) + populate(objectMap, "isEstimatedBalance", c.IsEstimatedBalance) populate(objectMap, "pendingCreditAdjustments", c.PendingCreditAdjustments) populate(objectMap, "pendingEligibleCharges", c.PendingEligibleCharges) populate(objectMap, "reseller", c.Reseller) @@ -728,6 +726,9 @@ func (c *CreditSummaryProperties) UnmarshalJSON(data []byte) error { case "expiredCredit": err = unpopulate(val, "ExpiredCredit", &c.ExpiredCredit) delete(rawMsg, key) + case "isEstimatedBalance": + err = unpopulate(val, "IsEstimatedBalance", &c.IsEstimatedBalance) + delete(rawMsg, key) case "pendingCreditAdjustments": err = unpopulate(val, "PendingCreditAdjustments", &c.PendingCreditAdjustments) delete(rawMsg, key) @@ -870,14 +871,18 @@ func (e EventProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "adjustments", e.Adjustments) populate(objectMap, "adjustmentsInBillingCurrency", e.AdjustmentsInBillingCurrency) + populate(objectMap, "billingAccountDisplayName", e.BillingAccountDisplayName) + populate(objectMap, "billingAccountId", e.BillingAccountID) populate(objectMap, "billingCurrency", e.BillingCurrency) populate(objectMap, "billingProfileDisplayName", e.BillingProfileDisplayName) populate(objectMap, "billingProfileId", e.BillingProfileID) populate(objectMap, "canceledCredit", e.CanceledCredit) populate(objectMap, "charges", e.Charges) populate(objectMap, "chargesInBillingCurrency", e.ChargesInBillingCurrency) + populate(objectMap, "chargesInLotCurrency", e.ChargesInLotCurrency) populate(objectMap, "closedBalance", e.ClosedBalance) populate(objectMap, "closedBalanceInBillingCurrency", e.ClosedBalanceInBillingCurrency) + populate(objectMap, "closedBalanceInLotCurrency", e.ClosedBalanceInLotCurrency) populate(objectMap, "creditCurrency", e.CreditCurrency) populate(objectMap, "creditExpired", e.CreditExpired) populate(objectMap, "creditExpiredInBillingCurrency", e.CreditExpiredInBillingCurrency) @@ -885,6 +890,7 @@ func (e EventProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "eTag", e.ETag) populate(objectMap, "eventType", e.EventType) populate(objectMap, "invoiceNumber", e.InvoiceNumber) + populate(objectMap, "isEstimatedBalance", e.IsEstimatedBalance) populate(objectMap, "lotId", e.LotID) populate(objectMap, "lotSource", e.LotSource) populate(objectMap, "newCredit", e.NewCredit) @@ -909,6 +915,12 @@ func (e *EventProperties) UnmarshalJSON(data []byte) error { case "adjustmentsInBillingCurrency": err = unpopulate(val, "AdjustmentsInBillingCurrency", &e.AdjustmentsInBillingCurrency) delete(rawMsg, key) + case "billingAccountDisplayName": + err = unpopulate(val, "BillingAccountDisplayName", &e.BillingAccountDisplayName) + delete(rawMsg, key) + case "billingAccountId": + err = unpopulate(val, "BillingAccountID", &e.BillingAccountID) + delete(rawMsg, key) case "billingCurrency": err = unpopulate(val, "BillingCurrency", &e.BillingCurrency) delete(rawMsg, key) @@ -927,12 +939,18 @@ func (e *EventProperties) UnmarshalJSON(data []byte) error { case "chargesInBillingCurrency": err = unpopulate(val, "ChargesInBillingCurrency", &e.ChargesInBillingCurrency) delete(rawMsg, key) + case "chargesInLotCurrency": + err = unpopulate(val, "ChargesInLotCurrency", &e.ChargesInLotCurrency) + delete(rawMsg, key) case "closedBalance": err = unpopulate(val, "ClosedBalance", &e.ClosedBalance) delete(rawMsg, key) case "closedBalanceInBillingCurrency": err = unpopulate(val, "ClosedBalanceInBillingCurrency", &e.ClosedBalanceInBillingCurrency) delete(rawMsg, key) + case "closedBalanceInLotCurrency": + err = unpopulate(val, "ClosedBalanceInLotCurrency", &e.ClosedBalanceInLotCurrency) + delete(rawMsg, key) case "creditCurrency": err = unpopulate(val, "CreditCurrency", &e.CreditCurrency) delete(rawMsg, key) @@ -954,6 +972,9 @@ func (e *EventProperties) UnmarshalJSON(data []byte) error { case "invoiceNumber": err = unpopulate(val, "InvoiceNumber", &e.InvoiceNumber) delete(rawMsg, key) + case "isEstimatedBalance": + err = unpopulate(val, "IsEstimatedBalance", &e.IsEstimatedBalance) + delete(rawMsg, key) case "lotId": err = unpopulate(val, "LotID", &e.LotID) delete(rawMsg, key) @@ -1194,10 +1215,10 @@ func (l *LegacyChargeSummary) UnmarshalJSON(data []byte) error { func (l LegacyChargeSummaryProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "azureCharges", l.AzureCharges) + populate(objectMap, "azureMarketplaceCharges", l.AzureMarketplaceCharges) populate(objectMap, "billingPeriodId", l.BillingPeriodID) populate(objectMap, "chargesBilledSeparately", l.ChargesBilledSeparately) populate(objectMap, "currency", l.Currency) - populate(objectMap, "marketplaceCharges", l.MarketplaceCharges) populate(objectMap, "usageEnd", l.UsageEnd) populate(objectMap, "usageStart", l.UsageStart) return json.Marshal(objectMap) @@ -1215,6 +1236,9 @@ func (l *LegacyChargeSummaryProperties) UnmarshalJSON(data []byte) error { case "azureCharges": err = unpopulate(val, "AzureCharges", &l.AzureCharges) delete(rawMsg, key) + case "azureMarketplaceCharges": + err = unpopulate(val, "AzureMarketplaceCharges", &l.AzureMarketplaceCharges) + delete(rawMsg, key) case "billingPeriodId": err = unpopulate(val, "BillingPeriodID", &l.BillingPeriodID) delete(rawMsg, key) @@ -1224,9 +1248,6 @@ func (l *LegacyChargeSummaryProperties) UnmarshalJSON(data []byte) error { case "currency": err = unpopulate(val, "Currency", &l.Currency) delete(rawMsg, key) - case "marketplaceCharges": - err = unpopulate(val, "MarketplaceCharges", &l.MarketplaceCharges) - delete(rawMsg, key) case "usageEnd": err = unpopulate(val, "UsageEnd", &l.UsageEnd) delete(rawMsg, key) @@ -1307,6 +1328,7 @@ func (l LegacyReservationRecommendationProperties) MarshalJSON() ([]byte, error) populateDateTimeRFC3339(objectMap, "firstUsageDate", l.FirstUsageDate) populate(objectMap, "instanceFlexibilityGroup", l.InstanceFlexibilityGroup) populate(objectMap, "instanceFlexibilityRatio", l.InstanceFlexibilityRatio) + populateDateTimeRFC3339(objectMap, "lastUsageDate", l.LastUsageDate) populate(objectMap, "lookBackPeriod", l.LookBackPeriod) populate(objectMap, "meterId", l.MeterID) populate(objectMap, "netSavings", l.NetSavings) @@ -1318,6 +1340,7 @@ func (l LegacyReservationRecommendationProperties) MarshalJSON() ([]byte, error) objectMap["scope"] = l.Scope populate(objectMap, "term", l.Term) populate(objectMap, "totalCostWithReservedInstances", l.TotalCostWithReservedInstances) + populate(objectMap, "totalHours", l.TotalHours) return json.Marshal(objectMap) } @@ -1342,6 +1365,9 @@ func (l *LegacyReservationRecommendationProperties) UnmarshalJSON(data []byte) e case "instanceFlexibilityRatio": err = unpopulate(val, "InstanceFlexibilityRatio", &l.InstanceFlexibilityRatio) delete(rawMsg, key) + case "lastUsageDate": + err = unpopulateDateTimeRFC3339(val, "LastUsageDate", &l.LastUsageDate) + delete(rawMsg, key) case "lookBackPeriod": err = unpopulate(val, "LookBackPeriod", &l.LookBackPeriod) delete(rawMsg, key) @@ -1375,6 +1401,9 @@ func (l *LegacyReservationRecommendationProperties) UnmarshalJSON(data []byte) e case "totalCostWithReservedInstances": err = unpopulate(val, "TotalCostWithReservedInstances", &l.TotalCostWithReservedInstances) delete(rawMsg, key) + case "totalHours": + err = unpopulate(val, "TotalHours", &l.TotalHours) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", l, err) @@ -1548,6 +1577,7 @@ func (l LegacySharedScopeReservationRecommendationProperties) MarshalJSON() ([]b populateDateTimeRFC3339(objectMap, "firstUsageDate", l.FirstUsageDate) populate(objectMap, "instanceFlexibilityGroup", l.InstanceFlexibilityGroup) populate(objectMap, "instanceFlexibilityRatio", l.InstanceFlexibilityRatio) + populateDateTimeRFC3339(objectMap, "lastUsageDate", l.LastUsageDate) populate(objectMap, "lookBackPeriod", l.LookBackPeriod) populate(objectMap, "meterId", l.MeterID) populate(objectMap, "netSavings", l.NetSavings) @@ -1559,6 +1589,7 @@ func (l LegacySharedScopeReservationRecommendationProperties) MarshalJSON() ([]b objectMap["scope"] = "Shared" populate(objectMap, "term", l.Term) populate(objectMap, "totalCostWithReservedInstances", l.TotalCostWithReservedInstances) + populate(objectMap, "totalHours", l.TotalHours) return json.Marshal(objectMap) } @@ -1583,6 +1614,9 @@ func (l *LegacySharedScopeReservationRecommendationProperties) UnmarshalJSON(dat case "instanceFlexibilityRatio": err = unpopulate(val, "InstanceFlexibilityRatio", &l.InstanceFlexibilityRatio) delete(rawMsg, key) + case "lastUsageDate": + err = unpopulateDateTimeRFC3339(val, "LastUsageDate", &l.LastUsageDate) + delete(rawMsg, key) case "lookBackPeriod": err = unpopulate(val, "LookBackPeriod", &l.LookBackPeriod) delete(rawMsg, key) @@ -1616,6 +1650,9 @@ func (l *LegacySharedScopeReservationRecommendationProperties) UnmarshalJSON(dat case "totalCostWithReservedInstances": err = unpopulate(val, "TotalCostWithReservedInstances", &l.TotalCostWithReservedInstances) delete(rawMsg, key) + case "totalHours": + err = unpopulate(val, "TotalHours", &l.TotalHours) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", l, err) @@ -1631,6 +1668,7 @@ func (l LegacySingleScopeReservationRecommendationProperties) MarshalJSON() ([]b populateDateTimeRFC3339(objectMap, "firstUsageDate", l.FirstUsageDate) populate(objectMap, "instanceFlexibilityGroup", l.InstanceFlexibilityGroup) populate(objectMap, "instanceFlexibilityRatio", l.InstanceFlexibilityRatio) + populateDateTimeRFC3339(objectMap, "lastUsageDate", l.LastUsageDate) populate(objectMap, "lookBackPeriod", l.LookBackPeriod) populate(objectMap, "meterId", l.MeterID) populate(objectMap, "netSavings", l.NetSavings) @@ -1643,6 +1681,7 @@ func (l LegacySingleScopeReservationRecommendationProperties) MarshalJSON() ([]b populate(objectMap, "subscriptionId", l.SubscriptionID) populate(objectMap, "term", l.Term) populate(objectMap, "totalCostWithReservedInstances", l.TotalCostWithReservedInstances) + populate(objectMap, "totalHours", l.TotalHours) return json.Marshal(objectMap) } @@ -1667,6 +1706,9 @@ func (l *LegacySingleScopeReservationRecommendationProperties) UnmarshalJSON(dat case "instanceFlexibilityRatio": err = unpopulate(val, "InstanceFlexibilityRatio", &l.InstanceFlexibilityRatio) delete(rawMsg, key) + case "lastUsageDate": + err = unpopulateDateTimeRFC3339(val, "LastUsageDate", &l.LastUsageDate) + delete(rawMsg, key) case "lookBackPeriod": err = unpopulate(val, "LookBackPeriod", &l.LookBackPeriod) delete(rawMsg, key) @@ -1703,6 +1745,9 @@ func (l *LegacySingleScopeReservationRecommendationProperties) UnmarshalJSON(dat case "totalCostWithReservedInstances": err = unpopulate(val, "TotalCostWithReservedInstances", &l.TotalCostWithReservedInstances) delete(rawMsg, key) + case "totalHours": + err = unpopulate(val, "TotalHours", &l.TotalHours) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", l, err) @@ -1978,6 +2023,8 @@ func (l LotProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "creditCurrency", l.CreditCurrency) populate(objectMap, "eTag", l.ETag) populateDateTimeRFC3339(objectMap, "expirationDate", l.ExpirationDate) + populate(objectMap, "isEstimatedBalance", l.IsEstimatedBalance) + populate(objectMap, "OrganizationType", l.OrganizationType) populate(objectMap, "originalAmount", l.OriginalAmount) populate(objectMap, "originalAmountInBillingCurrency", l.OriginalAmountInBillingCurrency) populate(objectMap, "poNumber", l.PoNumber) @@ -1986,6 +2033,7 @@ func (l LotProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "source", l.Source) populateDateTimeRFC3339(objectMap, "startDate", l.StartDate) populate(objectMap, "status", l.Status) + populate(objectMap, "usedAmount", l.UsedAmount) return json.Marshal(objectMap) } @@ -2016,6 +2064,12 @@ func (l *LotProperties) UnmarshalJSON(data []byte) error { case "expirationDate": err = unpopulateDateTimeRFC3339(val, "ExpirationDate", &l.ExpirationDate) delete(rawMsg, key) + case "isEstimatedBalance": + err = unpopulate(val, "IsEstimatedBalance", &l.IsEstimatedBalance) + delete(rawMsg, key) + case "OrganizationType": + err = unpopulate(val, "OrganizationType", &l.OrganizationType) + delete(rawMsg, key) case "originalAmount": err = unpopulate(val, "OriginalAmount", &l.OriginalAmount) delete(rawMsg, key) @@ -2040,6 +2094,9 @@ func (l *LotProperties) UnmarshalJSON(data []byte) error { case "status": err = unpopulate(val, "Status", &l.Status) delete(rawMsg, key) + case "usedAmount": + err = unpopulate(val, "UsedAmount", &l.UsedAmount) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", l, err) @@ -2598,6 +2655,7 @@ func (m ModernChargeSummaryProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "invoiceSectionId", m.InvoiceSectionID) populate(objectMap, "isInvoiced", m.IsInvoiced) populate(objectMap, "marketplaceCharges", m.MarketplaceCharges) + populate(objectMap, "subscriptionId", m.SubscriptionID) populate(objectMap, "usageEnd", m.UsageEnd) populate(objectMap, "usageStart", m.UsageStart) return json.Marshal(objectMap) @@ -2639,6 +2697,9 @@ func (m *ModernChargeSummaryProperties) UnmarshalJSON(data []byte) error { case "marketplaceCharges": err = unpopulate(val, "MarketplaceCharges", &m.MarketplaceCharges) delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, "SubscriptionID", &m.SubscriptionID) + delete(rawMsg, key) case "usageEnd": err = unpopulate(val, "UsageEnd", &m.UsageEnd) delete(rawMsg, key) @@ -2693,7 +2754,7 @@ func (m *ModernReservationRecommendation) UnmarshalJSON(data []byte) error { err = unpopulate(val, "Name", &m.Name) delete(rawMsg, key) case "properties": - err = unpopulate(val, "Properties", &m.Properties) + m.Properties, err = unmarshalModernReservationRecommendationPropertiesClassification(val) delete(rawMsg, key) case "sku": err = unpopulate(val, "SKU", &m.SKU) @@ -2719,6 +2780,7 @@ func (m ModernReservationRecommendationProperties) MarshalJSON() ([]byte, error) populateDateTimeRFC3339(objectMap, "firstUsageDate", m.FirstUsageDate) populate(objectMap, "instanceFlexibilityGroup", m.InstanceFlexibilityGroup) populate(objectMap, "instanceFlexibilityRatio", m.InstanceFlexibilityRatio) + populateDateTimeRFC3339(objectMap, "lastUsageDate", m.LastUsageDate) populate(objectMap, "location", m.Location) populate(objectMap, "lookBackPeriod", m.LookBackPeriod) populate(objectMap, "meterId", m.MeterID) @@ -2726,11 +2788,13 @@ func (m ModernReservationRecommendationProperties) MarshalJSON() ([]byte, error) populate(objectMap, "normalizedSize", m.NormalizedSize) populate(objectMap, "recommendedQuantity", m.RecommendedQuantity) populate(objectMap, "recommendedQuantityNormalized", m.RecommendedQuantityNormalized) + populate(objectMap, "resourceType", m.ResourceType) populate(objectMap, "skuName", m.SKUName) populate(objectMap, "skuProperties", m.SKUProperties) - populate(objectMap, "scope", m.Scope) + objectMap["scope"] = m.Scope populate(objectMap, "term", m.Term) populate(objectMap, "totalCostWithReservedInstances", m.TotalCostWithReservedInstances) + populate(objectMap, "totalHours", m.TotalHours) return json.Marshal(objectMap) } @@ -2755,6 +2819,9 @@ func (m *ModernReservationRecommendationProperties) UnmarshalJSON(data []byte) e case "instanceFlexibilityRatio": err = unpopulate(val, "InstanceFlexibilityRatio", &m.InstanceFlexibilityRatio) delete(rawMsg, key) + case "lastUsageDate": + err = unpopulateDateTimeRFC3339(val, "LastUsageDate", &m.LastUsageDate) + delete(rawMsg, key) case "location": err = unpopulate(val, "Location", &m.Location) delete(rawMsg, key) @@ -2776,6 +2843,9 @@ func (m *ModernReservationRecommendationProperties) UnmarshalJSON(data []byte) e case "recommendedQuantityNormalized": err = unpopulate(val, "RecommendedQuantityNormalized", &m.RecommendedQuantityNormalized) delete(rawMsg, key) + case "resourceType": + err = unpopulate(val, "ResourceType", &m.ResourceType) + delete(rawMsg, key) case "skuName": err = unpopulate(val, "SKUName", &m.SKUName) delete(rawMsg, key) @@ -2791,6 +2861,9 @@ func (m *ModernReservationRecommendationProperties) UnmarshalJSON(data []byte) e case "totalCostWithReservedInstances": err = unpopulate(val, "TotalCostWithReservedInstances", &m.TotalCostWithReservedInstances) delete(rawMsg, key) + case "totalHours": + err = unpopulate(val, "TotalHours", &m.TotalHours) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", m, err) @@ -2976,6 +3049,208 @@ func (m *ModernReservationTransactionsListResult) UnmarshalJSON(data []byte) err return nil } +// MarshalJSON implements the json.Marshaller interface for type ModernSharedScopeReservationRecommendationProperties. +func (m ModernSharedScopeReservationRecommendationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "costWithNoReservedInstances", m.CostWithNoReservedInstances) + populateDateTimeRFC3339(objectMap, "firstUsageDate", m.FirstUsageDate) + populate(objectMap, "instanceFlexibilityGroup", m.InstanceFlexibilityGroup) + populate(objectMap, "instanceFlexibilityRatio", m.InstanceFlexibilityRatio) + populateDateTimeRFC3339(objectMap, "lastUsageDate", m.LastUsageDate) + populate(objectMap, "location", m.Location) + populate(objectMap, "lookBackPeriod", m.LookBackPeriod) + populate(objectMap, "meterId", m.MeterID) + populate(objectMap, "netSavings", m.NetSavings) + populate(objectMap, "normalizedSize", m.NormalizedSize) + populate(objectMap, "recommendedQuantity", m.RecommendedQuantity) + populate(objectMap, "recommendedQuantityNormalized", m.RecommendedQuantityNormalized) + populate(objectMap, "resourceType", m.ResourceType) + populate(objectMap, "skuName", m.SKUName) + populate(objectMap, "skuProperties", m.SKUProperties) + objectMap["scope"] = "Shared" + populate(objectMap, "term", m.Term) + populate(objectMap, "totalCostWithReservedInstances", m.TotalCostWithReservedInstances) + populate(objectMap, "totalHours", m.TotalHours) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ModernSharedScopeReservationRecommendationProperties. +func (m *ModernSharedScopeReservationRecommendationProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "costWithNoReservedInstances": + err = unpopulate(val, "CostWithNoReservedInstances", &m.CostWithNoReservedInstances) + delete(rawMsg, key) + case "firstUsageDate": + err = unpopulateDateTimeRFC3339(val, "FirstUsageDate", &m.FirstUsageDate) + delete(rawMsg, key) + case "instanceFlexibilityGroup": + err = unpopulate(val, "InstanceFlexibilityGroup", &m.InstanceFlexibilityGroup) + delete(rawMsg, key) + case "instanceFlexibilityRatio": + err = unpopulate(val, "InstanceFlexibilityRatio", &m.InstanceFlexibilityRatio) + delete(rawMsg, key) + case "lastUsageDate": + err = unpopulateDateTimeRFC3339(val, "LastUsageDate", &m.LastUsageDate) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &m.Location) + delete(rawMsg, key) + case "lookBackPeriod": + err = unpopulate(val, "LookBackPeriod", &m.LookBackPeriod) + delete(rawMsg, key) + case "meterId": + err = unpopulate(val, "MeterID", &m.MeterID) + delete(rawMsg, key) + case "netSavings": + err = unpopulate(val, "NetSavings", &m.NetSavings) + delete(rawMsg, key) + case "normalizedSize": + err = unpopulate(val, "NormalizedSize", &m.NormalizedSize) + delete(rawMsg, key) + case "recommendedQuantity": + err = unpopulate(val, "RecommendedQuantity", &m.RecommendedQuantity) + delete(rawMsg, key) + case "recommendedQuantityNormalized": + err = unpopulate(val, "RecommendedQuantityNormalized", &m.RecommendedQuantityNormalized) + delete(rawMsg, key) + case "resourceType": + err = unpopulate(val, "ResourceType", &m.ResourceType) + delete(rawMsg, key) + case "skuName": + err = unpopulate(val, "SKUName", &m.SKUName) + delete(rawMsg, key) + case "skuProperties": + err = unpopulate(val, "SKUProperties", &m.SKUProperties) + delete(rawMsg, key) + case "scope": + err = unpopulate(val, "Scope", &m.Scope) + delete(rawMsg, key) + case "term": + err = unpopulate(val, "Term", &m.Term) + delete(rawMsg, key) + case "totalCostWithReservedInstances": + err = unpopulate(val, "TotalCostWithReservedInstances", &m.TotalCostWithReservedInstances) + delete(rawMsg, key) + case "totalHours": + err = unpopulate(val, "TotalHours", &m.TotalHours) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ModernSingleScopeReservationRecommendationProperties. +func (m ModernSingleScopeReservationRecommendationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "costWithNoReservedInstances", m.CostWithNoReservedInstances) + populateDateTimeRFC3339(objectMap, "firstUsageDate", m.FirstUsageDate) + populate(objectMap, "instanceFlexibilityGroup", m.InstanceFlexibilityGroup) + populate(objectMap, "instanceFlexibilityRatio", m.InstanceFlexibilityRatio) + populateDateTimeRFC3339(objectMap, "lastUsageDate", m.LastUsageDate) + populate(objectMap, "location", m.Location) + populate(objectMap, "lookBackPeriod", m.LookBackPeriod) + populate(objectMap, "meterId", m.MeterID) + populate(objectMap, "netSavings", m.NetSavings) + populate(objectMap, "normalizedSize", m.NormalizedSize) + populate(objectMap, "recommendedQuantity", m.RecommendedQuantity) + populate(objectMap, "recommendedQuantityNormalized", m.RecommendedQuantityNormalized) + populate(objectMap, "resourceType", m.ResourceType) + populate(objectMap, "skuName", m.SKUName) + populate(objectMap, "skuProperties", m.SKUProperties) + objectMap["scope"] = "Single" + populate(objectMap, "subscriptionId", m.SubscriptionID) + populate(objectMap, "term", m.Term) + populate(objectMap, "totalCostWithReservedInstances", m.TotalCostWithReservedInstances) + populate(objectMap, "totalHours", m.TotalHours) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ModernSingleScopeReservationRecommendationProperties. +func (m *ModernSingleScopeReservationRecommendationProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "costWithNoReservedInstances": + err = unpopulate(val, "CostWithNoReservedInstances", &m.CostWithNoReservedInstances) + delete(rawMsg, key) + case "firstUsageDate": + err = unpopulateDateTimeRFC3339(val, "FirstUsageDate", &m.FirstUsageDate) + delete(rawMsg, key) + case "instanceFlexibilityGroup": + err = unpopulate(val, "InstanceFlexibilityGroup", &m.InstanceFlexibilityGroup) + delete(rawMsg, key) + case "instanceFlexibilityRatio": + err = unpopulate(val, "InstanceFlexibilityRatio", &m.InstanceFlexibilityRatio) + delete(rawMsg, key) + case "lastUsageDate": + err = unpopulateDateTimeRFC3339(val, "LastUsageDate", &m.LastUsageDate) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &m.Location) + delete(rawMsg, key) + case "lookBackPeriod": + err = unpopulate(val, "LookBackPeriod", &m.LookBackPeriod) + delete(rawMsg, key) + case "meterId": + err = unpopulate(val, "MeterID", &m.MeterID) + delete(rawMsg, key) + case "netSavings": + err = unpopulate(val, "NetSavings", &m.NetSavings) + delete(rawMsg, key) + case "normalizedSize": + err = unpopulate(val, "NormalizedSize", &m.NormalizedSize) + delete(rawMsg, key) + case "recommendedQuantity": + err = unpopulate(val, "RecommendedQuantity", &m.RecommendedQuantity) + delete(rawMsg, key) + case "recommendedQuantityNormalized": + err = unpopulate(val, "RecommendedQuantityNormalized", &m.RecommendedQuantityNormalized) + delete(rawMsg, key) + case "resourceType": + err = unpopulate(val, "ResourceType", &m.ResourceType) + delete(rawMsg, key) + case "skuName": + err = unpopulate(val, "SKUName", &m.SKUName) + delete(rawMsg, key) + case "skuProperties": + err = unpopulate(val, "SKUProperties", &m.SKUProperties) + delete(rawMsg, key) + case "scope": + err = unpopulate(val, "Scope", &m.Scope) + delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, "SubscriptionID", &m.SubscriptionID) + delete(rawMsg, key) + case "term": + err = unpopulate(val, "Term", &m.Term) + delete(rawMsg, key) + case "totalCostWithReservedInstances": + err = unpopulate(val, "TotalCostWithReservedInstances", &m.TotalCostWithReservedInstances) + delete(rawMsg, key) + case "totalHours": + err = unpopulate(val, "TotalHours", &m.TotalHours) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type ModernUsageDetail. func (m ModernUsageDetail) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -3498,6 +3773,37 @@ func (o *OperationListResult) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type OperationStatus. +func (o OperationStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", o.Properties) + populate(objectMap, "status", o.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationStatus. +func (o *OperationStatus) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &o.Properties) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &o.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type PriceSheetModel. func (p PriceSheetModel) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -3543,6 +3849,7 @@ func (p PriceSheetProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "meterId", p.MeterID) populate(objectMap, "offerId", p.OfferID) populate(objectMap, "partNumber", p.PartNumber) + populate(objectMap, "savingsPlan", p.SavingsPlan) populate(objectMap, "unitOfMeasure", p.UnitOfMeasure) populate(objectMap, "unitPrice", p.UnitPrice) return json.Marshal(objectMap) @@ -3578,6 +3885,9 @@ func (p *PriceSheetProperties) UnmarshalJSON(data []byte) error { case "partNumber": err = unpopulate(val, "PartNumber", &p.PartNumber) delete(rawMsg, key) + case "savingsPlan": + err = unpopulate(val, "SavingsPlan", &p.SavingsPlan) + delete(rawMsg, key) case "unitOfMeasure": err = unpopulate(val, "UnitOfMeasure", &p.UnitOfMeasure) delete(rawMsg, key) @@ -3639,6 +3949,37 @@ func (p *PriceSheetResult) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type PricesheetDownloadProperties. +func (p PricesheetDownloadProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "downloadUrl", p.DownloadURL) + populateDateTimeRFC3339(objectMap, "validTill", p.ValidTill) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PricesheetDownloadProperties. +func (p *PricesheetDownloadProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "downloadUrl": + err = unpopulate(val, "DownloadURL", &p.DownloadURL) + delete(rawMsg, key) + case "validTill": + err = unpopulateDateTimeRFC3339(val, "ValidTill", &p.ValidTill) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type ProxyResource. func (p ProxyResource) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -4613,6 +4954,41 @@ func (s *SKUProperty) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type SavingsPlan. +func (s SavingsPlan) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "effectivePrice", s.EffectivePrice) + populate(objectMap, "marketPrice", s.MarketPrice) + populate(objectMap, "term", s.Term) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SavingsPlan. +func (s *SavingsPlan) 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 "effectivePrice": + err = unpopulate(val, "EffectivePrice", &s.EffectivePrice) + delete(rawMsg, key) + case "marketPrice": + err = unpopulate(val, "MarketPrice", &s.MarketPrice) + 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 Tag. func (t Tag) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -4811,7 +5187,7 @@ func populate(m map[string]any, k string, v any) { } func unpopulate(data json.RawMessage, fn string, v any) error { - if data == nil { + if data == nil || string(data) == "null" { return nil } if err := json.Unmarshal(data, v); err != nil { diff --git a/sdk/resourcemanager/consumption/armconsumption/operations_client.go b/sdk/resourcemanager/consumption/armconsumption/operations_client.go index 467ea5b7d09d..e39de8254de2 100644 --- a/sdk/resourcemanager/consumption/armconsumption/operations_client.go +++ b/sdk/resourcemanager/consumption/armconsumption/operations_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -39,7 +36,7 @@ func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientO // NewListPager - Lists all of the available consumption REST API operations. // -// Generated from API version 2021-10-01 +// Generated from API version 2025-04-01 // - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ @@ -65,14 +62,14 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption } // listCreateRequest creates the List request. -func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { +func (client *OperationsClient) listCreateRequest(ctx context.Context, _ *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Consumption/operations" req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-10-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/consumption/armconsumption/operations_client_example_test.go b/sdk/resourcemanager/consumption/armconsumption/operations_client_example_test.go deleted file mode 100644 index de858d0604b9..000000000000 --- a/sdk/resourcemanager/consumption/armconsumption/operations_client_example_test.go +++ /dev/null @@ -1,55 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armconsumption_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/OperationList.json -func ExampleOperationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewOperationsClient().NewListPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.OperationListResult = armconsumption.OperationListResult{ - // Value: []*armconsumption.Operation{ - // { - // Name: to.Ptr("Microsoft.Consumption/Operation"), - // Display: &armconsumption.OperationDisplay{ - // Description: to.Ptr("Create or Update Managed Applications"), - // Operation: to.Ptr("Create or Update Managed Applications"), - // Provider: to.Ptr("Microsoft Azure Distributed Managed Service"), - // Resource: to.Ptr("Managed Applications"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/consumption/armconsumption/options.go b/sdk/resourcemanager/consumption/armconsumption/options.go index 51ddd7530bf4..ecab45694054 100644 --- a/sdk/resourcemanager/consumption/armconsumption/options.go +++ b/sdk/resourcemanager/consumption/armconsumption/options.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -137,6 +134,13 @@ type OperationsClientListOptions struct { // placeholder for future optional parameters } +// PriceSheetClientBeginDownloadByBillingAccountPeriodOptions contains the optional parameters for the PriceSheetClient.BeginDownloadByBillingAccountPeriod +// method. +type PriceSheetClientBeginDownloadByBillingAccountPeriodOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + // PriceSheetClientGetByBillingPeriodOptions contains the optional parameters for the PriceSheetClient.GetByBillingPeriod // method. type PriceSheetClientGetByBillingPeriodOptions struct { @@ -171,7 +175,9 @@ type PriceSheetClientGetOptions struct { // ReservationRecommendationDetailsClientGetOptions contains the optional parameters for the ReservationRecommendationDetailsClient.Get // method. type ReservationRecommendationDetailsClientGetOptions struct { - // placeholder for future optional parameters + // Used to filter reservation recommendation details by: properties/subscriptionId can be specified for billing account and + // billing profile paths. + Filter *string } // ReservationRecommendationsClientListOptions contains the optional parameters for the ReservationRecommendationsClient.NewListPager @@ -191,7 +197,10 @@ type ReservationRecommendationsClientListOptions struct { // method. type ReservationTransactionsClientListByBillingProfileOptions struct { // Filter reservation transactions by date range. The properties/EventDate for start date and end date. The filter supports - // 'le' and 'ge' + // 'le' and 'ge'. Note: API returns data for the entire start date's and end + // date's billing month. For example, filter properties/eventDate+ge+2020-01-01+AND+properties/eventDate+le+2020-12-29 will + // include data for entire December 2020 month (i.e. will contain records for + // dates December 30 and 31) Filter *string } @@ -199,8 +208,17 @@ type ReservationTransactionsClientListByBillingProfileOptions struct { // method. type ReservationTransactionsClientListOptions struct { // Filter reservation transactions by date range. The properties/EventDate for start date and end date. The filter supports - // 'le' and 'ge' + // 'le' and 'ge'. Note: API returns data for the entire start date's and end + // date's billing month. For example, filter properties/eventDate+ge+2020-01-01+AND+properties/eventDate+le+2020-12-29 will + // include data for the entire December 2020 month (i.e. will contain records for + // dates December 30 and 31) Filter *string + + // Preview markup percentage to be applied. + PreviewMarkupPercentage *float64 + + // Applies mark up to the transactions if the caller is a partner. + UseMarkupIfPartner *bool } // ReservationsDetailsClientListByReservationOrderAndReservationOptions contains the optional parameters for the ReservationsDetailsClient.NewListByReservationOrderAndReservationPager diff --git a/sdk/resourcemanager/consumption/armconsumption/polymorphic_helpers.go b/sdk/resourcemanager/consumption/armconsumption/polymorphic_helpers.go index 92fd73996ef4..cc91f1790d1d 100644 --- a/sdk/resourcemanager/consumption/armconsumption/polymorphic_helpers.go +++ b/sdk/resourcemanager/consumption/armconsumption/polymorphic_helpers.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -11,7 +8,7 @@ package armconsumption import "encoding/json" func unmarshalChargeSummaryClassification(rawMsg json.RawMessage) (ChargeSummaryClassification, error) { - if rawMsg == nil { + if rawMsg == nil || string(rawMsg) == "null" { return nil, nil } var m map[string]any @@ -34,7 +31,7 @@ func unmarshalChargeSummaryClassification(rawMsg json.RawMessage) (ChargeSummary } func unmarshalChargeSummaryClassificationArray(rawMsg json.RawMessage) ([]ChargeSummaryClassification, error) { - if rawMsg == nil { + if rawMsg == nil || string(rawMsg) == "null" { return nil, nil } var rawMessages []json.RawMessage @@ -53,7 +50,7 @@ func unmarshalChargeSummaryClassificationArray(rawMsg json.RawMessage) ([]Charge } func unmarshalLegacyReservationRecommendationPropertiesClassification(rawMsg json.RawMessage) (LegacyReservationRecommendationPropertiesClassification, error) { - if rawMsg == nil { + if rawMsg == nil || string(rawMsg) == "null" { return nil, nil } var m map[string]any @@ -75,8 +72,31 @@ func unmarshalLegacyReservationRecommendationPropertiesClassification(rawMsg jso return b, nil } +func unmarshalModernReservationRecommendationPropertiesClassification(rawMsg json.RawMessage) (ModernReservationRecommendationPropertiesClassification, error) { + if rawMsg == nil || string(rawMsg) == "null" { + return nil, nil + } + var m map[string]any + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b ModernReservationRecommendationPropertiesClassification + switch m["scope"] { + case "Shared": + b = &ModernSharedScopeReservationRecommendationProperties{} + case "Single": + b = &ModernSingleScopeReservationRecommendationProperties{} + default: + b = &ModernReservationRecommendationProperties{} + } + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil +} + func unmarshalReservationRecommendationClassification(rawMsg json.RawMessage) (ReservationRecommendationClassification, error) { - if rawMsg == nil { + if rawMsg == nil || string(rawMsg) == "null" { return nil, nil } var m map[string]any @@ -99,7 +119,7 @@ func unmarshalReservationRecommendationClassification(rawMsg json.RawMessage) (R } func unmarshalReservationRecommendationClassificationArray(rawMsg json.RawMessage) ([]ReservationRecommendationClassification, error) { - if rawMsg == nil { + if rawMsg == nil || string(rawMsg) == "null" { return nil, nil } var rawMessages []json.RawMessage @@ -118,7 +138,7 @@ func unmarshalReservationRecommendationClassificationArray(rawMsg json.RawMessag } func unmarshalUsageDetailClassification(rawMsg json.RawMessage) (UsageDetailClassification, error) { - if rawMsg == nil { + if rawMsg == nil || string(rawMsg) == "null" { return nil, nil } var m map[string]any @@ -141,7 +161,7 @@ func unmarshalUsageDetailClassification(rawMsg json.RawMessage) (UsageDetailClas } func unmarshalUsageDetailClassificationArray(rawMsg json.RawMessage) ([]UsageDetailClassification, error) { - if rawMsg == nil { + if rawMsg == nil || string(rawMsg) == "null" { return nil, nil } var rawMessages []json.RawMessage diff --git a/sdk/resourcemanager/consumption/armconsumption/pricesheet_client.go b/sdk/resourcemanager/consumption/armconsumption/pricesheet_client.go index 2fb058398475..949735ef9864 100644 --- a/sdk/resourcemanager/consumption/armconsumption/pricesheet_client.go +++ b/sdk/resourcemanager/consumption/armconsumption/pricesheet_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -44,10 +41,85 @@ func NewPriceSheetClient(subscriptionID string, credential azcore.TokenCredentia return client, nil } +// BeginDownloadByBillingAccountPeriod - Generates the pricesheet for the provided billing period asynchronously based on +// the enrollment id +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-04-01 +// - billingAccountID - BillingAccount ID +// - billingPeriodName - Billing Period Name. +// - options - PriceSheetClientBeginDownloadByBillingAccountPeriodOptions contains the optional parameters for the PriceSheetClient.BeginDownloadByBillingAccountPeriod +// method. +func (client *PriceSheetClient) BeginDownloadByBillingAccountPeriod(ctx context.Context, billingAccountID string, billingPeriodName string, options *PriceSheetClientBeginDownloadByBillingAccountPeriodOptions) (*runtime.Poller[PriceSheetClientDownloadByBillingAccountPeriodResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.downloadByBillingAccountPeriod(ctx, billingAccountID, billingPeriodName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PriceSheetClientDownloadByBillingAccountPeriodResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[PriceSheetClientDownloadByBillingAccountPeriodResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// DownloadByBillingAccountPeriod - Generates the pricesheet for the provided billing period asynchronously based on the enrollment +// id +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-04-01 +func (client *PriceSheetClient) downloadByBillingAccountPeriod(ctx context.Context, billingAccountID string, billingPeriodName string, options *PriceSheetClientBeginDownloadByBillingAccountPeriodOptions) (*http.Response, error) { + var err error + const operationName = "PriceSheetClient.BeginDownloadByBillingAccountPeriod" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.downloadByBillingAccountPeriodCreateRequest(ctx, billingAccountID, billingPeriodName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// downloadByBillingAccountPeriodCreateRequest creates the DownloadByBillingAccountPeriod request. +func (client *PriceSheetClient) downloadByBillingAccountPeriodCreateRequest(ctx context.Context, billingAccountID string, billingPeriodName string, _ *PriceSheetClientBeginDownloadByBillingAccountPeriodOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingPeriods/{billingPeriodName}/providers/Microsoft.Consumption/pricesheets/download" + if billingAccountID == "" { + return nil, errors.New("parameter billingAccountID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountId}", url.PathEscape(billingAccountID)) + if billingPeriodName == "" { + return nil, errors.New("parameter billingPeriodName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingPeriodName}", url.PathEscape(billingPeriodName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-04-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + // Get - Gets the price sheet for a subscription. Price sheet is available via this API only for May 1, 2014 or later. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-10-01 +// Generated from API version 2025-04-01 // - options - PriceSheetClientGetOptions contains the optional parameters for the PriceSheetClient.Get method. func (client *PriceSheetClient) Get(ctx context.Context, options *PriceSheetClientGetOptions) (PriceSheetClientGetResponse, error) { var err error @@ -92,7 +164,7 @@ func (client *PriceSheetClient) getCreateRequest(ctx context.Context, options *P if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2021-10-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -111,7 +183,7 @@ func (client *PriceSheetClient) getHandleResponse(resp *http.Response) (PriceShe // this API only for May 1, 2014 or later. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-10-01 +// Generated from API version 2025-04-01 // - billingPeriodName - Billing Period Name. // - options - PriceSheetClientGetByBillingPeriodOptions contains the optional parameters for the PriceSheetClient.GetByBillingPeriod // method. @@ -162,7 +234,7 @@ func (client *PriceSheetClient) getByBillingPeriodCreateRequest(ctx context.Cont if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2021-10-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/consumption/armconsumption/pricesheet_client_example_test.go b/sdk/resourcemanager/consumption/armconsumption/pricesheet_client_example_test.go deleted file mode 100644 index caf6ef6fcd8c..000000000000 --- a/sdk/resourcemanager/consumption/armconsumption/pricesheet_client_example_test.go +++ /dev/null @@ -1,150 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armconsumption_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/consumption/armconsumption" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/PriceSheet.json -func ExamplePriceSheetClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewPriceSheetClient().Get(ctx, &armconsumption.PriceSheetClientGetOptions{Expand: nil, - Skiptoken: nil, - Top: nil, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.PriceSheetResult = armconsumption.PriceSheetResult{ - // Name: to.Ptr("default"), - // Type: to.Ptr("Microsoft.Consumption/pricesheets"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Billing/billingPeriods/201702/providers/Microsoft.Consumption/pricesheets/default"), - // Properties: &armconsumption.PriceSheetModel{ - // Pricesheets: []*armconsumption.PriceSheetProperties{ - // { - // BillingPeriodID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Billing/billingPeriods/201702"), - // CurrencyCode: to.Ptr("EUR"), - // IncludedQuantity: to.Ptr[float64](100), - // MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // OfferID: to.Ptr("OfferId 1"), - // PartNumber: to.Ptr("XX-11110"), - // UnitOfMeasure: to.Ptr("100 Hours"), - // UnitPrice: to.Ptr[float64](0.00328), - // }}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/PriceSheetExpand.json -func ExamplePriceSheetClient_GetByBillingPeriod_priceSheetExpand() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewPriceSheetClient().GetByBillingPeriod(ctx, "201801", &armconsumption.PriceSheetClientGetByBillingPeriodOptions{Expand: to.Ptr("meterDetails"), - Skiptoken: nil, - Top: nil, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.PriceSheetResult = armconsumption.PriceSheetResult{ - // Name: to.Ptr("default"), - // Type: to.Ptr("Microsoft.Consumption/pricesheets"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Billing/billingPeriods/201702/providers/Microsoft.Consumption/pricesheets/default"), - // Properties: &armconsumption.PriceSheetModel{ - // Pricesheets: []*armconsumption.PriceSheetProperties{ - // { - // BillingPeriodID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Billing/billingPeriods/201702"), - // CurrencyCode: to.Ptr("EUR"), - // IncludedQuantity: to.Ptr[float64](100), - // MeterDetails: &armconsumption.MeterDetails{ - // MeterCategory: to.Ptr("Networking"), - // MeterLocation: to.Ptr("Zone 2"), - // MeterName: to.Ptr("Data Transfer Out (GB)"), - // PretaxStandardRate: to.Ptr[float64](0.138), - // TotalIncludedQuantity: to.Ptr[float64](0), - // Unit: to.Ptr("GB"), - // }, - // MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // OfferID: to.Ptr("OfferId 1"), - // PartNumber: to.Ptr("XX-11110"), - // UnitOfMeasure: to.Ptr("100 Hours"), - // UnitPrice: to.Ptr[float64](0.00328), - // }}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/PriceSheetForBillingPeriod.json -func ExamplePriceSheetClient_GetByBillingPeriod_priceSheetForBillingPeriod() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewPriceSheetClient().GetByBillingPeriod(ctx, "201801", &armconsumption.PriceSheetClientGetByBillingPeriodOptions{Expand: nil, - Skiptoken: nil, - Top: nil, - }) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.PriceSheetResult = armconsumption.PriceSheetResult{ - // Name: to.Ptr("default"), - // Type: to.Ptr("Microsoft.Consumption/pricesheets"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Billing/billingPeriods/201702/providers/Microsoft.Consumption/pricesheets/default"), - // Properties: &armconsumption.PriceSheetModel{ - // Pricesheets: []*armconsumption.PriceSheetProperties{ - // { - // BillingPeriodID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Billing/billingPeriods/201702"), - // CurrencyCode: to.Ptr("EUR"), - // IncludedQuantity: to.Ptr[float64](100), - // MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // OfferID: to.Ptr("OfferId 1"), - // PartNumber: to.Ptr("XX-11110"), - // UnitOfMeasure: to.Ptr("100 Hours"), - // UnitPrice: to.Ptr[float64](0.00328), - // }}, - // }, - // } -} diff --git a/sdk/resourcemanager/consumption/armconsumption/reservationrecommendationdetails_client.go b/sdk/resourcemanager/consumption/armconsumption/reservationrecommendationdetails_client.go index 708da2cd3848..16ed055dd1fc 100644 --- a/sdk/resourcemanager/consumption/armconsumption/reservationrecommendationdetails_client.go +++ b/sdk/resourcemanager/consumption/armconsumption/reservationrecommendationdetails_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -41,7 +38,7 @@ func NewReservationRecommendationDetailsClient(credential azcore.TokenCredential // Get - Details of a reservation recommendation for what-if analysis of reserved instances. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-10-01 +// Generated from API version 2025-04-01 // - resourceScope - The scope associated with reservation recommendation details operations. This includes '/subscriptions/{subscriptionId}/' // for subscription scope, // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resource group scope, /providers/Microsoft.Billing/billingAccounts/{billingAccountId}' @@ -87,12 +84,15 @@ func (client *ReservationRecommendationDetailsClient) getCreateRequest(ctx conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-10-01") - reqQP.Set("scope", string(scope)) - reqQP.Set("region", region) - reqQP.Set("term", string(term)) + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + reqQP.Set("api-version", "2025-04-01") reqQP.Set("lookBackPeriod", string(lookBackPeriod)) reqQP.Set("product", product) + reqQP.Set("region", region) + reqQP.Set("scope", string(scope)) + reqQP.Set("term", string(term)) req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/consumption/armconsumption/reservationrecommendationdetails_client_example_test.go b/sdk/resourcemanager/consumption/armconsumption/reservationrecommendationdetails_client_example_test.go deleted file mode 100644 index 6769b8eafcaf..000000000000 --- a/sdk/resourcemanager/consumption/armconsumption/reservationrecommendationdetails_client_example_test.go +++ /dev/null @@ -1,345 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armconsumption_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/ReservationRecommendationDetailsByBillingAccount.json -func ExampleReservationRecommendationDetailsClient_Get_reservationRecommendationsByBillingAccountLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewReservationRecommendationDetailsClient().Get(ctx, "providers/Microsoft.Billing/billingAccounts/000000", armconsumption.ScopeShared, "eastus", armconsumption.TermP1Y, armconsumption.LookBackPeriodLast60Days, "Standard_DS14_v2", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ReservationRecommendationDetailsModel = armconsumption.ReservationRecommendationDetailsModel{ - // Name: to.Ptr("reservationRecommendationDetails"), - // Type: to.Ptr("Microsoft.Consumption/ReservationRecommendationDetails"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/00000000/providers/microsoft.consumption/reservationrecommendationdetails"), - // Properties: &armconsumption.ReservationRecommendationDetailsProperties{ - // Currency: to.Ptr("USD"), - // Resource: &armconsumption.ReservationRecommendationDetailsResourceProperties{ - // AppliedScopes: []*string{ - // to.Ptr("00000000-0000-0000-0000-00000000"), - // to.Ptr("00000000-0000-0000-0000-00000000")}, - // OnDemandRate: to.Ptr[float32](1.482), - // Product: to.Ptr("Standard_DS14_v2"), - // Region: to.Ptr("eastus"), - // ReservationRate: to.Ptr[float32](0.70570776255707), - // ResourceType: to.Ptr("virtualmachines"), - // }, - // Savings: &armconsumption.ReservationRecommendationDetailsSavingsProperties{ - // CalculatedSavings: []*armconsumption.ReservationRecommendationDetailsCalculatedSavingsProperties{ - // { - // OnDemandCost: to.Ptr[float32](529550.326618951), - // OverageCost: to.Ptr[float32](63253.5935111345), - // Quantity: to.Ptr[float32](220), - // ReservationCost: to.Ptr[float32](223102.452054792), - // Savings: to.Ptr[float32](243194.281053024), - // TotalReservationCost: to.Ptr[float32](286356.045565927), - // }, - // { - // OnDemandCost: to.Ptr[float32](529550.32661895), - // OverageCost: to.Ptr[float32](149335.025050147), - // Quantity: to.Ptr[float32](179), - // ReservationCost: to.Ptr[float32](181524.267808217), - // Savings: to.Ptr[float32](198691.033760586), - // TotalReservationCost: to.Ptr[float32](330859.292858364), - // }, - // { - // OnDemandCost: to.Ptr[float32](529550.32661895), - // OverageCost: to.Ptr[float32](195942.319606957), - // Quantity: to.Ptr[float32](157), - // ReservationCost: to.Ptr[float32](159214.022602738), - // Savings: to.Ptr[float32](174393.984409255), - // TotalReservationCost: to.Ptr[float32](355156.342209695), - // }, - // { - // OnDemandCost: to.Ptr[float32](529550.32661895), - // OverageCost: to.Ptr[float32](30975.2311896299), - // Quantity: to.Ptr[float32](241), - // ReservationCost: to.Ptr[float32](244398.595205477), - // Savings: to.Ptr[float32](254176.500223843), - // TotalReservationCost: to.Ptr[float32](275373.826395107), - // }}, - // LookBackPeriod: to.Ptr[int32](60), - // RecommendedQuantity: to.Ptr[float32](253), - // ReservationOrderTerm: to.Ptr("P1Y"), - // SavingsType: to.Ptr("instance"), - // UnitOfMeasure: to.Ptr("hour"), - // }, - // Scope: to.Ptr("Shared"), - // Usage: &armconsumption.ReservationRecommendationDetailsUsageProperties{ - // FirstConsumptionDate: to.Ptr("2019-11-27T00:00:00"), - // LastConsumptionDate: to.Ptr("2020-01-25T21:00:00"), - // LookBackUnitType: to.Ptr("virtualMachine quantity"), - // UsageData: []*float32{ - // to.Ptr[float32](275.95003899999995), - // to.Ptr[float32](275.916705), - // to.Ptr[float32](276), - // to.Ptr[float32](276), - // to.Ptr[float32](275.916725), - // to.Ptr[float32](275.916705), - // to.Ptr[float32](275.98335299999997), - // to.Ptr[float32](276), - // to.Ptr[float32](276), - // to.Ptr[float32](276), - // to.Ptr[float32](276), - // to.Ptr[float32](276), - // to.Ptr[float32](275.98335299999997), - // to.Ptr[float32](276), - // to.Ptr[float32](276), - // to.Ptr[float32](276), - // to.Ptr[float32](276), - // to.Ptr[float32](275.933352)}, - // UsageGrain: to.Ptr("hourly"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/ReservationRecommendationDetailsByBillingProfile.json -func ExampleReservationRecommendationDetailsClient_Get_reservationRecommendationsByBillingProfileModern() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewReservationRecommendationDetailsClient().Get(ctx, "providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-00000000:00000000-0000-0000-0000-00000000/billingProfiles/00000000-0000-0000-0000-00000000", armconsumption.ScopeShared, "australiaeast", armconsumption.TermP1Y, armconsumption.LookBackPeriodLast07Days, "Standard_B2s", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ReservationRecommendationDetailsModel = armconsumption.ReservationRecommendationDetailsModel{ - // Name: to.Ptr("reservationRecommendationDetails"), - // Type: to.Ptr("Microsoft.Consumption/ReservationRecommendationDetails"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-00000000:00000000-0000-0000-0000-00000000/billingProfiles/00000000-0000-0000-0000-00000000/providers/microsoft.consumption/reservationrecommendationdetails"), - // Properties: &armconsumption.ReservationRecommendationDetailsProperties{ - // Currency: to.Ptr("AUD"), - // Resource: &armconsumption.ReservationRecommendationDetailsResourceProperties{ - // AppliedScopes: []*string{ - // to.Ptr("00000000-0000-0000-0000-00000000")}, - // OnDemandRate: to.Ptr[float32](0.0725), - // Product: to.Ptr("Standard_B2s"), - // Region: to.Ptr("australiaeast"), - // ReservationRate: to.Ptr[float32](0.04414166531788041), - // ResourceType: to.Ptr("virtualmachines"), - // }, - // Savings: &armconsumption.ReservationRecommendationDetailsSavingsProperties{ - // CalculatedSavings: []*armconsumption.ReservationRecommendationDetailsCalculatedSavingsProperties{ - // { - // OnDemandCost: to.Ptr[float32](632.8844720496894), - // OverageCost: to.Ptr[float32](0), - // Quantity: to.Ptr[float32](1), - // ReservationCost: to.Ptr[float32](387.74038815226174), - // Savings: to.Ptr[float32](245.1440838974277), - // TotalReservationCost: to.Ptr[float32](387.74038815226174), - // }}, - // LookBackPeriod: to.Ptr[int32](7), - // RecommendedQuantity: to.Ptr[float32](1), - // ReservationOrderTerm: to.Ptr("P1Y"), - // SavingsType: to.Ptr("instance"), - // UnitOfMeasure: to.Ptr("hour"), - // }, - // Scope: to.Ptr("Shared"), - // Usage: &armconsumption.ReservationRecommendationDetailsUsageProperties{ - // FirstConsumptionDate: to.Ptr("2020-01-19T00:00:00"), - // LastConsumptionDate: to.Ptr("2020-01-25T17:00:00"), - // LookBackUnitType: to.Ptr("virtualMachine quantity"), - // UsageData: []*float32{ - // to.Ptr[float32](1), - // to.Ptr[float32](1), - // to.Ptr[float32](1), - // to.Ptr[float32](1), - // to.Ptr[float32](1), - // to.Ptr[float32](1), - // to.Ptr[float32](1), - // to.Ptr[float32](1), - // to.Ptr[float32](1), - // to.Ptr[float32](0)}, - // UsageGrain: to.Ptr("hourly"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/ReservationRecommendationDetailsByResourceGroup.json -func ExampleReservationRecommendationDetailsClient_Get_reservationRecommendationsByResourceGroupLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewReservationRecommendationDetailsClient().Get(ctx, "subscriptions/00000000-0000-0000-0000-00000000/resourceGroups/testGroup", armconsumption.ScopeSingle, "westus", armconsumption.TermP3Y, armconsumption.LookBackPeriodLast30Days, "Standard_DS13_v2", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ReservationRecommendationDetailsModel = armconsumption.ReservationRecommendationDetailsModel{ - // Name: to.Ptr("reservationRecommendationDetails"), - // Type: to.Ptr("Microsoft.Consumption/ReservationRecommendationDetails"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-00000000/resourceGroups/testGroup/providers/microsoft.consumption/reservationrecommendationdetails"), - // Properties: &armconsumption.ReservationRecommendationDetailsProperties{ - // Currency: to.Ptr("USD"), - // Resource: &armconsumption.ReservationRecommendationDetailsResourceProperties{ - // AppliedScopes: []*string{ - // to.Ptr("00000000-0000-0000-0000-00000000"), - // to.Ptr("testGroup")}, - // OnDemandRate: to.Ptr[float32](0.519), - // Product: to.Ptr("Standard_DS13_v2"), - // Region: to.Ptr("westus"), - // ReservationRate: to.Ptr[float32](0.302549467275493), - // ResourceType: to.Ptr("virtualmachines"), - // }, - // ResourceGroup: to.Ptr("testGroup"), - // Savings: &armconsumption.ReservationRecommendationDetailsSavingsProperties{ - // CalculatedSavings: []*armconsumption.ReservationRecommendationDetailsCalculatedSavingsProperties{ - // { - // OnDemandCost: to.Ptr[float32](368.4813602070006), - // OverageCost: to.Ptr[float32](0), - // Quantity: to.Ptr[float32](2), - // ReservationCost: to.Ptr[float32](429.01514459665), - // Savings: to.Ptr[float32](-60.5337843896494), - // TotalReservationCost: to.Ptr[float32](429.01514459665), - // }, - // { - // OnDemandCost: to.Ptr[float32](368.481360207), - // OverageCost: to.Ptr[float32](1.557), - // Quantity: to.Ptr[float32](1), - // ReservationCost: to.Ptr[float32](214.507572298325), - // Savings: to.Ptr[float32](152.416787908675), - // TotalReservationCost: to.Ptr[float32](216.064572298325), - // }}, - // LookBackPeriod: to.Ptr[int32](30), - // RecommendedQuantity: to.Ptr[float32](1), - // ReservationOrderTerm: to.Ptr("P3Y"), - // SavingsType: to.Ptr("instance"), - // UnitOfMeasure: to.Ptr("hour"), - // }, - // Scope: to.Ptr("Single"), - // Usage: &armconsumption.ReservationRecommendationDetailsUsageProperties{ - // FirstConsumptionDate: to.Ptr("2020-02-03T00:00:00"), - // LastConsumptionDate: to.Ptr("2020-03-03T13:00:00"), - // LookBackUnitType: to.Ptr("virtualMachine quantity"), - // UsageData: []*float32{ - // to.Ptr[float32](1), - // to.Ptr[float32](1), - // to.Ptr[float32](1), - // to.Ptr[float32](1), - // to.Ptr[float32](1), - // to.Ptr[float32](1)}, - // UsageGrain: to.Ptr("hourly"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/ReservationRecommendationDetailsBySubscription.json -func ExampleReservationRecommendationDetailsClient_Get_reservationRecommendationsBySubscriptionLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewReservationRecommendationDetailsClient().Get(ctx, "subscriptions/00000000-0000-0000-0000-00000000", armconsumption.ScopeSingle, "westus", armconsumption.TermP3Y, armconsumption.LookBackPeriodLast30Days, "Standard_DS13_v2", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ReservationRecommendationDetailsModel = armconsumption.ReservationRecommendationDetailsModel{ - // Name: to.Ptr("reservationRecommendationDetails"), - // Type: to.Ptr("Microsoft.Consumption/ReservationRecommendationDetails"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-00000000/providers/microsoft.consumption/reservationrecommendationdetails"), - // Properties: &armconsumption.ReservationRecommendationDetailsProperties{ - // Currency: to.Ptr("USD"), - // Resource: &armconsumption.ReservationRecommendationDetailsResourceProperties{ - // AppliedScopes: []*string{ - // to.Ptr("00000000-0000-0000-0000-00000000")}, - // OnDemandRate: to.Ptr[float32](0.519), - // Product: to.Ptr("Standard_DS13_v2"), - // Region: to.Ptr("westus"), - // ReservationRate: to.Ptr[float32](0.302549467275493), - // ResourceType: to.Ptr("virtualmachines"), - // }, - // Savings: &armconsumption.ReservationRecommendationDetailsSavingsProperties{ - // CalculatedSavings: []*armconsumption.ReservationRecommendationDetailsCalculatedSavingsProperties{ - // { - // OnDemandCost: to.Ptr[float32](368.4813602070006), - // OverageCost: to.Ptr[float32](0), - // Quantity: to.Ptr[float32](2), - // ReservationCost: to.Ptr[float32](429.01514459665), - // Savings: to.Ptr[float32](-60.5337843896494), - // TotalReservationCost: to.Ptr[float32](429.01514459665), - // }, - // { - // OnDemandCost: to.Ptr[float32](368.481360207), - // OverageCost: to.Ptr[float32](1.557), - // Quantity: to.Ptr[float32](1), - // ReservationCost: to.Ptr[float32](214.507572298325), - // Savings: to.Ptr[float32](152.416787908675), - // TotalReservationCost: to.Ptr[float32](216.064572298325), - // }}, - // LookBackPeriod: to.Ptr[int32](30), - // RecommendedQuantity: to.Ptr[float32](1), - // ReservationOrderTerm: to.Ptr("P3Y"), - // SavingsType: to.Ptr("instance"), - // UnitOfMeasure: to.Ptr("hour"), - // }, - // Scope: to.Ptr("Single"), - // Usage: &armconsumption.ReservationRecommendationDetailsUsageProperties{ - // FirstConsumptionDate: to.Ptr("2020-02-03T00:00:00"), - // LastConsumptionDate: to.Ptr("2020-03-03T13:00:00"), - // LookBackUnitType: to.Ptr("virtualMachine quantity"), - // UsageData: []*float32{ - // to.Ptr[float32](1), - // to.Ptr[float32](1), - // to.Ptr[float32](1), - // to.Ptr[float32](1), - // to.Ptr[float32](1), - // to.Ptr[float32](1)}, - // UsageGrain: to.Ptr("hourly"), - // }, - // }, - // } -} diff --git a/sdk/resourcemanager/consumption/armconsumption/reservationrecommendations_client.go b/sdk/resourcemanager/consumption/armconsumption/reservationrecommendations_client.go index 4b93c4193343..396e2de5198b 100644 --- a/sdk/resourcemanager/consumption/armconsumption/reservationrecommendations_client.go +++ b/sdk/resourcemanager/consumption/armconsumption/reservationrecommendations_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -40,7 +37,7 @@ func NewReservationRecommendationsClient(credential azcore.TokenCredential, opti // NewListPager - List of recommendations for purchasing reserved instances. // -// Generated from API version 2021-10-01 +// Generated from API version 2025-04-01 // - resourceScope - The scope associated with reservation recommendations operations. This includes '/subscriptions/{subscriptionId}/' // for subscription scope, // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resource group scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' @@ -84,7 +81,7 @@ func (client *ReservationRecommendationsClient) listCreateRequest(ctx context.Co if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - reqQP.Set("api-version", "2021-10-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/consumption/armconsumption/reservationrecommendations_client_example_test.go b/sdk/resourcemanager/consumption/armconsumption/reservationrecommendations_client_example_test.go deleted file mode 100644 index d3bb003b329f..000000000000 --- a/sdk/resourcemanager/consumption/armconsumption/reservationrecommendations_client_example_test.go +++ /dev/null @@ -1,443 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armconsumption_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/consumption/armconsumption" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/ReservationRecommendationsByBillingAccount.json -func ExampleReservationRecommendationsClient_NewListPager_reservationRecommendationsByBillingAccountLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewReservationRecommendationsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/123456", &armconsumption.ReservationRecommendationsClientListOptions{Filter: nil}) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ReservationRecommendationsListResult = armconsumption.ReservationRecommendationsListResult{ - // Value: []armconsumption.ReservationRecommendationClassification{ - // &armconsumption.LegacyReservationRecommendation{ - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.Consumption/reservationRecommendations"), - // ID: to.Ptr("billingAccount/123456/providers/Microsoft.Consumption/reservationRecommendations/00000000-0000-0000-0000-000000000000"), - // Location: to.Ptr("westus"), - // SKU: to.Ptr("Standard_DS1_v2"), - // Kind: to.Ptr(armconsumption.ReservationRecommendationKindLegacy), - // Properties: &armconsumption.LegacySharedScopeReservationRecommendationProperties{ - // CostWithNoReservedInstances: to.Ptr[float64](12.0785105), - // FirstUsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-07-07T07:00:00.000Z"); return t}()), - // InstanceFlexibilityGroup: to.Ptr("DSv2 Series"), - // InstanceFlexibilityRatio: to.Ptr[float32](1), - // LookBackPeriod: to.Ptr("Last7Days"), - // MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // NetSavings: to.Ptr[float64](0.588546019225182), - // NormalizedSize: to.Ptr("Standard_DS1_v2"), - // RecommendedQuantity: to.Ptr[float64](1), - // RecommendedQuantityNormalized: to.Ptr[float32](1), - // Scope: to.Ptr("Shared"), - // SKUProperties: []*armconsumption.SKUProperty{ - // { - // Name: to.Ptr("Cores"), - // Value: to.Ptr("1"), - // }, - // { - // Name: to.Ptr("Ram"), - // Value: to.Ptr("1"), - // }}, - // Term: to.Ptr("P1Y"), - // TotalCostWithReservedInstances: to.Ptr[float64](11.4899644807748), - // }, - // }, - // &armconsumption.LegacyReservationRecommendation{ - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.Consumption/reservationRecommendations"), - // ID: to.Ptr("billingAccount/123456/providers/Microsoft.Consumption/reservationRecommendations/00000000-0000-0000-0000-000000000000"), - // Location: to.Ptr("westus"), - // SKU: to.Ptr("Standard_DS1_v2"), - // Kind: to.Ptr(armconsumption.ReservationRecommendationKindLegacy), - // Properties: &armconsumption.LegacySharedScopeReservationRecommendationProperties{ - // CostWithNoReservedInstances: to.Ptr[float64](10.0785105), - // FirstUsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-07-07T07:00:00.000Z"); return t}()), - // InstanceFlexibilityGroup: to.Ptr("DSv2 Series"), - // InstanceFlexibilityRatio: to.Ptr[float32](1), - // LookBackPeriod: to.Ptr("Last7Days"), - // MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // NetSavings: to.Ptr[float64](0.68), - // NormalizedSize: to.Ptr("Standard_DS1"), - // RecommendedQuantity: to.Ptr[float64](1), - // RecommendedQuantityNormalized: to.Ptr[float32](1.2), - // Scope: to.Ptr("Shared"), - // SKUProperties: []*armconsumption.SKUProperty{ - // { - // Name: to.Ptr("SkuDisplayName"), - // Value: to.Ptr("B"), - // }, - // { - // Name: to.Ptr("CPU"), - // Value: to.Ptr("1"), - // }}, - // Term: to.Ptr("P1Y"), - // TotalCostWithReservedInstances: to.Ptr[float64](13.48), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/ReservationRecommendationsByBillingProfile.json -func ExampleReservationRecommendationsClient_NewListPager_reservationRecommendationsByBillingProfileModern() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewReservationRecommendationsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/123456/billingProfiles/6420", &armconsumption.ReservationRecommendationsClientListOptions{Filter: nil}) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ReservationRecommendationsListResult = armconsumption.ReservationRecommendationsListResult{ - // Value: []armconsumption.ReservationRecommendationClassification{ - // &armconsumption.ModernReservationRecommendation{ - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.Consumption/reservationRecommendations"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/123456/billingProfiles/6420/providers/Microsoft.Consumption/reservationRecommendations/00000000-0000-0000-0000-000000000000"), - // Location: to.Ptr("westus"), - // SKU: to.Ptr("Standard_DS1_v2"), - // Kind: to.Ptr(armconsumption.ReservationRecommendationKindModern), - // Properties: &armconsumption.ModernReservationRecommendationProperties{ - // CostWithNoReservedInstances: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](1.4749000882), - // }, - // FirstUsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-07-07T07:00:00.000Z"); return t}()), - // InstanceFlexibilityGroup: to.Ptr("DSv2 Series"), - // InstanceFlexibilityRatio: to.Ptr[float32](1), - // LookBackPeriod: to.Ptr[int32](7), - // MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // NetSavings: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](0.39824251795372), - // }, - // NormalizedSize: to.Ptr("Standard_DS1_v2"), - // RecommendedQuantity: to.Ptr[float64](1), - // RecommendedQuantityNormalized: to.Ptr[float32](1), - // Scope: to.Ptr("Shared"), - // SKUProperties: []*armconsumption.SKUProperty{ - // { - // Name: to.Ptr("Cores"), - // Value: to.Ptr("1"), - // }, - // { - // Name: to.Ptr("Ram"), - // Value: to.Ptr("1"), - // }}, - // Term: to.Ptr("P1Y"), - // TotalCostWithReservedInstances: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](1.07665757024628), - // }, - // }, - // }, - // &armconsumption.ModernReservationRecommendation{ - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.Consumption/reservationRecommendations"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/123456/billingProfiles/6420/providers/Microsoft.Consumption/reservationRecommendations/00000000-0000-0000-0000-000000000000"), - // Location: to.Ptr("westus"), - // SKU: to.Ptr("Standard_DS1_v2"), - // Kind: to.Ptr(armconsumption.ReservationRecommendationKindModern), - // Properties: &armconsumption.ModernReservationRecommendationProperties{ - // CostWithNoReservedInstances: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](1.4896), - // }, - // FirstUsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-07-07T07:00:00.000Z"); return t}()), - // InstanceFlexibilityGroup: to.Ptr("DSv2 Series"), - // InstanceFlexibilityRatio: to.Ptr[float32](1), - // LookBackPeriod: to.Ptr[int32](7), - // MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // NetSavings: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](0.40694246575372), - // }, - // NormalizedSize: to.Ptr("Standard_DS1"), - // RecommendedQuantity: to.Ptr[float64](1), - // RecommendedQuantityNormalized: to.Ptr[float32](1.2), - // Scope: to.Ptr("Shared"), - // SKUProperties: []*armconsumption.SKUProperty{ - // { - // Name: to.Ptr("SkuDisplayName"), - // Value: to.Ptr("B"), - // }, - // { - // Name: to.Ptr("CPU"), - // Value: to.Ptr("1"), - // }}, - // Term: to.Ptr("P1Y"), - // TotalCostWithReservedInstances: &armconsumption.Amount{ - // Currency: to.Ptr("USD"), - // Value: to.Ptr[float64](1.08265753424628), - // }, - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/ReservationRecommendationsByResourceGroup.json -func ExampleReservationRecommendationsClient_NewListPager_reservationRecommendationsByResourceGroupLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewReservationRecommendationsClient().NewListPager("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", &armconsumption.ReservationRecommendationsClientListOptions{Filter: nil}) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ReservationRecommendationsListResult = armconsumption.ReservationRecommendationsListResult{ - // Value: []armconsumption.ReservationRecommendationClassification{ - // &armconsumption.LegacyReservationRecommendation{ - // Name: to.Ptr("reservationRecommendations1"), - // Type: to.Ptr("Microsoft.Consumption/reservationRecommendations"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/resourceGrouups/testGroup/providers/Microsoft.Consumption/reservationRecommendations/reservationRecommendations1"), - // Location: to.Ptr("northeurope"), - // SKU: to.Ptr("Standard_DS1_v2"), - // Kind: to.Ptr(armconsumption.ReservationRecommendationKindLegacy), - // Properties: &armconsumption.LegacySingleScopeReservationRecommendationProperties{ - // CostWithNoReservedInstances: to.Ptr[float64](0), - // FirstUsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-06T00:00:00.000Z"); return t}()), - // LookBackPeriod: to.Ptr("Last7Days"), - // MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // NetSavings: to.Ptr[float64](4.634521202630137), - // RecommendedQuantity: to.Ptr[float64](1), - // Scope: to.Ptr("Single"), - // Term: to.Ptr("P1Y"), - // TotalCostWithReservedInstances: to.Ptr[float64](0), - // SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // }, - // }, - // &armconsumption.LegacyReservationRecommendation{ - // Name: to.Ptr("reservationRecommendations2"), - // Type: to.Ptr("Microsoft.Consumption/reservationRecommendations"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Consumption/reservationRecommendations/reservationRecommendations2"), - // Location: to.Ptr("northeurope"), - // SKU: to.Ptr("Standard_DS1_v2"), - // Kind: to.Ptr(armconsumption.ReservationRecommendationKindLegacy), - // Properties: &armconsumption.LegacySingleScopeReservationRecommendationProperties{ - // CostWithNoReservedInstances: to.Ptr[float64](0), - // FirstUsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-06T00:00:00.000Z"); return t}()), - // LookBackPeriod: to.Ptr("Last7Days"), - // MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // NetSavings: to.Ptr[float64](7.289315723178081), - // RecommendedQuantity: to.Ptr[float64](1), - // Scope: to.Ptr("Single"), - // Term: to.Ptr("P3Y"), - // TotalCostWithReservedInstances: to.Ptr[float64](0), - // SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/ReservationRecommendationsBySubscription.json -func ExampleReservationRecommendationsClient_NewListPager_reservationRecommendationsBySubscriptionLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewReservationRecommendationsClient().NewListPager("subscriptions/00000000-0000-0000-0000-000000000000", &armconsumption.ReservationRecommendationsClientListOptions{Filter: nil}) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ReservationRecommendationsListResult = armconsumption.ReservationRecommendationsListResult{ - // Value: []armconsumption.ReservationRecommendationClassification{ - // &armconsumption.LegacyReservationRecommendation{ - // Name: to.Ptr("reservationRecommendations1"), - // Type: to.Ptr("Microsoft.Consumption/reservationRecommendations"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/reservationRecommendations/reservationRecommendations1"), - // Location: to.Ptr("northeurope"), - // SKU: to.Ptr("Standard_DS1_v2"), - // Kind: to.Ptr(armconsumption.ReservationRecommendationKindLegacy), - // Properties: &armconsumption.LegacySingleScopeReservationRecommendationProperties{ - // CostWithNoReservedInstances: to.Ptr[float64](0), - // FirstUsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-06T00:00:00.000Z"); return t}()), - // LookBackPeriod: to.Ptr("Last7Days"), - // MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // NetSavings: to.Ptr[float64](4.634521202630137), - // RecommendedQuantity: to.Ptr[float64](1), - // Scope: to.Ptr("Single"), - // Term: to.Ptr("P1Y"), - // TotalCostWithReservedInstances: to.Ptr[float64](0), - // SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // }, - // }, - // &armconsumption.LegacyReservationRecommendation{ - // Name: to.Ptr("reservationRecommendations2"), - // Type: to.Ptr("Microsoft.Consumption/reservationRecommendations"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/reservationRecommendations/reservationRecommendations2"), - // Location: to.Ptr("northeurope"), - // SKU: to.Ptr("Standard_DS1_v2"), - // Kind: to.Ptr(armconsumption.ReservationRecommendationKindLegacy), - // Properties: &armconsumption.LegacySingleScopeReservationRecommendationProperties{ - // CostWithNoReservedInstances: to.Ptr[float64](0), - // FirstUsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-06T00:00:00.000Z"); return t}()), - // LookBackPeriod: to.Ptr("Last7Days"), - // MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // NetSavings: to.Ptr[float64](7.289315723178081), - // RecommendedQuantity: to.Ptr[float64](1), - // Scope: to.Ptr("Single"), - // Term: to.Ptr("P3Y"), - // TotalCostWithReservedInstances: to.Ptr[float64](0), - // SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/ReservationRecommendationsFilterBySubscriptionForScopeLookBackPeriod.json -func ExampleReservationRecommendationsClient_NewListPager_reservationRecommendationsFilterBySubscriptionForScopeLookBackPeriodLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewReservationRecommendationsClient().NewListPager("subscriptions/00000000-0000-0000-0000-000000000000", &armconsumption.ReservationRecommendationsClientListOptions{Filter: to.Ptr("properties/scope eq 'Single' AND properties/lookBackPeriod eq 'Last7Days'")}) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ReservationRecommendationsListResult = armconsumption.ReservationRecommendationsListResult{ - // Value: []armconsumption.ReservationRecommendationClassification{ - // &armconsumption.LegacyReservationRecommendation{ - // Name: to.Ptr("reservationRecommendations1"), - // Type: to.Ptr("Microsoft.Consumption/reservationRecommendations"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/reservationRecommendations/reservationRecommendations1"), - // Location: to.Ptr("northeurope"), - // SKU: to.Ptr("Standard_DS1_v2"), - // Kind: to.Ptr(armconsumption.ReservationRecommendationKindLegacy), - // Properties: &armconsumption.LegacySingleScopeReservationRecommendationProperties{ - // CostWithNoReservedInstances: to.Ptr[float64](0), - // FirstUsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-06T00:00:00.000Z"); return t}()), - // LookBackPeriod: to.Ptr("Last7Days"), - // MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // NetSavings: to.Ptr[float64](4.634521202630137), - // RecommendedQuantity: to.Ptr[float64](1), - // Scope: to.Ptr("Single"), - // SKUProperties: []*armconsumption.SKUProperty{ - // { - // Name: to.Ptr("Cores"), - // Value: to.Ptr("1"), - // }, - // { - // Name: to.Ptr("Ram"), - // Value: to.Ptr("1"), - // }}, - // Term: to.Ptr("P1Y"), - // TotalCostWithReservedInstances: to.Ptr[float64](0), - // SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // }, - // }, - // &armconsumption.LegacyReservationRecommendation{ - // Name: to.Ptr("reservationRecommendations2"), - // Type: to.Ptr("Microsoft.Consumption/reservationRecommendations"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/reservationRecommendations/reservationRecommendations2"), - // Location: to.Ptr("northeurope"), - // SKU: to.Ptr("Standard_DS1_v2"), - // Kind: to.Ptr(armconsumption.ReservationRecommendationKindLegacy), - // Properties: &armconsumption.LegacySingleScopeReservationRecommendationProperties{ - // CostWithNoReservedInstances: to.Ptr[float64](0), - // FirstUsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-06T00:00:00.000Z"); return t}()), - // LookBackPeriod: to.Ptr("Last7Days"), - // MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // NetSavings: to.Ptr[float64](7.289315723178081), - // RecommendedQuantity: to.Ptr[float64](1), - // Scope: to.Ptr("Single"), - // SKUProperties: []*armconsumption.SKUProperty{ - // { - // Name: to.Ptr("SkuDisplayName"), - // Value: to.Ptr("B"), - // }, - // { - // Name: to.Ptr("CPU"), - // Value: to.Ptr("1"), - // }}, - // Term: to.Ptr("P3Y"), - // TotalCostWithReservedInstances: to.Ptr[float64](0), - // SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/consumption/armconsumption/reservationsdetails_client.go b/sdk/resourcemanager/consumption/armconsumption/reservationsdetails_client.go index b31f32fe9c39..bf5058d3dafb 100644 --- a/sdk/resourcemanager/consumption/armconsumption/reservationsdetails_client.go +++ b/sdk/resourcemanager/consumption/armconsumption/reservationsdetails_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -40,9 +37,13 @@ func NewReservationsDetailsClient(credential azcore.TokenCredential, options *ar return client, nil } -// NewListPager - Lists the reservations details for the defined scope and provided date range. +// NewListPager - Lists the reservations details for provided date range. Note: ARM has a payload size limit of 12MB, so currently +// callers get 400 when the response size exceeds the ARM limit. If the data size is too +// large, customers may also get 504 as the API timed out preparing the data. In such cases, API call should be made with +// smaller date ranges or a call to Generate Reservation Details Report API should +// be made as it is asynchronous and will not run into response size time outs. // -// Generated from API version 2021-10-01 +// Generated from API version 2025-04-01 // - resourceScope - The scope associated with reservations details operations. This includes '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' // for BillingAccount scope (legacy), and // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for BillingProfile @@ -81,22 +82,22 @@ func (client *ReservationsDetailsClient) listCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - if options != nil && options.StartDate != nil { - reqQP.Set("startDate", *options.StartDate) + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) } + reqQP.Set("api-version", "2025-04-01") if options != nil && options.EndDate != nil { reqQP.Set("endDate", *options.EndDate) } - if options != nil && options.Filter != nil { - reqQP.Set("$filter", *options.Filter) - } if options != nil && options.ReservationID != nil { reqQP.Set("reservationId", *options.ReservationID) } if options != nil && options.ReservationOrderID != nil { reqQP.Set("reservationOrderId", *options.ReservationOrderID) } - reqQP.Set("api-version", "2021-10-01") + if options != nil && options.StartDate != nil { + reqQP.Set("startDate", *options.StartDate) + } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -111,9 +112,13 @@ func (client *ReservationsDetailsClient) listHandleResponse(resp *http.Response) return result, nil } -// NewListByReservationOrderPager - Lists the reservations details for provided date range. +// NewListByReservationOrderPager - Lists the reservations details for provided date range. Note: ARM has a payload size limit +// of 12MB, so currently callers get 400 when the response size exceeds the ARM limit. If the data size is too +// large, customers may also get 504 as the API timed out preparing the data. In such cases, API call should be made with +// smaller date ranges or a call to Generate Reservation Details Report API should +// be made as it is asynchronous and will not run into response size time outs. // -// Generated from API version 2021-10-01 +// Generated from API version 2025-04-01 // - reservationOrderID - Order Id of the reservation // - filter - Filter reservation details by date range. The properties/UsageDate for start date and end date. The filter supports // 'le' and 'ge' @@ -143,7 +148,7 @@ func (client *ReservationsDetailsClient) NewListByReservationOrderPager(reservat } // listByReservationOrderCreateRequest creates the ListByReservationOrder request. -func (client *ReservationsDetailsClient) listByReservationOrderCreateRequest(ctx context.Context, reservationOrderID string, filter string, options *ReservationsDetailsClientListByReservationOrderOptions) (*policy.Request, error) { +func (client *ReservationsDetailsClient) listByReservationOrderCreateRequest(ctx context.Context, reservationOrderID string, filter string, _ *ReservationsDetailsClientListByReservationOrderOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/providers/Microsoft.Consumption/reservationDetails" if reservationOrderID == "" { return nil, errors.New("parameter reservationOrderID cannot be empty") @@ -155,7 +160,7 @@ func (client *ReservationsDetailsClient) listByReservationOrderCreateRequest(ctx } reqQP := req.Raw().URL.Query() reqQP.Set("$filter", filter) - reqQP.Set("api-version", "2021-10-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -170,9 +175,14 @@ func (client *ReservationsDetailsClient) listByReservationOrderHandleResponse(re return result, nil } -// NewListByReservationOrderAndReservationPager - Lists the reservations details for provided date range. +// NewListByReservationOrderAndReservationPager - Lists the reservations details for provided date range. Note: ARM has a +// payload size limit of 12MB, so currently callers get 400 when the response size exceeds the ARM limit. If the data size +// is too +// large, customers may also get 504 as the API timed out preparing the data. In such cases, API call should be made with +// smaller date ranges or a call to Generate Reservation Details Report API should +// be made as it is asynchronous and will not run into response size time outs. // -// Generated from API version 2021-10-01 +// Generated from API version 2025-04-01 // - reservationOrderID - Order Id of the reservation // - reservationID - Id of the reservation // - filter - Filter reservation details by date range. The properties/UsageDate for start date and end date. The filter supports @@ -203,7 +213,7 @@ func (client *ReservationsDetailsClient) NewListByReservationOrderAndReservation } // listByReservationOrderAndReservationCreateRequest creates the ListByReservationOrderAndReservation request. -func (client *ReservationsDetailsClient) listByReservationOrderAndReservationCreateRequest(ctx context.Context, reservationOrderID string, reservationID string, filter string, options *ReservationsDetailsClientListByReservationOrderAndReservationOptions) (*policy.Request, error) { +func (client *ReservationsDetailsClient) listByReservationOrderAndReservationCreateRequest(ctx context.Context, reservationOrderID string, reservationID string, filter string, _ *ReservationsDetailsClientListByReservationOrderAndReservationOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/reservations/{reservationId}/providers/Microsoft.Consumption/reservationDetails" if reservationOrderID == "" { return nil, errors.New("parameter reservationOrderID cannot be empty") @@ -219,7 +229,7 @@ func (client *ReservationsDetailsClient) listByReservationOrderAndReservationCre } reqQP := req.Raw().URL.Query() reqQP.Set("$filter", filter) - reqQP.Set("api-version", "2021-10-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/consumption/armconsumption/reservationsdetails_client_example_test.go b/sdk/resourcemanager/consumption/armconsumption/reservationsdetails_client_example_test.go deleted file mode 100644 index 7eaf87948ac1..000000000000 --- a/sdk/resourcemanager/consumption/armconsumption/reservationsdetails_client_example_test.go +++ /dev/null @@ -1,268 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armconsumption_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/consumption/armconsumption" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/ReservationDetails.json -func ExampleReservationsDetailsClient_NewListByReservationOrderPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewReservationsDetailsClient().NewListByReservationOrderPager("00000000-0000-0000-0000-000000000000", "properties/usageDate ge 2017-10-01 AND properties/usageDate le 2017-12-05", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ReservationDetailsListResult = armconsumption.ReservationDetailsListResult{ - // Value: []*armconsumption.ReservationDetail{ - // { - // Name: to.Ptr("00000000-0000-0000-0000-000000000000_00000000-0000-0000-0000-000000000000_20171129"), - // Type: to.Ptr("Microsoft.Consumption/reservationDetails"), - // ID: to.Ptr("providers/Microsoft.Capacity/reservationOrders/00000000-0000-0000-0000-000000000000/reservations/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/reservationDetails/20171129"), - // Tags: map[string]*string{ - // "dev": to.Ptr("tools"), - // "env": to.Ptr("newcrp"), - // }, - // Properties: &armconsumption.ReservationDetailProperties{ - // InstanceFlexibilityGroup: to.Ptr("DSv2 Series"), - // InstanceFlexibilityRatio: to.Ptr("0.25"), - // InstanceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/wvn-sql/providers/microsoft.compute/virtualmachines/abc-sql2014sp33"), - // ReservationID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ReservationOrderID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ReservedHours: to.Ptr[float64](24), - // SKUName: to.Ptr("Standard_D2_v2"), - // TotalReservedQuantity: to.Ptr[float64](1), - // UsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-11-29T00:00:00.000Z"); return t}()), - // UsedHours: to.Ptr[float64](24), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/ReservationDetailsWithReservationId.json -func ExampleReservationsDetailsClient_NewListByReservationOrderAndReservationPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewReservationsDetailsClient().NewListByReservationOrderAndReservationPager("00000000-0000-0000-0000-000000000000", "00000000-0000-0000-0000-000000000000", "properties/usageDate ge 2017-10-01 AND properties/usageDate le 2017-12-05", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ReservationDetailsListResult = armconsumption.ReservationDetailsListResult{ - // Value: []*armconsumption.ReservationDetail{ - // { - // Name: to.Ptr("00000000-0000-0000-0000-000000000000_00000000-0000-0000-0000-000000000000_20171129"), - // Type: to.Ptr("Microsoft.Consumption/reservationDetails"), - // ID: to.Ptr("providers/Microsoft.Capacity/reservationOrders/00000000-0000-0000-0000-000000000000/reservations/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/reservationDetails/20171129"), - // Tags: map[string]*string{ - // "dev": to.Ptr("tools"), - // "env": to.Ptr("newcrp"), - // }, - // Properties: &armconsumption.ReservationDetailProperties{ - // InstanceFlexibilityGroup: to.Ptr("D2v2 Series"), - // InstanceFlexibilityRatio: to.Ptr("1"), - // InstanceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/wvn-sql/providers/microsoft.compute/virtualmachines/wvn-sql2014sp33"), - // Kind: to.Ptr("Reservation"), - // ReservationID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ReservationOrderID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ReservedHours: to.Ptr[float64](24), - // SKUName: to.Ptr("Standard_D2_v2"), - // TotalReservedQuantity: to.Ptr[float64](1), - // UsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-11-29T00:00:00.000Z"); return t}()), - // UsedHours: to.Ptr[float64](24), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/ReservationDetailsByBillingAccountId.json -func ExampleReservationsDetailsClient_NewListPager_reservationDetailsByBillingAccountId() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewReservationsDetailsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345", &armconsumption.ReservationsDetailsClientListOptions{StartDate: nil, - EndDate: nil, - Filter: to.Ptr("properties/usageDate ge 2017-10-01 AND properties/usageDate le 2017-12-05"), - ReservationID: nil, - ReservationOrderID: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ReservationDetailsListResult = armconsumption.ReservationDetailsListResult{ - // Value: []*armconsumption.ReservationDetail{ - // { - // Name: to.Ptr("reservationDetails_Id1"), - // Type: to.Ptr("Microsoft.Consumption/reservationDetails"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/12345/providers/Microsoft.Consumption/reservationDetails/reservationDetails_Id1"), - // Properties: &armconsumption.ReservationDetailProperties{ - // InstanceFlexibilityGroup: to.Ptr("DSv3 Series"), - // InstanceFlexibilityRatio: to.Ptr("1"), - // InstanceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/sqlh1/providers/microsoft.compute/virtualmachines/sqlh1"), - // ReservationID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ReservationOrderID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ReservedHours: to.Ptr[float64](48), - // SKUName: to.Ptr("Standard_D2s_v3"), - // TotalReservedQuantity: to.Ptr[float64](0), - // UsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-11-30T08:00:00.000Z"); return t}()), - // UsedHours: to.Ptr[float64](0.6), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/ReservationDetailsByBillingProfileId.json -func ExampleReservationsDetailsClient_NewListPager_reservationDetailsByBillingProfileId() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewReservationsDetailsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345:2468/billingProfiles/13579", &armconsumption.ReservationsDetailsClientListOptions{StartDate: to.Ptr("2019-09-01"), - EndDate: to.Ptr("2019-10-31"), - Filter: nil, - ReservationID: nil, - ReservationOrderID: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ReservationDetailsListResult = armconsumption.ReservationDetailsListResult{ - // Value: []*armconsumption.ReservationDetail{ - // { - // Name: to.Ptr("reservationDetails_Id1"), - // Type: to.Ptr("Microsoft.Consumption/reservationDetails"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/12345:2468/billingProfiles/13579/providers/Microsoft.Consumption/reservationDetails/reservationDetails_Id1"), - // Properties: &armconsumption.ReservationDetailProperties{ - // InstanceFlexibilityGroup: to.Ptr("DSv3 Series"), - // InstanceFlexibilityRatio: to.Ptr("1"), - // InstanceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/sqlh1/providers/microsoft.compute/virtualmachines/sqlh1"), - // ReservationID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ReservationOrderID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ReservedHours: to.Ptr[float64](48), - // SKUName: to.Ptr("Standard_D2s_v3"), - // TotalReservedQuantity: to.Ptr[float64](0), - // UsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-30T08:00:00.000Z"); return t}()), - // UsedHours: to.Ptr[float64](0.6), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/ReservationDetailsByBillingProfileIdReservationId.json -func ExampleReservationsDetailsClient_NewListPager_reservationDetailsByBillingProfileIdReservationId() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewReservationsDetailsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345:2468/billingProfiles/13579", &armconsumption.ReservationsDetailsClientListOptions{StartDate: to.Ptr("2019-09-01"), - EndDate: to.Ptr("2019-10-31"), - Filter: nil, - ReservationID: to.Ptr("1c6b6358-709f-484c-85f1-72e862a0cf3b"), - ReservationOrderID: to.Ptr("9f39ba10-794f-4dcb-8f4b-8d0cb47c27dc"), - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ReservationDetailsListResult = armconsumption.ReservationDetailsListResult{ - // Value: []*armconsumption.ReservationDetail{ - // { - // Name: to.Ptr("reservationDetails_Id1"), - // Type: to.Ptr("Microsoft.Consumption/reservationDetails"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/12345:2468/billingProfiles/13579/providers/Microsoft.Consumption/reservationDetails/reservationDetails_Id1"), - // Properties: &armconsumption.ReservationDetailProperties{ - // InstanceFlexibilityGroup: to.Ptr("DSv3 Series"), - // InstanceFlexibilityRatio: to.Ptr("1"), - // InstanceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/sqlh1/providers/microsoft.compute/virtualmachines/sqlh1"), - // ReservationID: to.Ptr("1c6b6358-709f-484c-85f1-72e862a0cf3b"), - // ReservationOrderID: to.Ptr("9f39ba10-794f-4dcb-8f4b-8d0cb47c27dc"), - // ReservedHours: to.Ptr[float64](48), - // SKUName: to.Ptr("Standard_D2s_v3"), - // TotalReservedQuantity: to.Ptr[float64](0), - // UsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-30T08:00:00.000Z"); return t}()), - // UsedHours: to.Ptr[float64](0.6), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/consumption/armconsumption/reservationssummaries_client.go b/sdk/resourcemanager/consumption/armconsumption/reservationssummaries_client.go index e78cee84eda8..45cc7005d77f 100644 --- a/sdk/resourcemanager/consumption/armconsumption/reservationssummaries_client.go +++ b/sdk/resourcemanager/consumption/armconsumption/reservationssummaries_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -40,9 +37,11 @@ func NewReservationsSummariesClient(credential azcore.TokenCredential, options * return client, nil } -// NewListPager - Lists the reservations summaries for the defined scope daily or monthly grain. +// NewListPager - Lists the reservations summaries for the defined scope daily or monthly grain. Note: ARM has a payload size +// limit of 12MB, so currently callers get 400 when the response size exceeds the ARM limit. In +// such cases, API call should be made with smaller date ranges. // -// Generated from API version 2021-10-01 +// Generated from API version 2025-04-01 // - resourceScope - The scope associated with reservations summaries operations. This includes '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' // for BillingAccount scope (legacy), and // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for BillingProfile @@ -82,23 +81,23 @@ func (client *ReservationsSummariesClient) listCreateRequest(ctx context.Context return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("grain", string(grain)) - if options != nil && options.StartDate != nil { - reqQP.Set("startDate", *options.StartDate) + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) } + reqQP.Set("api-version", "2025-04-01") if options != nil && options.EndDate != nil { reqQP.Set("endDate", *options.EndDate) } - if options != nil && options.Filter != nil { - reqQP.Set("$filter", *options.Filter) - } + reqQP.Set("grain", string(grain)) if options != nil && options.ReservationID != nil { reqQP.Set("reservationId", *options.ReservationID) } if options != nil && options.ReservationOrderID != nil { reqQP.Set("reservationOrderId", *options.ReservationOrderID) } - reqQP.Set("api-version", "2021-10-01") + if options != nil && options.StartDate != nil { + reqQP.Set("startDate", *options.StartDate) + } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -113,9 +112,11 @@ func (client *ReservationsSummariesClient) listHandleResponse(resp *http.Respons return result, nil } -// NewListByReservationOrderPager - Lists the reservations summaries for daily or monthly grain. +// NewListByReservationOrderPager - Lists the reservations summaries for daily or monthly grain. Note: ARM has a payload size +// limit of 12MB, so currently callers get 400 when the response size exceeds the ARM limit. In such cases, API +// call should be made with smaller date ranges. // -// Generated from API version 2021-10-01 +// Generated from API version 2025-04-01 // - reservationOrderID - Order Id of the reservation // - grain - Can be daily or monthly // - options - ReservationsSummariesClientListByReservationOrderOptions contains the optional parameters for the ReservationsSummariesClient.NewListByReservationOrderPager @@ -155,11 +156,11 @@ func (client *ReservationsSummariesClient) listByReservationOrderCreateRequest(c return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("grain", string(grain)) if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - reqQP.Set("api-version", "2021-10-01") + reqQP.Set("api-version", "2025-04-01") + reqQP.Set("grain", string(grain)) req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -174,9 +175,12 @@ func (client *ReservationsSummariesClient) listByReservationOrderHandleResponse( return result, nil } -// NewListByReservationOrderAndReservationPager - Lists the reservations summaries for daily or monthly grain. +// NewListByReservationOrderAndReservationPager - Lists the reservations summaries for daily or monthly grain. Note: ARM has +// a payload size limit of 12MB, so currently callers get 400 when the response size exceeds the ARM limit. In such cases, +// API +// call should be made with smaller date ranges. // -// Generated from API version 2021-10-01 +// Generated from API version 2025-04-01 // - reservationOrderID - Order Id of the reservation // - reservationID - Id of the reservation // - grain - Can be daily or monthly @@ -221,11 +225,11 @@ func (client *ReservationsSummariesClient) listByReservationOrderAndReservationC return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("grain", string(grain)) if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - reqQP.Set("api-version", "2021-10-01") + reqQP.Set("api-version", "2025-04-01") + reqQP.Set("grain", string(grain)) req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/consumption/armconsumption/reservationssummaries_client_example_test.go b/sdk/resourcemanager/consumption/armconsumption/reservationssummaries_client_example_test.go deleted file mode 100644 index 769846de1db0..000000000000 --- a/sdk/resourcemanager/consumption/armconsumption/reservationssummaries_client_example_test.go +++ /dev/null @@ -1,480 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armconsumption_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/consumption/armconsumption" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/ReservationSummariesDaily.json -func ExampleReservationsSummariesClient_NewListByReservationOrderPager_reservationSummariesDaily() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewReservationsSummariesClient().NewListByReservationOrderPager("00000000-0000-0000-0000-000000000000", armconsumption.DatagrainDailyGrain, &armconsumption.ReservationsSummariesClientListByReservationOrderOptions{Filter: to.Ptr("properties/usageDate ge 2017-10-01 AND properties/usageDate le 2017-11-20")}) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ReservationSummariesListResult = armconsumption.ReservationSummariesListResult{ - // Value: []*armconsumption.ReservationSummary{ - // { - // Name: to.Ptr("00000000-0000-0000-0000-000000000000_00000000-0000-0000-0000-000000000000_20171001"), - // Type: to.Ptr("Microsoft.Consumption/reservationSummaries"), - // ID: to.Ptr("providers/Microsoft.Capacity/reservationOrders/00000000-0000-0000-0000-000000000000/reservations/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/reservationSummaries/20171001"), - // Tags: map[string]*string{ - // "dev": to.Ptr("tools"), - // "env": to.Ptr("newcrp"), - // }, - // Properties: &armconsumption.ReservationSummaryProperties{ - // AvgUtilizationPercentage: to.Ptr[float64](0), - // Kind: to.Ptr("Reservation"), - // MaxUtilizationPercentage: to.Ptr[float64](0), - // MinUtilizationPercentage: to.Ptr[float64](0), - // PurchasedQuantity: to.Ptr[float64](0), - // RemainingQuantity: to.Ptr[float64](0), - // ReservationID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ReservationOrderID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ReservedHours: to.Ptr[float64](0), - // SKUName: to.Ptr("Standard_D8s_v3"), - // TotalReservedQuantity: to.Ptr[float64](155), - // UsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-10-01T00:00:00.000Z"); return t}()), - // UsedHours: to.Ptr[float64](0), - // UsedQuantity: to.Ptr[float64](0), - // UtilizedPercentage: to.Ptr[float64](0), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/ReservationSummariesMonthly.json -func ExampleReservationsSummariesClient_NewListByReservationOrderPager_reservationSummariesMonthly() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewReservationsSummariesClient().NewListByReservationOrderPager("00000000-0000-0000-0000-000000000000", armconsumption.DatagrainMonthlyGrain, &armconsumption.ReservationsSummariesClientListByReservationOrderOptions{Filter: nil}) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ReservationSummariesListResult = armconsumption.ReservationSummariesListResult{ - // Value: []*armconsumption.ReservationSummary{ - // { - // Name: to.Ptr("00000000-0000-0000-0000-000000000000_00000000-0000-0000-0000-000000000000_20171001"), - // Type: to.Ptr("Microsoft.Consumption/reservationSummaries"), - // ID: to.Ptr("providers/Microsoft.Capacity/reservationOrders/00000000-0000-0000-0000-000000000000/reservations/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/reservationSummaries/20171001"), - // Tags: map[string]*string{ - // "dev": to.Ptr("tools"), - // "env": to.Ptr("newcrp"), - // }, - // Properties: &armconsumption.ReservationSummaryProperties{ - // AvgUtilizationPercentage: to.Ptr[float64](0), - // Kind: to.Ptr("Reservation"), - // MaxUtilizationPercentage: to.Ptr[float64](0), - // MinUtilizationPercentage: to.Ptr[float64](0), - // PurchasedQuantity: to.Ptr[float64](0), - // RemainingQuantity: to.Ptr[float64](0), - // ReservationID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ReservationOrderID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ReservedHours: to.Ptr[float64](0), - // SKUName: to.Ptr("Standard_D8s_v3"), - // TotalReservedQuantity: to.Ptr[float64](155), - // UsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-10-01T00:00:00.000Z"); return t}()), - // UsedHours: to.Ptr[float64](0), - // UsedQuantity: to.Ptr[float64](0), - // UtilizedPercentage: to.Ptr[float64](0), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/ReservationSummariesDailyWithReservationId.json -func ExampleReservationsSummariesClient_NewListByReservationOrderAndReservationPager_reservationSummariesDailyWithReservationId() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewReservationsSummariesClient().NewListByReservationOrderAndReservationPager("00000000-0000-0000-0000-000000000000", "00000000-0000-0000-0000-000000000000", armconsumption.DatagrainDailyGrain, &armconsumption.ReservationsSummariesClientListByReservationOrderAndReservationOptions{Filter: to.Ptr("properties/usageDate ge 2017-10-01 AND properties/usageDate le 2017-11-20")}) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ReservationSummariesListResult = armconsumption.ReservationSummariesListResult{ - // Value: []*armconsumption.ReservationSummary{ - // { - // Name: to.Ptr("00000000-0000-0000-0000-000000000000_00000000-0000-0000-0000-000000000000_20171001"), - // Type: to.Ptr("Microsoft.Consumption/reservationSummaries"), - // ID: to.Ptr("providers/Microsoft.Capacity/reservationOrders/00000000-0000-0000-0000-000000000000/reservations/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/reservationSummaries/20171001"), - // Tags: map[string]*string{ - // "dev": to.Ptr("tools"), - // "env": to.Ptr("newcrp"), - // }, - // Properties: &armconsumption.ReservationSummaryProperties{ - // AvgUtilizationPercentage: to.Ptr[float64](0), - // Kind: to.Ptr("Reservation"), - // MaxUtilizationPercentage: to.Ptr[float64](0), - // MinUtilizationPercentage: to.Ptr[float64](0), - // PurchasedQuantity: to.Ptr[float64](0), - // RemainingQuantity: to.Ptr[float64](0), - // ReservationID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ReservationOrderID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ReservedHours: to.Ptr[float64](0), - // SKUName: to.Ptr("Standard_D8s_v3"), - // TotalReservedQuantity: to.Ptr[float64](155), - // UsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-10-01T00:00:00.000Z"); return t}()), - // UsedHours: to.Ptr[float64](0), - // UsedQuantity: to.Ptr[float64](0), - // UtilizedPercentage: to.Ptr[float64](0), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/ReservationSummariesMonthlyWithReservationId.json -func ExampleReservationsSummariesClient_NewListByReservationOrderAndReservationPager_reservationSummariesMonthlyWithReservationId() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewReservationsSummariesClient().NewListByReservationOrderAndReservationPager("00000000-0000-0000-0000-000000000000", "00000000-0000-0000-0000-000000000000", armconsumption.DatagrainMonthlyGrain, &armconsumption.ReservationsSummariesClientListByReservationOrderAndReservationOptions{Filter: nil}) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ReservationSummariesListResult = armconsumption.ReservationSummariesListResult{ - // Value: []*armconsumption.ReservationSummary{ - // { - // Name: to.Ptr("00000000-0000-0000-0000-000000000000_00000000-0000-0000-0000-000000000000_20171001"), - // Type: to.Ptr("Microsoft.Consumption/reservationSummaries"), - // ID: to.Ptr("providers/Microsoft.Capacity/reservationOrders/00000000-0000-0000-0000-000000000000/reservations/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/reservationSummaries/20171001"), - // Tags: map[string]*string{ - // "dev": to.Ptr("tools"), - // "env": to.Ptr("newcrp"), - // }, - // Properties: &armconsumption.ReservationSummaryProperties{ - // AvgUtilizationPercentage: to.Ptr[float64](0), - // Kind: to.Ptr("Reservation"), - // MaxUtilizationPercentage: to.Ptr[float64](0), - // MinUtilizationPercentage: to.Ptr[float64](0), - // PurchasedQuantity: to.Ptr[float64](0), - // RemainingQuantity: to.Ptr[float64](0), - // ReservationID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ReservationOrderID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ReservedHours: to.Ptr[float64](0), - // SKUName: to.Ptr("Standard_D8s_v3"), - // TotalReservedQuantity: to.Ptr[float64](155), - // UsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-10-01T00:00:00.000Z"); return t}()), - // UsedHours: to.Ptr[float64](0), - // UsedQuantity: to.Ptr[float64](0), - // UtilizedPercentage: to.Ptr[float64](0), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/ReservationSummariesDailyWithBillingAccountId.json -func ExampleReservationsSummariesClient_NewListPager_reservationSummariesDailyWithBillingAccountId() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewReservationsSummariesClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345", armconsumption.DatagrainDailyGrain, &armconsumption.ReservationsSummariesClientListOptions{StartDate: nil, - EndDate: nil, - Filter: to.Ptr("properties/usageDate ge 2017-10-01 AND properties/usageDate le 2017-11-20"), - ReservationID: nil, - ReservationOrderID: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ReservationSummariesListResult = armconsumption.ReservationSummariesListResult{ - // Value: []*armconsumption.ReservationSummary{ - // { - // Name: to.Ptr("reservationSummaries_Id1"), - // Type: to.Ptr("Microsoft.Consumption/reservationSummaries"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/12345/providers/Microsoft.Consumption/reservationSummaries/reservationSummaries_Id1"), - // Properties: &armconsumption.ReservationSummaryProperties{ - // AvgUtilizationPercentage: to.Ptr[float64](0), - // MaxUtilizationPercentage: to.Ptr[float64](0), - // MinUtilizationPercentage: to.Ptr[float64](0), - // ReservationID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ReservationOrderID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ReservedHours: to.Ptr[float64](720), - // SKUName: to.Ptr("Standard_B1s"), - // UsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-01T07:00:00.000Z"); return t}()), - // UsedHours: to.Ptr[float64](0), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/ReservationSummariesDailyWithBillingProfileId.json -func ExampleReservationsSummariesClient_NewListPager_reservationSummariesDailyWithBillingProfileId() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewReservationsSummariesClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345:2468/billingProfiles/13579", armconsumption.DatagrainDailyGrain, &armconsumption.ReservationsSummariesClientListOptions{StartDate: to.Ptr("2017-10-01"), - EndDate: to.Ptr("2017-11-20"), - Filter: nil, - ReservationID: nil, - ReservationOrderID: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ReservationSummariesListResult = armconsumption.ReservationSummariesListResult{ - // Value: []*armconsumption.ReservationSummary{ - // { - // Name: to.Ptr("reservationSummaries_Id1"), - // Type: to.Ptr("Microsoft.Consumption/reservationSummaries"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/12345:2468/billingProfiles/13579/providers/Microsoft.Consumption/reservationSummaries/reservationSummaries_Id1"), - // Properties: &armconsumption.ReservationSummaryProperties{ - // AvgUtilizationPercentage: to.Ptr[float64](0), - // MaxUtilizationPercentage: to.Ptr[float64](0), - // MinUtilizationPercentage: to.Ptr[float64](0), - // ReservationID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ReservationOrderID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ReservedHours: to.Ptr[float64](720), - // SKUName: to.Ptr("Standard_B1s"), - // UsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-01T07:00:00.000Z"); return t}()), - // UsedHours: to.Ptr[float64](0), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/ReservationSummariesMonthlyWithBillingAccountId.json -func ExampleReservationsSummariesClient_NewListPager_reservationSummariesMonthlyWithBillingAccountId() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewReservationsSummariesClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345", armconsumption.DatagrainMonthlyGrain, &armconsumption.ReservationsSummariesClientListOptions{StartDate: nil, - EndDate: nil, - Filter: nil, - ReservationID: nil, - ReservationOrderID: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ReservationSummariesListResult = armconsumption.ReservationSummariesListResult{ - // Value: []*armconsumption.ReservationSummary{ - // { - // Name: to.Ptr("reservationSummaries_Id1"), - // Type: to.Ptr("Microsoft.Consumption/reservationSummaries"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/12345/providers/Microsoft.Consumption/reservationSummaries/reservationSummaries_Id1"), - // Properties: &armconsumption.ReservationSummaryProperties{ - // AvgUtilizationPercentage: to.Ptr[float64](0), - // MaxUtilizationPercentage: to.Ptr[float64](0), - // MinUtilizationPercentage: to.Ptr[float64](0), - // ReservationID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ReservationOrderID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ReservedHours: to.Ptr[float64](720), - // SKUName: to.Ptr("Standard_B1s"), - // UsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-01T07:00:00.000Z"); return t}()), - // UsedHours: to.Ptr[float64](0), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/ReservationSummariesMonthlyWithBillingProfileId.json -func ExampleReservationsSummariesClient_NewListPager_reservationSummariesMonthlyWithBillingProfileId() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewReservationsSummariesClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345:2468/billingProfiles/13579", armconsumption.DatagrainMonthlyGrain, &armconsumption.ReservationsSummariesClientListOptions{StartDate: nil, - EndDate: nil, - Filter: nil, - ReservationID: nil, - ReservationOrderID: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ReservationSummariesListResult = armconsumption.ReservationSummariesListResult{ - // Value: []*armconsumption.ReservationSummary{ - // { - // Name: to.Ptr("reservationSummaries_Id1"), - // Type: to.Ptr("Microsoft.Consumption/reservationSummaries"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/12345:2468/billingProfiles/13579/providers/Microsoft.Consumption/reservationSummaries/reservationSummaries_Id1"), - // Properties: &armconsumption.ReservationSummaryProperties{ - // AvgUtilizationPercentage: to.Ptr[float64](0), - // MaxUtilizationPercentage: to.Ptr[float64](0), - // MinUtilizationPercentage: to.Ptr[float64](0), - // ReservationID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ReservationOrderID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ReservedHours: to.Ptr[float64](720), - // SKUName: to.Ptr("Standard_B1s"), - // UsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-01T07:00:00.000Z"); return t}()), - // UsedHours: to.Ptr[float64](0), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/ReservationSummariesMonthlyWithBillingProfileIdReservationId.json -func ExampleReservationsSummariesClient_NewListPager_reservationSummariesMonthlyWithBillingProfileIdReservationId() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewReservationsSummariesClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345:2468/billingProfiles/13579", armconsumption.DatagrainMonthlyGrain, &armconsumption.ReservationsSummariesClientListOptions{StartDate: nil, - EndDate: nil, - Filter: nil, - ReservationID: to.Ptr("1c6b6358-709f-484c-85f1-72e862a0cf3b"), - ReservationOrderID: to.Ptr("9f39ba10-794f-4dcb-8f4b-8d0cb47c27dc"), - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ReservationSummariesListResult = armconsumption.ReservationSummariesListResult{ - // Value: []*armconsumption.ReservationSummary{ - // { - // Name: to.Ptr("reservationSummaries_Id1"), - // Type: to.Ptr("Microsoft.Consumption/reservationSummaries"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/12345:2468/billingProfiles/13579/providers/Microsoft.Consumption/reservationSummaries/reservationSummaries_Id1"), - // Properties: &armconsumption.ReservationSummaryProperties{ - // AvgUtilizationPercentage: to.Ptr[float64](0), - // MaxUtilizationPercentage: to.Ptr[float64](0), - // MinUtilizationPercentage: to.Ptr[float64](0), - // ReservationID: to.Ptr("1c6b6358-709f-484c-85f1-72e862a0cf3b"), - // ReservationOrderID: to.Ptr("9f39ba10-794f-4dcb-8f4b-8d0cb47c27dc"), - // ReservedHours: to.Ptr[float64](720), - // SKUName: to.Ptr("Standard_B1s"), - // UsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-09-01T07:00:00.000Z"); return t}()), - // UsedHours: to.Ptr[float64](0), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/consumption/armconsumption/reservationtransactions_client.go b/sdk/resourcemanager/consumption/armconsumption/reservationtransactions_client.go index ea8f95481142..02f7eddc338f 100644 --- a/sdk/resourcemanager/consumption/armconsumption/reservationtransactions_client.go +++ b/sdk/resourcemanager/consumption/armconsumption/reservationtransactions_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -17,6 +14,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" "net/url" + "strconv" "strings" ) @@ -40,9 +38,14 @@ func NewReservationTransactionsClient(credential azcore.TokenCredential, options return client, nil } -// NewListPager - List of transactions for reserved instances on billing account scope +// NewListPager - List of transactions for reserved instances on billing account scope. Note: The refund transactions are +// posted along with its purchase transaction (i.e. in the purchase billing month). For example, +// The refund is requested in May 2021. This refund transaction will have event date as May 2021 but the billing month as +// April 2020 when the reservation purchase was made. Note: ARM has a payload size +// limit of 12MB, so currently callers get 400 when the response size exceeds the ARM limit. In such cases, API call should +// be made with smaller date ranges. // -// Generated from API version 2021-10-01 +// Generated from API version 2025-04-01 // - billingAccountID - BillingAccount ID // - options - ReservationTransactionsClientListOptions contains the optional parameters for the ReservationTransactionsClient.NewListPager // method. @@ -84,7 +87,13 @@ func (client *ReservationTransactionsClient) listCreateRequest(ctx context.Conte if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - reqQP.Set("api-version", "2021-10-01") + reqQP.Set("api-version", "2025-04-01") + if options != nil && options.PreviewMarkupPercentage != nil { + reqQP.Set("previewMarkupPercentage", strconv.FormatFloat(*options.PreviewMarkupPercentage, 'f', -1, 64)) + } + if options != nil && options.UseMarkupIfPartner != nil { + reqQP.Set("useMarkupIfPartner", strconv.FormatBool(*options.UseMarkupIfPartner)) + } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -99,9 +108,14 @@ func (client *ReservationTransactionsClient) listHandleResponse(resp *http.Respo return result, nil } -// NewListByBillingProfilePager - List of transactions for reserved instances on billing account scope +// NewListByBillingProfilePager - List of transactions for reserved instances on billing profile scope. The refund transactions +// are posted along with its purchase transaction (i.e. in the purchase billing month). For example, The +// refund is requested in May 2021. This refund transaction will have event date as May 2021 but the billing month as April +// 2020 when the reservation purchase was made. Note: ARM has a payload size limit +// of 12MB, so currently callers get 400 when the response size exceeds the ARM limit. In such cases, API call should be made +// with smaller date ranges. // -// Generated from API version 2021-10-01 +// Generated from API version 2025-04-01 // - billingAccountID - BillingAccount ID // - billingProfileID - Azure Billing Profile ID. // - options - ReservationTransactionsClientListByBillingProfileOptions contains the optional parameters for the ReservationTransactionsClient.NewListByBillingProfilePager @@ -148,7 +162,7 @@ func (client *ReservationTransactionsClient) listByBillingProfileCreateRequest(c if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - reqQP.Set("api-version", "2021-10-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/consumption/armconsumption/reservationtransactions_client_example_test.go b/sdk/resourcemanager/consumption/armconsumption/reservationtransactions_client_example_test.go deleted file mode 100644 index d8cd9184e357..000000000000 --- a/sdk/resourcemanager/consumption/armconsumption/reservationtransactions_client_example_test.go +++ /dev/null @@ -1,166 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armconsumption_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/consumption/armconsumption" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/ReservationTransactionsListByEnrollmentNumber.json -func ExampleReservationTransactionsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewReservationTransactionsClient().NewListPager("123456", &armconsumption.ReservationTransactionsClientListOptions{Filter: to.Ptr("properties/eventDate+ge+2020-05-20+AND+properties/eventDate+le+2020-05-30")}) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ReservationTransactionsListResult = armconsumption.ReservationTransactionsListResult{ - // Value: []*armconsumption.ReservationTransaction{ - // { - // Name: to.Ptr("201909091919"), - // Type: to.Ptr("Microsoft.Consumption/reservationTransactions"), - // ID: to.Ptr("/billingAccounts/123456/providers/Microsoft.Consumption/reservationtransactions/201909091919"), - // Tags: []*string{ - // }, - // Properties: &armconsumption.LegacyReservationTransactionProperties{ - // Description: to.Ptr("Standard_DS1_v2 westus 1 Year"), - // AccountName: to.Ptr("Microsoft Infrastructure"), - // AccountOwnerEmail: to.Ptr("admin@microsoft.com"), - // Amount: to.Ptr[float64](-21), - // ArmSKUName: to.Ptr("Standard_DS1_v2"), - // BillingFrequency: to.Ptr("recurring"), - // BillingMonth: to.Ptr[int32](20190901), - // CostCenter: to.Ptr(""), - // Currency: to.Ptr("USD"), - // CurrentEnrollment: to.Ptr("123456"), - // DepartmentName: to.Ptr("Unassigned"), - // EventDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-09T19:19:04.000Z"); return t}()), - // EventType: to.Ptr("Refund"), - // MonetaryCommitment: to.Ptr[float64](523123.9), - // Overage: to.Ptr[float64](23234.49), - // PurchasingEnrollment: to.Ptr("123456"), - // PurchasingSubscriptionGUID: to.Ptr("a838a8c3-a408-49e1-ac90-42cb95bff9b2"), - // PurchasingSubscriptionName: to.Ptr("Infrastructure Subscription"), - // Quantity: to.Ptr[float64](1), - // Region: to.Ptr("westus"), - // ReservationOrderID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ReservationOrderName: to.Ptr("Transaction-DS1_v2"), - // Term: to.Ptr("P1Y"), - // }, - // }, - // { - // Name: to.Ptr("201909091919"), - // Type: to.Ptr("Microsoft.Consumption/reservationTransactions"), - // ID: to.Ptr("/billingAccounts/123456/providers/Microsoft.Consumption/reservationtransactions/201909091919"), - // Tags: []*string{ - // }, - // Properties: &armconsumption.LegacyReservationTransactionProperties{ - // Description: to.Ptr("Standard_DS1_v2 westus 1 Year"), - // AccountName: to.Ptr("Microsoft Infrastructure"), - // AccountOwnerEmail: to.Ptr("admin@microsoft.com"), - // Amount: to.Ptr[float64](21), - // ArmSKUName: to.Ptr("Standard_DS1_v2"), - // BillingFrequency: to.Ptr("recurring"), - // BillingMonth: to.Ptr[int32](20190901), - // CostCenter: to.Ptr(""), - // Currency: to.Ptr("USD"), - // CurrentEnrollment: to.Ptr("123456"), - // DepartmentName: to.Ptr("Unassigned"), - // EventDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-09T19:19:04.000Z"); return t}()), - // EventType: to.Ptr("Purchase"), - // MonetaryCommitment: to.Ptr[float64](523123.9), - // Overage: to.Ptr[float64](23234.49), - // PurchasingEnrollment: to.Ptr("123456"), - // PurchasingSubscriptionGUID: to.Ptr("a838a8c3-a408-49e1-ac90-42cb95bff9b2"), - // PurchasingSubscriptionName: to.Ptr("Infrastructure Subscription"), - // Quantity: to.Ptr[float64](1), - // Region: to.Ptr("westus"), - // ReservationOrderID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ReservationOrderName: to.Ptr("Transaction-DS1_v2"), - // Term: to.Ptr("P1Y"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/ReservationTransactionsListByBillingProfileId.json -func ExampleReservationTransactionsClient_NewListByBillingProfilePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewReservationTransactionsClient().NewListByBillingProfilePager("fcebaabc-fced-4284-a83d-79f83dee183c:45796ba8-988f-45ad-bea9-7b71fc6c7513_2018-09-30", "Z76D-SGAF-BG7-TGB", &armconsumption.ReservationTransactionsClientListByBillingProfileOptions{Filter: to.Ptr("properties/eventDate+ge+2020-05-20+AND+properties/eventDate+le+2020-05-30")}) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ModernReservationTransactionsListResult = armconsumption.ModernReservationTransactionsListResult{ - // Value: []*armconsumption.ModernReservationTransaction{ - // { - // Name: to.Ptr("a838a8c3-a408-49e1-ac90-42cb95bff9b2"), - // Type: to.Ptr("Microsoft.Consumption/reservationTransactions"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/fcebaabc-fced-4284-a83d-79f83dee183c:45796ba8-988f-45ad-bea9-7b71fc6c7513_2018-09-30/billingProfiles/Z76D-SGAF-BG7-TGB/providers/Microsoft.Consumption/reservationTransactions"), - // Properties: &armconsumption.ModernReservationTransactionProperties{ - // Description: to.Ptr("Reserved VM Instance, Standard_B1ls, US East, 3 Years"), - // Amount: to.Ptr[float64](1.44), - // ArmSKUName: to.Ptr("Standard_B1ls"), - // BillingFrequency: to.Ptr("Recurring"), - // BillingProfileID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/fcebaabc-fced-4284-a83d-79f83dee183c:45796ba8-988f-45ad-bea9-7b71fc6c7513_2018-09-30/billingProfiles/Z76D-SGAF-BG7-TGB"), - // BillingProfileName: to.Ptr("IT Department*"), - // Currency: to.Ptr("USD"), - // EventDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-25T21:21:38.000Z"); return t}()), - // EventType: to.Ptr("Purchase"), - // Invoice: to.Ptr("T000456437"), - // InvoiceID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/fcebaabc-fced-4284-a83d-79f83dee183c:45796ba8-988f-45ad-bea9-7b71fc6c7513_2018-09-30/billingProfiles/Z76D-SGAF-BG7-TGB/invoices/T000456437"), - // InvoiceSectionID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/fcebaabc-fced-4284-a83d-79f83dee183c:45796ba8-988f-45ad-bea9-7b71fc6c7513_2018-09-30/invoiceSections/QBTB-EYAK-PJA-TGB"), - // InvoiceSectionName: to.Ptr("IT Department"), - // PurchasingSubscriptionGUID: to.Ptr("d924ad15-4a3d-4047-971d-c8b1b300a97b"), - // PurchasingSubscriptionName: to.Ptr("contoso"), - // Quantity: to.Ptr[float64](1), - // Region: to.Ptr("eastus"), - // ReservationOrderID: to.Ptr("a838a8c3-a408-49e1-ac90-42cb95bff9b2"), - // ReservationOrderName: to.Ptr("VM_RI_03-25-2020_14-18"), - // Term: to.Ptr("P3Y"), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/consumption/armconsumption/response_types.go b/sdk/resourcemanager/consumption/armconsumption/responses.go similarity index 96% rename from sdk/resourcemanager/consumption/armconsumption/response_types.go rename to sdk/resourcemanager/consumption/armconsumption/responses.go index c3def1925343..dfdac47e6338 100644 --- a/sdk/resourcemanager/consumption/armconsumption/response_types.go +++ b/sdk/resourcemanager/consumption/armconsumption/responses.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -110,6 +107,12 @@ type OperationsClientListResponse struct { OperationListResult } +// PriceSheetClientDownloadByBillingAccountPeriodResponse contains the response from method PriceSheetClient.BeginDownloadByBillingAccountPeriod. +type PriceSheetClientDownloadByBillingAccountPeriodResponse struct { + // The status of the long running operation. + OperationStatus +} + // PriceSheetClientGetByBillingPeriodResponse contains the response from method PriceSheetClient.GetByBillingPeriod. type PriceSheetClientGetByBillingPeriodResponse struct { // An pricesheet resource. diff --git a/sdk/resourcemanager/consumption/armconsumption/tags_client.go b/sdk/resourcemanager/consumption/armconsumption/tags_client.go index afa7808d3d80..a5d98f2cabba 100644 --- a/sdk/resourcemanager/consumption/armconsumption/tags_client.go +++ b/sdk/resourcemanager/consumption/armconsumption/tags_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -41,7 +38,7 @@ func NewTagsClient(credential azcore.TokenCredential, options *arm.ClientOptions // Get - Get all available tag keys for the defined scope // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2021-10-01 +// Generated from API version 2025-04-01 // - scope - The scope associated with tags operations. This includes '/subscriptions/{subscriptionId}/' for subscription scope, // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for // resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, @@ -73,7 +70,7 @@ func (client *TagsClient) Get(ctx context.Context, scope string, options *TagsCl } // getCreateRequest creates the Get request. -func (client *TagsClient) getCreateRequest(ctx context.Context, scope string, options *TagsClientGetOptions) (*policy.Request, error) { +func (client *TagsClient) getCreateRequest(ctx context.Context, scope string, _ *TagsClientGetOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.Consumption/tags" urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) @@ -81,7 +78,7 @@ func (client *TagsClient) getCreateRequest(ctx context.Context, scope string, op return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-10-01") + reqQP.Set("api-version", "2025-04-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/consumption/armconsumption/tags_client_example_test.go b/sdk/resourcemanager/consumption/armconsumption/tags_client_example_test.go deleted file mode 100644 index 3324f16a88e6..000000000000 --- a/sdk/resourcemanager/consumption/armconsumption/tags_client_example_test.go +++ /dev/null @@ -1,75 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armconsumption_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/Tags.json -func ExampleTagsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewTagsClient().Get(ctx, "providers/Microsoft.CostManagement/billingAccounts/1234", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.TagsResult = armconsumption.TagsResult{ - // Name: to.Ptr("tags1"), - // Type: to.Ptr("Microsoft.Consumption/tags"), - // ETag: to.Ptr("\"1d34d012214157f\""), - // ID: to.Ptr("providers/Microsoft.CostManagement/billingAccounts/{billingaccount-id}/providers/Microsoft.Consumption/tags/tags1"), - // Properties: &armconsumption.TagProperties{ - // PreviousLink: to.Ptr("https://management.azure.com/providers/Microsoft.Billing/billingAccounts/{billingaccount-id}/providers/Microsoft.Consumption/tags/?$expand=properties/tags/value&api-version=2021-10-01&startDate=2020-12-01&endDate=2020-12-31&$top=1000&$skiptoken=AQAAAA%3D%3D"), - // Tags: []*armconsumption.Tag{ - // { - // Key: to.Ptr("Department"), - // }, - // { - // Key: to.Ptr("CostCenter"), - // }, - // { - // Key: to.Ptr("Portal"), - // }, - // { - // Key: to.Ptr("OrgName"), - // }, - // { - // Key: to.Ptr("Namespace"), - // }, - // { - // Key: to.Ptr("resourceType"), - // }, - // { - // Key: to.Ptr("Subsystem"), - // }, - // { - // Key: to.Ptr("Environment"), - // }, - // { - // Key: to.Ptr("clusterName"), - // }}, - // }, - // } -} diff --git a/sdk/resourcemanager/consumption/armconsumption/time_rfc3339.go b/sdk/resourcemanager/consumption/armconsumption/time_rfc3339.go index be5c05d4f7fb..4403795a9f77 100644 --- a/sdk/resourcemanager/consumption/armconsumption/time_rfc3339.go +++ b/sdk/resourcemanager/consumption/armconsumption/time_rfc3339.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -19,12 +16,16 @@ import ( ) // Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. -var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) +var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) const ( - utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` - utcDateTime = "2006-01-02T15:04:05.999999999" - dateTimeJSON = `"` + time.RFC3339Nano + `"` + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` ) type dateTimeRFC3339 time.Time @@ -40,17 +41,36 @@ func (t dateTimeRFC3339) MarshalText() ([]byte, error) { } func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcDateTimeJSON - if tzOffsetRegex.Match(data) { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT } return t.Parse(layout, string(data)) } func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { - layout := utcDateTime - if tzOffsetRegex.Match(data) { + if len(data) == 0 { + return nil + } + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT } return t.Parse(layout, string(data)) } @@ -61,6 +81,10 @@ func (t *dateTimeRFC3339) Parse(layout, value string) error { return err } +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return @@ -74,7 +98,7 @@ func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { } func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { - if data == nil || strings.EqualFold(string(data), "null") { + if data == nil || string(data) == "null" { return nil } var aux dateTimeRFC3339 diff --git a/sdk/resourcemanager/consumption/armconsumption/usagedetails_client.go b/sdk/resourcemanager/consumption/armconsumption/usagedetails_client.go index f40aab92033b..76ae21f7a980 100644 --- a/sdk/resourcemanager/consumption/armconsumption/usagedetails_client.go +++ b/sdk/resourcemanager/consumption/armconsumption/usagedetails_client.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. @@ -41,8 +38,13 @@ func NewUsageDetailsClient(credential azcore.TokenCredential, options *arm.Clien // NewListPager - Lists the usage details for the defined scope. Usage details are available via this API only for May 1, // 2014 or later. +// Note:Microsoft will be retiring the Consumption Usage Details API at some point in the future. We do not recommend that +// you take a new dependency on this API. Please use the Cost Details API instead. +// We will notify customers once a date for retirement has been determined.For Learn more,see Generate Cost Details Report +// - Create Operation +// [https://learn.microsoft.com/en-us/rest/api/cost-management/generate-cost-details-report/create-operation?tabs=HTTP] // -// Generated from API version 2021-10-01 +// Generated from API version 2025-04-01 // - scope - The scope associated with usage details operations. This includes '/subscriptions/{subscriptionId}/' for subscription // scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for // Billing Account scope, '/providers/Microsoft.Billing/departments/{departmentId}' for Department scope, '/providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}' @@ -55,9 +57,9 @@ func NewUsageDetailsClient(credential azcore.TokenCredential, options *arm.Clien // Also, Modern Commerce Account scopes are // '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for billingAccount scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' // for -// billingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' +// billingProfile scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' // for invoiceSection scope, and -// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for partners. +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for partners. // - options - UsageDetailsClientListOptions contains the optional parameters for the UsageDetailsClient.NewListPager method. func (client *UsageDetailsClient) NewListPager(scope string, options *UsageDetailsClientListOptions) *runtime.Pager[UsageDetailsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[UsageDetailsClientListResponse]{ @@ -103,7 +105,7 @@ func (client *UsageDetailsClient) listCreateRequest(ctx context.Context, scope s if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } - reqQP.Set("api-version", "2021-10-01") + reqQP.Set("api-version", "2025-04-01") if options != nil && options.Metric != nil { reqQP.Set("metric", string(*options.Metric)) } diff --git a/sdk/resourcemanager/consumption/armconsumption/usagedetails_client_example_test.go b/sdk/resourcemanager/consumption/armconsumption/usagedetails_client_example_test.go deleted file mode 100644 index dc8cef100a4b..000000000000 --- a/sdk/resourcemanager/consumption/armconsumption/usagedetails_client_example_test.go +++ /dev/null @@ -1,1662 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armconsumption_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/consumption/armconsumption" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/UsageDetailsListByBillingAccount.json -func ExampleUsageDetailsClient_NewListPager_billingAccountUsageDetailsListLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewUsageDetailsClient().NewListPager("providers/Microsoft.Billing/BillingAccounts/1234", &armconsumption.UsageDetailsClientListOptions{Expand: nil, - Filter: nil, - Skiptoken: nil, - Top: nil, - Metric: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.UsageDetailsListResult = armconsumption.UsageDetailsListResult{ - // Value: []armconsumption.UsageDetailClassification{ - // &armconsumption.LegacyUsageDetail{ - // Name: to.Ptr("usageDetails_Id1"), - // Type: to.Ptr("Microsoft.Consumption/usageDetails"), - // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/1234/providers/Microsoft.Billing/billingPeriods/201903/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1"), - // Tags: map[string]*string{ - // "dev": to.Ptr("tools"), - // "env": to.Ptr("newcrp"), - // }, - // Kind: to.Ptr(armconsumption.UsageDetailsKindLegacy), - // Properties: &armconsumption.LegacyUsageDetailProperties{ - // AccountName: to.Ptr("Account Name 1"), - // BenefitID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // BenefitName: to.Ptr("Reservation_purchase_03-09-2018_10-59"), - // BillingAccountID: to.Ptr("xxxxxxxx"), - // BillingAccountName: to.Ptr("Account Name 1"), - // BillingCurrency: to.Ptr("CAD"), - // BillingPeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-31T00:00:00.000Z"); return t}()), - // BillingPeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T00:00:00.000Z"); return t}()), - // BillingProfileID: to.Ptr("xxxxxxxx"), - // BillingProfileName: to.Ptr("Account Name 1"), - // ChargeType: to.Ptr("Usage"), - // ConsumedService: to.Ptr("Microsoft.Storage"), - // Cost: to.Ptr[float64](0.000295194820065), - // CostCenter: to.Ptr("DEV"), - // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-30T00:00:00.000Z"); return t}()), - // EffectivePrice: to.Ptr[float64](0.000402776395232), - // InvoiceSection: to.Ptr("Invoice Section 1"), - // IsAzureCreditEligible: to.Ptr(false), - // MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // OfferID: to.Ptr("Offer Id 1"), - // PartNumber: to.Ptr("Part Number 1"), - // Product: to.Ptr("Product Name 1"), - // Quantity: to.Ptr[float64](0.7329), - // ResourceGroup: to.Ptr("Resource Group 1"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 1/providers/Microsoft.Storage/storageAccounts/Resource Name 1"), - // ResourceLocation: to.Ptr("USEast"), - // ResourceName: to.Ptr("Resource Name 1"), - // SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // SubscriptionName: to.Ptr("Subscription Name 1"), - // UnitPrice: to.Ptr[float64](4.38), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/UsageDetailsListByMCABillingAccount.json -func ExampleUsageDetailsClient_NewListPager_billingAccountUsageDetailsListModern() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewUsageDetailsClient().NewListPager("providers/Microsoft.Billing/BillingAccounts/1234:56789", &armconsumption.UsageDetailsClientListOptions{Expand: nil, - Filter: nil, - Skiptoken: nil, - Top: nil, - Metric: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.UsageDetailsListResult = armconsumption.UsageDetailsListResult{ - // Value: []armconsumption.UsageDetailClassification{ - // &armconsumption.ModernUsageDetail{ - // Name: to.Ptr("usageDetails_Id1"), - // Type: to.Ptr("Microsoft.Consumption/usageDetails"), - // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/1234:56789/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1"), - // Tags: map[string]*string{ - // "dev": to.Ptr("tools"), - // "env": to.Ptr("newcrp"), - // }, - // Kind: to.Ptr(armconsumption.UsageDetailsKindModern), - // Properties: &armconsumption.ModernUsageDetailProperties{ - // AdditionalInfo: to.Ptr("{ \"UsageType\": \"ComputeHR\", \"ImageType\": \"Windows Client BYOL\", \"ServiceType\": \"Standard_D1\", \"VMName\": null, \"VMProperties\": null, \"VCPUs\": 1, \"CPUs\": 0}"), - // BenefitID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // BenefitName: to.Ptr("Reservation_purchase_03-09-2018_10-59"), - // BillingAccountID: to.Ptr("1234:56789"), - // BillingAccountName: to.Ptr("Account Name 1"), - // BillingCurrencyCode: to.Ptr("USD"), - // BillingPeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-31T00:00:00.000Z"); return t}()), - // BillingPeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-10-01T00:00:00.000Z"); return t}()), - // BillingProfileID: to.Ptr("2468"), - // BillingProfileName: to.Ptr("Account Name 1"), - // ChargeType: to.Ptr("Usage"), - // ConsumedService: to.Ptr("Microsoft.Storage"), - // CostCenter: to.Ptr("DEV"), - // CostInBillingCurrency: to.Ptr[float64](1.84763819095477), - // CostInPricingCurrency: to.Ptr[float64](1.84763819095477), - // CostInUSD: to.Ptr[float64](1.84763819095477), - // CustomerName: to.Ptr("Modern Azure Customer 1"), - // CustomerTenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-30T00:00:00.000Z"); return t}()), - // ExchangeRate: to.Ptr("1"), - // ExchangeRateDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-10-01T00:00:00.000Z"); return t}()), - // ExchangeRatePricingToBilling: to.Ptr[float64](0.077), - // Frequency: to.Ptr("UsageBased"), - // InstanceName: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 1/providers/Microsoft.Storage/storageAccounts/Resource Name 1"), - // InvoiceID: to.Ptr(""), - // InvoiceSectionID: to.Ptr("98765"), - // InvoiceSectionName: to.Ptr("Invoice Section 1"), - // IsAzureCreditEligible: to.Ptr(false), - // MarketPrice: to.Ptr[float64](0.077), - // MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // PartnerEarnedCreditApplied: to.Ptr("0"), - // PartnerEarnedCreditRate: to.Ptr[float64](0.077), - // PartnerName: to.Ptr("Partner Name 1"), - // PartnerTenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // PaygCostInBillingCurrency: to.Ptr[float64](1.848), - // PaygCostInUSD: to.Ptr[float64](1.848), - // PreviousInvoiceID: to.Ptr(""), - // PricingCurrencyCode: to.Ptr("USD"), - // Product: to.Ptr("Virtual Machines D Series - D1 - US East"), - // ProductIdentifier: to.Ptr("DZH318Z0BQ4B00FV"), - // ProductOrderID: to.Ptr("a3db7880-70eb-4b4c-6a79-1425a058df5a"), - // ProductOrderName: to.Ptr("Azure plan"), - // PublisherID: to.Ptr(""), - // PublisherName: to.Ptr("Microsoft"), - // PublisherType: to.Ptr("Microsoft"), - // Quantity: to.Ptr[float64](0.7329), - // ResellerMpnID: to.Ptr(""), - // ResellerName: to.Ptr("Reseller Name 1"), - // ReservationID: to.Ptr(""), - // ReservationName: to.Ptr(""), - // ResourceGroup: to.Ptr("Resource Group 1"), - // ResourceLocation: to.Ptr("USEast"), - // ResourceLocationNormalized: to.Ptr("US East"), - // ServiceInfo1: to.Ptr(""), - // ServiceInfo2: to.Ptr("Windows Client BYOL"), - // ServicePeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-12-01T00:00:00.000Z"); return t}()), - // ServicePeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-10-01T00:00:00.000Z"); return t}()), - // SubscriptionGUID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // SubscriptionName: to.Ptr("Subscription Name 1"), - // Term: to.Ptr(""), - // UnitPrice: to.Ptr[float64](4.38), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/UsageDetailsListForBillingPeriodByBillingAccount.json -func ExampleUsageDetailsClient_NewListPager_billingAccountUsageDetailsListForBillingPeriodLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewUsageDetailsClient().NewListPager("providers/Microsoft.Billing/BillingAccounts/1234", &armconsumption.UsageDetailsClientListOptions{Expand: nil, - Filter: nil, - Skiptoken: nil, - Top: nil, - Metric: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.UsageDetailsListResult = armconsumption.UsageDetailsListResult{ - // Value: []armconsumption.UsageDetailClassification{ - // &armconsumption.LegacyUsageDetail{ - // Name: to.Ptr("usageDetails_Id1"), - // Type: to.Ptr("Microsoft.Consumption/usageDetails"), - // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/1234/providers/Microsoft.Billing/billingPeriods/201903/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1"), - // Tags: map[string]*string{ - // "dev": to.Ptr("tools"), - // "env": to.Ptr("newcrp"), - // }, - // Kind: to.Ptr(armconsumption.UsageDetailsKindLegacy), - // Properties: &armconsumption.LegacyUsageDetailProperties{ - // AccountName: to.Ptr("Account Name 1"), - // BenefitID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // BenefitName: to.Ptr("Reservation_purchase_03-09-2018_10-59"), - // BillingAccountID: to.Ptr("xxxxxxxx"), - // BillingAccountName: to.Ptr("Account Name 1"), - // BillingCurrency: to.Ptr("CAD"), - // BillingPeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-31T00:00:00.000Z"); return t}()), - // BillingPeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T00:00:00.000Z"); return t}()), - // BillingProfileID: to.Ptr("xxxxxxxx"), - // BillingProfileName: to.Ptr("Account Name 1"), - // ChargeType: to.Ptr("Usage"), - // ConsumedService: to.Ptr("Microsoft.Storage"), - // Cost: to.Ptr[float64](0.000342194841184), - // CostCenter: to.Ptr("DEV"), - // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-30T00:00:00.000Z"); return t}()), - // EffectivePrice: to.Ptr[float64](0.010534556373432), - // InvoiceSection: to.Ptr("Invoice Section 1"), - // IsAzureCreditEligible: to.Ptr(false), - // MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // OfferID: to.Ptr("Offer Id 1"), - // PartNumber: to.Ptr("Part Number 1"), - // Product: to.Ptr("Product Name 1"), - // Quantity: to.Ptr[float64](0.8234), - // ResourceGroup: to.Ptr("Resource Group 1"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 1/providers/Microsoft.Storage/storageAccounts/Resource Name 1"), - // ResourceLocation: to.Ptr("USEast"), - // ResourceName: to.Ptr("Resource Name 1"), - // SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // SubscriptionName: to.Ptr("Subscription Name 1"), - // UnitPrice: to.Ptr[float64](3.74), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/UsageDetailsListByMCABillingProfile.json -func ExampleUsageDetailsClient_NewListPager_billingProfileUsageDetailsListModern() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewUsageDetailsClient().NewListPager("providers/Microsoft.Billing/BillingAccounts/1234:56789/billingProfiles/2468", &armconsumption.UsageDetailsClientListOptions{Expand: nil, - Filter: nil, - Skiptoken: nil, - Top: nil, - Metric: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.UsageDetailsListResult = armconsumption.UsageDetailsListResult{ - // Value: []armconsumption.UsageDetailClassification{ - // &armconsumption.ModernUsageDetail{ - // Name: to.Ptr("usageDetails_Id1"), - // Type: to.Ptr("Microsoft.Consumption/usageDetails"), - // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/1234:56789/billingProfiles/2468/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1"), - // Tags: map[string]*string{ - // "dev": to.Ptr("tools"), - // "env": to.Ptr("newcrp"), - // }, - // Kind: to.Ptr(armconsumption.UsageDetailsKindModern), - // Properties: &armconsumption.ModernUsageDetailProperties{ - // AdditionalInfo: to.Ptr("{ \"UsageType\": \"ComputeHR\", \"ImageType\": \"Windows Client BYOL\", \"ServiceType\": \"Standard_D1\", \"VMName\": null, \"VMProperties\": null, \"VCPUs\": 1, \"CPUs\": 0}"), - // BenefitID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // BenefitName: to.Ptr("Reservation_purchase_03-09-2018_10-59"), - // BillingAccountID: to.Ptr("1234:56789"), - // BillingAccountName: to.Ptr("Account Name 1"), - // BillingCurrencyCode: to.Ptr("USD"), - // BillingPeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-31T00:00:00.000Z"); return t}()), - // BillingPeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-10-01T00:00:00.000Z"); return t}()), - // BillingProfileID: to.Ptr("2468"), - // BillingProfileName: to.Ptr("Account Name 1"), - // ChargeType: to.Ptr("Usage"), - // ConsumedService: to.Ptr("Microsoft.Storage"), - // CostCenter: to.Ptr("DEV"), - // CostInBillingCurrency: to.Ptr[float64](1.84763819095477), - // CostInPricingCurrency: to.Ptr[float64](1.84763819095477), - // CostInUSD: to.Ptr[float64](1.84763819095477), - // CustomerName: to.Ptr("Modern Azure Customer 1"), - // CustomerTenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-30T00:00:00.000Z"); return t}()), - // ExchangeRate: to.Ptr("1"), - // ExchangeRateDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-10-01T00:00:00.000Z"); return t}()), - // ExchangeRatePricingToBilling: to.Ptr[float64](0.077), - // Frequency: to.Ptr("UsageBased"), - // InstanceName: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 1/providers/Microsoft.Storage/storageAccounts/Resource Name 1"), - // InvoiceID: to.Ptr(""), - // InvoiceSectionID: to.Ptr("98765"), - // InvoiceSectionName: to.Ptr("Invoice Section 1"), - // IsAzureCreditEligible: to.Ptr(false), - // MarketPrice: to.Ptr[float64](0.077), - // MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // PartnerEarnedCreditApplied: to.Ptr("0"), - // PartnerEarnedCreditRate: to.Ptr[float64](0.077), - // PartnerName: to.Ptr("Partner Name 1"), - // PartnerTenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // PaygCostInBillingCurrency: to.Ptr[float64](1.848), - // PaygCostInUSD: to.Ptr[float64](1.848), - // PreviousInvoiceID: to.Ptr(""), - // PricingCurrencyCode: to.Ptr("USD"), - // Product: to.Ptr("Virtual Machines D Series - D1 - US East"), - // ProductIdentifier: to.Ptr("DZH318Z0BQ4B00FV"), - // ProductOrderID: to.Ptr("a3db7880-70eb-4b4c-6a79-1425a058df5a"), - // ProductOrderName: to.Ptr("Azure plan"), - // PublisherID: to.Ptr(""), - // PublisherName: to.Ptr("Microsoft"), - // PublisherType: to.Ptr("Microsoft"), - // Quantity: to.Ptr[float64](0.7329), - // ResellerMpnID: to.Ptr(""), - // ResellerName: to.Ptr("Reseller Name 1"), - // ReservationID: to.Ptr(""), - // ReservationName: to.Ptr(""), - // ResourceGroup: to.Ptr("Resource Group 1"), - // ResourceLocation: to.Ptr("USEast"), - // ResourceLocationNormalized: to.Ptr("US East"), - // ServiceInfo1: to.Ptr(""), - // ServiceInfo2: to.Ptr("Windows Client BYOL"), - // ServicePeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-12-01T00:00:00.000Z"); return t}()), - // ServicePeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-10-01T00:00:00.000Z"); return t}()), - // SubscriptionGUID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // SubscriptionName: to.Ptr("Subscription Name 1"), - // Term: to.Ptr(""), - // UnitPrice: to.Ptr[float64](4.38), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/UsageDetailsListByMCACustomer.json -func ExampleUsageDetailsClient_NewListPager_customerUsageDetailsListModern() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewUsageDetailsClient().NewListPager("providers/Microsoft.Billing/BillingAccounts/1234:56789/customers/00000000-0000-0000-0000-000000000000", &armconsumption.UsageDetailsClientListOptions{Expand: nil, - Filter: nil, - Skiptoken: nil, - Top: nil, - Metric: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.UsageDetailsListResult = armconsumption.UsageDetailsListResult{ - // Value: []armconsumption.UsageDetailClassification{ - // &armconsumption.ModernUsageDetail{ - // Name: to.Ptr("usageDetails_Id1"), - // Type: to.Ptr("Microsoft.Consumption/usageDetails"), - // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/1234:56789/customers/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1"), - // Tags: map[string]*string{ - // "dev": to.Ptr("tools"), - // "env": to.Ptr("newcrp"), - // }, - // Kind: to.Ptr(armconsumption.UsageDetailsKindModern), - // Properties: &armconsumption.ModernUsageDetailProperties{ - // AdditionalInfo: to.Ptr("{ \"UsageType\": \"ComputeHR\", \"ImageType\": \"Windows Client BYOL\", \"ServiceType\": \"Standard_D1\", \"VMName\": null, \"VMProperties\": null, \"VCPUs\": 1, \"CPUs\": 0}"), - // BenefitID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // BenefitName: to.Ptr("Reservation_purchase_03-09-2018_10-59"), - // BillingAccountID: to.Ptr("1234:56789"), - // BillingAccountName: to.Ptr("Account Name 1"), - // BillingCurrencyCode: to.Ptr("USD"), - // BillingPeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-31T00:00:00.000Z"); return t}()), - // BillingPeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-10-01T00:00:00.000Z"); return t}()), - // BillingProfileID: to.Ptr("2468"), - // BillingProfileName: to.Ptr("Account Name 1"), - // ChargeType: to.Ptr("Usage"), - // ConsumedService: to.Ptr("Microsoft.Storage"), - // CostCenter: to.Ptr("DEV"), - // CostInBillingCurrency: to.Ptr[float64](1.84763819095477), - // CostInPricingCurrency: to.Ptr[float64](1.84763819095477), - // CostInUSD: to.Ptr[float64](1.84763819095477), - // CustomerName: to.Ptr("Modern Azure Customer 1"), - // CustomerTenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-30T00:00:00.000Z"); return t}()), - // ExchangeRate: to.Ptr("1"), - // ExchangeRateDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-10-01T00:00:00.000Z"); return t}()), - // ExchangeRatePricingToBilling: to.Ptr[float64](0.077), - // Frequency: to.Ptr("UsageBased"), - // InstanceName: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 1/providers/Microsoft.Storage/storageAccounts/Resource Name 1"), - // InvoiceID: to.Ptr(""), - // InvoiceSectionID: to.Ptr("98765"), - // InvoiceSectionName: to.Ptr("Invoice Section 1"), - // IsAzureCreditEligible: to.Ptr(false), - // MarketPrice: to.Ptr[float64](0.077), - // MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // PartnerEarnedCreditApplied: to.Ptr("0"), - // PartnerEarnedCreditRate: to.Ptr[float64](0.077), - // PartnerName: to.Ptr("Partner Name 1"), - // PartnerTenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // PaygCostInBillingCurrency: to.Ptr[float64](1.848), - // PaygCostInUSD: to.Ptr[float64](1.848), - // PreviousInvoiceID: to.Ptr(""), - // PricingCurrencyCode: to.Ptr("USD"), - // Product: to.Ptr("Virtual Machines D Series - D1 - US East"), - // ProductIdentifier: to.Ptr("DZH318Z0BQ4B00FV"), - // ProductOrderID: to.Ptr("a3db7880-70eb-4b4c-6a79-1425a058df5a"), - // ProductOrderName: to.Ptr("Azure plan"), - // PublisherID: to.Ptr(""), - // PublisherName: to.Ptr("Microsoft"), - // PublisherType: to.Ptr("Microsoft"), - // Quantity: to.Ptr[float64](0.7329), - // ResellerMpnID: to.Ptr(""), - // ResellerName: to.Ptr("Reseller Name 1"), - // ReservationID: to.Ptr(""), - // ReservationName: to.Ptr(""), - // ResourceGroup: to.Ptr("Resource Group 1"), - // ResourceLocation: to.Ptr("USEast"), - // ResourceLocationNormalized: to.Ptr("US East"), - // ServiceInfo1: to.Ptr(""), - // ServiceInfo2: to.Ptr("Windows Client BYOL"), - // ServicePeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-12-01T00:00:00.000Z"); return t}()), - // ServicePeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-10-01T00:00:00.000Z"); return t}()), - // SubscriptionGUID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // SubscriptionName: to.Ptr("Subscription Name 1"), - // Term: to.Ptr(""), - // UnitPrice: to.Ptr[float64](4.38), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/UsageDetailsListByDepartment.json -func ExampleUsageDetailsClient_NewListPager_departmentUsageDetailsListLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewUsageDetailsClient().NewListPager("providers/Microsoft.Billing/Departments/1234", &armconsumption.UsageDetailsClientListOptions{Expand: nil, - Filter: nil, - Skiptoken: nil, - Top: nil, - Metric: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.UsageDetailsListResult = armconsumption.UsageDetailsListResult{ - // Value: []armconsumption.UsageDetailClassification{ - // &armconsumption.LegacyUsageDetail{ - // Name: to.Ptr("usageDetails_Id1"), - // Type: to.Ptr("Microsoft.Consumption/usageDetails"), - // ID: to.Ptr("/providers/Microsoft.Billing/Departments/1234/providers/Microsoft.Billing/billingPeriods/201903/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1"), - // Tags: map[string]*string{ - // "dev": to.Ptr("tools"), - // "env": to.Ptr("newcrp"), - // }, - // Kind: to.Ptr(armconsumption.UsageDetailsKindLegacy), - // Properties: &armconsumption.LegacyUsageDetailProperties{ - // AccountName: to.Ptr("Account Name 1"), - // BenefitID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // BenefitName: to.Ptr("Reservation_purchase_03-09-2018_10-59"), - // BillingAccountID: to.Ptr("xxxxxxxx"), - // BillingAccountName: to.Ptr("Account Name 1"), - // BillingCurrency: to.Ptr("CAD"), - // BillingPeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-31T00:00:00.000Z"); return t}()), - // BillingPeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T00:00:00.000Z"); return t}()), - // BillingProfileID: to.Ptr("xxxxxxxx"), - // BillingProfileName: to.Ptr("Account Name 1"), - // ChargeType: to.Ptr("Usage"), - // ConsumedService: to.Ptr("Microsoft.Storage"), - // Cost: to.Ptr[float64](0.000295194820065), - // CostCenter: to.Ptr("DEV"), - // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-30T00:00:00.000Z"); return t}()), - // EffectivePrice: to.Ptr[float64](0.000402776395232), - // InvoiceSection: to.Ptr("Invoice Section 1"), - // IsAzureCreditEligible: to.Ptr(false), - // MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // OfferID: to.Ptr("Offer Id 1"), - // PartNumber: to.Ptr("Part Number 1"), - // Product: to.Ptr("Product Name 1"), - // Quantity: to.Ptr[float64](0.7329), - // ResourceGroup: to.Ptr("Resource Group 1"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 1/providers/Microsoft.Storage/storageAccounts/Resource Name 1"), - // ResourceLocation: to.Ptr("USEast"), - // ResourceName: to.Ptr("Resource Name 1"), - // SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // SubscriptionName: to.Ptr("Subscription Name 1"), - // UnitPrice: to.Ptr[float64](4.38), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/UsageDetailsListForBillingPeriodByDepartment.json -func ExampleUsageDetailsClient_NewListPager_departmentUsageDetailsListForBillingPeriodLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewUsageDetailsClient().NewListPager("providers/Microsoft.Billing/Departments/1234", &armconsumption.UsageDetailsClientListOptions{Expand: nil, - Filter: nil, - Skiptoken: nil, - Top: nil, - Metric: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.UsageDetailsListResult = armconsumption.UsageDetailsListResult{ - // Value: []armconsumption.UsageDetailClassification{ - // &armconsumption.LegacyUsageDetail{ - // Name: to.Ptr("usageDetails_Id1"), - // Type: to.Ptr("Microsoft.Consumption/usageDetails"), - // ID: to.Ptr("/providers/Microsoft.Billing/Departments/1234/providers/Microsoft.Billing/billingPeriods/201903/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1"), - // Tags: map[string]*string{ - // "dev": to.Ptr("tools"), - // "env": to.Ptr("newcrp"), - // }, - // Kind: to.Ptr(armconsumption.UsageDetailsKindLegacy), - // Properties: &armconsumption.LegacyUsageDetailProperties{ - // AccountName: to.Ptr("Account Name 1"), - // BenefitID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // BenefitName: to.Ptr("Reservation_purchase_03-09-2018_10-59"), - // BillingAccountID: to.Ptr("xxxxxxxx"), - // BillingAccountName: to.Ptr("Account Name 1"), - // BillingCurrency: to.Ptr("CAD"), - // BillingPeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-31T00:00:00.000Z"); return t}()), - // BillingPeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T00:00:00.000Z"); return t}()), - // BillingProfileID: to.Ptr("xxxxxxxx"), - // BillingProfileName: to.Ptr("Account Name 1"), - // ChargeType: to.Ptr("Usage"), - // ConsumedService: to.Ptr("Microsoft.Storage"), - // Cost: to.Ptr[float64](0.000342194841184), - // CostCenter: to.Ptr("DEV"), - // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-30T00:00:00.000Z"); return t}()), - // EffectivePrice: to.Ptr[float64](0.010534556373432), - // InvoiceSection: to.Ptr("Invoice Section 1"), - // IsAzureCreditEligible: to.Ptr(false), - // MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // OfferID: to.Ptr("Offer Id 1"), - // PartNumber: to.Ptr("Part Number 1"), - // Product: to.Ptr("Product Name 1"), - // Quantity: to.Ptr[float64](0.8234), - // ResourceGroup: to.Ptr("Resource Group 1"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 1/providers/Microsoft.Storage/storageAccounts/Resource Name 1"), - // ResourceLocation: to.Ptr("USEast"), - // ResourceName: to.Ptr("Resource Name 1"), - // SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // SubscriptionName: to.Ptr("Subscription Name 1"), - // UnitPrice: to.Ptr[float64](3.74), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/UsageDetailsListByEnrollmentAccount.json -func ExampleUsageDetailsClient_NewListPager_enrollmentAccountUsageDetailsListLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewUsageDetailsClient().NewListPager("providers/Microsoft.Billing/EnrollmentAccounts/1234", &armconsumption.UsageDetailsClientListOptions{Expand: nil, - Filter: nil, - Skiptoken: nil, - Top: nil, - Metric: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.UsageDetailsListResult = armconsumption.UsageDetailsListResult{ - // Value: []armconsumption.UsageDetailClassification{ - // &armconsumption.LegacyUsageDetail{ - // Name: to.Ptr("usageDetails_Id1"), - // Type: to.Ptr("Microsoft.Consumption/usageDetails"), - // ID: to.Ptr("/providers/Microsoft.Billing/EnrollmentAccounts/1234/providers/Microsoft.Billing/billingPeriods/201903/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1"), - // Tags: map[string]*string{ - // "dev": to.Ptr("tools"), - // "env": to.Ptr("newcrp"), - // }, - // Kind: to.Ptr(armconsumption.UsageDetailsKindLegacy), - // Properties: &armconsumption.LegacyUsageDetailProperties{ - // AccountName: to.Ptr("Account Name 1"), - // BenefitID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // BenefitName: to.Ptr("Reservation_purchase_03-09-2018_10-59"), - // BillingAccountID: to.Ptr("xxxxxxxx"), - // BillingAccountName: to.Ptr("Account Name 1"), - // BillingCurrency: to.Ptr("CAD"), - // BillingPeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-31T00:00:00.000Z"); return t}()), - // BillingPeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T00:00:00.000Z"); return t}()), - // BillingProfileID: to.Ptr("xxxxxxxx"), - // BillingProfileName: to.Ptr("Account Name 1"), - // ChargeType: to.Ptr("Usage"), - // ConsumedService: to.Ptr("Microsoft.Storage"), - // Cost: to.Ptr[float64](0.000295194820065), - // CostCenter: to.Ptr("DEV"), - // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-30T00:00:00.000Z"); return t}()), - // EffectivePrice: to.Ptr[float64](0.000402776395232), - // InvoiceSection: to.Ptr("Invoice Section 1"), - // IsAzureCreditEligible: to.Ptr(false), - // MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // OfferID: to.Ptr("Offer Id 1"), - // PartNumber: to.Ptr("Part Number 1"), - // Product: to.Ptr("Product Name 1"), - // Quantity: to.Ptr[float64](0.7329), - // ResourceGroup: to.Ptr("Resource Group 1"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 1/providers/Microsoft.Storage/storageAccounts/Resource Name 1"), - // ResourceLocation: to.Ptr("USEast"), - // ResourceName: to.Ptr("Resource Name 1"), - // SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // SubscriptionName: to.Ptr("Subscription Name 1"), - // UnitPrice: to.Ptr[float64](4.38), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/UsageDetailsListForBillingPeriodByEnrollmentAccount.json -func ExampleUsageDetailsClient_NewListPager_enrollmentAccountUsageDetailsListForBillingPeriodLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewUsageDetailsClient().NewListPager("providers/Microsoft.Billing/EnrollmentAccounts/1234", &armconsumption.UsageDetailsClientListOptions{Expand: nil, - Filter: nil, - Skiptoken: nil, - Top: nil, - Metric: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.UsageDetailsListResult = armconsumption.UsageDetailsListResult{ - // Value: []armconsumption.UsageDetailClassification{ - // &armconsumption.LegacyUsageDetail{ - // Name: to.Ptr("usageDetails_Id1"), - // Type: to.Ptr("Microsoft.Consumption/usageDetails"), - // ID: to.Ptr("/providers/Microsoft.Billing/EnrollmentAccounts/1234/providers/Microsoft.Billing/billingPeriods/201903/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1"), - // Tags: map[string]*string{ - // "dev": to.Ptr("tools"), - // "env": to.Ptr("newcrp"), - // }, - // Kind: to.Ptr(armconsumption.UsageDetailsKindLegacy), - // Properties: &armconsumption.LegacyUsageDetailProperties{ - // AccountName: to.Ptr("Account Name 1"), - // BenefitID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // BenefitName: to.Ptr("Reservation_purchase_03-09-2018_10-59"), - // BillingAccountID: to.Ptr("xxxxxxxx"), - // BillingAccountName: to.Ptr("Account Name 1"), - // BillingCurrency: to.Ptr("CAD"), - // BillingPeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-31T00:00:00.000Z"); return t}()), - // BillingPeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T00:00:00.000Z"); return t}()), - // BillingProfileID: to.Ptr("xxxxxxxx"), - // BillingProfileName: to.Ptr("Account Name 1"), - // ChargeType: to.Ptr("Usage"), - // ConsumedService: to.Ptr("Microsoft.Storage"), - // Cost: to.Ptr[float64](0.000342194841184), - // CostCenter: to.Ptr("DEV"), - // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-30T00:00:00.000Z"); return t}()), - // EffectivePrice: to.Ptr[float64](0.010534556373432), - // InvoiceSection: to.Ptr("Invoice Section 1"), - // IsAzureCreditEligible: to.Ptr(false), - // MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // OfferID: to.Ptr("Offer Id 1"), - // PartNumber: to.Ptr("Part Number 1"), - // Product: to.Ptr("Product Name 1"), - // Quantity: to.Ptr[float64](0.8234), - // ResourceGroup: to.Ptr("Resource Group 1"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 1/providers/Microsoft.Storage/storageAccounts/Resource Name 1"), - // ResourceLocation: to.Ptr("USEast"), - // ResourceName: to.Ptr("Resource Name 1"), - // SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // SubscriptionName: to.Ptr("Subscription Name 1"), - // UnitPrice: to.Ptr[float64](3.74), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/UsageDetailsListByMCAInvoiceSection.json -func ExampleUsageDetailsClient_NewListPager_invoiceSectionUsageDetailsListModern() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewUsageDetailsClient().NewListPager("providers/Microsoft.Billing/BillingAccounts/1234:56789/invoiceSections/98765", &armconsumption.UsageDetailsClientListOptions{Expand: nil, - Filter: nil, - Skiptoken: nil, - Top: nil, - Metric: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.UsageDetailsListResult = armconsumption.UsageDetailsListResult{ - // Value: []armconsumption.UsageDetailClassification{ - // &armconsumption.ModernUsageDetail{ - // Name: to.Ptr("usageDetails_Id1"), - // Type: to.Ptr("Microsoft.Consumption/usageDetails"), - // ID: to.Ptr("/providers/Microsoft.Billing/BillingAccounts/1234:56789/invoiceSections/98765/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1"), - // Tags: map[string]*string{ - // "dev": to.Ptr("tools"), - // "env": to.Ptr("newcrp"), - // }, - // Kind: to.Ptr(armconsumption.UsageDetailsKindModern), - // Properties: &armconsumption.ModernUsageDetailProperties{ - // AdditionalInfo: to.Ptr("{ \"UsageType\": \"ComputeHR\", \"ImageType\": \"Windows Client BYOL\", \"ServiceType\": \"Standard_D1\", \"VMName\": null, \"VMProperties\": null, \"VCPUs\": 1, \"CPUs\": 0}"), - // BenefitID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // BenefitName: to.Ptr("Reservation_purchase_03-09-2018_10-59"), - // BillingAccountID: to.Ptr("1234:56789"), - // BillingAccountName: to.Ptr("Account Name 1"), - // BillingCurrencyCode: to.Ptr("USD"), - // BillingPeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-31T00:00:00.000Z"); return t}()), - // BillingPeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-10-01T00:00:00.000Z"); return t}()), - // BillingProfileID: to.Ptr("2468"), - // BillingProfileName: to.Ptr("Account Name 1"), - // ChargeType: to.Ptr("Usage"), - // ConsumedService: to.Ptr("Microsoft.Storage"), - // CostCenter: to.Ptr("DEV"), - // CostInBillingCurrency: to.Ptr[float64](1.84763819095477), - // CostInPricingCurrency: to.Ptr[float64](1.84763819095477), - // CostInUSD: to.Ptr[float64](1.84763819095477), - // CustomerName: to.Ptr("Modern Azure Customer 1"), - // CustomerTenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-30T00:00:00.000Z"); return t}()), - // ExchangeRate: to.Ptr("1"), - // ExchangeRateDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-10-01T00:00:00.000Z"); return t}()), - // ExchangeRatePricingToBilling: to.Ptr[float64](0.077), - // Frequency: to.Ptr("UsageBased"), - // InstanceName: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 1/providers/Microsoft.Storage/storageAccounts/Resource Name 1"), - // InvoiceID: to.Ptr(""), - // InvoiceSectionID: to.Ptr("98765"), - // InvoiceSectionName: to.Ptr("Invoice Section 1"), - // IsAzureCreditEligible: to.Ptr(false), - // MarketPrice: to.Ptr[float64](0.077), - // MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // PartnerEarnedCreditApplied: to.Ptr("0"), - // PartnerEarnedCreditRate: to.Ptr[float64](0.077), - // PartnerName: to.Ptr("Partner Name 1"), - // PartnerTenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // PaygCostInBillingCurrency: to.Ptr[float64](1.848), - // PaygCostInUSD: to.Ptr[float64](1.848), - // PreviousInvoiceID: to.Ptr(""), - // PricingCurrencyCode: to.Ptr("USD"), - // Product: to.Ptr("Virtual Machines D Series - D1 - US East"), - // ProductIdentifier: to.Ptr("DZH318Z0BQ4B00FV"), - // ProductOrderID: to.Ptr("a3db7880-70eb-4b4c-6a79-1425a058df5a"), - // ProductOrderName: to.Ptr("Azure plan"), - // PublisherID: to.Ptr(""), - // PublisherName: to.Ptr("Microsoft"), - // PublisherType: to.Ptr("Microsoft"), - // Quantity: to.Ptr[float64](0.7329), - // ResellerMpnID: to.Ptr(""), - // ResellerName: to.Ptr("Reseller Name 1"), - // ReservationID: to.Ptr(""), - // ReservationName: to.Ptr(""), - // ResourceGroup: to.Ptr("Resource Group 1"), - // ResourceLocation: to.Ptr("USEast"), - // ResourceLocationNormalized: to.Ptr("US East"), - // ServiceInfo1: to.Ptr(""), - // ServiceInfo2: to.Ptr("Windows Client BYOL"), - // ServicePeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-12-01T00:00:00.000Z"); return t}()), - // ServicePeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-10-01T00:00:00.000Z"); return t}()), - // SubscriptionGUID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // SubscriptionName: to.Ptr("Subscription Name 1"), - // Term: to.Ptr(""), - // UnitPrice: to.Ptr[float64](4.38), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/UsageDetailsListByManagementGroup.json -func ExampleUsageDetailsClient_NewListPager_managementGroupUsageDetailsListLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewUsageDetailsClient().NewListPager("subscriptions/00000000-0000-0000-0000-000000000000", &armconsumption.UsageDetailsClientListOptions{Expand: nil, - Filter: nil, - Skiptoken: nil, - Top: nil, - Metric: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.UsageDetailsListResult = armconsumption.UsageDetailsListResult{ - // Value: []armconsumption.UsageDetailClassification{ - // &armconsumption.LegacyUsageDetail{ - // Name: to.Ptr("usageDetails_Id1"), - // Type: to.Ptr("Microsoft.Consumption/usageDetails"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Billing/billingPeriods/201903/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1"), - // Tags: map[string]*string{ - // "dev": to.Ptr("tools"), - // "env": to.Ptr("newcrp"), - // }, - // Kind: to.Ptr(armconsumption.UsageDetailsKindLegacy), - // Properties: &armconsumption.LegacyUsageDetailProperties{ - // AccountName: to.Ptr("Account Name 1"), - // BenefitID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // BenefitName: to.Ptr("Reservation_purchase_03-09-2018_10-59"), - // BillingAccountID: to.Ptr("xxxxxxxx"), - // BillingAccountName: to.Ptr("Account Name 1"), - // BillingCurrency: to.Ptr("CAD"), - // BillingPeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-31T00:00:00.000Z"); return t}()), - // BillingPeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T00:00:00.000Z"); return t}()), - // BillingProfileID: to.Ptr("xxxxxxxx"), - // BillingProfileName: to.Ptr("Account Name 1"), - // ChargeType: to.Ptr("Usage"), - // ConsumedService: to.Ptr("Microsoft.Storage"), - // Cost: to.Ptr[float64](0.000342194841184), - // CostCenter: to.Ptr("DEV"), - // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-30T00:00:00.000Z"); return t}()), - // EffectivePrice: to.Ptr[float64](0.010534556373432), - // InvoiceSection: to.Ptr("Invoice Section 1"), - // IsAzureCreditEligible: to.Ptr(false), - // MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // OfferID: to.Ptr("Offer Id 1"), - // PartNumber: to.Ptr("Part Number 1"), - // Product: to.Ptr("Product Name 1"), - // Quantity: to.Ptr[float64](0.8234), - // ResourceGroup: to.Ptr("Resource Group 1"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 1/providers/Microsoft.Storage/storageAccounts/Resource Name 1"), - // ResourceLocation: to.Ptr("USEast"), - // ResourceName: to.Ptr("Resource Name 1"), - // SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // SubscriptionName: to.Ptr("Subscription Name 1"), - // UnitPrice: to.Ptr[float64](3.74), - // }, - // }, - // &armconsumption.LegacyUsageDetail{ - // Name: to.Ptr("usageDetails_Id2"), - // Type: to.Ptr("Microsoft.Consumption/usageDetails"), - // ID: to.Ptr("/scope/providers/Microsoft.Billing/billingPeriods/20180801/providers/Microsoft.Consumption/usageDetails/usageDetails_Id2"), - // Tags: map[string]*string{ - // "dev": to.Ptr("tools"), - // "env": to.Ptr("newcrp"), - // }, - // Kind: to.Ptr(armconsumption.UsageDetailsKindLegacy), - // Properties: &armconsumption.LegacyUsageDetailProperties{ - // AccountName: to.Ptr("Account Name 1"), - // BenefitID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // BenefitName: to.Ptr("Reservation_purchase_03-09-2018_10-59"), - // BillingAccountID: to.Ptr("xxxxxxxx"), - // BillingAccountName: to.Ptr("Account Name 2"), - // BillingCurrency: to.Ptr("CAD"), - // BillingPeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-31T00:00:00.000Z"); return t}()), - // BillingPeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T00:00:00.000Z"); return t}()), - // BillingProfileID: to.Ptr("xxxxxxxx"), - // BillingProfileName: to.Ptr("Account Name 2"), - // ChargeType: to.Ptr("Usage"), - // ConsumedService: to.Ptr("Microsoft.Storage"), - // Cost: to.Ptr[float64](0.000295194820065), - // CostCenter: to.Ptr("DEV"), - // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-30T00:00:00.000Z"); return t}()), - // EffectivePrice: to.Ptr[float64](0.000402776395232), - // InvoiceSection: to.Ptr("Invoice Section 2"), - // IsAzureCreditEligible: to.Ptr(false), - // MeterID: to.Ptr("11111111-1111-1111-1111-111111111111"), - // OfferID: to.Ptr("Offer Id 2"), - // PartNumber: to.Ptr("Part Number 2"), - // Product: to.Ptr("Product Name 2"), - // Quantity: to.Ptr[float64](0.7329), - // ResourceGroup: to.Ptr("Resource Group 2"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 2/providers/Microsoft.Storage/storageAccounts/Resource Name 2"), - // ResourceLocation: to.Ptr("USEast"), - // ResourceName: to.Ptr("Resource Name 2"), - // SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // SubscriptionName: to.Ptr("Subscription Name 1"), - // UnitPrice: to.Ptr[float64](4.38), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/UsageDetailsListForBillingPeriodByManagementGroup.json -func ExampleUsageDetailsClient_NewListPager_managementGroupUsageDetailsListForBillingPeriodLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewUsageDetailsClient().NewListPager("subscriptions/00000000-0000-0000-0000-000000000000", &armconsumption.UsageDetailsClientListOptions{Expand: nil, - Filter: nil, - Skiptoken: nil, - Top: nil, - Metric: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.UsageDetailsListResult = armconsumption.UsageDetailsListResult{ - // Value: []armconsumption.UsageDetailClassification{ - // &armconsumption.LegacyUsageDetail{ - // Name: to.Ptr("usageDetails_Id1"), - // Type: to.Ptr("Microsoft.Consumption/usageDetails"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Billing/billingPeriods/201903/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1"), - // Tags: map[string]*string{ - // "dev": to.Ptr("tools"), - // "env": to.Ptr("newcrp"), - // }, - // Kind: to.Ptr(armconsumption.UsageDetailsKindLegacy), - // Properties: &armconsumption.LegacyUsageDetailProperties{ - // AccountName: to.Ptr("Account Name 1"), - // BenefitID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // BenefitName: to.Ptr("Reservation_purchase_03-09-2018_10-59"), - // BillingAccountID: to.Ptr("xxxxxxxx"), - // BillingAccountName: to.Ptr("Account Name 1"), - // BillingCurrency: to.Ptr("CAD"), - // BillingPeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-31T00:00:00.000Z"); return t}()), - // BillingPeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T00:00:00.000Z"); return t}()), - // BillingProfileID: to.Ptr("xxxxxxxx"), - // BillingProfileName: to.Ptr("Account Name 1"), - // ChargeType: to.Ptr("Usage"), - // ConsumedService: to.Ptr("Microsoft.Storage"), - // Cost: to.Ptr[float64](0.000342194841184), - // CostCenter: to.Ptr("DEV"), - // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-30T00:00:00.000Z"); return t}()), - // EffectivePrice: to.Ptr[float64](0.010534556373432), - // InvoiceSection: to.Ptr("Invoice Section 1"), - // IsAzureCreditEligible: to.Ptr(false), - // MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // OfferID: to.Ptr("Offer Id 1"), - // PartNumber: to.Ptr("Part Number 1"), - // Product: to.Ptr("Product Name 1"), - // Quantity: to.Ptr[float64](0.8234), - // ResourceGroup: to.Ptr("Resource Group 1"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 1/providers/Microsoft.Storage/storageAccounts/Resource Name 1"), - // ResourceLocation: to.Ptr("USEast"), - // ResourceName: to.Ptr("Resource Name 1"), - // SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // SubscriptionName: to.Ptr("Subscription Name 1"), - // UnitPrice: to.Ptr[float64](3.74), - // }, - // }, - // &armconsumption.LegacyUsageDetail{ - // Name: to.Ptr("usageDetails_Id2"), - // Type: to.Ptr("Microsoft.Consumption/usageDetails"), - // ID: to.Ptr("/scope/providers/Microsoft.Billing/billingPeriods/billingPeriodName/providers/Microsoft.Consumption/usageDetails/usageDetails_Id2"), - // Tags: map[string]*string{ - // "dev": to.Ptr("tools"), - // "env": to.Ptr("newcrp"), - // }, - // Kind: to.Ptr(armconsumption.UsageDetailsKindLegacy), - // Properties: &armconsumption.LegacyUsageDetailProperties{ - // AccountName: to.Ptr("Account Name 2"), - // BenefitID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // BenefitName: to.Ptr("Reservation_purchase_03-09-2018_10-59"), - // BillingAccountID: to.Ptr("xxxxxxxx"), - // BillingAccountName: to.Ptr("Account Name 2"), - // BillingCurrency: to.Ptr("CAD"), - // BillingPeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-31T00:00:00.000Z"); return t}()), - // BillingPeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T00:00:00.000Z"); return t}()), - // BillingProfileID: to.Ptr("xxxxxxxx"), - // BillingProfileName: to.Ptr("Account Name 2"), - // ChargeType: to.Ptr("UnusedReservation"), - // ConsumedService: to.Ptr("Microsoft.Storage"), - // Cost: to.Ptr[float64](0.000821821271948), - // CostCenter: to.Ptr("DEV"), - // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-30T00:00:00.000Z"); return t}()), - // EffectivePrice: to.Ptr[float64](0.073488920944598), - // InvoiceSection: to.Ptr("Invoice Section 2"), - // IsAzureCreditEligible: to.Ptr(false), - // MeterID: to.Ptr("11111111-1111-1111-1111-111111111111"), - // OfferID: to.Ptr("Offer Id 2"), - // PartNumber: to.Ptr("Part Number 2"), - // Product: to.Ptr("Product Name 2"), - // Quantity: to.Ptr[float64](0.4759), - // ResourceGroup: to.Ptr("Resource Group 2"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 2/providers/Microsoft.Storage/storageAccounts/Resource Name 2"), - // ResourceLocation: to.Ptr("USEast"), - // ResourceName: to.Ptr("Resource Name 2"), - // SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // SubscriptionName: to.Ptr("Subscription Name 2"), - // UnitPrice: to.Ptr[float64](5.74), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/UsageDetailsExpand.json -func ExampleUsageDetailsClient_NewListPager_usageDetailsExpandLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewUsageDetailsClient().NewListPager("subscriptions/00000000-0000-0000-0000-000000000000", &armconsumption.UsageDetailsClientListOptions{Expand: to.Ptr("meterDetails,additionalInfo"), - Filter: to.Ptr("tags eq 'dev:tools'"), - Skiptoken: nil, - Top: to.Ptr[int32](1), - Metric: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.UsageDetailsListResult = armconsumption.UsageDetailsListResult{ - // Value: []armconsumption.UsageDetailClassification{ - // &armconsumption.LegacyUsageDetail{ - // Name: to.Ptr("usageDetails_Id1"), - // Type: to.Ptr("Microsoft.Consumption/usageDetails"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Billing/billingPeriods/201903/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1"), - // Tags: map[string]*string{ - // "dev": to.Ptr("tools"), - // "env": to.Ptr("newcrp"), - // }, - // Kind: to.Ptr(armconsumption.UsageDetailsKindLegacy), - // Properties: &armconsumption.LegacyUsageDetailProperties{ - // AccountName: to.Ptr("Account Name 1"), - // AdditionalInfo: to.Ptr("{\"MyType\":\"\",\"ServiceType\":\"\",\"VMName\":\"\",\"UsageType\":\"MyUsage\"}"), - // BenefitID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // BenefitName: to.Ptr("Reservation_purchase_03-09-2018_10-59"), - // BillingAccountID: to.Ptr("xxxxxxxx"), - // BillingAccountName: to.Ptr("Account Name 1"), - // BillingCurrency: to.Ptr("CAD"), - // BillingPeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-31T00:00:00.000Z"); return t}()), - // BillingPeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T00:00:00.000Z"); return t}()), - // BillingProfileID: to.Ptr("xxxxxxxx"), - // BillingProfileName: to.Ptr("Account Name 1"), - // ChargeType: to.Ptr("Usage"), - // ConsumedService: to.Ptr("Microsoft.Storage"), - // Cost: to.Ptr[float64](0.000342194841184), - // CostCenter: to.Ptr("DEV"), - // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-30T00:00:00.000Z"); return t}()), - // EffectivePrice: to.Ptr[float64](0.010464556322455), - // Frequency: to.Ptr("UsageBased"), - // InvoiceSection: to.Ptr("Invoice Section 1"), - // IsAzureCreditEligible: to.Ptr(false), - // MeterDetails: &armconsumption.MeterDetailsResponse{ - // MeterCategory: to.Ptr("Networking"), - // MeterName: to.Ptr("Data Transfer Out (GB)"), - // MeterSubCategory: to.Ptr("ExpressRoute"), - // ServiceFamily: to.Ptr("Compute"), - // UnitOfMeasure: to.Ptr("GB"), - // }, - // MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // OfferID: to.Ptr("Offer Id 1"), - // PartNumber: to.Ptr("Part Number 1"), - // Product: to.Ptr("Product Name 1"), - // Quantity: to.Ptr[float64](0.8234), - // ResourceGroup: to.Ptr("Resource Group 1"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 1/providers/Microsoft.Storage/storageAccounts/Resource Name 1"), - // ResourceLocation: to.Ptr("USEast"), - // ResourceName: to.Ptr("Resource Name 1"), - // SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // SubscriptionName: to.Ptr("Subscription Name 1"), - // UnitPrice: to.Ptr[float64](3.54), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/UsageDetailsList.json -func ExampleUsageDetailsClient_NewListPager_usageDetailsListLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewUsageDetailsClient().NewListPager("subscriptions/00000000-0000-0000-0000-000000000000", &armconsumption.UsageDetailsClientListOptions{Expand: nil, - Filter: nil, - Skiptoken: nil, - Top: nil, - Metric: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.UsageDetailsListResult = armconsumption.UsageDetailsListResult{ - // Value: []armconsumption.UsageDetailClassification{ - // &armconsumption.LegacyUsageDetail{ - // Name: to.Ptr("usageDetails_Id1"), - // Type: to.Ptr("Microsoft.Consumption/usageDetails"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Billing/billingPeriods/201903/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1"), - // Tags: map[string]*string{ - // "dev": to.Ptr("tools"), - // "env": to.Ptr("newcrp"), - // }, - // Kind: to.Ptr(armconsumption.UsageDetailsKindLegacy), - // Properties: &armconsumption.LegacyUsageDetailProperties{ - // AccountName: to.Ptr("AccountName"), - // BenefitID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // BenefitName: to.Ptr("Reservation_purchase_03-09-2018_10-59"), - // BillingAccountID: to.Ptr("xxxxxxxx"), - // BillingAccountName: to.Ptr("Customer Name 1"), - // BillingCurrency: to.Ptr("CAD"), - // BillingPeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-30T00:00:00.000Z"); return t}()), - // BillingPeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-01T00:00:00.000Z"); return t}()), - // BillingProfileID: to.Ptr("xxxxxxxx"), - // BillingProfileName: to.Ptr("Customer Name 1"), - // ChargeType: to.Ptr("Usage"), - // ConsumedService: to.Ptr("Microsoft.ClassicStorage"), - // Cost: to.Ptr[float64](0.000001980949998), - // CostCenter: to.Ptr("BAS"), - // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-09T00:00:00.000Z"); return t}()), - // EffectivePrice: to.Ptr[float64](0.054693034210767), - // Frequency: to.Ptr("UsageBased"), - // InvoiceSection: to.Ptr("Invoice Section 1"), - // IsAzureCreditEligible: to.Ptr(false), - // MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // OfferID: to.Ptr("Offer Id 1"), - // PartNumber: to.Ptr("Part Number 1"), - // Product: to.Ptr("Product1"), - // Quantity: to.Ptr[float64](0.000036), - // ResourceGroup: to.Ptr("Resource-Group-westus"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource-Group-westus/providers/Microsoft.ClassicStorage/storageAccounts/ResourceName1"), - // ResourceLocation: to.Ptr("uswest"), - // ResourceName: to.Ptr("ResourceName1"), - // SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // SubscriptionName: to.Ptr("SubscriptionName 1"), - // UnitPrice: to.Ptr[float64](5.47), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/UsageDetailsListByMetricActualCost.json -func ExampleUsageDetailsClient_NewListPager_usageDetailsListByMetricActualCostLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewUsageDetailsClient().NewListPager("subscriptions/00000000-0000-0000-0000-000000000000", &armconsumption.UsageDetailsClientListOptions{Expand: nil, - Filter: nil, - Skiptoken: nil, - Top: nil, - Metric: to.Ptr(armconsumption.MetrictypeActualCostMetricType), - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.UsageDetailsListResult = armconsumption.UsageDetailsListResult{ - // Value: []armconsumption.UsageDetailClassification{ - // &armconsumption.LegacyUsageDetail{ - // Name: to.Ptr("usageDetails_Id1"), - // Type: to.Ptr("Microsoft.Consumption/usageDetails"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Billing/billingPeriods/201903/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1"), - // Tags: map[string]*string{ - // "dev": to.Ptr("tools"), - // "env": to.Ptr("newcrp"), - // }, - // Kind: to.Ptr(armconsumption.UsageDetailsKindLegacy), - // Properties: &armconsumption.LegacyUsageDetailProperties{ - // AccountName: to.Ptr("AccountName"), - // BenefitID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // BenefitName: to.Ptr("Reservation_purchase_03-09-2018_10-59"), - // BillingAccountID: to.Ptr("xxxxxxxx"), - // BillingAccountName: to.Ptr("Customer Name 1"), - // BillingCurrency: to.Ptr("CAD"), - // BillingPeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-30T00:00:00.000Z"); return t}()), - // BillingPeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-01T00:00:00.000Z"); return t}()), - // BillingProfileID: to.Ptr("xxxxxxxx"), - // BillingProfileName: to.Ptr("Customer Name 1"), - // ChargeType: to.Ptr("Usage"), - // ConsumedService: to.Ptr("Microsoft.ClassicStorage"), - // Cost: to.Ptr[float64](0.000001968949998), - // CostCenter: to.Ptr("BAS"), - // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-09T00:00:00.000Z"); return t}()), - // EffectivePrice: to.Ptr[float64](0.054693055510767), - // InvoiceSection: to.Ptr("Invoice Section 1"), - // IsAzureCreditEligible: to.Ptr(false), - // MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // OfferID: to.Ptr("Offer Id 1"), - // PartNumber: to.Ptr("Part Number 1"), - // Product: to.Ptr("Product1"), - // Quantity: to.Ptr[float64](0.000036), - // ResourceGroup: to.Ptr("Resource-Group-westus"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource-Group-westus/providers/Microsoft.ClassicStorage/storageAccounts/ResourceName1"), - // ResourceLocation: to.Ptr("uswest"), - // ResourceName: to.Ptr("ResourceName1"), - // SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // SubscriptionName: to.Ptr("SubscriptionName 1"), - // UnitPrice: to.Ptr[float64](5.47), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/UsageDetailsListByMetricAmortizedCost.json -func ExampleUsageDetailsClient_NewListPager_usageDetailsListByMetricAmortizedCostLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewUsageDetailsClient().NewListPager("subscriptions/00000000-0000-0000-0000-000000000000", &armconsumption.UsageDetailsClientListOptions{Expand: nil, - Filter: nil, - Skiptoken: nil, - Top: nil, - Metric: to.Ptr(armconsumption.MetrictypeAmortizedCostMetricType), - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.UsageDetailsListResult = armconsumption.UsageDetailsListResult{ - // Value: []armconsumption.UsageDetailClassification{ - // &armconsumption.LegacyUsageDetail{ - // Name: to.Ptr("usageDetails_Id1"), - // Type: to.Ptr("Microsoft.Consumption/usageDetails"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Billing/billingPeriods/201903/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1"), - // Tags: map[string]*string{ - // "dev": to.Ptr("tools"), - // "env": to.Ptr("newcrp"), - // }, - // Kind: to.Ptr(armconsumption.UsageDetailsKindLegacy), - // Properties: &armconsumption.LegacyUsageDetailProperties{ - // AccountName: to.Ptr("AccountName"), - // BenefitID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // BenefitName: to.Ptr("Reservation_purchase_03-09-2018_10-59"), - // BillingAccountID: to.Ptr("xxxxxxxx"), - // BillingAccountName: to.Ptr("Customer Name 1"), - // BillingCurrency: to.Ptr("CAD"), - // BillingPeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-30T00:00:00.000Z"); return t}()), - // BillingPeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-01T00:00:00.000Z"); return t}()), - // BillingProfileID: to.Ptr("xxxxxxxx"), - // BillingProfileName: to.Ptr("Customer Name 1"), - // ChargeType: to.Ptr("Usage"), - // ConsumedService: to.Ptr("Microsoft.ClassicStorage"), - // Cost: to.Ptr[float64](0.000001968949998), - // CostCenter: to.Ptr("BAS"), - // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-09T00:00:00.000Z"); return t}()), - // EffectivePrice: to.Ptr[float64](0.054693055510767), - // Frequency: to.Ptr("UsageBased"), - // InvoiceSection: to.Ptr("Invoice Section 1"), - // IsAzureCreditEligible: to.Ptr(false), - // MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // OfferID: to.Ptr("Offer Id 1"), - // PartNumber: to.Ptr("Part Number 1"), - // Product: to.Ptr("Product1"), - // Quantity: to.Ptr[float64](0.000036), - // ResourceGroup: to.Ptr("Resource-Group-westus"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource-Group-westus/providers/Microsoft.ClassicStorage/storageAccounts/ResourceName1"), - // ResourceLocation: to.Ptr("uswest"), - // ResourceName: to.Ptr("ResourceName1"), - // SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // SubscriptionName: to.Ptr("SubscriptionName 1"), - // UnitPrice: to.Ptr[float64](5.47), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/UsageDetailsListByMetricUsage.json -func ExampleUsageDetailsClient_NewListPager_usageDetailsListByMetricUsageLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewUsageDetailsClient().NewListPager("subscriptions/00000000-0000-0000-0000-000000000000", &armconsumption.UsageDetailsClientListOptions{Expand: nil, - Filter: nil, - Skiptoken: nil, - Top: nil, - Metric: to.Ptr(armconsumption.MetrictypeUsageMetricType), - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.UsageDetailsListResult = armconsumption.UsageDetailsListResult{ - // Value: []armconsumption.UsageDetailClassification{ - // &armconsumption.LegacyUsageDetail{ - // Name: to.Ptr("usageDetails_Id1"), - // Type: to.Ptr("Microsoft.Consumption/usageDetails"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Billing/billingPeriods/201903/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1"), - // Tags: map[string]*string{ - // "dev": to.Ptr("tools"), - // "env": to.Ptr("newcrp"), - // }, - // Kind: to.Ptr(armconsumption.UsageDetailsKindLegacy), - // Properties: &armconsumption.LegacyUsageDetailProperties{ - // AccountName: to.Ptr("AccountName"), - // BenefitID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // BenefitName: to.Ptr("Reservation_purchase_03-09-2018_10-59"), - // BillingAccountID: to.Ptr("xxxxxxxx"), - // BillingAccountName: to.Ptr("Customer Name 1"), - // BillingCurrency: to.Ptr("CAD"), - // BillingPeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-30T00:00:00.000Z"); return t}()), - // BillingPeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-01T00:00:00.000Z"); return t}()), - // BillingProfileID: to.Ptr("xxxxxxxx"), - // BillingProfileName: to.Ptr("Customer Name 1"), - // ChargeType: to.Ptr("Usage"), - // ConsumedService: to.Ptr("Microsoft.ClassicStorage"), - // Cost: to.Ptr[float64](0.000001968949998), - // CostCenter: to.Ptr("BAS"), - // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-04-09T00:00:00.000Z"); return t}()), - // EffectivePrice: to.Ptr[float64](0.054693055510767), - // InvoiceSection: to.Ptr("Invoice Section 1"), - // IsAzureCreditEligible: to.Ptr(false), - // MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // OfferID: to.Ptr("Offer Id 1"), - // PartNumber: to.Ptr("Part Number 1"), - // Product: to.Ptr("Product1"), - // Quantity: to.Ptr[float64](0.000036), - // ResourceGroup: to.Ptr("Resource-Group-westus"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource-Group-westus/providers/Microsoft.ClassicStorage/storageAccounts/ResourceName1"), - // ResourceLocation: to.Ptr("uswest"), - // ResourceName: to.Ptr("ResourceName1"), - // SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // SubscriptionName: to.Ptr("SubscriptionName 1"), - // UnitPrice: to.Ptr[float64](5.47), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/UsageDetailsListFilterByTag.json -func ExampleUsageDetailsClient_NewListPager_usageDetailsListFilterByTagLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewUsageDetailsClient().NewListPager("subscriptions/00000000-0000-0000-0000-000000000000", &armconsumption.UsageDetailsClientListOptions{Expand: nil, - Filter: to.Ptr("tags eq 'dev:tools'"), - Skiptoken: nil, - Top: nil, - Metric: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.UsageDetailsListResult = armconsumption.UsageDetailsListResult{ - // Value: []armconsumption.UsageDetailClassification{ - // &armconsumption.LegacyUsageDetail{ - // Name: to.Ptr("usageDetails_Id1"), - // Type: to.Ptr("Microsoft.Consumption/usageDetails"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Billing/billingPeriods/201903/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1"), - // Tags: map[string]*string{ - // "dev": to.Ptr("tools"), - // }, - // Kind: to.Ptr(armconsumption.UsageDetailsKindLegacy), - // Properties: &armconsumption.LegacyUsageDetailProperties{ - // AccountName: to.Ptr("Account Name 1"), - // BenefitID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // BenefitName: to.Ptr("Reservation_purchase_03-09-2018_10-59"), - // BillingAccountID: to.Ptr("xxxxxxxx"), - // BillingAccountName: to.Ptr("Account Name 1"), - // BillingCurrency: to.Ptr("CAD"), - // BillingPeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-31T00:00:00.000Z"); return t}()), - // BillingPeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T00:00:00.000Z"); return t}()), - // BillingProfileID: to.Ptr("xxxxxxxx"), - // BillingProfileName: to.Ptr("Account Name 1"), - // ChargeType: to.Ptr("Usage"), - // ConsumedService: to.Ptr("Microsoft.Storage"), - // Cost: to.Ptr[float64](0.000342194841184), - // CostCenter: to.Ptr("DEV"), - // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-30T00:00:00.000Z"); return t}()), - // EffectivePrice: to.Ptr[float64](0.010534556373432), - // InvoiceSection: to.Ptr("Invoice Section 1"), - // IsAzureCreditEligible: to.Ptr(false), - // MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // OfferID: to.Ptr("Offer Id 1"), - // PartNumber: to.Ptr("Part Number 1"), - // Product: to.Ptr("Product Name 1"), - // Quantity: to.Ptr[float64](0.8234), - // ResourceGroup: to.Ptr("Resource Group 1"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 1/providers/Microsoft.Storage/storageAccounts/Resource Name 1"), - // ResourceLocation: to.Ptr("USEast"), - // ResourceName: to.Ptr("Resource Name 1"), - // SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // SubscriptionName: to.Ptr("Subscription Name 1"), - // UnitPrice: to.Ptr[float64](3.74), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/UsageDetailsListForBillingPeriod.json -func ExampleUsageDetailsClient_NewListPager_usageDetailsListForBillingPeriodLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armconsumption.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewUsageDetailsClient().NewListPager("subscriptions/00000000-0000-0000-0000-000000000000", &armconsumption.UsageDetailsClientListOptions{Expand: nil, - Filter: nil, - Skiptoken: nil, - Top: nil, - Metric: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.UsageDetailsListResult = armconsumption.UsageDetailsListResult{ - // Value: []armconsumption.UsageDetailClassification{ - // &armconsumption.LegacyUsageDetail{ - // Name: to.Ptr("usageDetails_Id1"), - // Type: to.Ptr("Microsoft.Consumption/usageDetails"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Billing/billingPeriods/201903/providers/Microsoft.Consumption/usageDetails/usageDetails_Id1"), - // Tags: map[string]*string{ - // "dev": to.Ptr("tools"), - // "env": to.Ptr("newcrp"), - // }, - // Kind: to.Ptr(armconsumption.UsageDetailsKindLegacy), - // Properties: &armconsumption.LegacyUsageDetailProperties{ - // AccountName: to.Ptr("Account Name 1"), - // BenefitID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // BenefitName: to.Ptr("Reservation_purchase_03-09-2018_10-59"), - // BillingAccountID: to.Ptr("xxxxxxxx"), - // BillingAccountName: to.Ptr("Account Name 1"), - // BillingCurrency: to.Ptr("CAD"), - // BillingPeriodEndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-31T00:00:00.000Z"); return t}()), - // BillingPeriodStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-01T00:00:00.000Z"); return t}()), - // BillingProfileID: to.Ptr("xxxxxxxx"), - // BillingProfileName: to.Ptr("Account Name 1"), - // ChargeType: to.Ptr("Usage"), - // ConsumedService: to.Ptr("Microsoft.Storage"), - // Cost: to.Ptr[float64](0.000342194841184), - // CostCenter: to.Ptr("DEV"), - // Date: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-03-30T00:00:00.000Z"); return t}()), - // EffectivePrice: to.Ptr[float64](0.010534556373432), - // InvoiceSection: to.Ptr("Invoice Section 1"), - // IsAzureCreditEligible: to.Ptr(false), - // MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // OfferID: to.Ptr("Offer Id 1"), - // PartNumber: to.Ptr("Part Number 1"), - // Product: to.Ptr("Product Name 1"), - // Quantity: to.Ptr[float64](0.8234), - // ResourceGroup: to.Ptr("Resource Group 1"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/Resource Group 1/providers/Microsoft.Storage/storageAccounts/Resource Name 1"), - // ResourceLocation: to.Ptr("USEast"), - // ResourceName: to.Ptr("Resource Name 1"), - // SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"), - // SubscriptionName: to.Ptr("Subscription Name 1"), - // UnitPrice: to.Ptr[float64](3.74), - // }, - // }}, - // } - } -}