diff --git a/sdk/resourcemanager/consumption/armconsumption/CHANGELOG.md b/sdk/resourcemanager/consumption/armconsumption/CHANGELOG.md index 259b594fb26c..72b852391fa9 100644 --- a/sdk/resourcemanager/consumption/armconsumption/CHANGELOG.md +++ b/sdk/resourcemanager/consumption/armconsumption/CHANGELOG.md @@ -1,5 +1,41 @@ # Release History +## 2.0.0 (2024-05-07) +### 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 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`, `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 70c2d3eaf4a1..2ce5f65c0851 100644 --- a/sdk/resourcemanager/consumption/armconsumption/README.md +++ b/sdk/resourcemanager/consumption/armconsumption/README.md @@ -1,6 +1,6 @@ # Azure Consumption Module for Go -[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption) +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2) The `armconsumption` module provides operations for working with Azure Consumption. @@ -20,7 +20,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..61b2a5aa6c37 100644 --- a/sdk/resourcemanager/consumption/armconsumption/aggregatedcost_client.go +++ b/sdk/resourcemanager/consumption/armconsumption/aggregatedcost_client.go @@ -44,7 +44,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 2023-11-01 // - managementGroupID - Azure Management Group ID. // - options - AggregatedCostClientGetByManagementGroupOptions contains the optional parameters for the AggregatedCostClient.GetByManagementGroup // method. @@ -82,10 +82,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", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -104,7 +104,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 2023-11-01 // - managementGroupID - Azure Management Group ID. // - billingPeriodName - Billing Period Name. // - options - AggregatedCostClientGetForBillingPeriodByManagementGroupOptions contains the optional parameters for the AggregatedCostClient.GetForBillingPeriodByManagementGroup @@ -147,7 +147,7 @@ func (client *AggregatedCostClient) getForBillingPeriodByManagementGroupCreateRe return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-10-01") + reqQP.Set("api-version", "2023-11-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..2c3ce6d085b8 100644 --- a/sdk/resourcemanager/consumption/armconsumption/balances_client.go +++ b/sdk/resourcemanager/consumption/armconsumption/balances_client.go @@ -44,7 +44,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 2023-11-01 // - billingAccountID - BillingAccount ID // - options - BalancesClientGetByBillingAccountOptions contains the optional parameters for the BalancesClient.GetByBillingAccount // method. @@ -82,7 +82,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", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -101,7 +101,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 2023-11-01 // - billingAccountID - BillingAccount ID // - billingPeriodName - Billing Period Name. // - options - BalancesClientGetForBillingPeriodByBillingAccountOptions contains the optional parameters for the BalancesClient.GetForBillingPeriodByBillingAccount @@ -144,7 +144,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", "2023-11-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..187e69898080 100644 --- a/sdk/resourcemanager/consumption/armconsumption/budgets_client.go +++ b/sdk/resourcemanager/consumption/armconsumption/budgets_client.go @@ -45,7 +45,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 2023-11-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 +53,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. @@ -93,7 +93,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", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -114,7 +114,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 2023-11-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 +122,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. @@ -160,7 +160,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", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -169,7 +169,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 2023-11-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 +177,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. @@ -216,7 +216,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", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -233,7 +233,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 2023-11-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 +241,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] { @@ -276,7 +276,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", "2023-11-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..f25671b2167b 100644 --- a/sdk/resourcemanager/consumption/armconsumption/charges_client.go +++ b/sdk/resourcemanager/consumption/armconsumption/charges_client.go @@ -41,7 +41,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 2023-11-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 +52,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 +87,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", "2023-11-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..98b584ec873d 100644 --- a/sdk/resourcemanager/consumption/armconsumption/client_factory.go +++ b/sdk/resourcemanager/consumption/armconsumption/client_factory.go @@ -17,8 +17,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 +26,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..0c66ceee868b 100644 --- a/sdk/resourcemanager/consumption/armconsumption/constants.go +++ b/sdk/resourcemanager/consumption/armconsumption/constants.go @@ -10,7 +10,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 +150,7 @@ func PossibleDatagrainValues() []Datagrain { type EventType string const ( + EventTypeCreditExpired EventType = "CreditExpired" EventTypeNewCredit EventType = "NewCredit" EventTypePendingAdjustments EventType = "PendingAdjustments" EventTypePendingCharges EventType = "PendingCharges" @@ -162,6 +163,7 @@ const ( // PossibleEventTypeValues returns the possible values for the EventType const type. func PossibleEventTypeValues() []EventType { return []EventType{ + EventTypeCreditExpired, EventTypeNewCredit, EventTypePendingAdjustments, EventTypePendingCharges, @@ -230,12 +232,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 +275,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 @@ -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..2e409baf49c1 100644 --- a/sdk/resourcemanager/consumption/armconsumption/credits_client.go +++ b/sdk/resourcemanager/consumption/armconsumption/credits_client.go @@ -43,7 +43,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 2023-11-01 // - billingAccountID - BillingAccount ID // - billingProfileID - Azure Billing Profile ID. // - options - CreditsClientGetOptions contains the optional parameters for the CreditsClient.Get method. @@ -85,7 +85,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", "2023-11-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..f085a5d26f5e 100644 --- a/sdk/resourcemanager/consumption/armconsumption/events_client.go +++ b/sdk/resourcemanager/consumption/armconsumption/events_client.go @@ -43,7 +43,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 2023-11-01 // - billingAccountID - BillingAccount ID // - options - EventsClientListByBillingAccountOptions contains the optional parameters for the EventsClient.NewListByBillingAccountPager // method. @@ -82,10 +82,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", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -103,7 +103,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 2023-11-01 // - billingAccountID - BillingAccount ID // - billingProfileID - Azure Billing Profile ID. // - startDate - Start date @@ -149,9 +149,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", "2023-11-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..3b98f639676d 100644 --- a/sdk/resourcemanager/consumption/armconsumption/fake/aggregatedcost_server.go +++ b/sdk/resourcemanager/consumption/armconsumption/fake/aggregatedcost_server.go @@ -15,7 +15,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" diff --git a/sdk/resourcemanager/consumption/armconsumption/fake/balances_server.go b/sdk/resourcemanager/consumption/armconsumption/fake/balances_server.go index 178dc3c19cc6..87ec31fc29ed 100644 --- a/sdk/resourcemanager/consumption/armconsumption/fake/balances_server.go +++ b/sdk/resourcemanager/consumption/armconsumption/fake/balances_server.go @@ -15,7 +15,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" diff --git a/sdk/resourcemanager/consumption/armconsumption/fake/budgets_server.go b/sdk/resourcemanager/consumption/armconsumption/fake/budgets_server.go index 5fc66ef4f274..0490ec2358e6 100644 --- a/sdk/resourcemanager/consumption/armconsumption/fake/budgets_server.go +++ b/sdk/resourcemanager/consumption/armconsumption/fake/budgets_server.go @@ -16,7 +16,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" diff --git a/sdk/resourcemanager/consumption/armconsumption/fake/charges_server.go b/sdk/resourcemanager/consumption/armconsumption/fake/charges_server.go index b5b8f5a98021..46dfa0edc006 100644 --- a/sdk/resourcemanager/consumption/armconsumption/fake/charges_server.go +++ b/sdk/resourcemanager/consumption/armconsumption/fake/charges_server.go @@ -15,7 +15,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" diff --git a/sdk/resourcemanager/consumption/armconsumption/fake/credits_server.go b/sdk/resourcemanager/consumption/armconsumption/fake/credits_server.go index b7236a1f0536..9257adfefddf 100644 --- a/sdk/resourcemanager/consumption/armconsumption/fake/credits_server.go +++ b/sdk/resourcemanager/consumption/armconsumption/fake/credits_server.go @@ -15,7 +15,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" diff --git a/sdk/resourcemanager/consumption/armconsumption/fake/events_server.go b/sdk/resourcemanager/consumption/armconsumption/fake/events_server.go index 51d00305c1a5..d648e5403eb3 100644 --- a/sdk/resourcemanager/consumption/armconsumption/fake/events_server.go +++ b/sdk/resourcemanager/consumption/armconsumption/fake/events_server.go @@ -15,7 +15,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" diff --git a/sdk/resourcemanager/consumption/armconsumption/fake/lots_server.go b/sdk/resourcemanager/consumption/armconsumption/fake/lots_server.go index d023ac534e84..12c2aa2467ea 100644 --- a/sdk/resourcemanager/consumption/armconsumption/fake/lots_server.go +++ b/sdk/resourcemanager/consumption/armconsumption/fake/lots_server.go @@ -15,7 +15,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" diff --git a/sdk/resourcemanager/consumption/armconsumption/fake/marketplaces_server.go b/sdk/resourcemanager/consumption/armconsumption/fake/marketplaces_server.go index 9cb655048a06..7b3682fd027c 100644 --- a/sdk/resourcemanager/consumption/armconsumption/fake/marketplaces_server.go +++ b/sdk/resourcemanager/consumption/armconsumption/fake/marketplaces_server.go @@ -15,7 +15,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 +25,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]) } @@ -131,9 +131,9 @@ 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) diff --git a/sdk/resourcemanager/consumption/armconsumption/fake/operations_server.go b/sdk/resourcemanager/consumption/armconsumption/fake/operations_server.go index 14ebf240ffb8..feeb509b4bfa 100644 --- a/sdk/resourcemanager/consumption/armconsumption/fake/operations_server.go +++ b/sdk/resourcemanager/consumption/armconsumption/fake/operations_server.go @@ -15,7 +15,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" ) diff --git a/sdk/resourcemanager/consumption/armconsumption/fake/pricesheet_server.go b/sdk/resourcemanager/consumption/armconsumption/fake/pricesheet_server.go index e7aa4eef3132..c98db8ab2565 100644 --- a/sdk/resourcemanager/consumption/armconsumption/fake/pricesheet_server.go +++ b/sdk/resourcemanager/consumption/armconsumption/fake/pricesheet_server.go @@ -15,7 +15,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 +24,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 +41,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. @@ -58,6 +66,8 @@ func (p *PriceSheetServerTransport) Do(req *http.Request) (*http.Response, error var err error switch method { + case "PriceSheetClient.BeginDownloadByBillingAccountPeriod": + resp, err = p.dispatchBeginDownloadByBillingAccountPeriod(req) case "PriceSheetClient.Get": resp, err = p.dispatchGet(req) case "PriceSheetClient.GetByBillingPeriod": @@ -73,6 +83,50 @@ func (p *PriceSheetServerTransport) Do(req *http.Request) (*http.Response, error return resp, nil } +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 +} + func (p *PriceSheetServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { if p.srv.Get == nil { return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} diff --git a/sdk/resourcemanager/consumption/armconsumption/fake/reservationrecommendationdetails_server.go b/sdk/resourcemanager/consumption/armconsumption/fake/reservationrecommendationdetails_server.go index cca46e72a905..83a01d77ca2a 100644 --- a/sdk/resourcemanager/consumption/armconsumption/fake/reservationrecommendationdetails_server.go +++ b/sdk/resourcemanager/consumption/armconsumption/fake/reservationrecommendationdetails_server.go @@ -15,7 +15,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" @@ -119,7 +119,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 } diff --git a/sdk/resourcemanager/consumption/armconsumption/fake/reservationrecommendations_server.go b/sdk/resourcemanager/consumption/armconsumption/fake/reservationrecommendations_server.go index 58752173fff4..13bb0a7a9e71 100644 --- a/sdk/resourcemanager/consumption/armconsumption/fake/reservationrecommendations_server.go +++ b/sdk/resourcemanager/consumption/armconsumption/fake/reservationrecommendations_server.go @@ -15,7 +15,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" diff --git a/sdk/resourcemanager/consumption/armconsumption/fake/reservationsdetails_server.go b/sdk/resourcemanager/consumption/armconsumption/fake/reservationsdetails_server.go index aee85767826f..723ce4c0c1ff 100644 --- a/sdk/resourcemanager/consumption/armconsumption/fake/reservationsdetails_server.go +++ b/sdk/resourcemanager/consumption/armconsumption/fake/reservationsdetails_server.go @@ -15,7 +15,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" diff --git a/sdk/resourcemanager/consumption/armconsumption/fake/reservationssummaries_server.go b/sdk/resourcemanager/consumption/armconsumption/fake/reservationssummaries_server.go index b88d806fbf3d..ff70b824db7b 100644 --- a/sdk/resourcemanager/consumption/armconsumption/fake/reservationssummaries_server.go +++ b/sdk/resourcemanager/consumption/armconsumption/fake/reservationssummaries_server.go @@ -15,7 +15,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" diff --git a/sdk/resourcemanager/consumption/armconsumption/fake/reservationtransactions_server.go b/sdk/resourcemanager/consumption/armconsumption/fake/reservationtransactions_server.go index 6ac68f2b9977..d792a1617731 100644 --- a/sdk/resourcemanager/consumption/armconsumption/fake/reservationtransactions_server.go +++ b/sdk/resourcemanager/consumption/armconsumption/fake/reservationtransactions_server.go @@ -15,10 +15,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. @@ -96,14 +97,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) diff --git a/sdk/resourcemanager/consumption/armconsumption/fake/tags_server.go b/sdk/resourcemanager/consumption/armconsumption/fake/tags_server.go index f30ca1a2a7e1..6483d54e38fb 100644 --- a/sdk/resourcemanager/consumption/armconsumption/fake/tags_server.go +++ b/sdk/resourcemanager/consumption/armconsumption/fake/tags_server.go @@ -15,7 +15,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" diff --git a/sdk/resourcemanager/consumption/armconsumption/fake/time_rfc3339.go b/sdk/resourcemanager/consumption/armconsumption/fake/time_rfc3339.go index b0535a7b63e6..81f308b0d343 100644 --- a/sdk/resourcemanager/consumption/armconsumption/fake/time_rfc3339.go +++ b/sdk/resourcemanager/consumption/armconsumption/fake/time_rfc3339.go @@ -19,12 +19,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 +44,33 @@ 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) { + 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/fake/usagedetails_server.go b/sdk/resourcemanager/consumption/armconsumption/fake/usagedetails_server.go index fd4b49758831..c66a9d0f80ef 100644 --- a/sdk/resourcemanager/consumption/armconsumption/fake/usagedetails_server.go +++ b/sdk/resourcemanager/consumption/armconsumption/fake/usagedetails_server.go @@ -15,7 +15,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" diff --git a/sdk/resourcemanager/consumption/armconsumption/go.mod b/sdk/resourcemanager/consumption/armconsumption/go.mod index bc1cf33b2a35..dd1c25686351 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.18 -require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.11.1 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.5.2 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.11.1 require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.7.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect - github.com/golang-jwt/jwt/v5 v5.2.1 // 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.22.0 // indirect golang.org/x/net v0.24.0 // indirect - golang.org/x/sys v0.19.0 // indirect golang.org/x/text v0.14.0 // indirect ) diff --git a/sdk/resourcemanager/consumption/armconsumption/go.sum b/sdk/resourcemanager/consumption/armconsumption/go.sum index 453385ef9f88..ffdff03203f8 100644 --- a/sdk/resourcemanager/consumption/armconsumption/go.sum +++ b/sdk/resourcemanager/consumption/armconsumption/go.sum @@ -1,29 +1,12 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.11.1 h1:E+OJmp2tPvt1W+amx48v1eqbjDYsgN+RzP4q16yV5eM= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.11.1/go.mod h1:a6xsAQUZg+VsS3TJ05SRp524Hs4pZ/AeFSr5ENf0Yjo= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.5.2 h1:FDif4R1+UUR+00q6wquyX90K7A8dN+R5E8GEadoP7sU= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.5.2/go.mod h1:aiYBYui4BJ/BJCAIKs92XiPyQfTaBWqvHujDwKb6CBU= github.com/Azure/azure-sdk-for-go/sdk/internal v1.7.0 h1:rTfKOCZGy5ViVrlA74ZPE99a+SgoEE2K/yg3RyW9dFA= github.com/Azure/azure-sdk-for-go/sdk/internal v1.7.0/go.mod h1:4OG6tQ9EOP/MT0NMjDlRzWoVFxfu9rN9B2X+tlSVktg= -github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 h1:XHOnouVk1mxXfQidrMEnLlPk9UMeRtyBTnEFtxkV0kU= -github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= -github.com/golang-jwt/jwt/v5 v5.2.1/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/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/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= -golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= -golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= 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..91537339b3e7 100644 --- a/sdk/resourcemanager/consumption/armconsumption/interfaces.go +++ b/sdk/resourcemanager/consumption/armconsumption/interfaces.go @@ -26,6 +26,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..d8577f306845 100644 --- a/sdk/resourcemanager/consumption/armconsumption/lots_client.go +++ b/sdk/resourcemanager/consumption/armconsumption/lots_client.go @@ -43,7 +43,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 2023-11-01 // - billingAccountID - BillingAccount ID // - options - LotsClientListByBillingAccountOptions contains the optional parameters for the LotsClient.NewListByBillingAccountPager // method. @@ -82,10 +82,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", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -103,7 +103,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 2023-11-01 // - billingAccountID - BillingAccount ID // - billingProfileID - Azure Billing Profile ID. // - options - LotsClientListByBillingProfileOptions contains the optional parameters for the LotsClient.NewListByBillingProfilePager @@ -147,7 +147,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", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -165,7 +165,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 2023-11-01 // - billingAccountID - BillingAccount ID // - customerID - Customer ID // - options - LotsClientListByCustomerOptions contains the optional parameters for the LotsClient.NewListByCustomerPager method. @@ -208,10 +208,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", "2023-11-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..ba466e2f0873 100644 --- a/sdk/resourcemanager/consumption/armconsumption/marketplaces_client.go +++ b/sdk/resourcemanager/consumption/armconsumption/marketplaces_client.go @@ -42,7 +42,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 2023-11-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 +88,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", "2023-11-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..4918ba15f47e 100644 --- a/sdk/resourcemanager/consumption/armconsumption/models.go +++ b/sdk/resourcemanager/consumption/armconsumption/models.go @@ -87,6 +87,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 +265,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 +299,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 +347,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 +365,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 @@ -379,10 +391,12 @@ type EventProperties struct { // 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 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 credit currency of the event. @@ -404,6 +418,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 +538,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 +550,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 +618,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 @@ -630,6 +650,9 @@ type LegacyReservationRecommendationProperties struct { // 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 +717,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 +771,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 @@ -777,6 +803,9 @@ type LegacySharedScopeReservationRecommendationProperties struct { // 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 +816,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 +828,7 @@ func (l *LegacySharedScopeReservationRecommendationProperties) GetLegacyReservat Scope: l.Scope, Term: l.Term, TotalCostWithReservedInstances: l.TotalCostWithReservedInstances, + TotalHours: l.TotalHours, } } @@ -819,6 +850,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 @@ -851,6 +885,9 @@ type LegacySingleScopeReservationRecommendationProperties struct { // 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 +898,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 +910,7 @@ func (l *LegacySingleScopeReservationRecommendationProperties) GetLegacyReservat Scope: l.Scope, Term: l.Term, TotalCostWithReservedInstances: l.TotalCostWithReservedInstances, + TotalHours: l.TotalHours, } } @@ -1080,10 +1119,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 +1151,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 +1460,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 +1476,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 +1516,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 +1531,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 +1555,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. 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 +1624,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 +1672,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; RI recommendations in one or three year terms. + 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; RI recommendations in one or three year terms. + 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 +2191,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 +2235,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 +2266,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 +2403,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 +2481,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 +2490,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. @@ -2448,6 +2715,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..b443afccc1c2 100644 --- a/sdk/resourcemanager/consumption/armconsumption/models_serde.go +++ b/sdk/resourcemanager/consumption/armconsumption/models_serde.go @@ -145,6 +145,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 +193,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 +650,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 +667,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 +679,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 +698,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 +729,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,6 +874,8 @@ 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) @@ -885,6 +891,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 +916,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) @@ -954,6 +967,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 +1210,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 +1231,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 +1243,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 +1323,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 +1335,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 +1360,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 +1396,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 +1572,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 +1584,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 +1609,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 +1645,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 +1663,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 +1676,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 +1701,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 +1740,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 +2018,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 +2028,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 +2059,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 +2089,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 +2650,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 +2692,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 +2749,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 +2775,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 +2783,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 +2814,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 +2838,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 +2856,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 +3044,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 +3768,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 +3844,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 +3880,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 +3944,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 +4949,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 +5182,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..5203a8e8c11b 100644 --- a/sdk/resourcemanager/consumption/armconsumption/operations_client.go +++ b/sdk/resourcemanager/consumption/armconsumption/operations_client.go @@ -39,7 +39,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 2023-11-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]{ @@ -72,7 +72,7 @@ func (client *OperationsClient) listCreateRequest(ctx context.Context, options * return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-10-01") + reqQP.Set("api-version", "2023-11-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..928141086900 100644 --- a/sdk/resourcemanager/consumption/armconsumption/options.go +++ b/sdk/resourcemanager/consumption/armconsumption/options.go @@ -137,6 +137,13 @@ type OperationsClientListOptions struct { // placeholder for future optional parameters } +// PriceSheetClientBeginDownloadByBillingAccountPeriodOptions contains the optional parameters for the PriceSheetClient.BeginDownloadByBillingAccountPeriod +// method. +type PriceSheetClientBeginDownloadByBillingAccountPeriodOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + // PriceSheetClientGetByBillingPeriodOptions contains the optional parameters for the PriceSheetClient.GetByBillingPeriod // method. type PriceSheetClientGetByBillingPeriodOptions struct { @@ -171,7 +178,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 +200,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 +211,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..0b250ea337a2 100644 --- a/sdk/resourcemanager/consumption/armconsumption/polymorphic_helpers.go +++ b/sdk/resourcemanager/consumption/armconsumption/polymorphic_helpers.go @@ -11,7 +11,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 +34,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 +53,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 +75,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 +122,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 +141,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 +164,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..a5d3a8281cda 100644 --- a/sdk/resourcemanager/consumption/armconsumption/pricesheet_client.go +++ b/sdk/resourcemanager/consumption/armconsumption/pricesheet_client.go @@ -44,10 +44,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 2023-11-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 2023-11-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, options *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", "2023-11-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 2023-11-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 +167,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", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -111,7 +186,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 2023-11-01 // - billingPeriodName - Billing Period Name. // - options - PriceSheetClientGetByBillingPeriodOptions contains the optional parameters for the PriceSheetClient.GetByBillingPeriod // method. @@ -162,7 +237,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", "2023-11-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..3067606c87e1 100644 --- a/sdk/resourcemanager/consumption/armconsumption/reservationrecommendationdetails_client.go +++ b/sdk/resourcemanager/consumption/armconsumption/reservationrecommendationdetails_client.go @@ -41,7 +41,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 2023-11-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 +87,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", "2023-11-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..cebb7cfdac97 100644 --- a/sdk/resourcemanager/consumption/armconsumption/reservationrecommendations_client.go +++ b/sdk/resourcemanager/consumption/armconsumption/reservationrecommendations_client.go @@ -40,7 +40,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 2023-11-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 +84,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", "2023-11-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..273c082f4dc9 100644 --- a/sdk/resourcemanager/consumption/armconsumption/reservationsdetails_client.go +++ b/sdk/resourcemanager/consumption/armconsumption/reservationsdetails_client.go @@ -40,9 +40,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 2023-11-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 +85,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", "2023-11-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 +115,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 2023-11-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' @@ -155,7 +163,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", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -170,9 +178,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 2023-11-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 @@ -219,7 +232,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", "2023-11-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..00d5a40fa780 100644 --- a/sdk/resourcemanager/consumption/armconsumption/reservationssummaries_client.go +++ b/sdk/resourcemanager/consumption/armconsumption/reservationssummaries_client.go @@ -40,9 +40,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 2023-11-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 +84,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", "2023-11-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 +115,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 2023-11-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 +159,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", "2023-11-01") + reqQP.Set("grain", string(grain)) req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -174,9 +178,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 2023-11-01 // - reservationOrderID - Order Id of the reservation // - reservationID - Id of the reservation // - grain - Can be daily or monthly @@ -221,11 +228,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", "2023-11-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..a6b3d71af44f 100644 --- a/sdk/resourcemanager/consumption/armconsumption/reservationtransactions_client.go +++ b/sdk/resourcemanager/consumption/armconsumption/reservationtransactions_client.go @@ -17,6 +17,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" "net/url" + "strconv" "strings" ) @@ -40,9 +41,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 2023-11-01 // - billingAccountID - BillingAccount ID // - options - ReservationTransactionsClientListOptions contains the optional parameters for the ReservationTransactionsClient.NewListPager // method. @@ -84,7 +90,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", "2023-11-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 +111,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 2023-11-01 // - billingAccountID - BillingAccount ID // - billingProfileID - Azure Billing Profile ID. // - options - ReservationTransactionsClientListByBillingProfileOptions contains the optional parameters for the ReservationTransactionsClient.NewListByBillingProfilePager @@ -148,7 +165,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", "2023-11-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..1a4d4421c76b 100644 --- a/sdk/resourcemanager/consumption/armconsumption/response_types.go +++ b/sdk/resourcemanager/consumption/armconsumption/responses.go @@ -110,6 +110,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..02c3decd2c50 100644 --- a/sdk/resourcemanager/consumption/armconsumption/tags_client.go +++ b/sdk/resourcemanager/consumption/armconsumption/tags_client.go @@ -41,7 +41,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 2023-11-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, @@ -81,7 +81,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", "2023-11-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..cddb6c1d418c 100644 --- a/sdk/resourcemanager/consumption/armconsumption/time_rfc3339.go +++ b/sdk/resourcemanager/consumption/armconsumption/time_rfc3339.go @@ -19,12 +19,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 +44,33 @@ 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) { + 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..f60a55c36a00 100644 --- a/sdk/resourcemanager/consumption/armconsumption/usagedetails_client.go +++ b/sdk/resourcemanager/consumption/armconsumption/usagedetails_client.go @@ -41,8 +41,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 2023-11-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 +60,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 +108,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", "2023-11-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), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/CHANGELOG.md b/sdk/resourcemanager/costmanagement/armcostmanagement/CHANGELOG.md index 14bd641be201..f0ae9655f680 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/CHANGELOG.md +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/CHANGELOG.md @@ -1,5 +1,95 @@ # Release History +## 3.0.0 (2024-05-07) +### Breaking Changes + +- Function `*PriceSheetClient.BeginDownload` has been removed +- Field `DownloadURL` of struct `PriceSheetClientDownloadByBillingProfileResponse` has been removed + +### Features Added + +- New value `OperationStatusTypeComplete` added to enum type `OperationStatusType` +- New enum type `BenefitUtilizationSummaryReportSchema` with values `BenefitUtilizationSummaryReportSchemaAvgUtilizationPercentage`, `BenefitUtilizationSummaryReportSchemaBenefitID`, `BenefitUtilizationSummaryReportSchemaBenefitOrderID`, `BenefitUtilizationSummaryReportSchemaBenefitType`, `BenefitUtilizationSummaryReportSchemaKind`, `BenefitUtilizationSummaryReportSchemaMaxUtilizationPercentage`, `BenefitUtilizationSummaryReportSchemaMinUtilizationPercentage`, `BenefitUtilizationSummaryReportSchemaUsageDate`, `BenefitUtilizationSummaryReportSchemaUtilizedPercentage` +- New enum type `BudgetNotificationOperatorType` with values `BudgetNotificationOperatorTypeEqualTo`, `BudgetNotificationOperatorTypeGreaterThan`, `BudgetNotificationOperatorTypeGreaterThanOrEqualTo`, `BudgetNotificationOperatorTypeLessThan` +- New enum type `BudgetOperatorType` with values `BudgetOperatorTypeIn` +- New enum type `CategoryType` with values `CategoryTypeCost`, `CategoryTypeReservationUtilization` +- New enum type `CostAllocationPolicyType` with values `CostAllocationPolicyTypeFixedProportion` +- New enum type `CostAllocationResourceType` with values `CostAllocationResourceTypeDimension`, `CostAllocationResourceTypeTag` +- New enum type `CultureCode` with values `CultureCodeCsCz`, `CultureCodeDaDk`, `CultureCodeDeDe`, `CultureCodeEnGb`, `CultureCodeEnUs`, `CultureCodeEsEs`, `CultureCodeFrFr`, `CultureCodeHuHu`, `CultureCodeItIt`, `CultureCodeJaJp`, `CultureCodeKoKr`, `CultureCodeNbNo`, `CultureCodeNlNl`, `CultureCodePlPl`, `CultureCodePtBr`, `CultureCodePtPt`, `CultureCodeRuRu`, `CultureCodeSvSe`, `CultureCodeTrTr`, `CultureCodeZhCn`, `CultureCodeZhTw` +- New enum type `Frequency` with values `FrequencyDaily`, `FrequencyMonthly`, `FrequencyWeekly` +- New enum type `Reason` with values `ReasonAlreadyExists`, `ReasonInvalid`, `ReasonValid` +- New enum type `RuleStatus` with values `RuleStatusActive`, `RuleStatusNotActive`, `RuleStatusProcessing` +- New enum type `SettingType` with values `SettingTypeTaginheritance` +- New enum type `SettingsKind` with values `SettingsKindTaginheritance` +- New enum type `SystemAssignedServiceIdentityType` with values `SystemAssignedServiceIdentityTypeNone`, `SystemAssignedServiceIdentityTypeSystemAssigned` +- New enum type `ThresholdType` with values `ThresholdTypeActual`, `ThresholdTypeForecasted` +- New enum type `TimeGrainType` with values `TimeGrainTypeAnnually`, `TimeGrainTypeBillingAnnual`, `TimeGrainTypeBillingMonth`, `TimeGrainTypeBillingQuarter`, `TimeGrainTypeLast30Days`, `TimeGrainTypeLast7Days`, `TimeGrainTypeMonthly`, `TimeGrainTypeQuarterly` +- New function `NewBudgetsClient(azcore.TokenCredential, *arm.ClientOptions) (*BudgetsClient, error)` +- New function `*BudgetsClient.CreateOrUpdate(context.Context, string, string, Budget, *BudgetsClientCreateOrUpdateOptions) (BudgetsClientCreateOrUpdateResponse, error)` +- New function `*BudgetsClient.Delete(context.Context, string, string, *BudgetsClientDeleteOptions) (BudgetsClientDeleteResponse, error)` +- New function `*BudgetsClient.Get(context.Context, string, string, *BudgetsClientGetOptions) (BudgetsClientGetResponse, error)` +- New function `*BudgetsClient.NewListPager(string, *BudgetsClientListOptions) *runtime.Pager[BudgetsClientListResponse]` +- New function `*ClientFactory.NewBudgetsClient() *BudgetsClient` +- New function `*ClientFactory.NewCostAllocationRulesClient() *CostAllocationRulesClient` +- New function `*ClientFactory.NewGenerateBenefitUtilizationSummariesReportClient() *GenerateBenefitUtilizationSummariesReportClient` +- New function `*ClientFactory.NewSettingsClient() *SettingsClient` +- New function `NewCostAllocationRulesClient(azcore.TokenCredential, *arm.ClientOptions) (*CostAllocationRulesClient, error)` +- New function `*CostAllocationRulesClient.CheckNameAvailability(context.Context, string, CostAllocationRuleCheckNameAvailabilityRequest, *CostAllocationRulesClientCheckNameAvailabilityOptions) (CostAllocationRulesClientCheckNameAvailabilityResponse, error)` +- New function `*CostAllocationRulesClient.CreateOrUpdate(context.Context, string, string, CostAllocationRuleDefinition, *CostAllocationRulesClientCreateOrUpdateOptions) (CostAllocationRulesClientCreateOrUpdateResponse, error)` +- New function `*CostAllocationRulesClient.Delete(context.Context, string, string, *CostAllocationRulesClientDeleteOptions) (CostAllocationRulesClientDeleteResponse, error)` +- New function `*CostAllocationRulesClient.Get(context.Context, string, string, *CostAllocationRulesClientGetOptions) (CostAllocationRulesClientGetResponse, error)` +- New function `*CostAllocationRulesClient.NewListPager(string, *CostAllocationRulesClientListOptions) *runtime.Pager[CostAllocationRulesClientListResponse]` +- New function `NewGenerateBenefitUtilizationSummariesReportClient(azcore.TokenCredential, *arm.ClientOptions) (*GenerateBenefitUtilizationSummariesReportClient, error)` +- New function `*GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByBillingAccount(context.Context, string, BenefitUtilizationSummariesRequest, *GenerateBenefitUtilizationSummariesReportClientBeginGenerateByBillingAccountOptions) (*runtime.Poller[GenerateBenefitUtilizationSummariesReportClientGenerateByBillingAccountResponse], error)` +- New function `*GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByBillingProfile(context.Context, string, string, BenefitUtilizationSummariesRequest, *GenerateBenefitUtilizationSummariesReportClientBeginGenerateByBillingProfileOptions) (*runtime.Poller[GenerateBenefitUtilizationSummariesReportClientGenerateByBillingProfileResponse], error)` +- New function `*GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByReservationID(context.Context, string, string, BenefitUtilizationSummariesRequest, *GenerateBenefitUtilizationSummariesReportClientBeginGenerateByReservationIDOptions) (*runtime.Poller[GenerateBenefitUtilizationSummariesReportClientGenerateByReservationIDResponse], error)` +- New function `*GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByReservationOrderID(context.Context, string, BenefitUtilizationSummariesRequest, *GenerateBenefitUtilizationSummariesReportClientBeginGenerateByReservationOrderIDOptions) (*runtime.Poller[GenerateBenefitUtilizationSummariesReportClientGenerateByReservationOrderIDResponse], error)` +- New function `*GenerateBenefitUtilizationSummariesReportClient.BeginGenerateBySavingsPlanID(context.Context, string, string, BenefitUtilizationSummariesRequest, *GenerateBenefitUtilizationSummariesReportClientBeginGenerateBySavingsPlanIDOptions) (*runtime.Poller[GenerateBenefitUtilizationSummariesReportClientGenerateBySavingsPlanIDResponse], error)` +- New function `*GenerateBenefitUtilizationSummariesReportClient.BeginGenerateBySavingsPlanOrderID(context.Context, string, BenefitUtilizationSummariesRequest, *GenerateBenefitUtilizationSummariesReportClientBeginGenerateBySavingsPlanOrderIDOptions) (*runtime.Poller[GenerateBenefitUtilizationSummariesReportClientGenerateBySavingsPlanOrderIDResponse], error)` +- New function `*PriceSheetClient.BeginDownloadByBillingAccount(context.Context, string, string, *PriceSheetClientBeginDownloadByBillingAccountOptions) (*runtime.Poller[PriceSheetClientDownloadByBillingAccountResponse], error)` +- New function `*PriceSheetClient.BeginDownloadByInvoice(context.Context, string, string, string, *PriceSheetClientBeginDownloadByInvoiceOptions) (*runtime.Poller[PriceSheetClientDownloadByInvoiceResponse], error)` +- New function `*Setting.GetSetting() *Setting` +- New function `NewSettingsClient(azcore.TokenCredential, *arm.ClientOptions) (*SettingsClient, error)` +- New function `*SettingsClient.CreateOrUpdateByScope(context.Context, string, SettingType, SettingClassification, *SettingsClientCreateOrUpdateByScopeOptions) (SettingsClientCreateOrUpdateByScopeResponse, error)` +- New function `*SettingsClient.DeleteByScope(context.Context, string, SettingType, *SettingsClientDeleteByScopeOptions) (SettingsClientDeleteByScopeResponse, error)` +- New function `*SettingsClient.GetByScope(context.Context, string, SettingType, *SettingsClientGetByScopeOptions) (SettingsClientGetByScopeResponse, error)` +- New function `*SettingsClient.List(context.Context, string, *SettingsClientListOptions) (SettingsClientListResponse, error)` +- New function `*TagInheritanceSetting.GetSetting() *Setting` +- New struct `AsyncOperationStatusProperties` +- New struct `BenefitUtilizationSummariesOperationStatus` +- New struct `BenefitUtilizationSummariesRequest` +- New struct `Budget` +- New struct `BudgetComparisonExpression` +- New struct `BudgetFilter` +- New struct `BudgetFilterProperties` +- New struct `BudgetProperties` +- New struct `BudgetTimePeriod` +- New struct `BudgetsListResult` +- New struct `CostAllocationProportion` +- New struct `CostAllocationRuleCheckNameAvailabilityRequest` +- New struct `CostAllocationRuleCheckNameAvailabilityResponse` +- New struct `CostAllocationRuleDefinition` +- New struct `CostAllocationRuleDetails` +- New struct `CostAllocationRuleList` +- New struct `CostAllocationRuleProperties` +- New struct `CurrentSpend` +- New struct `EAPriceSheetProperties` +- New struct `EAPricesheetDownloadProperties` +- New struct `ForecastSpend` +- New struct `MCAPriceSheetProperties` +- New struct `Notification` +- New struct `OperationStatusAutoGenerated` +- New struct `PricesheetDownloadProperties` +- New struct `SettingsListResult` +- New struct `SourceCostAllocationResource` +- New struct `SystemAssignedServiceIdentity` +- New struct `TagInheritanceProperties` +- New struct `TagInheritanceSetting` +- New struct `TargetCostAllocationResource` +- New field `Identity`, `Location` in struct `Export` +- New anonymous field `PricesheetDownloadProperties` in struct `PriceSheetClientDownloadByBillingProfileResponse` + + ## 2.1.0 (2023-11-24) ### Features Added diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/README.md b/sdk/resourcemanager/costmanagement/armcostmanagement/README.md index 5db86fd93c1f..2effc794ec2c 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/README.md +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/README.md @@ -1,6 +1,6 @@ # Azure Costmanagement Module for Go -[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v2)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v2) +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v3)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v3) The `armcostmanagement` module provides operations for working with Azure Costmanagement. @@ -20,7 +20,7 @@ This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for ve Install the Azure Costmanagement module: ```sh -go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v2 +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v3 ``` ## Authorization diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/alerts_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/alerts_client.go index d06f91cd690d..73e187d4eb1c 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/alerts_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/alerts_client.go @@ -43,7 +43,7 @@ func NewAlertsClient(credential azcore.TokenCredential, options *arm.ClientOptio // Dismiss - Dismisses the specified alert // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - scope - The scope associated with alerts operations. This includes '/subscriptions/{subscriptionId}/' for subscription // scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for // resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and @@ -89,7 +89,7 @@ func (client *AlertsClient) dismissCreateRequest(ctx context.Context, scope stri return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -110,7 +110,7 @@ func (client *AlertsClient) dismissHandleResponse(resp *http.Response) (AlertsCl // Get - Gets the alert for the scope by alert ID. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - scope - The scope associated with alerts operations. This includes '/subscriptions/{subscriptionId}/' for subscription // scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for // resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and @@ -155,7 +155,7 @@ func (client *AlertsClient) getCreateRequest(ctx context.Context, scope string, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -173,7 +173,7 @@ func (client *AlertsClient) getHandleResponse(resp *http.Response) (AlertsClient // List - Lists the alerts for scope defined. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - scope - The scope associated with alerts operations. This includes '/subscriptions/{subscriptionId}/' for subscription // scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for // resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and @@ -216,7 +216,7 @@ func (client *AlertsClient) listCreateRequest(ctx context.Context, scope string, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -234,7 +234,7 @@ func (client *AlertsClient) listHandleResponse(resp *http.Response) (AlertsClien // ListExternal - Lists the Alerts for external cloud provider type defined. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - externalCloudProviderType - The external cloud provider type associated with dimension/query operations. This includes // 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account. // - externalCloudProviderID - This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' for @@ -278,7 +278,7 @@ func (client *AlertsClient) listExternalCreateRequest(ctx context.Context, exter return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/alerts_client_example_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/alerts_client_example_test.go deleted file mode 100644 index 4d7c45d49bc1..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/alerts_client_example_test.go +++ /dev/null @@ -1,1282 +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 armcostmanagement_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/costmanagement/armcostmanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BillingAccountAlerts.json -func ExampleAlertsClient_List_billingAccountAlerts() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAlertsClient().List(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789", 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.AlertsResult = armcostmanagement.AlertsResult{ - // Value: []*armcostmanagement.Alert{ - // { - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.CostManagement/alerts"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/providers/Microsoft.CostManagement/alerts/00000000-0000-0000-0000-000000000000"), - // Properties: &armcostmanagement.AlertProperties{ - // Description: to.Ptr(""), - // CloseTime: to.Ptr("0001-01-01T00:00:00"), - // CostEntityID: to.Ptr("budget1"), - // CreationTime: to.Ptr("2020-04-27T11:07:52.7143901Z"), - // Definition: &armcostmanagement.AlertPropertiesDefinition{ - // Type: to.Ptr(armcostmanagement.AlertTypeBudget), - // Category: to.Ptr(armcostmanagement.AlertCategoryCost), - // Criteria: to.Ptr(armcostmanagement.AlertCriteriaCostThresholdExceeded), - // }, - // ModificationTime: to.Ptr("2020-04-28T11:06:02.8999373Z"), - // Source: to.Ptr(armcostmanagement.AlertSourcePreset), - // Status: to.Ptr(armcostmanagement.AlertStatusActive), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, - // ContactGroups: []*string{ - // }, - // ContactRoles: []*string{ - // }, - // CurrentSpend: to.Ptr[float64](161000.12), - // MeterFilter: []any{ - // }, - // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), - // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), - // ResourceFilter: []any{ - // }, - // ResourceGroupFilter: []any{ - // }, - // TagFilter: map[string]any{ - // }, - // Threshold: to.Ptr[float64](0.8), - // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), - // TriggeredBy: to.Ptr("00000000-0000-0000-0000-000000000000_1_01"), - // Unit: to.Ptr("USD"), - // }, - // }, - // }, - // { - // Name: to.Ptr("11111111-1111-1111-111111111111"), - // Type: to.Ptr("Microsoft.CostManagement/alerts"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/providers/Microsoft.CostManagement/alerts/11111111-1111-1111-111111111111"), - // Properties: &armcostmanagement.AlertProperties{ - // Description: to.Ptr(""), - // CloseTime: to.Ptr("0001-01-01T00:00:00"), - // CostEntityID: to.Ptr("budget1"), - // CreationTime: to.Ptr("2019-06-24T05:51:52.8713179Z"), - // Definition: &armcostmanagement.AlertPropertiesDefinition{ - // Type: to.Ptr(armcostmanagement.AlertTypeBudget), - // Category: to.Ptr(armcostmanagement.AlertCategoryCost), - // Criteria: to.Ptr(armcostmanagement.AlertCriteriaCostThresholdExceeded), - // }, - // ModificationTime: to.Ptr("2019-08-31T17:51:55.1808807Z"), - // Source: to.Ptr(armcostmanagement.AlertSourcePreset), - // Status: to.Ptr(armcostmanagement.AlertStatusActive), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, - // ContactGroups: []*string{ - // }, - // ContactRoles: []*string{ - // }, - // CurrentSpend: to.Ptr[float64](171000.32), - // MeterFilter: []any{ - // }, - // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), - // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), - // ResourceFilter: []any{ - // }, - // ResourceGroupFilter: []any{ - // }, - // TagFilter: map[string]any{ - // }, - // Threshold: to.Ptr[float64](0.8), - // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), - // TriggeredBy: to.Ptr("11111111-1111-1111-111111111111_1_01"), - // Unit: to.Ptr("USD"), - // }, - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BillingProfileAlerts.json -func ExampleAlertsClient_List_billingProfileAlerts() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAlertsClient().List(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579", 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.AlertsResult = armcostmanagement.AlertsResult{ - // Value: []*armcostmanagement.Alert{ - // { - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.CostManagement/alerts"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/providers/Microsoft.CostManagement/alerts/00000000-0000-0000-0000-000000000000"), - // Properties: &armcostmanagement.AlertProperties{ - // Description: to.Ptr(""), - // CloseTime: to.Ptr("0001-01-01T00:00:00"), - // CostEntityID: to.Ptr("budget1"), - // CreationTime: to.Ptr("2020-04-27T11:07:52.7143901Z"), - // Definition: &armcostmanagement.AlertPropertiesDefinition{ - // Type: to.Ptr(armcostmanagement.AlertTypeBudget), - // Category: to.Ptr(armcostmanagement.AlertCategoryCost), - // Criteria: to.Ptr(armcostmanagement.AlertCriteriaCostThresholdExceeded), - // }, - // ModificationTime: to.Ptr("2020-04-28T11:06:02.8999373Z"), - // Source: to.Ptr(armcostmanagement.AlertSourcePreset), - // Status: to.Ptr(armcostmanagement.AlertStatusActive), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, - // ContactGroups: []*string{ - // }, - // ContactRoles: []*string{ - // }, - // CurrentSpend: to.Ptr[float64](161000.12), - // MeterFilter: []any{ - // }, - // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), - // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), - // ResourceFilter: []any{ - // }, - // ResourceGroupFilter: []any{ - // }, - // TagFilter: map[string]any{ - // }, - // Threshold: to.Ptr[float64](0.8), - // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), - // TriggeredBy: to.Ptr("00000000-0000-0000-0000-000000000000_1_01"), - // Unit: to.Ptr("USD"), - // }, - // }, - // }, - // { - // Name: to.Ptr("11111111-1111-1111-111111111111"), - // Type: to.Ptr("Microsoft.CostManagement/alerts"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/providers/Microsoft.CostManagement/alerts/11111111-1111-1111-111111111111"), - // Properties: &armcostmanagement.AlertProperties{ - // Description: to.Ptr(""), - // CloseTime: to.Ptr("0001-01-01T00:00:00"), - // CostEntityID: to.Ptr("budget1"), - // CreationTime: to.Ptr("2019-06-24T05:51:52.8713179Z"), - // Definition: &armcostmanagement.AlertPropertiesDefinition{ - // Type: to.Ptr(armcostmanagement.AlertTypeBudget), - // Category: to.Ptr(armcostmanagement.AlertCategoryCost), - // Criteria: to.Ptr(armcostmanagement.AlertCriteriaCostThresholdExceeded), - // }, - // ModificationTime: to.Ptr("2019-08-31T17:51:55.1808807Z"), - // Source: to.Ptr(armcostmanagement.AlertSourcePreset), - // Status: to.Ptr(armcostmanagement.AlertStatusActive), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, - // ContactGroups: []*string{ - // }, - // ContactRoles: []*string{ - // }, - // CurrentSpend: to.Ptr[float64](171000.32), - // MeterFilter: []any{ - // }, - // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), - // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), - // ResourceFilter: []any{ - // }, - // ResourceGroupFilter: []any{ - // }, - // TagFilter: map[string]any{ - // }, - // Threshold: to.Ptr[float64](0.8), - // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), - // TriggeredBy: to.Ptr("11111111-1111-1111-111111111111_1_01"), - // Unit: to.Ptr("USD"), - // }, - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/DepartmentAlerts.json -func ExampleAlertsClient_List_departmentAlerts() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAlertsClient().List(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789/departments/123", 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.AlertsResult = armcostmanagement.AlertsResult{ - // Value: []*armcostmanagement.Alert{ - // { - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.CostManagement/alerts"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/departments/123/providers/Microsoft.CostManagement/alerts/00000000-0000-0000-0000-000000000000"), - // Properties: &armcostmanagement.AlertProperties{ - // Description: to.Ptr(""), - // CloseTime: to.Ptr("0001-01-01T00:00:00"), - // CostEntityID: to.Ptr("budget1"), - // CreationTime: to.Ptr("2020-04-27T11:07:52.7143901Z"), - // Definition: &armcostmanagement.AlertPropertiesDefinition{ - // Type: to.Ptr(armcostmanagement.AlertTypeBudget), - // Category: to.Ptr(armcostmanagement.AlertCategoryCost), - // Criteria: to.Ptr(armcostmanagement.AlertCriteriaCostThresholdExceeded), - // }, - // ModificationTime: to.Ptr("2020-04-28T11:06:02.8999373Z"), - // Source: to.Ptr(armcostmanagement.AlertSourcePreset), - // Status: to.Ptr(armcostmanagement.AlertStatusActive), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, - // ContactGroups: []*string{ - // }, - // ContactRoles: []*string{ - // }, - // CurrentSpend: to.Ptr[float64](161000.12), - // MeterFilter: []any{ - // }, - // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), - // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), - // ResourceFilter: []any{ - // }, - // ResourceGroupFilter: []any{ - // }, - // TagFilter: map[string]any{ - // }, - // Threshold: to.Ptr[float64](0.8), - // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), - // TriggeredBy: to.Ptr("00000000-0000-0000-0000-000000000000_1_01"), - // Unit: to.Ptr("USD"), - // }, - // }, - // }, - // { - // Name: to.Ptr("11111111-1111-1111-111111111111"), - // Type: to.Ptr("Microsoft.CostManagement/alerts"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/departments/123/providers/Microsoft.CostManagement/alerts/11111111-1111-1111-111111111111"), - // Properties: &armcostmanagement.AlertProperties{ - // Description: to.Ptr(""), - // CloseTime: to.Ptr("0001-01-01T00:00:00"), - // CostEntityID: to.Ptr("budget1"), - // CreationTime: to.Ptr("2019-06-24T05:51:52.8713179Z"), - // Definition: &armcostmanagement.AlertPropertiesDefinition{ - // Type: to.Ptr(armcostmanagement.AlertTypeBudget), - // Category: to.Ptr(armcostmanagement.AlertCategoryCost), - // Criteria: to.Ptr(armcostmanagement.AlertCriteriaCostThresholdExceeded), - // }, - // ModificationTime: to.Ptr("2019-08-31T17:51:55.1808807Z"), - // Source: to.Ptr(armcostmanagement.AlertSourcePreset), - // Status: to.Ptr(armcostmanagement.AlertStatusActive), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, - // ContactGroups: []*string{ - // }, - // ContactRoles: []*string{ - // }, - // CurrentSpend: to.Ptr[float64](171000.32), - // MeterFilter: []any{ - // }, - // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), - // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), - // ResourceFilter: []any{ - // }, - // ResourceGroupFilter: []any{ - // }, - // TagFilter: map[string]any{ - // }, - // Threshold: to.Ptr[float64](0.8), - // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), - // TriggeredBy: to.Ptr("11111111-1111-1111-111111111111_1_01"), - // Unit: to.Ptr("USD"), - // }, - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/EnrollmentAccountAlerts.json -func ExampleAlertsClient_List_enrollmentAccountAlerts() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAlertsClient().List(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789/enrollmentAccounts/456", 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.AlertsResult = armcostmanagement.AlertsResult{ - // Value: []*armcostmanagement.Alert{ - // { - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.CostManagement/alerts"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/enrollmentAccounts/456/providers/Microsoft.CostManagement/alerts/00000000-0000-0000-0000-000000000000"), - // Properties: &armcostmanagement.AlertProperties{ - // Description: to.Ptr(""), - // CloseTime: to.Ptr("0001-01-01T00:00:00"), - // CostEntityID: to.Ptr("budget1"), - // CreationTime: to.Ptr("2020-04-27T11:07:52.7143901Z"), - // Definition: &armcostmanagement.AlertPropertiesDefinition{ - // Type: to.Ptr(armcostmanagement.AlertTypeBudget), - // Category: to.Ptr(armcostmanagement.AlertCategoryCost), - // Criteria: to.Ptr(armcostmanagement.AlertCriteriaCostThresholdExceeded), - // }, - // ModificationTime: to.Ptr("2020-04-28T11:06:02.8999373Z"), - // Source: to.Ptr(armcostmanagement.AlertSourcePreset), - // Status: to.Ptr(armcostmanagement.AlertStatusActive), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, - // ContactGroups: []*string{ - // }, - // ContactRoles: []*string{ - // }, - // CurrentSpend: to.Ptr[float64](161000.12), - // MeterFilter: []any{ - // }, - // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), - // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), - // ResourceFilter: []any{ - // }, - // ResourceGroupFilter: []any{ - // }, - // TagFilter: map[string]any{ - // }, - // Threshold: to.Ptr[float64](0.8), - // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), - // TriggeredBy: to.Ptr("00000000-0000-0000-0000-000000000000_1_01"), - // Unit: to.Ptr("USD"), - // }, - // }, - // }, - // { - // Name: to.Ptr("11111111-1111-1111-111111111111"), - // Type: to.Ptr("Microsoft.CostManagement/alerts"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/enrollmentAccounts/456/providers/Microsoft.CostManagement/alerts/11111111-1111-1111-111111111111"), - // Properties: &armcostmanagement.AlertProperties{ - // Description: to.Ptr(""), - // CloseTime: to.Ptr("0001-01-01T00:00:00"), - // CostEntityID: to.Ptr("budget1"), - // CreationTime: to.Ptr("2019-06-24T05:51:52.8713179Z"), - // Definition: &armcostmanagement.AlertPropertiesDefinition{ - // Type: to.Ptr(armcostmanagement.AlertTypeBudget), - // Category: to.Ptr(armcostmanagement.AlertCategoryCost), - // Criteria: to.Ptr(armcostmanagement.AlertCriteriaCostThresholdExceeded), - // }, - // ModificationTime: to.Ptr("2019-08-31T17:51:55.1808807Z"), - // Source: to.Ptr(armcostmanagement.AlertSourcePreset), - // Status: to.Ptr(armcostmanagement.AlertStatusActive), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, - // ContactGroups: []*string{ - // }, - // ContactRoles: []*string{ - // }, - // CurrentSpend: to.Ptr[float64](171000.32), - // MeterFilter: []any{ - // }, - // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), - // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), - // ResourceFilter: []any{ - // }, - // ResourceGroupFilter: []any{ - // }, - // TagFilter: map[string]any{ - // }, - // Threshold: to.Ptr[float64](0.8), - // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), - // TriggeredBy: to.Ptr("11111111-1111-1111-111111111111_1_01"), - // Unit: to.Ptr("USD"), - // }, - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/InvoiceSectionAlerts.json -func ExampleAlertsClient_List_invoiceSectionAlerts() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAlertsClient().List(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876", 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.AlertsResult = armcostmanagement.AlertsResult{ - // Value: []*armcostmanagement.Alert{ - // { - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.CostManagement/alerts"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876/providers/Microsoft.CostManagement/alerts/00000000-0000-0000-0000-000000000000"), - // Properties: &armcostmanagement.AlertProperties{ - // Description: to.Ptr(""), - // CloseTime: to.Ptr("0001-01-01T00:00:00"), - // CostEntityID: to.Ptr("budget1"), - // CreationTime: to.Ptr("2020-04-27T11:07:52.7143901Z"), - // Definition: &armcostmanagement.AlertPropertiesDefinition{ - // Type: to.Ptr(armcostmanagement.AlertTypeBudget), - // Category: to.Ptr(armcostmanagement.AlertCategoryCost), - // Criteria: to.Ptr(armcostmanagement.AlertCriteriaCostThresholdExceeded), - // }, - // ModificationTime: to.Ptr("2020-04-28T11:06:02.8999373Z"), - // Source: to.Ptr(armcostmanagement.AlertSourcePreset), - // Status: to.Ptr(armcostmanagement.AlertStatusActive), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, - // ContactGroups: []*string{ - // }, - // ContactRoles: []*string{ - // }, - // CurrentSpend: to.Ptr[float64](161000.12), - // MeterFilter: []any{ - // }, - // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), - // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), - // ResourceFilter: []any{ - // }, - // ResourceGroupFilter: []any{ - // }, - // TagFilter: map[string]any{ - // }, - // Threshold: to.Ptr[float64](0.8), - // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), - // TriggeredBy: to.Ptr("00000000-0000-0000-0000-000000000000_1_01"), - // Unit: to.Ptr("USD"), - // }, - // }, - // }, - // { - // Name: to.Ptr("11111111-1111-1111-111111111111"), - // Type: to.Ptr("Microsoft.CostManagement/alerts"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876/providers/Microsoft.CostManagement/alerts/11111111-1111-1111-111111111111"), - // Properties: &armcostmanagement.AlertProperties{ - // Description: to.Ptr(""), - // CloseTime: to.Ptr("0001-01-01T00:00:00"), - // CostEntityID: to.Ptr("budget1"), - // CreationTime: to.Ptr("2019-06-24T05:51:52.8713179Z"), - // Definition: &armcostmanagement.AlertPropertiesDefinition{ - // Type: to.Ptr(armcostmanagement.AlertTypeBudget), - // Category: to.Ptr(armcostmanagement.AlertCategoryCost), - // Criteria: to.Ptr(armcostmanagement.AlertCriteriaCostThresholdExceeded), - // }, - // ModificationTime: to.Ptr("2019-08-31T17:51:55.1808807Z"), - // Source: to.Ptr(armcostmanagement.AlertSourcePreset), - // Status: to.Ptr(armcostmanagement.AlertStatusActive), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, - // ContactGroups: []*string{ - // }, - // ContactRoles: []*string{ - // }, - // CurrentSpend: to.Ptr[float64](171000.32), - // MeterFilter: []any{ - // }, - // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), - // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), - // ResourceFilter: []any{ - // }, - // ResourceGroupFilter: []any{ - // }, - // TagFilter: map[string]any{ - // }, - // Threshold: to.Ptr[float64](0.8), - // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), - // TriggeredBy: to.Ptr("11111111-1111-1111-111111111111_1_01"), - // Unit: to.Ptr("USD"), - // }, - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ResourceGroupAlerts.json -func ExampleAlertsClient_List_resourceGroupAlerts() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAlertsClient().List(ctx, "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ScreenSharingTest-peer", 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.AlertsResult = armcostmanagement.AlertsResult{ - // Value: []*armcostmanagement.Alert{ - // { - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.CostManagement/alerts"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ScreenSharingTest-peer/providers/Microsoft.CostManagement/alerts/00000000-0000-0000-0000-000000000000"), - // Properties: &armcostmanagement.AlertProperties{ - // Description: to.Ptr(""), - // CloseTime: to.Ptr("0001-01-01T00:00:00"), - // CostEntityID: to.Ptr("budget1"), - // CreationTime: to.Ptr("2020-04-27T11:07:52.7143901Z"), - // Definition: &armcostmanagement.AlertPropertiesDefinition{ - // Type: to.Ptr(armcostmanagement.AlertTypeBudget), - // Category: to.Ptr(armcostmanagement.AlertCategoryCost), - // Criteria: to.Ptr(armcostmanagement.AlertCriteriaCostThresholdExceeded), - // }, - // ModificationTime: to.Ptr("2020-04-28T11:06:02.8999373Z"), - // Source: to.Ptr(armcostmanagement.AlertSourcePreset), - // Status: to.Ptr(armcostmanagement.AlertStatusActive), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, - // ContactGroups: []*string{ - // }, - // ContactRoles: []*string{ - // }, - // CurrentSpend: to.Ptr[float64](161000.12), - // MeterFilter: []any{ - // }, - // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), - // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), - // ResourceFilter: []any{ - // }, - // ResourceGroupFilter: []any{ - // }, - // TagFilter: map[string]any{ - // }, - // Threshold: to.Ptr[float64](0.8), - // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), - // TriggeredBy: to.Ptr("00000000-0000-0000-0000-000000000000_1_01"), - // Unit: to.Ptr("USD"), - // }, - // }, - // }, - // { - // Name: to.Ptr("11111111-1111-1111-111111111111"), - // Type: to.Ptr("Microsoft.CostManagement/alerts"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ScreenSharingTest-peer/providers/Microsoft.CostManagement/alerts/11111111-1111-1111-111111111111"), - // Properties: &armcostmanagement.AlertProperties{ - // Description: to.Ptr(""), - // CloseTime: to.Ptr("0001-01-01T00:00:00"), - // CostEntityID: to.Ptr("budget1"), - // CreationTime: to.Ptr("2019-06-24T05:51:52.8713179Z"), - // Definition: &armcostmanagement.AlertPropertiesDefinition{ - // Type: to.Ptr(armcostmanagement.AlertTypeBudget), - // Category: to.Ptr(armcostmanagement.AlertCategoryCost), - // Criteria: to.Ptr(armcostmanagement.AlertCriteriaCostThresholdExceeded), - // }, - // ModificationTime: to.Ptr("2019-08-31T17:51:55.1808807Z"), - // Source: to.Ptr(armcostmanagement.AlertSourcePreset), - // Status: to.Ptr(armcostmanagement.AlertStatusActive), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, - // ContactGroups: []*string{ - // }, - // ContactRoles: []*string{ - // }, - // CurrentSpend: to.Ptr[float64](171000.32), - // MeterFilter: []any{ - // }, - // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), - // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), - // ResourceFilter: []any{ - // }, - // ResourceGroupFilter: []any{ - // }, - // TagFilter: map[string]any{ - // }, - // Threshold: to.Ptr[float64](0.8), - // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), - // TriggeredBy: to.Ptr("11111111-1111-1111-111111111111_1_01"), - // Unit: to.Ptr("USD"), - // }, - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/SubscriptionAlerts.json -func ExampleAlertsClient_List_subscriptionAlerts() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAlertsClient().List(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", 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.AlertsResult = armcostmanagement.AlertsResult{ - // Value: []*armcostmanagement.Alert{ - // { - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.CostManagement/alerts"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/alerts/00000000-0000-0000-0000-000000000000"), - // Properties: &armcostmanagement.AlertProperties{ - // Description: to.Ptr(""), - // CloseTime: to.Ptr("0001-01-01T00:00:00"), - // CostEntityID: to.Ptr("budget1"), - // CreationTime: to.Ptr("2020-04-27T11:07:52.7143901Z"), - // Definition: &armcostmanagement.AlertPropertiesDefinition{ - // Type: to.Ptr(armcostmanagement.AlertTypeBudget), - // Category: to.Ptr(armcostmanagement.AlertCategoryCost), - // Criteria: to.Ptr(armcostmanagement.AlertCriteriaCostThresholdExceeded), - // }, - // ModificationTime: to.Ptr("2020-04-28T11:06:02.8999373Z"), - // Source: to.Ptr(armcostmanagement.AlertSourcePreset), - // Status: to.Ptr(armcostmanagement.AlertStatusActive), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, - // ContactGroups: []*string{ - // }, - // ContactRoles: []*string{ - // }, - // CurrentSpend: to.Ptr[float64](161000.12), - // MeterFilter: []any{ - // }, - // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), - // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), - // ResourceFilter: []any{ - // }, - // ResourceGroupFilter: []any{ - // }, - // TagFilter: map[string]any{ - // }, - // Threshold: to.Ptr[float64](0.8), - // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), - // TriggeredBy: to.Ptr("00000000-0000-0000-0000-000000000000_1_01"), - // Unit: to.Ptr("USD"), - // }, - // }, - // }, - // { - // Name: to.Ptr("11111111-1111-1111-111111111111"), - // Type: to.Ptr("Microsoft.CostManagement/alerts"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/alerts/11111111-1111-1111-111111111111"), - // Properties: &armcostmanagement.AlertProperties{ - // Description: to.Ptr(""), - // CloseTime: to.Ptr("0001-01-01T00:00:00"), - // CostEntityID: to.Ptr("budget1"), - // CreationTime: to.Ptr("2019-06-24T05:51:52.8713179Z"), - // Definition: &armcostmanagement.AlertPropertiesDefinition{ - // Type: to.Ptr(armcostmanagement.AlertTypeBudget), - // Category: to.Ptr(armcostmanagement.AlertCategoryCost), - // Criteria: to.Ptr(armcostmanagement.AlertCriteriaCostThresholdExceeded), - // }, - // ModificationTime: to.Ptr("2019-08-31T17:51:55.1808807Z"), - // Source: to.Ptr(armcostmanagement.AlertSourcePreset), - // Status: to.Ptr(armcostmanagement.AlertStatusActive), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, - // ContactGroups: []*string{ - // }, - // ContactRoles: []*string{ - // }, - // CurrentSpend: to.Ptr[float64](171000.32), - // MeterFilter: []any{ - // }, - // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), - // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), - // ResourceFilter: []any{ - // }, - // ResourceGroupFilter: []any{ - // }, - // TagFilter: map[string]any{ - // }, - // Threshold: to.Ptr[float64](0.8), - // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), - // TriggeredBy: to.Ptr("11111111-1111-1111-111111111111_1_01"), - // Unit: to.Ptr("USD"), - // }, - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/SingleResourceGroupAlert.json -func ExampleAlertsClient_Get_singleResourceGroupAlerts() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAlertsClient().Get(ctx, "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ScreenSharingTest-peer", "22222222-2222-2222-2222-222222222222", 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.Alert = armcostmanagement.Alert{ - // Name: to.Ptr("22222222-2222-2222-2222-222222222222"), - // Type: to.Ptr("Microsoft.CostManagement/alerts"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ScreenSharingTest-peer/providers/Microsoft.CostManagement/alerts/22222222-2222-2222-2222-222222222222"), - // Properties: &armcostmanagement.AlertProperties{ - // Description: to.Ptr(""), - // CloseTime: to.Ptr("0001-01-01T00:00:00"), - // CostEntityID: to.Ptr("budget1"), - // CreationTime: to.Ptr("2020-04-27T11:07:52.7143901Z"), - // Definition: &armcostmanagement.AlertPropertiesDefinition{ - // Type: to.Ptr(armcostmanagement.AlertTypeBudget), - // Category: to.Ptr(armcostmanagement.AlertCategoryCost), - // Criteria: to.Ptr(armcostmanagement.AlertCriteriaCostThresholdExceeded), - // }, - // ModificationTime: to.Ptr("2020-04-28T11:06:02.8999373Z"), - // Source: to.Ptr(armcostmanagement.AlertSourcePreset), - // Status: to.Ptr(armcostmanagement.AlertStatusActive), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, - // ContactGroups: []*string{ - // }, - // ContactRoles: []*string{ - // }, - // CurrentSpend: to.Ptr[float64](161000.12), - // MeterFilter: []any{ - // }, - // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), - // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), - // ResourceFilter: []any{ - // }, - // ResourceGroupFilter: []any{ - // }, - // TagFilter: map[string]any{ - // }, - // Threshold: to.Ptr[float64](0.8), - // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), - // TriggeredBy: to.Ptr("22222222-2222-2222-2222-222222222222_1_01"), - // Unit: to.Ptr("USD"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/SingleSubscriptionAlert.json -func ExampleAlertsClient_Get_singleSubscriptionAlerts() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAlertsClient().Get(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", "22222222-2222-2222-2222-222222222222", 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.Alert = armcostmanagement.Alert{ - // Name: to.Ptr("22222222-2222-2222-2222-222222222222"), - // Type: to.Ptr("Microsoft.CostManagement/alerts"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/alerts/22222222-2222-2222-2222-222222222222"), - // Properties: &armcostmanagement.AlertProperties{ - // Description: to.Ptr(""), - // CloseTime: to.Ptr("0001-01-01T00:00:00"), - // CostEntityID: to.Ptr("budget1"), - // CreationTime: to.Ptr("2020-04-27T11:07:52.7143901Z"), - // Definition: &armcostmanagement.AlertPropertiesDefinition{ - // Type: to.Ptr(armcostmanagement.AlertTypeBudget), - // Category: to.Ptr(armcostmanagement.AlertCategoryCost), - // Criteria: to.Ptr(armcostmanagement.AlertCriteriaCostThresholdExceeded), - // }, - // ModificationTime: to.Ptr("2020-04-28T11:06:02.8999373Z"), - // Source: to.Ptr(armcostmanagement.AlertSourcePreset), - // Status: to.Ptr(armcostmanagement.AlertStatusActive), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, - // ContactGroups: []*string{ - // }, - // ContactRoles: []*string{ - // }, - // CurrentSpend: to.Ptr[float64](161000.12), - // MeterFilter: []any{ - // }, - // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), - // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), - // ResourceFilter: []any{ - // }, - // ResourceGroupFilter: []any{ - // }, - // TagFilter: map[string]any{ - // }, - // Threshold: to.Ptr[float64](0.8), - // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), - // TriggeredBy: to.Ptr("22222222-2222-2222-2222-222222222222_1_01"), - // Unit: to.Ptr("USD"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/DismissResourceGroupAlerts.json -func ExampleAlertsClient_Dismiss_patchResourceGroupAlerts() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAlertsClient().Dismiss(ctx, "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ScreenSharingTest-peer", "22222222-2222-2222-2222-222222222222", armcostmanagement.DismissAlertPayload{ - Properties: &armcostmanagement.AlertProperties{ - Status: to.Ptr(armcostmanagement.AlertStatusDismissed), - }, - }, 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.Alert = armcostmanagement.Alert{ - // Name: to.Ptr("22222222-2222-2222-2222-222222222222"), - // Type: to.Ptr("Microsoft.CostManagement/alerts"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ScreenSharingTest-peer/providers/Microsoft.CostManagement/alerts/22222222-2222-2222-2222-222222222222"), - // Properties: &armcostmanagement.AlertProperties{ - // Description: to.Ptr(""), - // CloseTime: to.Ptr("0001-01-01T00:00:00"), - // CostEntityID: to.Ptr("budget1"), - // CreationTime: to.Ptr("2020-04-27T11:07:52.7143901Z"), - // Definition: &armcostmanagement.AlertPropertiesDefinition{ - // Type: to.Ptr(armcostmanagement.AlertTypeBudget), - // Category: to.Ptr(armcostmanagement.AlertCategoryCost), - // Criteria: to.Ptr(armcostmanagement.AlertCriteriaCostThresholdExceeded), - // }, - // ModificationTime: to.Ptr("2020-04-28T11:06:02.8999373Z"), - // Source: to.Ptr(armcostmanagement.AlertSourcePreset), - // Status: to.Ptr(armcostmanagement.AlertStatusDismissed), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, - // ContactGroups: []*string{ - // }, - // ContactRoles: []*string{ - // }, - // CurrentSpend: to.Ptr[float64](161000.12), - // MeterFilter: []any{ - // }, - // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), - // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), - // ResourceFilter: []any{ - // }, - // ResourceGroupFilter: []any{ - // }, - // TagFilter: map[string]any{ - // }, - // Threshold: to.Ptr[float64](0.8), - // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), - // TriggeredBy: to.Ptr("22222222-2222-2222-2222-222222222222_1_01"), - // Unit: to.Ptr("USD"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/DismissSubscriptionAlerts.json -func ExampleAlertsClient_Dismiss_patchSubscriptionAlerts() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAlertsClient().Dismiss(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", "22222222-2222-2222-2222-222222222222", armcostmanagement.DismissAlertPayload{ - Properties: &armcostmanagement.AlertProperties{ - Status: to.Ptr(armcostmanagement.AlertStatusDismissed), - }, - }, 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.Alert = armcostmanagement.Alert{ - // Name: to.Ptr("22222222-2222-2222-2222-222222222222"), - // Type: to.Ptr("Microsoft.CostManagement/alerts"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/alerts/22222222-2222-2222-2222-222222222222"), - // Properties: &armcostmanagement.AlertProperties{ - // Description: to.Ptr(""), - // CloseTime: to.Ptr("0001-01-01T00:00:00"), - // CostEntityID: to.Ptr("budget1"), - // CreationTime: to.Ptr("2020-04-27T11:07:52.7143901Z"), - // Definition: &armcostmanagement.AlertPropertiesDefinition{ - // Type: to.Ptr(armcostmanagement.AlertTypeBudget), - // Category: to.Ptr(armcostmanagement.AlertCategoryCost), - // Criteria: to.Ptr(armcostmanagement.AlertCriteriaCostThresholdExceeded), - // }, - // ModificationTime: to.Ptr("2020-04-28T11:06:02.8999373Z"), - // Source: to.Ptr(armcostmanagement.AlertSourcePreset), - // Status: to.Ptr(armcostmanagement.AlertStatusDismissed), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, - // ContactGroups: []*string{ - // }, - // ContactRoles: []*string{ - // }, - // CurrentSpend: to.Ptr[float64](161000.12), - // MeterFilter: []any{ - // }, - // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), - // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), - // ResourceFilter: []any{ - // }, - // ResourceGroupFilter: []any{ - // }, - // TagFilter: map[string]any{ - // }, - // Threshold: to.Ptr[float64](0.8), - // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), - // TriggeredBy: to.Ptr("22222222-2222-2222-2222-222222222222_1_01"), - // Unit: to.Ptr("USD"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExternalBillingAccountAlerts.json -func ExampleAlertsClient_ListExternal_externalBillingAccountAlerts() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAlertsClient().ListExternal(ctx, armcostmanagement.ExternalCloudProviderTypeExternalBillingAccounts, "100", 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.AlertsResult = armcostmanagement.AlertsResult{ - // Value: []*armcostmanagement.Alert{ - // { - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.CostManagement/alerts"), - // ID: to.Ptr("providers/Microsoft.CostManagement/externalBillingAccounts/100/providers/Microsoft.CostManagement/alerts/00000000-0000-0000-0000-000000000000"), - // Properties: &armcostmanagement.AlertProperties{ - // Description: to.Ptr(""), - // CloseTime: to.Ptr("0001-01-01T00:00:00"), - // CostEntityID: to.Ptr("budget1"), - // CreationTime: to.Ptr("2020-04-27T11:07:52.7143901Z"), - // Definition: &armcostmanagement.AlertPropertiesDefinition{ - // Type: to.Ptr(armcostmanagement.AlertTypeBudget), - // Category: to.Ptr(armcostmanagement.AlertCategoryCost), - // Criteria: to.Ptr(armcostmanagement.AlertCriteriaCostThresholdExceeded), - // }, - // ModificationTime: to.Ptr("2020-04-28T11:06:02.8999373Z"), - // Source: to.Ptr(armcostmanagement.AlertSourcePreset), - // Status: to.Ptr(armcostmanagement.AlertStatusActive), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, - // ContactGroups: []*string{ - // }, - // ContactRoles: []*string{ - // }, - // CurrentSpend: to.Ptr[float64](161000.12), - // MeterFilter: []any{ - // }, - // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), - // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), - // ResourceFilter: []any{ - // }, - // ResourceGroupFilter: []any{ - // }, - // TagFilter: map[string]any{ - // }, - // Threshold: to.Ptr[float64](0.8), - // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), - // TriggeredBy: to.Ptr("00000000-0000-0000-0000-000000000000_1_01"), - // Unit: to.Ptr("USD"), - // }, - // }, - // }, - // { - // Name: to.Ptr("11111111-1111-1111-111111111111"), - // Type: to.Ptr("Microsoft.CostManagement/alerts"), - // ID: to.Ptr("providers/Microsoft.CostManagement/externalBillingAccounts/100/providers/Microsoft.CostManagement/alerts/11111111-1111-1111-111111111111"), - // Properties: &armcostmanagement.AlertProperties{ - // Description: to.Ptr(""), - // CloseTime: to.Ptr("0001-01-01T00:00:00"), - // CostEntityID: to.Ptr("budget1"), - // CreationTime: to.Ptr("2019-06-24T05:51:52.8713179Z"), - // Definition: &armcostmanagement.AlertPropertiesDefinition{ - // Type: to.Ptr(armcostmanagement.AlertTypeBudget), - // Category: to.Ptr(armcostmanagement.AlertCategoryCost), - // Criteria: to.Ptr(armcostmanagement.AlertCriteriaCostThresholdExceeded), - // }, - // ModificationTime: to.Ptr("2019-08-31T17:51:55.1808807Z"), - // Source: to.Ptr(armcostmanagement.AlertSourcePreset), - // Status: to.Ptr(armcostmanagement.AlertStatusActive), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, - // ContactGroups: []*string{ - // }, - // ContactRoles: []*string{ - // }, - // CurrentSpend: to.Ptr[float64](171000.32), - // MeterFilter: []any{ - // }, - // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), - // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), - // ResourceFilter: []any{ - // }, - // ResourceGroupFilter: []any{ - // }, - // TagFilter: map[string]any{ - // }, - // Threshold: to.Ptr[float64](0.8), - // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), - // TriggeredBy: to.Ptr("11111111-1111-1111-111111111111_1_01"), - // Unit: to.Ptr("USD"), - // }, - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExternalSubscriptionAlerts.json -func ExampleAlertsClient_ListExternal_externalSubscriptionAlerts() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAlertsClient().ListExternal(ctx, armcostmanagement.ExternalCloudProviderTypeExternalSubscriptions, "100", 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.AlertsResult = armcostmanagement.AlertsResult{ - // Value: []*armcostmanagement.Alert{ - // { - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.CostManagement/alerts"), - // ID: to.Ptr("providers/Microsoft.CostManagement/externalSubscriptions/100/providers/Microsoft.CostManagement/alerts/00000000-0000-0000-0000-000000000000"), - // Properties: &armcostmanagement.AlertProperties{ - // Description: to.Ptr(""), - // CloseTime: to.Ptr("0001-01-01T00:00:00"), - // CostEntityID: to.Ptr("budget1"), - // CreationTime: to.Ptr("2020-04-27T11:07:52.7143901Z"), - // Definition: &armcostmanagement.AlertPropertiesDefinition{ - // Type: to.Ptr(armcostmanagement.AlertTypeBudget), - // Category: to.Ptr(armcostmanagement.AlertCategoryCost), - // Criteria: to.Ptr(armcostmanagement.AlertCriteriaCostThresholdExceeded), - // }, - // ModificationTime: to.Ptr("2020-04-28T11:06:02.8999373Z"), - // Source: to.Ptr(armcostmanagement.AlertSourcePreset), - // Status: to.Ptr(armcostmanagement.AlertStatusActive), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, - // ContactGroups: []*string{ - // }, - // ContactRoles: []*string{ - // }, - // CurrentSpend: to.Ptr[float64](161000.12), - // MeterFilter: []any{ - // }, - // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), - // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), - // ResourceFilter: []any{ - // }, - // ResourceGroupFilter: []any{ - // }, - // TagFilter: map[string]any{ - // }, - // Threshold: to.Ptr[float64](0.8), - // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), - // TriggeredBy: to.Ptr("00000000-0000-0000-0000-000000000000_1_01"), - // Unit: to.Ptr("USD"), - // }, - // }, - // }, - // { - // Name: to.Ptr("11111111-1111-1111-111111111111"), - // Type: to.Ptr("Microsoft.CostManagement/alerts"), - // ID: to.Ptr("providers/Microsoft.CostManagement/externalSubscriptions/100/providers/Microsoft.CostManagement/alerts/11111111-1111-1111-111111111111"), - // Properties: &armcostmanagement.AlertProperties{ - // Description: to.Ptr(""), - // CloseTime: to.Ptr("0001-01-01T00:00:00"), - // CostEntityID: to.Ptr("budget1"), - // CreationTime: to.Ptr("2019-06-24T05:51:52.8713179Z"), - // Definition: &armcostmanagement.AlertPropertiesDefinition{ - // Type: to.Ptr(armcostmanagement.AlertTypeBudget), - // Category: to.Ptr(armcostmanagement.AlertCategoryCost), - // Criteria: to.Ptr(armcostmanagement.AlertCriteriaCostThresholdExceeded), - // }, - // ModificationTime: to.Ptr("2019-08-31T17:51:55.1808807Z"), - // Source: to.Ptr(armcostmanagement.AlertSourcePreset), - // Status: to.Ptr(armcostmanagement.AlertStatusActive), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, - // ContactGroups: []*string{ - // }, - // ContactRoles: []*string{ - // }, - // CurrentSpend: to.Ptr[float64](171000.32), - // MeterFilter: []any{ - // }, - // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), - // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), - // ResourceFilter: []any{ - // }, - // ResourceGroupFilter: []any{ - // }, - // TagFilter: map[string]any{ - // }, - // Threshold: to.Ptr[float64](0.8), - // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), - // TriggeredBy: to.Ptr("11111111-1111-1111-111111111111_1_01"), - // Unit: to.Ptr("USD"), - // }, - // }, - // }}, - // } -} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/autorest.md b/sdk/resourcemanager/costmanagement/armcostmanagement/autorest.md index 4feb493f501a..9551c2e59568 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/autorest.md +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/autorest.md @@ -5,9 +5,8 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/cost-management/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/cost-management/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 2.1.0 -tag: package-2022-10 +module-version: 3.0.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/benefitrecommendations_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/benefitrecommendations_client.go index 2777c9e9deee..d5596b9afaab 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/benefitrecommendations_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/benefitrecommendations_client.go @@ -40,7 +40,7 @@ func NewBenefitRecommendationsClient(credential azcore.TokenCredential, options // NewListPager - List of recommendations for purchasing savings plan. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - billingScope - The scope associated with benefit recommendation operations. This includes '/subscriptions/{subscriptionId}/' // for subscription scope, // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resource group scope, /providers/Microsoft.Billing/billingAccounts/{billingAccountId}' @@ -81,16 +81,16 @@ func (client *BenefitRecommendationsClient) listCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() + if options != nil && options.Expand != nil { + reqQP.Set("$expand", *options.Expand) + } if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } if options != nil && options.Orderby != nil { reqQP.Set("$orderby", *options.Orderby) } - if options != nil && options.Expand != nil { - reqQP.Set("$expand", *options.Expand) - } - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/benefitrecommendations_client_example_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/benefitrecommendations_client_example_test.go deleted file mode 100644 index 79cd70adad44..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/benefitrecommendations_client_example_test.go +++ /dev/null @@ -1,154 +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 armcostmanagement_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/costmanagement/armcostmanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BenefitRecommendationsByBillingAccount.json -func ExampleBenefitRecommendationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewBenefitRecommendationsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/123456", &armcostmanagement.BenefitRecommendationsClientListOptions{Filter: to.Ptr("properties/lookBackPeriod eq 'Last7Days' AND properties/term eq 'P1Y'"), - Orderby: nil, - Expand: to.Ptr("properties/usage,properties/allRecommendationDetails"), - }) - 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.BenefitRecommendationsListResult = armcostmanagement.BenefitRecommendationsListResult{ - // Value: []*armcostmanagement.BenefitRecommendationModel{ - // { - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.CostManagement/benefitRecommendations"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/benefitRecommendations/00000000-0000-0000-0000-000000000000"), - // Kind: to.Ptr(armcostmanagement.BenefitKindSavingsPlan), - // Properties: &armcostmanagement.SharedScopeBenefitRecommendationProperties{ - // AllRecommendationDetails: &armcostmanagement.AllSavingsList{ - // Value: []*armcostmanagement.AllSavingsBenefitDetails{ - // { - // AverageUtilizationPercentage: to.Ptr[float64](99.33), - // BenefitCost: to.Ptr[float64](52.002), - // CommitmentAmount: to.Ptr[float64](0.164), - // CoveragePercentage: to.Ptr[float64](54.609), - // OverageCost: to.Ptr[float64](144.841), - // SavingsAmount: to.Ptr[float64](21.424), - // SavingsPercentage: to.Ptr[float64](9.815), - // TotalCost: to.Ptr[float64](196.843), - // WastageCost: to.Ptr[float64](0.035), - // }, - // { - // AverageUtilizationPercentage: to.Ptr[float64](81.474), - // BenefitCost: to.Ptr[float64](83.754), - // CommitmentAmount: to.Ptr[float64](0.161), - // CoveragePercentage: to.Ptr[float64](56.748), - // OverageCost: to.Ptr[float64](120.389), - // SavingsAmount: to.Ptr[float64](14.124), - // SavingsPercentage: to.Ptr[float64](6.47), - // TotalCost: to.Ptr[float64](204.143), - // WastageCost: to.Ptr[float64](0.1), - // }}, - // }, - // ArmSKUName: to.Ptr("Compute_Savings_Plan"), - // CommitmentGranularity: to.Ptr(armcostmanagement.GrainHourly), - // CostWithoutBenefit: to.Ptr[float64](218.267), - // CurrencyCode: to.Ptr("USD"), - // FirstConsumptionDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-18T00:00:00.000Z"); return t}()), - // LastConsumptionDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-25T00:00:00.000Z"); return t}()), - // LookBackPeriod: to.Ptr(armcostmanagement.LookBackPeriodLast7Days), - // RecommendationDetails: &armcostmanagement.AllSavingsBenefitDetails{ - // AverageUtilizationPercentage: to.Ptr[float64](99.33), - // BenefitCost: to.Ptr[float64](52.002), - // CommitmentAmount: to.Ptr[float64](0.164), - // CoveragePercentage: to.Ptr[float64](54.609), - // OverageCost: to.Ptr[float64](144.841), - // SavingsAmount: to.Ptr[float64](21.424), - // SavingsPercentage: to.Ptr[float64](9.815), - // TotalCost: to.Ptr[float64](196.843), - // WastageCost: to.Ptr[float64](0.035), - // }, - // Scope: to.Ptr(armcostmanagement.ScopeShared), - // Term: to.Ptr(armcostmanagement.TermP1Y), - // TotalHours: to.Ptr[int32](168), - // Usage: &armcostmanagement.RecommendationUsageDetails{ - // Charges: []*float64{ - // to.Ptr[float64](1), - // to.Ptr[float64](1), - // to.Ptr[float64](0), - // to.Ptr[float64](1), - // to.Ptr[float64](1), - // to.Ptr[float64](1), - // to.Ptr[float64](1), - // to.Ptr[float64](1), - // to.Ptr[float64](1), - // to.Ptr[float64](1), - // to.Ptr[float64](1), - // to.Ptr[float64](1), - // to.Ptr[float64](1), - // to.Ptr[float64](1), - // to.Ptr[float64](1), - // to.Ptr[float64](1), - // to.Ptr[float64](1), - // to.Ptr[float64](1), - // to.Ptr[float64](1), - // to.Ptr[float64](1), - // to.Ptr[float64](1), - // to.Ptr[float64](1), - // to.Ptr[float64](1), - // to.Ptr[float64](1), - // to.Ptr[float64](1), - // to.Ptr[float64](1), - // to.Ptr[float64](1), - // to.Ptr[float64](1), - // to.Ptr[float64](1), - // to.Ptr[float64](1), - // to.Ptr[float64](1), - // to.Ptr[float64](1), - // to.Ptr[float64](1), - // to.Ptr[float64](1), - // to.Ptr[float64](1), - // to.Ptr[float64](1), - // to.Ptr[float64](1), - // to.Ptr[float64](1), - // to.Ptr[float64](1), - // to.Ptr[float64](1), - // to.Ptr[float64](1), - // to.Ptr[float64](1), - // to.Ptr[float64](2), - // to.Ptr[float64](2), - // to.Ptr[float64](2), - // to.Ptr[float64](2)}, - // UsageGrain: to.Ptr(armcostmanagement.GrainHourly), - // }, - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/benefitutilizationsummaries_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/benefitutilizationsummaries_client.go index 9c3f1fca6b40..f34ec7ea2073 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/benefitutilizationsummaries_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/benefitutilizationsummaries_client.go @@ -43,7 +43,7 @@ func NewBenefitUtilizationSummariesClient(credential azcore.TokenCredential, opt // NewListByBillingAccountIDPager - Lists savings plan utilization summaries for the enterprise agreement scope. Supported // at grain values: 'Daily' and 'Monthly'. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - billingAccountID - Billing account ID // - options - BenefitUtilizationSummariesClientListByBillingAccountIDOptions contains the optional parameters for the BenefitUtilizationSummariesClient.NewListByBillingAccountIDPager // method. @@ -82,13 +82,13 @@ func (client *BenefitUtilizationSummariesClient) listByBillingAccountIDCreateReq return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") - if options != nil && options.GrainParameter != nil { - reqQP.Set("grainParameter", string(*options.GrainParameter)) - } + reqQP.Set("api-version", "2023-11-01") if options != nil && options.Filter != nil { reqQP.Set("filter", *options.Filter) } + if options != nil && options.GrainParameter != nil { + reqQP.Set("grainParameter", string(*options.GrainParameter)) + } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -106,7 +106,7 @@ func (client *BenefitUtilizationSummariesClient) listByBillingAccountIDHandleRes // NewListByBillingProfileIDPager - Lists savings plan utilization summaries for billing profile. Supported at grain values: // 'Daily' and 'Monthly'. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - billingAccountID - Billing account ID // - billingProfileID - Billing profile ID. // - options - BenefitUtilizationSummariesClientListByBillingProfileIDOptions contains the optional parameters for the BenefitUtilizationSummariesClient.NewListByBillingProfileIDPager @@ -150,13 +150,13 @@ func (client *BenefitUtilizationSummariesClient) listByBillingProfileIDCreateReq return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") - if options != nil && options.GrainParameter != nil { - reqQP.Set("grainParameter", string(*options.GrainParameter)) - } + reqQP.Set("api-version", "2023-11-01") if options != nil && options.Filter != nil { reqQP.Set("filter", *options.Filter) } + if options != nil && options.GrainParameter != nil { + reqQP.Set("grainParameter", string(*options.GrainParameter)) + } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -173,7 +173,7 @@ func (client *BenefitUtilizationSummariesClient) listByBillingProfileIDHandleRes // NewListBySavingsPlanIDPager - Lists the savings plan utilization summaries for daily or monthly grain. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - savingsPlanOrderID - Savings plan order ID. // - savingsPlanID - Savings plan ID. // - options - BenefitUtilizationSummariesClientListBySavingsPlanIDOptions contains the optional parameters for the BenefitUtilizationSummariesClient.NewListBySavingsPlanIDPager @@ -217,10 +217,10 @@ func (client *BenefitUtilizationSummariesClient) listBySavingsPlanIDCreateReques return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } + reqQP.Set("api-version", "2023-11-01") if options != nil && options.GrainParameter != nil { reqQP.Set("grainParameter", string(*options.GrainParameter)) } @@ -240,7 +240,7 @@ func (client *BenefitUtilizationSummariesClient) listBySavingsPlanIDHandleRespon // NewListBySavingsPlanOrderPager - Lists the savings plan utilization summaries for daily or monthly grain. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - savingsPlanOrderID - Savings plan order ID. // - options - BenefitUtilizationSummariesClientListBySavingsPlanOrderOptions contains the optional parameters for the BenefitUtilizationSummariesClient.NewListBySavingsPlanOrderPager // method. @@ -279,10 +279,10 @@ func (client *BenefitUtilizationSummariesClient) listBySavingsPlanOrderCreateReq return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } + reqQP.Set("api-version", "2023-11-01") if options != nil && options.GrainParameter != nil { reqQP.Set("grainParameter", string(*options.GrainParameter)) } diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/benefitutilizationsummaries_client_example_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/benefitutilizationsummaries_client_example_test.go deleted file mode 100644 index 1b54647d3d7a..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/benefitutilizationsummaries_client_example_test.go +++ /dev/null @@ -1,235 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armcostmanagement_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/costmanagement/armcostmanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BenefitUtilizationSummaries/SavingsPlan-BillingAccount.json -func ExampleBenefitUtilizationSummariesClient_NewListByBillingAccountIDPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewBenefitUtilizationSummariesClient().NewListByBillingAccountIDPager("12345", &armcostmanagement.BenefitUtilizationSummariesClientListByBillingAccountIDOptions{GrainParameter: nil, - Filter: to.Ptr("properties/usageDate ge 2022-10-15 and properties/usageDate le 2022-10-18"), - }) - 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.BenefitUtilizationSummariesListResult = armcostmanagement.BenefitUtilizationSummariesListResult{ - // Value: []armcostmanagement.BenefitUtilizationSummaryClassification{ - // &armcostmanagement.SavingsPlanUtilizationSummary{ - // Name: to.Ptr("66cccc66-6ccc-6c66-666c-66cc6c6c66c6_222d22dd-d2d2-2dd2-222d-2dd2222ddddd_20211116"), - // Type: to.Ptr("Microsoft.CostManagement/benefitUtilizationSummaries"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/12345/providers/Microsoft.CostManagement/benefitUtilizationSummaries/66cccc66-6ccc-6c66-666c-66cc6c6c66c6_222d22dd-d2d2-2dd2-222d-2dd2222ddddd_20211116"), - // Kind: to.Ptr(armcostmanagement.BenefitKindSavingsPlan), - // Properties: &armcostmanagement.SavingsPlanUtilizationSummaryProperties{ - // ArmSKUName: to.Ptr("Compute_Savings_Plan"), - // BenefitID: to.Ptr("/providers/Microsoft.BillingBenefits/savingsPlanOrders/66cccc66-6ccc-6c66-666c-66cc6c6c66c6/savingsPlans/222d22dd-d2d2-2dd2-222d-2dd2222ddddd"), - // BenefitOrderID: to.Ptr("/providers/Microsoft.BillingBenefits/savingsPlanOrders/66cccc66-6ccc-6c66-666c-66cc6c6c66c6"), - // BenefitType: to.Ptr(armcostmanagement.BenefitKindSavingsPlan), - // UsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-16T00:00:00.000Z"); return t}()), - // AvgUtilizationPercentage: to.Ptr[float64](90), - // MaxUtilizationPercentage: to.Ptr[float64](100), - // MinUtilizationPercentage: to.Ptr[float64](80), - // }, - // }, - // &armcostmanagement.SavingsPlanUtilizationSummary{ - // Name: to.Ptr("88cccc88-8ccc-8c88-888c-88cc8c8c88c8_444d44dd-d4d4-4dd4-444d-4dd4444ddddd_20211117"), - // Type: to.Ptr("Microsoft.CostManagement/benefitUtilizationSummaries"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/12345/providers/Microsoft.CostManagement/benefitUtilizationSummaries/88cccc88-8ccc-8c88-888c-88cc8c8c88c8_444d44dd-d4d4-4dd4-444d-4dd4444ddddd_20211117"), - // Kind: to.Ptr(armcostmanagement.BenefitKindSavingsPlan), - // Properties: &armcostmanagement.SavingsPlanUtilizationSummaryProperties{ - // ArmSKUName: to.Ptr("Compute_Savings_Plan"), - // BenefitID: to.Ptr("/providers/Microsoft.BillingBenefits/savingsPlanOrders/88cccc88-8ccc-8c88-888c-88cc8c8c88c8/savingsPlans/444d44dd-d4d4-4dd4-444d-4dd4444ddddd"), - // BenefitOrderID: to.Ptr("/providers/Microsoft.BillingBenefits/savingsPlanOrders/88cccc88-8ccc-8c88-888c-88cc8c8c88c8"), - // BenefitType: to.Ptr(armcostmanagement.BenefitKindSavingsPlan), - // UsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T00:00:00.000Z"); return t}()), - // AvgUtilizationPercentage: to.Ptr[float64](60), - // MaxUtilizationPercentage: to.Ptr[float64](70), - // MinUtilizationPercentage: to.Ptr[float64](50), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BenefitUtilizationSummaries/SavingsPlan-BillingProfile.json -func ExampleBenefitUtilizationSummariesClient_NewListByBillingProfileIDPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewBenefitUtilizationSummariesClient().NewListByBillingProfileIDPager("c0a00000-0e04-5ee3-000e-f0c6e00000ec:c0a00000-0e04-5ee3-000e-f0c6e00000ec", "200e5e90-000e-4960-8dcd-8d00a02db000", &armcostmanagement.BenefitUtilizationSummariesClientListByBillingProfileIDOptions{GrainParameter: nil, - Filter: to.Ptr("properties/usageDate ge 2022-10-15 and properties/usageDate le 2022-10-18"), - }) - 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.BenefitUtilizationSummariesListResult = armcostmanagement.BenefitUtilizationSummariesListResult{ - // Value: []armcostmanagement.BenefitUtilizationSummaryClassification{ - // &armcostmanagement.SavingsPlanUtilizationSummary{ - // Name: to.Ptr("66cccc66-6ccc-6c66-666c-66cc6c6c66c6_222d22dd-d2d2-2dd2-222d-2dd2222ddddd_20211116"), - // Type: to.Ptr("Microsoft.CostManagement/benefitUtilizationSummaries"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/c0a00000-0e04-5ee3-000e-f0c6e00000ec:c0a00000-0e04-5ee3-000e-f0c6e00000ec/billingProfiles/200e5e90-000e-4960-8dcd-8d00a02db000/providers/Microsoft.CostManagement/benefitUtilizationSummaries/66cccc66-6ccc-6c66-666c-66cc6c6c66c6_222d22dd-d2d2-2dd2-222d-2dd2222ddddd_20211116"), - // Kind: to.Ptr(armcostmanagement.BenefitKindSavingsPlan), - // Properties: &armcostmanagement.SavingsPlanUtilizationSummaryProperties{ - // ArmSKUName: to.Ptr("Compute_Savings_Plan"), - // BenefitID: to.Ptr("/providers/Microsoft.BillingBenefits/savingsPlanOrders/66cccc66-6ccc-6c66-666c-66cc6c6c66c6/savingsPlans/222d22dd-d2d2-2dd2-222d-2dd2222ddddd"), - // BenefitOrderID: to.Ptr("/providers/Microsoft.BillingBenefits/savingsPlanOrders/66cccc66-6ccc-6c66-666c-66cc6c6c66c6"), - // BenefitType: to.Ptr(armcostmanagement.BenefitKindSavingsPlan), - // UsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-16T00:00:00.000Z"); return t}()), - // AvgUtilizationPercentage: to.Ptr[float64](90), - // MaxUtilizationPercentage: to.Ptr[float64](100), - // MinUtilizationPercentage: to.Ptr[float64](80), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BenefitUtilizationSummaries/SavingsPlan-SavingsPlanOrderId-Daily.json -func ExampleBenefitUtilizationSummariesClient_NewListBySavingsPlanOrderPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewBenefitUtilizationSummariesClient().NewListBySavingsPlanOrderPager("66cccc66-6ccc-6c66-666c-66cc6c6c66c6", &armcostmanagement.BenefitUtilizationSummariesClientListBySavingsPlanOrderOptions{Filter: nil, - GrainParameter: 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.BenefitUtilizationSummariesListResult = armcostmanagement.BenefitUtilizationSummariesListResult{ - // Value: []armcostmanagement.BenefitUtilizationSummaryClassification{ - // &armcostmanagement.SavingsPlanUtilizationSummary{ - // Name: to.Ptr("66cccc66-6ccc-6c66-666c-66cc6c6c66c6_222d22dd-d2d2-2dd2-222d-2dd2222ddddd_20211116"), - // Type: to.Ptr("Microsoft.CostManagement/benefitUtilizationSummaries"), - // ID: to.Ptr("/providers/Microsoft.BillingBenefits/savingsPlanOrders/66cccc66-6ccc-6c66-666c-66cc6c6c66c6/providers/Microsoft.CostManagement/benefitUtilizationSummaries/66cccc66-6ccc-6c66-666c-66cc6c6c66c6_222d22dd-d2d2-2dd2-222d-2dd2222ddddd_20211116"), - // Kind: to.Ptr(armcostmanagement.BenefitKindSavingsPlan), - // Properties: &armcostmanagement.SavingsPlanUtilizationSummaryProperties{ - // ArmSKUName: to.Ptr("Compute_Savings_Plan"), - // BenefitID: to.Ptr("/providers/Microsoft.BillingBenefits/savingsPlanOrders/66cccc66-6ccc-6c66-666c-66cc6c6c66c6/savingsPlans/222d22dd-d2d2-2dd2-222d-2dd2222ddddd"), - // BenefitOrderID: to.Ptr("/providers/Microsoft.BillingBenefits/savingsPlanOrders/66cccc66-6ccc-6c66-666c-66cc6c6c66c6"), - // BenefitType: to.Ptr(armcostmanagement.BenefitKindSavingsPlan), - // UsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-16T00:00:00.000Z"); return t}()), - // AvgUtilizationPercentage: to.Ptr[float64](90), - // MaxUtilizationPercentage: to.Ptr[float64](100), - // MinUtilizationPercentage: to.Ptr[float64](80), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BenefitUtilizationSummaries/SavingsPlan-SavingsPlanId-Monthly.json -func ExampleBenefitUtilizationSummariesClient_NewListBySavingsPlanIDPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewBenefitUtilizationSummariesClient().NewListBySavingsPlanIDPager("66cccc66-6ccc-6c66-666c-66cc6c6c66c6", "222d22dd-d2d2-2dd2-222d-2dd2222ddddd", &armcostmanagement.BenefitUtilizationSummariesClientListBySavingsPlanIDOptions{Filter: nil, - GrainParameter: 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.BenefitUtilizationSummariesListResult = armcostmanagement.BenefitUtilizationSummariesListResult{ - // Value: []armcostmanagement.BenefitUtilizationSummaryClassification{ - // &armcostmanagement.SavingsPlanUtilizationSummary{ - // Name: to.Ptr("66cccc66-6ccc-6c66-666c-66cc6c6c66c6_222d22dd-d2d2-2dd2-222d-2dd2222ddddd_202111"), - // Type: to.Ptr("Microsoft.CostManagement/benefitUtilizationSummaries"), - // ID: to.Ptr("/providers/Microsoft.BillingBenefits/savingsPlanOrders/66cccc66-6ccc-6c66-666c-66cc6c6c66c6/savingsPlans/222d22dd-d2d2-2dd2-222d-2dd2222ddddd/providers/Microsoft.CostManagement/benefitUtilizationSummaries/66cccc66-6ccc-6c66-666c-66cc6c6c66c6_222d22dd-d2d2-2dd2-222d-2dd2222ddddd_202111"), - // Kind: to.Ptr(armcostmanagement.BenefitKindSavingsPlan), - // Properties: &armcostmanagement.SavingsPlanUtilizationSummaryProperties{ - // ArmSKUName: to.Ptr("Compute_Savings_Plan"), - // BenefitID: to.Ptr("/providers/Microsoft.BillingBenefits/savingsPlanOrders/66cccc66-6ccc-6c66-666c-66cc6c6c66c6/savingsPlans/222d22dd-d2d2-2dd2-222d-2dd2222ddddd"), - // BenefitOrderID: to.Ptr("/providers/Microsoft.BillingBenefits/savingsPlanOrders/66cccc66-6ccc-6c66-666c-66cc6c6c66c6"), - // BenefitType: to.Ptr(armcostmanagement.BenefitKindSavingsPlan), - // UsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-16T00:00:00.000Z"); return t}()), - // AvgUtilizationPercentage: to.Ptr[float64](90), - // MaxUtilizationPercentage: to.Ptr[float64](100), - // MinUtilizationPercentage: to.Ptr[float64](80), - // }, - // }, - // &armcostmanagement.SavingsPlanUtilizationSummary{ - // Name: to.Ptr("66cccc66-6ccc-6c66-666c-66cc6c6c66c6_222d22dd-d2d2-2dd2-222d-2dd2222ddddd_202112"), - // Type: to.Ptr("Microsoft.CostManagement/benefitUtilizationSummaries"), - // ID: to.Ptr("/providers/Microsoft.BillingBenefits/savingsPlanOrders/66cccc66-6ccc-6c66-666c-66cc6c6c66c6/savingsPlans/222d22dd-d2d2-2dd2-222d-2dd2222ddddd/providers/Microsoft.CostManagement/benefitUtilizationSummaries/66cccc66-6ccc-6c66-666c-66cc6c6c66c6_222d22dd-d2d2-2dd2-222d-2dd2222ddddd_202112"), - // Kind: to.Ptr(armcostmanagement.BenefitKindSavingsPlan), - // Properties: &armcostmanagement.SavingsPlanUtilizationSummaryProperties{ - // ArmSKUName: to.Ptr("Compute_Savings_Plan"), - // BenefitID: to.Ptr("/providers/Microsoft.BillingBenefits/savingsPlanOrders/66cccc66-6ccc-6c66-666c-66cc6c6c66c6/savingsPlans/222d22dd-d2d2-2dd2-222d-2dd2222ddddd"), - // BenefitOrderID: to.Ptr("/providers/Microsoft.BillingBenefits/savingsPlanOrders/66cccc66-6ccc-6c66-666c-66cc6c6c66c6"), - // BenefitType: to.Ptr(armcostmanagement.BenefitKindSavingsPlan), - // UsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T00:00:00.000Z"); return t}()), - // AvgUtilizationPercentage: to.Ptr[float64](80), - // MaxUtilizationPercentage: to.Ptr[float64](90), - // MinUtilizationPercentage: to.Ptr[float64](70), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/budgets_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/budgets_client.go new file mode 100644 index 000000000000..b513607a6056 --- /dev/null +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/budgets_client.go @@ -0,0 +1,443 @@ +//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 armcostmanagement + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// BudgetsClient contains the methods for the Budgets group. +// Don't use this type directly, use NewBudgetsClient() instead. +type BudgetsClient struct { + internal *arm.Client +} + +// NewBudgetsClient creates a new instance of BudgetsClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewBudgetsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*BudgetsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &BudgetsClient{ + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - The operation to create or update a budget. You can optionally provide an eTag if desired as a form of +// concurrency control. To obtain the latest eTag for a given budget, perform a get operation prior +// to your put operation. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +// +// - scope - The scope associated with budget operations. +// Supported scopes for CategoryType: Cost +// Azure RBAC Scopes: +// +// - '/subscriptions/{subscriptionId}/' for subscription scope +// +// - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope +// +// - '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope +// +// EA (Enterprise Agreement) Scopes: +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount +// scope +// +// MCA (Modern Customer Agreement) Scopes: +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile +// scope +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' +// for invoiceSection scope +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' for customer scope (CSP only) +// +// Supported scopes for CategoryType: ReservationUtilization +// +// EA (Enterprise Agreement) Scopes: +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account Scope +// +// MCA (Modern Customer Agreement) Scopes: +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile +// scope (non-CSP only) +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' for customer scope (CSP only) +// +// - budgetName - Budget Name. +// +// - parameters - Parameters supplied to the Create Budget operation. +// +// - options - BudgetsClientCreateOrUpdateOptions contains the optional parameters for the BudgetsClient.CreateOrUpdate method. +func (client *BudgetsClient) CreateOrUpdate(ctx context.Context, scope string, budgetName string, parameters Budget, options *BudgetsClientCreateOrUpdateOptions) (BudgetsClientCreateOrUpdateResponse, error) { + var err error + const operationName = "BudgetsClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, scope, budgetName, parameters, options) + if err != nil { + return BudgetsClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return BudgetsClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return BudgetsClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *BudgetsClient) createOrUpdateCreateRequest(ctx context.Context, scope string, budgetName string, parameters Budget, options *BudgetsClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/{scope}/providers/Microsoft.CostManagement/budgets/{budgetName}" + urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) + if budgetName == "" { + return nil, errors.New("parameter budgetName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{budgetName}", url.PathEscape(budgetName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *BudgetsClient) createOrUpdateHandleResponse(resp *http.Response) (BudgetsClientCreateOrUpdateResponse, error) { + result := BudgetsClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Budget); err != nil { + return BudgetsClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - The operation to delete a budget. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +// +// - scope - The scope associated with budget operations. +// Supported scopes for CategoryType: Cost +// Azure RBAC Scopes: +// +// - '/subscriptions/{subscriptionId}/' for subscription scope +// +// - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope +// +// - '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope +// +// EA (Enterprise Agreement) Scopes: +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount +// scope +// +// MCA (Modern Customer Agreement) Scopes: +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile +// scope +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' +// for invoiceSection scope +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' for customer scope (CSP only) +// +// Supported scopes for CategoryType: ReservationUtilization +// +// EA (Enterprise Agreement) Scopes: +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account Scope +// +// MCA (Modern Customer Agreement) Scopes: +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile +// scope (non-CSP only) +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' for customer scope (CSP only) +// +// - budgetName - Budget Name. +// +// - options - BudgetsClientDeleteOptions contains the optional parameters for the BudgetsClient.Delete method. +func (client *BudgetsClient) Delete(ctx context.Context, scope string, budgetName string, options *BudgetsClientDeleteOptions) (BudgetsClientDeleteResponse, error) { + var err error + const operationName = "BudgetsClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, scope, budgetName, options) + if err != nil { + return BudgetsClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return BudgetsClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return BudgetsClientDeleteResponse{}, err + } + return BudgetsClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *BudgetsClient) deleteCreateRequest(ctx context.Context, scope string, budgetName string, options *BudgetsClientDeleteOptions) (*policy.Request, error) { + urlPath := "/{scope}/providers/Microsoft.CostManagement/budgets/{budgetName}" + urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) + if budgetName == "" { + return nil, errors.New("parameter budgetName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{budgetName}", url.PathEscape(budgetName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets the budget for the scope by budget name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +// +// - scope - The scope associated with budget operations. +// Supported scopes for CategoryType: Cost +// Azure RBAC Scopes: +// +// - '/subscriptions/{subscriptionId}/' for subscription scope +// +// - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope +// +// - '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope +// +// EA (Enterprise Agreement) Scopes: +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount +// scope +// +// MCA (Modern Customer Agreement) Scopes: +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile +// scope +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' +// for invoiceSection scope +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' for customer scope (CSP only) +// +// Supported scopes for CategoryType: ReservationUtilization +// +// EA (Enterprise Agreement) Scopes: +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account Scope +// +// MCA (Modern Customer Agreement) Scopes: +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile +// scope (non-CSP only) +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' for customer scope (CSP only) +// +// - budgetName - Budget Name. +// +// - options - BudgetsClientGetOptions contains the optional parameters for the BudgetsClient.Get method. +func (client *BudgetsClient) Get(ctx context.Context, scope string, budgetName string, options *BudgetsClientGetOptions) (BudgetsClientGetResponse, error) { + var err error + const operationName = "BudgetsClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, scope, budgetName, options) + if err != nil { + return BudgetsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return BudgetsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return BudgetsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *BudgetsClient) getCreateRequest(ctx context.Context, scope string, budgetName string, options *BudgetsClientGetOptions) (*policy.Request, error) { + urlPath := "/{scope}/providers/Microsoft.CostManagement/budgets/{budgetName}" + urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) + if budgetName == "" { + return nil, errors.New("parameter budgetName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{budgetName}", url.PathEscape(budgetName)) + 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", "2023-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *BudgetsClient) getHandleResponse(resp *http.Response) (BudgetsClientGetResponse, error) { + result := BudgetsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Budget); err != nil { + return BudgetsClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Lists all budgets for the defined scope. +// +// Generated from API version 2023-11-01 +// +// - scope - The scope associated with budget operations. +// Supported scopes for CategoryType: Cost +// Azure RBAC Scopes: +// +// - '/subscriptions/{subscriptionId}/' for subscription scope +// +// - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope +// +// - '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope +// +// EA (Enterprise Agreement) Scopes: +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount +// scope +// +// MCA (Modern Customer Agreement) Scopes: +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile +// scope +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' +// for invoiceSection scope +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' for customer scope (CSP only) +// +// Supported scopes for CategoryType: ReservationUtilization +// +// EA (Enterprise Agreement) Scopes: +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account Scope +// +// MCA (Modern Customer Agreement) Scopes: +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile +// scope (non-CSP only) +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' for customer scope (CSP only) +// +// - options - BudgetsClientListOptions contains the optional parameters for the BudgetsClient.NewListPager method. +func (client *BudgetsClient) NewListPager(scope string, options *BudgetsClientListOptions) *runtime.Pager[BudgetsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[BudgetsClientListResponse]{ + More: func(page BudgetsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *BudgetsClientListResponse) (BudgetsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "BudgetsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, scope, options) + }, nil) + if err != nil { + return BudgetsClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *BudgetsClient) listCreateRequest(ctx context.Context, scope string, options *BudgetsClientListOptions) (*policy.Request, error) { + urlPath := "/{scope}/providers/Microsoft.CostManagement/budgets" + urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + reqQP.Set("api-version", "2023-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *BudgetsClient) listHandleResponse(resp *http.Response) (BudgetsClientListResponse, error) { + result := BudgetsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.BudgetsListResult); err != nil { + return BudgetsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/client_factory.go b/sdk/resourcemanager/costmanagement/armcostmanagement/client_factory.go index a4d60d2f18f1..e332d4a69a2c 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/client_factory.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/client_factory.go @@ -16,8 +16,7 @@ import ( // ClientFactory is a client factory used to create any client in this module. // Don't use this type directly, use NewClientFactory instead. type ClientFactory struct { - credential azcore.TokenCredential - options *arm.ClientOptions + internal *arm.Client } // NewClientFactory creates a new instance of ClientFactory with the specified values. @@ -25,108 +24,151 @@ type ClientFactory struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewClientFactory(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{ - credential: credential, - options: options.Clone(), + internal: internal, }, nil } // NewAlertsClient creates a new instance of AlertsClient. func (c *ClientFactory) NewAlertsClient() *AlertsClient { - subClient, _ := NewAlertsClient(c.credential, c.options) - return subClient + return &AlertsClient{ + internal: c.internal, + } } // NewBenefitRecommendationsClient creates a new instance of BenefitRecommendationsClient. func (c *ClientFactory) NewBenefitRecommendationsClient() *BenefitRecommendationsClient { - subClient, _ := NewBenefitRecommendationsClient(c.credential, c.options) - return subClient + return &BenefitRecommendationsClient{ + internal: c.internal, + } } // NewBenefitUtilizationSummariesClient creates a new instance of BenefitUtilizationSummariesClient. func (c *ClientFactory) NewBenefitUtilizationSummariesClient() *BenefitUtilizationSummariesClient { - subClient, _ := NewBenefitUtilizationSummariesClient(c.credential, c.options) - return subClient + return &BenefitUtilizationSummariesClient{ + internal: c.internal, + } +} + +// NewBudgetsClient creates a new instance of BudgetsClient. +func (c *ClientFactory) NewBudgetsClient() *BudgetsClient { + return &BudgetsClient{ + internal: c.internal, + } +} + +// NewCostAllocationRulesClient creates a new instance of CostAllocationRulesClient. +func (c *ClientFactory) NewCostAllocationRulesClient() *CostAllocationRulesClient { + return &CostAllocationRulesClient{ + internal: c.internal, + } } // NewDimensionsClient creates a new instance of DimensionsClient. func (c *ClientFactory) NewDimensionsClient() *DimensionsClient { - subClient, _ := NewDimensionsClient(c.credential, c.options) - return subClient + return &DimensionsClient{ + internal: c.internal, + } } // NewExportsClient creates a new instance of ExportsClient. func (c *ClientFactory) NewExportsClient() *ExportsClient { - subClient, _ := NewExportsClient(c.credential, c.options) - return subClient + return &ExportsClient{ + internal: c.internal, + } } // NewForecastClient creates a new instance of ForecastClient. func (c *ClientFactory) NewForecastClient() *ForecastClient { - subClient, _ := NewForecastClient(c.credential, c.options) - return subClient + return &ForecastClient{ + internal: c.internal, + } +} + +// NewGenerateBenefitUtilizationSummariesReportClient creates a new instance of GenerateBenefitUtilizationSummariesReportClient. +func (c *ClientFactory) NewGenerateBenefitUtilizationSummariesReportClient() *GenerateBenefitUtilizationSummariesReportClient { + return &GenerateBenefitUtilizationSummariesReportClient{ + internal: c.internal, + } } // NewGenerateCostDetailsReportClient creates a new instance of GenerateCostDetailsReportClient. func (c *ClientFactory) NewGenerateCostDetailsReportClient() *GenerateCostDetailsReportClient { - subClient, _ := NewGenerateCostDetailsReportClient(c.credential, c.options) - return subClient + return &GenerateCostDetailsReportClient{ + internal: c.internal, + } } // NewGenerateDetailedCostReportClient creates a new instance of GenerateDetailedCostReportClient. func (c *ClientFactory) NewGenerateDetailedCostReportClient() *GenerateDetailedCostReportClient { - subClient, _ := NewGenerateDetailedCostReportClient(c.credential, c.options) - return subClient + return &GenerateDetailedCostReportClient{ + internal: c.internal, + } } // NewGenerateDetailedCostReportOperationResultsClient creates a new instance of GenerateDetailedCostReportOperationResultsClient. func (c *ClientFactory) NewGenerateDetailedCostReportOperationResultsClient() *GenerateDetailedCostReportOperationResultsClient { - subClient, _ := NewGenerateDetailedCostReportOperationResultsClient(c.credential, c.options) - return subClient + return &GenerateDetailedCostReportOperationResultsClient{ + internal: c.internal, + } } // NewGenerateDetailedCostReportOperationStatusClient creates a new instance of GenerateDetailedCostReportOperationStatusClient. func (c *ClientFactory) NewGenerateDetailedCostReportOperationStatusClient() *GenerateDetailedCostReportOperationStatusClient { - subClient, _ := NewGenerateDetailedCostReportOperationStatusClient(c.credential, c.options) - return subClient + return &GenerateDetailedCostReportOperationStatusClient{ + internal: c.internal, + } } // NewGenerateReservationDetailsReportClient creates a new instance of GenerateReservationDetailsReportClient. func (c *ClientFactory) NewGenerateReservationDetailsReportClient() *GenerateReservationDetailsReportClient { - subClient, _ := NewGenerateReservationDetailsReportClient(c.credential, c.options) - return subClient + return &GenerateReservationDetailsReportClient{ + 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.credential, c.options) - return subClient + return &PriceSheetClient{ + internal: c.internal, + } } // NewQueryClient creates a new instance of QueryClient. func (c *ClientFactory) NewQueryClient() *QueryClient { - subClient, _ := NewQueryClient(c.credential, c.options) - return subClient + return &QueryClient{ + internal: c.internal, + } } // NewScheduledActionsClient creates a new instance of ScheduledActionsClient. func (c *ClientFactory) NewScheduledActionsClient() *ScheduledActionsClient { - subClient, _ := NewScheduledActionsClient(c.credential, c.options) - return subClient + return &ScheduledActionsClient{ + internal: c.internal, + } +} + +// NewSettingsClient creates a new instance of SettingsClient. +func (c *ClientFactory) NewSettingsClient() *SettingsClient { + return &SettingsClient{ + internal: c.internal, + } } // NewViewsClient creates a new instance of ViewsClient. func (c *ClientFactory) NewViewsClient() *ViewsClient { - subClient, _ := NewViewsClient(c.credential, c.options) - return subClient + return &ViewsClient{ + internal: c.internal, + } } diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/constants.go b/sdk/resourcemanager/costmanagement/armcostmanagement/constants.go index 04c9be366ce6..f12febcc948a 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/constants.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/constants.go @@ -10,7 +10,7 @@ package armcostmanagement const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement" - moduleVersion = "v2.1.0" + moduleVersion = "v3.0.0" ) // AccumulatedType - Show costs accumulated over time. @@ -238,6 +238,116 @@ func PossibleBenefitKindValues() []BenefitKind { } } +// BenefitUtilizationSummaryReportSchema - The CSV file from the reportUrl and secondaryReportUrl blob link will consist of +// the following columns of benefit utilization data. UtilizedPercentage will be 0 for savings plans reports and non data +// bricks reservations. Utilization percentages will be 0 for data bricks reservations. +type BenefitUtilizationSummaryReportSchema string + +const ( + BenefitUtilizationSummaryReportSchemaAvgUtilizationPercentage BenefitUtilizationSummaryReportSchema = "AvgUtilizationPercentage" + BenefitUtilizationSummaryReportSchemaBenefitID BenefitUtilizationSummaryReportSchema = "BenefitId" + BenefitUtilizationSummaryReportSchemaBenefitOrderID BenefitUtilizationSummaryReportSchema = "BenefitOrderId" + BenefitUtilizationSummaryReportSchemaBenefitType BenefitUtilizationSummaryReportSchema = "BenefitType" + BenefitUtilizationSummaryReportSchemaKind BenefitUtilizationSummaryReportSchema = "Kind" + BenefitUtilizationSummaryReportSchemaMaxUtilizationPercentage BenefitUtilizationSummaryReportSchema = "MaxUtilizationPercentage" + BenefitUtilizationSummaryReportSchemaMinUtilizationPercentage BenefitUtilizationSummaryReportSchema = "MinUtilizationPercentage" + BenefitUtilizationSummaryReportSchemaUsageDate BenefitUtilizationSummaryReportSchema = "UsageDate" + BenefitUtilizationSummaryReportSchemaUtilizedPercentage BenefitUtilizationSummaryReportSchema = "UtilizedPercentage" +) + +// PossibleBenefitUtilizationSummaryReportSchemaValues returns the possible values for the BenefitUtilizationSummaryReportSchema const type. +func PossibleBenefitUtilizationSummaryReportSchemaValues() []BenefitUtilizationSummaryReportSchema { + return []BenefitUtilizationSummaryReportSchema{ + BenefitUtilizationSummaryReportSchemaAvgUtilizationPercentage, + BenefitUtilizationSummaryReportSchemaBenefitID, + BenefitUtilizationSummaryReportSchemaBenefitOrderID, + BenefitUtilizationSummaryReportSchemaBenefitType, + BenefitUtilizationSummaryReportSchemaKind, + BenefitUtilizationSummaryReportSchemaMaxUtilizationPercentage, + BenefitUtilizationSummaryReportSchemaMinUtilizationPercentage, + BenefitUtilizationSummaryReportSchemaUsageDate, + BenefitUtilizationSummaryReportSchemaUtilizedPercentage, + } +} + +// BudgetNotificationOperatorType - The comparison operator. +// Supported for CategoryType(s): Cost, ReservationUtilization. +// Supported operators for CategoryType: Cost +// * GreaterThan +// +// * GreaterThanOrEqualTo +// +// Supported operators for CategoryType: ReservationUtilization +// +// * LessThan +type BudgetNotificationOperatorType string + +const ( + // BudgetNotificationOperatorTypeEqualTo - Notification 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. + // Supported for CategoryType(s): Cost. + BudgetNotificationOperatorTypeEqualTo BudgetNotificationOperatorType = "EqualTo" + // BudgetNotificationOperatorTypeGreaterThan - Notification will be triggered if the evaluated cost is greater than the threshold + // value. Note: This is the recommended OperatorType while configuring Budget Alert. + // Supported for CategoryType(s): Cost. + BudgetNotificationOperatorTypeGreaterThan BudgetNotificationOperatorType = "GreaterThan" + // BudgetNotificationOperatorTypeGreaterThanOrEqualTo - Notification will be triggered if the evaluated cost is greater than + // or equal to the threshold value. + // Supported for CategoryType(s): Cost. + BudgetNotificationOperatorTypeGreaterThanOrEqualTo BudgetNotificationOperatorType = "GreaterThanOrEqualTo" + // BudgetNotificationOperatorTypeLessThan - Notification will be triggered if any Reservations in the scope of the Reservation + // Utilization Alert Rule have a utilization less than the threshold percentage. + // Supported for CategoryType(s): ReservationUtilization. + BudgetNotificationOperatorTypeLessThan BudgetNotificationOperatorType = "LessThan" +) + +// PossibleBudgetNotificationOperatorTypeValues returns the possible values for the BudgetNotificationOperatorType const type. +func PossibleBudgetNotificationOperatorTypeValues() []BudgetNotificationOperatorType { + return []BudgetNotificationOperatorType{ + BudgetNotificationOperatorTypeEqualTo, + BudgetNotificationOperatorTypeGreaterThan, + BudgetNotificationOperatorTypeGreaterThanOrEqualTo, + BudgetNotificationOperatorTypeLessThan, + } +} + +// BudgetOperatorType - The operator to use for comparison. +type BudgetOperatorType string + +const ( + BudgetOperatorTypeIn BudgetOperatorType = "In" +) + +// PossibleBudgetOperatorTypeValues returns the possible values for the BudgetOperatorType const type. +func PossibleBudgetOperatorTypeValues() []BudgetOperatorType { + return []BudgetOperatorType{ + BudgetOperatorTypeIn, + } +} + +// CategoryType - The category of the budget. +// * 'Cost' defines a Budget. +// * 'ReservationUtilization' defines a Reservation Utilization Alert Rule. +type CategoryType string + +const ( + // CategoryTypeCost - A Budget that evaluates monetary cost of Azure resources against an amount, and alerts based on a configured + // notification threshold. + CategoryTypeCost CategoryType = "Cost" + // CategoryTypeReservationUtilization - An Alert Rule that evaluates the utilization percentage of Azure Reservations, and + // alerts based on a configured notification threshold. + CategoryTypeReservationUtilization CategoryType = "ReservationUtilization" +) + +// PossibleCategoryTypeValues returns the possible values for the CategoryType const type. +func PossibleCategoryTypeValues() []CategoryType { + return []CategoryType{ + CategoryTypeCost, + CategoryTypeReservationUtilization, + } +} + // ChartType - Chart type of the main view in Cost Analysis. Required. type ChartType string @@ -276,6 +386,40 @@ func PossibleCheckNameAvailabilityReasonValues() []CheckNameAvailabilityReason { } } +// CostAllocationPolicyType - Method to use for allocating cost. FixedProportion indicates that cost will be split based on +// specified percentage values. +type CostAllocationPolicyType string + +const ( + CostAllocationPolicyTypeFixedProportion CostAllocationPolicyType = "FixedProportion" +) + +// PossibleCostAllocationPolicyTypeValues returns the possible values for the CostAllocationPolicyType const type. +func PossibleCostAllocationPolicyTypeValues() []CostAllocationPolicyType { + return []CostAllocationPolicyType{ + CostAllocationPolicyTypeFixedProportion, + } +} + +// CostAllocationResourceType - Category of resource to use for allocation. +type CostAllocationResourceType string + +const ( + // CostAllocationResourceTypeDimension - Indicates an Azure dimension such as a subscription id or resource group name is + // being used for allocation. + CostAllocationResourceTypeDimension CostAllocationResourceType = "Dimension" + // CostAllocationResourceTypeTag - Allocates cost based on Azure Tag key value pairs. + CostAllocationResourceTypeTag CostAllocationResourceType = "Tag" +) + +// PossibleCostAllocationResourceTypeValues returns the possible values for the CostAllocationResourceType const type. +func PossibleCostAllocationResourceTypeValues() []CostAllocationResourceType { + return []CostAllocationResourceType{ + CostAllocationResourceTypeDimension, + CostAllocationResourceTypeTag, + } +} + // CostDetailsDataFormat - The data format of the report type CostDetailsDataFormat string @@ -350,6 +494,61 @@ func PossibleCreatedByTypeValues() []CreatedByType { } } +// CultureCode - Language in which the recipient will receive the notification, +// Supported for CategoryType(s): Cost, ReservationUtilization. +type CultureCode string + +const ( + CultureCodeCsCz CultureCode = "cs-cz" + CultureCodeDaDk CultureCode = "da-dk" + CultureCodeDeDe CultureCode = "de-de" + CultureCodeEnGb CultureCode = "en-gb" + CultureCodeEnUs CultureCode = "en-us" + CultureCodeEsEs CultureCode = "es-es" + CultureCodeFrFr CultureCode = "fr-fr" + CultureCodeHuHu CultureCode = "hu-hu" + CultureCodeItIt CultureCode = "it-it" + CultureCodeJaJp CultureCode = "ja-jp" + CultureCodeKoKr CultureCode = "ko-kr" + CultureCodeNbNo CultureCode = "nb-no" + CultureCodeNlNl CultureCode = "nl-nl" + CultureCodePlPl CultureCode = "pl-pl" + CultureCodePtBr CultureCode = "pt-br" + CultureCodePtPt CultureCode = "pt-pt" + CultureCodeRuRu CultureCode = "ru-ru" + CultureCodeSvSe CultureCode = "sv-se" + CultureCodeTrTr CultureCode = "tr-tr" + CultureCodeZhCn CultureCode = "zh-cn" + CultureCodeZhTw CultureCode = "zh-tw" +) + +// PossibleCultureCodeValues returns the possible values for the CultureCode const type. +func PossibleCultureCodeValues() []CultureCode { + return []CultureCode{ + CultureCodeCsCz, + CultureCodeDaDk, + CultureCodeDeDe, + CultureCodeEnGb, + CultureCodeEnUs, + CultureCodeEsEs, + CultureCodeFrFr, + CultureCodeHuHu, + CultureCodeItIt, + CultureCodeJaJp, + CultureCodeKoKr, + CultureCodeNbNo, + CultureCodeNlNl, + CultureCodePlPl, + CultureCodePtBr, + CultureCodePtPt, + CultureCodeRuRu, + CultureCodeSvSe, + CultureCodeTrTr, + CultureCodeZhCn, + CultureCodeZhTw, + } +} + // DaysOfWeek - Days of Week. type DaysOfWeek string @@ -418,7 +617,8 @@ func PossibleExecutionTypeValues() []ExecutionType { } } -// ExportType - The type of the query. +// ExportType - The type of the export. Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that +// do not yet provide data for charges or amortization for service reservations. type ExportType string const ( @@ -525,6 +725,31 @@ func PossibleFormatTypeValues() []FormatType { } } +// Frequency - Frequency of a notification. Represents how long the notification will be silent after triggering an alert +// for a threshold breach. If not specified, the frequency will be set by default based on the +// timeGrain (Weekly when timeGrain: Last7Days, Monthly when timeGrain: Last30Days). +// Supported for CategoryType(s): ReservationUtilization. +type Frequency string + +const ( + // FrequencyDaily - After the threshold breaches and an Alert is fired, no further alerts will be sent until the next calendar + // day. + FrequencyDaily Frequency = "Daily" + // FrequencyMonthly - After the threshold breaches and an Alert is fired, no further alerts will be sent for 30 calendar days. + FrequencyMonthly Frequency = "Monthly" + // FrequencyWeekly - After the threshold breaches and an Alert is fired, no further alerts will be sent for 7 calendar days. + FrequencyWeekly Frequency = "Weekly" +) + +// PossibleFrequencyValues returns the possible values for the Frequency const type. +func PossibleFrequencyValues() []Frequency { + return []Frequency{ + FrequencyDaily, + FrequencyMonthly, + FrequencyWeekly, + } +} + // FunctionName - The name of the column to aggregate. type FunctionName string @@ -616,7 +841,7 @@ func PossibleGrainParameterValues() []GrainParameter { } } -// GranularityType - The granularity of rows in the forecast. +// GranularityType - The granularity of rows in the export. Currently only 'Daily' is supported. type GranularityType string const ( @@ -685,10 +910,11 @@ func PossibleMetricTypeValues() []MetricType { } } -// OperationStatusType - The status of the long running operation. +// OperationStatusType - Enum representing the status of an async operation. type OperationStatusType string const ( + OperationStatusTypeComplete OperationStatusType = "Complete" OperationStatusTypeCompleted OperationStatusType = "Completed" OperationStatusTypeFailed OperationStatusType = "Failed" OperationStatusTypeRunning OperationStatusType = "Running" @@ -697,6 +923,7 @@ const ( // PossibleOperationStatusTypeValues returns the possible values for the OperationStatusType const type. func PossibleOperationStatusTypeValues() []OperationStatusType { return []OperationStatusType{ + OperationStatusTypeComplete, OperationStatusTypeCompleted, OperationStatusTypeFailed, OperationStatusTypeRunning, @@ -786,6 +1013,24 @@ func PossibleQueryOperatorTypeValues() []QueryOperatorType { } } +// Reason - The reason this name is not available. +type Reason string + +const ( + ReasonAlreadyExists Reason = "AlreadyExists" + ReasonInvalid Reason = "Invalid" + ReasonValid Reason = "Valid" +) + +// PossibleReasonValues returns the possible values for the Reason const type. +func PossibleReasonValues() []Reason { + return []Reason{ + ReasonAlreadyExists, + ReasonInvalid, + ReasonValid, + } +} + // RecurrenceType - The schedule recurrence. type RecurrenceType string @@ -935,6 +1180,28 @@ func PossibleReservationReportSchemaValues() []ReservationReportSchema { } } +// RuleStatus - Current status of the rule. +type RuleStatus string + +const ( + // RuleStatusActive - Rule is saved and impacting cost allocation. + RuleStatusActive RuleStatus = "Active" + // RuleStatusNotActive - Rule is saved but not used to allocate costs. + RuleStatusNotActive RuleStatus = "NotActive" + // RuleStatusProcessing - Rule is saved and cost allocation is being updated. Readonly value that cannot be submitted in a + // put request. + RuleStatusProcessing RuleStatus = "Processing" +) + +// PossibleRuleStatusValues returns the possible values for the RuleStatus const type. +func PossibleRuleStatusValues() []RuleStatus { + return []RuleStatus{ + RuleStatusActive, + RuleStatusNotActive, + RuleStatusProcessing, + } +} + // ScheduleFrequency - Frequency of the schedule. type ScheduleFrequency string @@ -1014,6 +1281,35 @@ func PossibleScopeValues() []Scope { } } +type SettingType string + +const ( + // SettingTypeTaginheritance - This setting applies billing profile, invoice section, subscription and resource group tags + // to current month's usage data of child resources. + SettingTypeTaginheritance SettingType = "taginheritance" +) + +// PossibleSettingTypeValues returns the possible values for the SettingType const type. +func PossibleSettingTypeValues() []SettingType { + return []SettingType{ + SettingTypeTaginheritance, + } +} + +// SettingsKind - Specifies the kind of settings. +type SettingsKind string + +const ( + SettingsKindTaginheritance SettingsKind = "taginheritance" +) + +// PossibleSettingsKindValues returns the possible values for the SettingsKind const type. +func PossibleSettingsKindValues() []SettingsKind { + return []SettingsKind{ + SettingsKindTaginheritance, + } +} + // StatusType - The status of the export's schedule. If 'Inactive', the export's schedule is paused. type StatusType string @@ -1030,6 +1326,22 @@ func PossibleStatusTypeValues() []StatusType { } } +// SystemAssignedServiceIdentityType - Type of managed service identity (either system assigned, or none). +type SystemAssignedServiceIdentityType string + +const ( + SystemAssignedServiceIdentityTypeNone SystemAssignedServiceIdentityType = "None" + SystemAssignedServiceIdentityTypeSystemAssigned SystemAssignedServiceIdentityType = "SystemAssigned" +) + +// PossibleSystemAssignedServiceIdentityTypeValues returns the possible values for the SystemAssignedServiceIdentityType const type. +func PossibleSystemAssignedServiceIdentityTypeValues() []SystemAssignedServiceIdentityType { + return []SystemAssignedServiceIdentityType{ + SystemAssignedServiceIdentityTypeNone, + SystemAssignedServiceIdentityTypeSystemAssigned, + } +} + // Term - Grain which corresponds to value. type Term string @@ -1048,7 +1360,96 @@ func PossibleTermValues() []Term { } } -// TimeframeType - The time frame for pulling data for the query. If custom, then a specific time period must be provided. +// ThresholdType - The type of threshold. +// Supported for CategoryType(s): Cost. +type ThresholdType string + +const ( + // 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" +) + +// PossibleThresholdTypeValues returns the possible values for the ThresholdType const type. +func PossibleThresholdTypeValues() []ThresholdType { + return []ThresholdType{ + ThresholdTypeActual, + ThresholdTypeForecasted, + } +} + +// TimeGrainType - The time covered by a budget. Tracking of the amount will be reset based on the time grain. +// Supported for CategoryType(s): Cost, ReservationUtilization. +// Supported timeGrainTypes for CategoryType: Cost +// * Monthly +// +// * Quarterly +// +// * Annually +// +// * BillingMonth* +// +// * BillingQuarter* +// +// * BillingAnnual* +// +// *only supported for Web Direct customers. +// +// Supported timeGrainTypes for CategoryType: ReservationUtilization +// +// * Last7Days +// +// * Last30Days +// +// Required for CategoryType(s): Cost, ReservationUtilization. +type TimeGrainType string + +const ( + // TimeGrainTypeAnnually - The budget will track costs in the current calendar year against the amount. + // Supported for CategoryType: Cost only. + TimeGrainTypeAnnually TimeGrainType = "Annually" + // TimeGrainTypeBillingAnnual - The budget will track costs in the current billing year against the amount. + // Supported for CategoryType: Cost and Web Direct customers only. + TimeGrainTypeBillingAnnual TimeGrainType = "BillingAnnual" + // TimeGrainTypeBillingMonth - The budget will track costs in the current billing month against the amount. + // Supported for CategoryType: Cost and Web Direct customers only. + TimeGrainTypeBillingMonth TimeGrainType = "BillingMonth" + // TimeGrainTypeBillingQuarter - The budget will track costs in the current billing quarter against the amount. + // Supported for CategoryType: Cost and Web Direct customers only. + TimeGrainTypeBillingQuarter TimeGrainType = "BillingQuarter" + // TimeGrainTypeLast30Days - The Reservation Utilization Alert Rule will evaluate reservations based on their 30-Day utilization + // percentage. + // Supported for CategoryType: ReservationUtilization only. + TimeGrainTypeLast30Days TimeGrainType = "Last30Days" + // TimeGrainTypeLast7Days - The Reservation Utilization Alert Rule will evaluate reservations based on their 7-Day utilization + // percentage. + // Supported for CategoryType: ReservationUtilization only. + TimeGrainTypeLast7Days TimeGrainType = "Last7Days" + // TimeGrainTypeMonthly - The budget will track costs in the current calendar month against the amount. + // Supported for CategoryType: Cost only. + TimeGrainTypeMonthly TimeGrainType = "Monthly" + // TimeGrainTypeQuarterly - The budget will track costs in the current calendar quarter against the amount. + // Supported for CategoryType: Cost only. + TimeGrainTypeQuarterly TimeGrainType = "Quarterly" +) + +// PossibleTimeGrainTypeValues returns the possible values for the TimeGrainType const type. +func PossibleTimeGrainTypeValues() []TimeGrainType { + return []TimeGrainType{ + TimeGrainTypeAnnually, + TimeGrainTypeBillingAnnual, + TimeGrainTypeBillingMonth, + TimeGrainTypeBillingQuarter, + TimeGrainTypeLast30Days, + TimeGrainTypeLast7Days, + TimeGrainTypeMonthly, + TimeGrainTypeQuarterly, + } +} + +// TimeframeType - The time frame for pulling data for the export. If custom, then a specific time period must be provided. type TimeframeType string const ( diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/costallocationrules_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/costallocationrules_client.go new file mode 100644 index 000000000000..3cf28456e946 --- /dev/null +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/costallocationrules_client.go @@ -0,0 +1,337 @@ +//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 armcostmanagement + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// CostAllocationRulesClient contains the methods for the CostAllocationRules group. +// Don't use this type directly, use NewCostAllocationRulesClient() instead. +type CostAllocationRulesClient struct { + internal *arm.Client +} + +// NewCostAllocationRulesClient creates a new instance of CostAllocationRulesClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewCostAllocationRulesClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*CostAllocationRulesClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &CostAllocationRulesClient{ + internal: cl, + } + return client, nil +} + +// CheckNameAvailability - Checks availability and correctness of a name for a cost allocation rule +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +// - billingAccountID - BillingAccount ID +// - costAllocationRuleCheckNameAvailabilityRequest - Cost allocation rule to be created or updated +// - options - CostAllocationRulesClientCheckNameAvailabilityOptions contains the optional parameters for the CostAllocationRulesClient.CheckNameAvailability +// method. +func (client *CostAllocationRulesClient) CheckNameAvailability(ctx context.Context, billingAccountID string, costAllocationRuleCheckNameAvailabilityRequest CostAllocationRuleCheckNameAvailabilityRequest, options *CostAllocationRulesClientCheckNameAvailabilityOptions) (CostAllocationRulesClientCheckNameAvailabilityResponse, error) { + var err error + const operationName = "CostAllocationRulesClient.CheckNameAvailability" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.checkNameAvailabilityCreateRequest(ctx, billingAccountID, costAllocationRuleCheckNameAvailabilityRequest, options) + if err != nil { + return CostAllocationRulesClientCheckNameAvailabilityResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return CostAllocationRulesClientCheckNameAvailabilityResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return CostAllocationRulesClientCheckNameAvailabilityResponse{}, err + } + resp, err := client.checkNameAvailabilityHandleResponse(httpResp) + return resp, err +} + +// checkNameAvailabilityCreateRequest creates the CheckNameAvailability request. +func (client *CostAllocationRulesClient) checkNameAvailabilityCreateRequest(ctx context.Context, billingAccountID string, costAllocationRuleCheckNameAvailabilityRequest CostAllocationRuleCheckNameAvailabilityRequest, options *CostAllocationRulesClientCheckNameAvailabilityOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.CostManagement/costAllocationRules/checkNameAvailability" + if billingAccountID == "" { + return nil, errors.New("parameter billingAccountID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountId}", url.PathEscape(billingAccountID)) + 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", "2023-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, costAllocationRuleCheckNameAvailabilityRequest); err != nil { + return nil, err + } + return req, nil +} + +// checkNameAvailabilityHandleResponse handles the CheckNameAvailability response. +func (client *CostAllocationRulesClient) checkNameAvailabilityHandleResponse(resp *http.Response) (CostAllocationRulesClientCheckNameAvailabilityResponse, error) { + result := CostAllocationRulesClientCheckNameAvailabilityResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CostAllocationRuleCheckNameAvailabilityResponse); err != nil { + return CostAllocationRulesClientCheckNameAvailabilityResponse{}, err + } + return result, nil +} + +// CreateOrUpdate - Create/Update a rule to allocate cost between different resources within a billing account or enterprise +// enrollment. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +// - billingAccountID - BillingAccount ID +// - ruleName - Cost allocation rule name. The name cannot include spaces or any non alphanumeric characters other than '_' +// and '-'. The max length is 260 characters. +// - costAllocationRule - Cost allocation rule to be created or updated +// - options - CostAllocationRulesClientCreateOrUpdateOptions contains the optional parameters for the CostAllocationRulesClient.CreateOrUpdate +// method. +func (client *CostAllocationRulesClient) CreateOrUpdate(ctx context.Context, billingAccountID string, ruleName string, costAllocationRule CostAllocationRuleDefinition, options *CostAllocationRulesClientCreateOrUpdateOptions) (CostAllocationRulesClientCreateOrUpdateResponse, error) { + var err error + const operationName = "CostAllocationRulesClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, billingAccountID, ruleName, costAllocationRule, options) + if err != nil { + return CostAllocationRulesClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return CostAllocationRulesClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return CostAllocationRulesClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *CostAllocationRulesClient) createOrUpdateCreateRequest(ctx context.Context, billingAccountID string, ruleName string, costAllocationRule CostAllocationRuleDefinition, options *CostAllocationRulesClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.CostManagement/costAllocationRules/{ruleName}" + if billingAccountID == "" { + return nil, errors.New("parameter billingAccountID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountId}", url.PathEscape(billingAccountID)) + if ruleName == "" { + return nil, errors.New("parameter ruleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{ruleName}", url.PathEscape(ruleName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, costAllocationRule); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *CostAllocationRulesClient) createOrUpdateHandleResponse(resp *http.Response) (CostAllocationRulesClientCreateOrUpdateResponse, error) { + result := CostAllocationRulesClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CostAllocationRuleDefinition); err != nil { + return CostAllocationRulesClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Delete cost allocation rule for billing account or enterprise enrollment. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +// - billingAccountID - BillingAccount ID +// - ruleName - Cost allocation rule name. The name cannot include spaces or any non alphanumeric characters other than '_' +// and '-'. The max length is 260 characters. +// - options - CostAllocationRulesClientDeleteOptions contains the optional parameters for the CostAllocationRulesClient.Delete +// method. +func (client *CostAllocationRulesClient) Delete(ctx context.Context, billingAccountID string, ruleName string, options *CostAllocationRulesClientDeleteOptions) (CostAllocationRulesClientDeleteResponse, error) { + var err error + const operationName = "CostAllocationRulesClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, billingAccountID, ruleName, options) + if err != nil { + return CostAllocationRulesClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return CostAllocationRulesClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return CostAllocationRulesClientDeleteResponse{}, err + } + return CostAllocationRulesClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *CostAllocationRulesClient) deleteCreateRequest(ctx context.Context, billingAccountID string, ruleName string, options *CostAllocationRulesClientDeleteOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.CostManagement/costAllocationRules/{ruleName}" + if billingAccountID == "" { + return nil, errors.New("parameter billingAccountID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountId}", url.PathEscape(billingAccountID)) + if ruleName == "" { + return nil, errors.New("parameter ruleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{ruleName}", url.PathEscape(ruleName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get a cost allocation rule by rule name and billing account or enterprise enrollment. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +// - billingAccountID - BillingAccount ID +// - ruleName - Cost allocation rule name. The name cannot include spaces or any non alphanumeric characters other than '_' +// and '-'. The max length is 260 characters. +// - options - CostAllocationRulesClientGetOptions contains the optional parameters for the CostAllocationRulesClient.Get method. +func (client *CostAllocationRulesClient) Get(ctx context.Context, billingAccountID string, ruleName string, options *CostAllocationRulesClientGetOptions) (CostAllocationRulesClientGetResponse, error) { + var err error + const operationName = "CostAllocationRulesClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, billingAccountID, ruleName, options) + if err != nil { + return CostAllocationRulesClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return CostAllocationRulesClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return CostAllocationRulesClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *CostAllocationRulesClient) getCreateRequest(ctx context.Context, billingAccountID string, ruleName string, options *CostAllocationRulesClientGetOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.CostManagement/costAllocationRules/{ruleName}" + if billingAccountID == "" { + return nil, errors.New("parameter billingAccountID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountId}", url.PathEscape(billingAccountID)) + if ruleName == "" { + return nil, errors.New("parameter ruleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{ruleName}", url.PathEscape(ruleName)) + 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", "2023-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *CostAllocationRulesClient) getHandleResponse(resp *http.Response) (CostAllocationRulesClientGetResponse, error) { + result := CostAllocationRulesClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CostAllocationRuleDefinition); err != nil { + return CostAllocationRulesClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Get the list of all cost allocation rules for a billing account or enterprise enrollment. +// +// Generated from API version 2023-11-01 +// - billingAccountID - BillingAccount ID +// - options - CostAllocationRulesClientListOptions contains the optional parameters for the CostAllocationRulesClient.NewListPager +// method. +func (client *CostAllocationRulesClient) NewListPager(billingAccountID string, options *CostAllocationRulesClientListOptions) *runtime.Pager[CostAllocationRulesClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[CostAllocationRulesClientListResponse]{ + More: func(page CostAllocationRulesClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *CostAllocationRulesClientListResponse) (CostAllocationRulesClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "CostAllocationRulesClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, billingAccountID, options) + }, nil) + if err != nil { + return CostAllocationRulesClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *CostAllocationRulesClient) listCreateRequest(ctx context.Context, billingAccountID string, options *CostAllocationRulesClientListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.CostManagement/costAllocationRules" + if billingAccountID == "" { + return nil, errors.New("parameter billingAccountID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountId}", url.PathEscape(billingAccountID)) + 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", "2023-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *CostAllocationRulesClient) listHandleResponse(resp *http.Response) (CostAllocationRulesClientListResponse, error) { + result := CostAllocationRulesClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CostAllocationRuleList); err != nil { + return CostAllocationRulesClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/dimensions_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/dimensions_client.go index f2c2c622ab3a..534ab7f3b363 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/dimensions_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/dimensions_client.go @@ -43,7 +43,7 @@ func NewDimensionsClient(credential azcore.TokenCredential, options *arm.ClientO // NewByExternalCloudProviderTypePager - Lists the dimensions by the external cloud provider type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - externalCloudProviderType - The external cloud provider type associated with dimension/query operations. This includes // 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account. // - externalCloudProviderID - This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' for @@ -90,19 +90,19 @@ func (client *DimensionsClient) byExternalCloudProviderTypeCreateRequest(ctx con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") - if options != nil && options.Filter != nil { - reqQP.Set("$filter", *options.Filter) - } if options != nil && options.Expand != nil { reqQP.Set("$expand", *options.Expand) } + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } if options != nil && options.Skiptoken != nil { reqQP.Set("$skiptoken", *options.Skiptoken) } if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -119,7 +119,7 @@ func (client *DimensionsClient) byExternalCloudProviderTypeHandleResponse(resp * // NewListPager - Lists the dimensions by the defined scope. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - scope - The scope associated with dimension operations. This includes '/subscriptions/{subscriptionId}/' for subscription // scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for // resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, @@ -164,19 +164,19 @@ func (client *DimensionsClient) listCreateRequest(ctx context.Context, scope str return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") - if options != nil && options.Filter != nil { - reqQP.Set("$filter", *options.Filter) - } if options != nil && options.Expand != nil { reqQP.Set("$expand", *options.Expand) } + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } if options != nil && options.Skiptoken != nil { reqQP.Set("$skiptoken", *options.Skiptoken) } if options != nil && options.Top != nil { reqQP.Set("$top", strconv.FormatInt(int64(*options.Top), 10)) } + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/dimensions_client_example_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/dimensions_client_example_test.go deleted file mode 100644 index ab7c6414e353..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/dimensions_client_example_test.go +++ /dev/null @@ -1,1822 +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 armcostmanagement_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/costmanagement/armcostmanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BillingAccountDimensionsList.json -func ExampleDimensionsClient_NewListPager_billingAccountDimensionsListLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/100", &armcostmanagement.DimensionsClientListOptions{Filter: nil, - Expand: nil, - Skiptoken: nil, - Top: 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.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceGroup_2018-05-01_2018-05-31"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/100/providers/microsoft.CostManagement/dimensions_ResourceGroup_2018-05-01_2018-05-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource group"), - // Category: to.Ptr("ResourceGroup"), - // Data: []*string{ - // to.Ptr("thoroetrg01"), - // to.Ptr("default-notificationhubs-westus"), - // to.Ptr("jedikeyvaultrg"), - // to.Ptr("contosocodeflow8d4a"), - // to.Ptr("noobaa")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](377), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-31T07:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T07:00:00.000Z"); return t}()), - // }, - // }, - // { - // Name: to.Ptr("dimensions_ResourceType_2018-05-01_2018-05-31"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/100/providers/microsoft.CostManagement/dimensions_ResourceType_2018-05-01_2018-05-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource type"), - // Category: to.Ptr("ResourceType"), - // Data: []*string{ - // to.Ptr("thoroetrg01"), - // to.Ptr("default-notificationhubs-westus"), - // to.Ptr("jedikeyvaultrg"), - // to.Ptr("contosocodeflow8d4a"), - // to.Ptr("noobaa")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](37), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-31T07:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T07:00:00.000Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCABillingAccountDimensionsList.json -func ExampleDimensionsClient_NewListPager_billingAccountDimensionsListMca() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345:6789", &armcostmanagement.DimensionsClientListOptions{Filter: nil, - Expand: nil, - Skiptoken: nil, - Top: 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.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceGroup_2019-10-01_2019-10-31"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/providers/microsoft.CostManagement/dimensions_ResourceGroup_2019-10-01_2019-10-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource group"), - // Category: to.Ptr("ResourceGroup"), - // Data: []*string{ - // }, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](377), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-31T07:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-01T07:00:00.000Z"); return t}()), - // }, - // }, - // { - // Name: to.Ptr("dimensions_ResourceType_2019-10-01_2019-10-31"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/providers/microsoft.CostManagement/dimensions_ResourceType_2019-10-01_2019-10-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource type"), - // Category: to.Ptr("ResourceType"), - // Data: []*string{ - // }, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](37), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-31T07:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-01T07:00:00.000Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BillingAccountDimensionsListExpandAndTop.json -func ExampleDimensionsClient_NewListPager_billingAccountDimensionsListExpandAndTopLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/100", &armcostmanagement.DimensionsClientListOptions{Filter: nil, - Expand: to.Ptr("properties/data"), - Skiptoken: nil, - Top: to.Ptr[int32](5), - }) - 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.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceGroup_2018-05-01_2018-05-31_5"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/100/providers/microsoft.CostManagement/dimensions_ResourceGroup_2018-05-01_2018-05-31_5"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource group"), - // Category: to.Ptr("ResourceGroup"), - // Data: []*string{ - // to.Ptr("thoroetrg01"), - // to.Ptr("default-notificationhubs-westus"), - // to.Ptr("jedikeyvaultrg"), - // to.Ptr("contosocodeflow8d4a"), - // to.Ptr("noobaa")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](377), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-31T07:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T07:00:00.000Z"); return t}()), - // }, - // }, - // { - // Name: to.Ptr("dimensions_ResourceType_2018-05-01_2018-05-31_5"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/100/providers/microsoft.CostManagement/dimensions_ResourceType_2018-05-01_2018-05-31_5"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource type"), - // Category: to.Ptr("ResourceType"), - // Data: []*string{ - // to.Ptr("microsoft.automation/automationaccounts"), - // to.Ptr("microsoft.databricks/workspaces"), - // to.Ptr("microsoft.dbformysql/servers"), - // to.Ptr("microsoft.containerregistry/registries"), - // to.Ptr("microsoft.search/searchservices")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](37), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-31T07:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T07:00:00.000Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCABillingAccountDimensionsListExpandAndTop.json -func ExampleDimensionsClient_NewListPager_billingAccountDimensionsListExpandAndTopMca() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345:6789", &armcostmanagement.DimensionsClientListOptions{Filter: nil, - Expand: to.Ptr("properties/data"), - Skiptoken: nil, - Top: to.Ptr[int32](5), - }) - 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.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceGroup_2019-10-01_2019-10-31"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/providers/microsoft.CostManagement/dimensions_ResourceGroup_2019-10-01_2019-10-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource group"), - // Category: to.Ptr("ResourceGroup"), - // Data: []*string{ - // to.Ptr("thoroetrg01"), - // to.Ptr("default-notificationhubs-westus"), - // to.Ptr("jedikeyvaultrg"), - // to.Ptr("contosocodeflow8d4a"), - // to.Ptr("noobaa")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](377), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-31T07:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-01T07:00:00.000Z"); return t}()), - // }, - // }, - // { - // Name: to.Ptr("dimensions_ResourceType_2019-10-01_2019-10-31"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/providers/microsoft.CostManagement/dimensions_ResourceType_2019-10-01_2019-10-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource type"), - // Category: to.Ptr("ResourceType"), - // Data: []*string{ - // to.Ptr("microsoft.automation/automationaccounts"), - // to.Ptr("microsoft.databricks/workspaces"), - // to.Ptr("microsoft.dbformysql/servers"), - // to.Ptr("microsoft.containerregistry/registries"), - // to.Ptr("microsoft.search/searchservices")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](37), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-31T07:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-01T07:00:00.000Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BillingAccountDimensionsListWithFilter.json -func ExampleDimensionsClient_NewListPager_billingAccountDimensionsListWithFilterLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/100", &armcostmanagement.DimensionsClientListOptions{Filter: to.Ptr("properties/category eq 'resourceId'"), - Expand: to.Ptr("properties/data"), - Skiptoken: nil, - Top: to.Ptr[int32](5), - }) - 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.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceId_2018-05-01_2018-05-31_5"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/100/providers/microsoft.CostManagement/dimensions_ResourceId_2018-05-01_2018-05-31_5"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource Id"), - // Category: to.Ptr("ResourceId"), - // Data: []*string{ - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/system.orlando/providers/microsoft.storage/storageaccounts/urphealthaccount"), - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/system.orlando/providers/microsoft.storage/storageaccounts/srphytenaccount"), - // to.Ptr("/subscriptions/67e24f6b-1ec2-4c90-993a-dc2d25b00b6c/resourcegroups/defaultresourcegroup-eus/providers/microsoft.operationalinsights/workspaces/defaultworkspace-67e24f6b-1ec2-4c90-993a-dc2d25b00b6c-eus"), - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg-sql-ha/providers/microsoft.compute/virtualmachines/sql-4qqp1"), - // to.Ptr("/subscriptions/a98d6dc5-eb8f-46cf-8938-f1fb08f03706/resourcegroups/databricks-rg-testwsp-xijmsdubneexm/providers/microsoft.compute/disks/488cdb42bf74474a98075415be3f806c-containerrootvolume")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](1409), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-31T07:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T07:00:00.000Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCABillingAccountDimensionsListWithFilter.json -func ExampleDimensionsClient_NewListPager_billingAccountDimensionsListWithFilterMca() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345:6789", &armcostmanagement.DimensionsClientListOptions{Filter: to.Ptr("properties/category eq 'resourceId'"), - Expand: to.Ptr("properties/data"), - Skiptoken: nil, - Top: to.Ptr[int32](5), - }) - 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.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceId_2019-10-01_2019-10-31"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/providers/microsoft.CostManagement/dimensions_ResourceId_2019-10-01_2019-10-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource Id"), - // Category: to.Ptr("ResourceId"), - // Data: []*string{ - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/system.orlando/providers/microsoft.storage/storageaccounts/urphealthaccount"), - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/system.orlando/providers/microsoft.storage/storageaccounts/srphytenaccount"), - // to.Ptr("/subscriptions/67e24f6b-1ec2-4c90-993a-dc2d25b00b6c/resourcegroups/defaultresourcegroup-eus/providers/microsoft.operationalinsights/workspaces/defaultworkspace-67e24f6b-1ec2-4c90-993a-dc2d25b00b6c-eus"), - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg-sql-ha/providers/microsoft.compute/virtualmachines/sql-4qqp1"), - // to.Ptr("/subscriptions/a98d6dc5-eb8f-46cf-8938-f1fb08f03706/resourcegroups/databricks-rg-testwsp-xijmsdubneexm/providers/microsoft.compute/disks/488cdb42bf74474a98075415be3f806c-containerrootvolume")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](1409), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-31T07:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-01T07:00:00.000Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCABillingProfileDimensionsList.json -func ExampleDimensionsClient_NewListPager_billingProfileDimensionsListMca() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579", &armcostmanagement.DimensionsClientListOptions{Filter: nil, - Expand: nil, - Skiptoken: nil, - Top: 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.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceGroup_2019-10-01_2019-10-31"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/providers/microsoft.CostManagement/dimensions_ResourceGroup_2019-10-01_2019-10-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource group"), - // Category: to.Ptr("ResourceGroup"), - // Data: []*string{ - // }, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](377), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-31T07:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-01T07:00:00.000Z"); return t}()), - // }, - // }, - // { - // Name: to.Ptr("dimensions_ResourceType_2019-10-01_2019-10-31"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/providers/microsoft.CostManagement/dimensions_ResourceType_2019-10-01_2019-10-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource type"), - // Category: to.Ptr("ResourceType"), - // Data: []*string{ - // }, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](37), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-31T07:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-01T07:00:00.000Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCABillingProfileDimensionsListExpandAndTop.json -func ExampleDimensionsClient_NewListPager_billingProfileDimensionsListExpandAndTopMca() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579", &armcostmanagement.DimensionsClientListOptions{Filter: nil, - Expand: to.Ptr("properties/data"), - Skiptoken: nil, - Top: to.Ptr[int32](5), - }) - 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.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceGroup_2019-10-01_2019-10-31"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/providers/microsoft.CostManagement/dimensions_ResourceGroup_2019-10-01_2019-10-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource group"), - // Category: to.Ptr("ResourceGroup"), - // Data: []*string{ - // to.Ptr("thoroetrg01"), - // to.Ptr("default-notificationhubs-westus"), - // to.Ptr("jedikeyvaultrg"), - // to.Ptr("contosocodeflow8d4a"), - // to.Ptr("noobaa")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](377), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-31T07:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-01T07:00:00.000Z"); return t}()), - // }, - // }, - // { - // Name: to.Ptr("dimensions_ResourceType_2019-10-01_2019-10-31"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/providers/microsoft.CostManagement/dimensions_ResourceType_2019-10-01_2019-10-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource type"), - // Category: to.Ptr("ResourceType"), - // Data: []*string{ - // to.Ptr("microsoft.automation/automationaccounts"), - // to.Ptr("microsoft.databricks/workspaces"), - // to.Ptr("microsoft.dbformysql/servers"), - // to.Ptr("microsoft.containerregistry/registries"), - // to.Ptr("microsoft.search/searchservices")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](37), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-31T07:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-01T07:00:00.000Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCABillingProfileDimensionsListWithFilter.json -func ExampleDimensionsClient_NewListPager_billingProfileDimensionsListWithFilterMca() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579", &armcostmanagement.DimensionsClientListOptions{Filter: to.Ptr("properties/category eq 'resourceId'"), - Expand: to.Ptr("properties/data"), - Skiptoken: nil, - Top: to.Ptr[int32](5), - }) - 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.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceId_2019-10-01_2019-10-31"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/providers/microsoft.CostManagement/dimensions_ResourceId_2019-10-01_2019-10-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource Id"), - // Category: to.Ptr("ResourceId"), - // Data: []*string{ - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/system.orlando/providers/microsoft.storage/storageaccounts/urphealthaccount"), - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/system.orlando/providers/microsoft.storage/storageaccounts/srphytenaccount"), - // to.Ptr("/subscriptions/67e24f6b-1ec2-4c90-993a-dc2d25b00b6c/resourcegroups/defaultresourcegroup-eus/providers/microsoft.operationalinsights/workspaces/defaultworkspace-67e24f6b-1ec2-4c90-993a-dc2d25b00b6c-eus"), - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg-sql-ha/providers/microsoft.compute/virtualmachines/sql-4qqp1"), - // to.Ptr("/subscriptions/a98d6dc5-eb8f-46cf-8938-f1fb08f03706/resourcegroups/databricks-rg-testwsp-xijmsdubneexm/providers/microsoft.compute/disks/488cdb42bf74474a98075415be3f806c-containerrootvolume")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](1409), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-31T07:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-01T07:00:00.000Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCACustomerDimensionsList.json -func ExampleDimensionsClient_NewListPager_customerDimensionsListMca() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678", &armcostmanagement.DimensionsClientListOptions{Filter: nil, - Expand: nil, - Skiptoken: nil, - Top: 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.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceGroup_2019-10-01_2019-10-31"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678/providers/microsoft.CostManagement/dimensions_ResourceGroup_2019-10-01_2019-10-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource group"), - // Category: to.Ptr("ResourceGroup"), - // Data: []*string{ - // }, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](377), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-31T07:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-01T07:00:00.000Z"); return t}()), - // }, - // }, - // { - // Name: to.Ptr("dimensions_ResourceType_2019-10-01_2019-10-31"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678/providers/microsoft.CostManagement/dimensions_ResourceType_2019-10-01_2019-10-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource type"), - // Category: to.Ptr("ResourceType"), - // Data: []*string{ - // }, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](37), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-31T07:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-01T07:00:00.000Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCACustomerDimensionsListExpandAndTop.json -func ExampleDimensionsClient_NewListPager_customerDimensionsListExpandAndTopMca() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678", &armcostmanagement.DimensionsClientListOptions{Filter: nil, - Expand: to.Ptr("properties/data"), - Skiptoken: nil, - Top: to.Ptr[int32](5), - }) - 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.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceGroup_2019-10-01_2019-10-31"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678/providers/microsoft.CostManagement/dimensions_ResourceGroup_2019-10-01_2019-10-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource group"), - // Category: to.Ptr("ResourceGroup"), - // Data: []*string{ - // to.Ptr("thoroetrg01"), - // to.Ptr("default-notificationhubs-westus"), - // to.Ptr("jedikeyvaultrg"), - // to.Ptr("contosocodeflow8d4a"), - // to.Ptr("noobaa")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](377), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-31T07:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-01T07:00:00.000Z"); return t}()), - // }, - // }, - // { - // Name: to.Ptr("dimensions_ResourceType_2019-10-01_2019-10-31"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678/providers/microsoft.CostManagement/dimensions_ResourceType_2019-10-01_2019-10-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource type"), - // Category: to.Ptr("ResourceType"), - // Data: []*string{ - // to.Ptr("microsoft.automation/automationaccounts"), - // to.Ptr("microsoft.databricks/workspaces"), - // to.Ptr("microsoft.dbformysql/servers"), - // to.Ptr("microsoft.containerregistry/registries"), - // to.Ptr("microsoft.search/searchservices")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](37), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-31T07:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-01T07:00:00.000Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCACustomerDimensionsListWithFilter.json -func ExampleDimensionsClient_NewListPager_customerDimensionsListWithFilterMca() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678", &armcostmanagement.DimensionsClientListOptions{Filter: to.Ptr("properties/category eq 'resourceId'"), - Expand: to.Ptr("properties/data"), - Skiptoken: nil, - Top: to.Ptr[int32](5), - }) - 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.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceId_2019-10-01_2019-10-31"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678/providers/microsoft.CostManagement/dimensions_ResourceId_2019-10-01_2019-10-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource Id"), - // Category: to.Ptr("ResourceId"), - // Data: []*string{ - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/system.orlando/providers/microsoft.storage/storageaccounts/urphealthaccount"), - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/system.orlando/providers/microsoft.storage/storageaccounts/srphytenaccount"), - // to.Ptr("/subscriptions/67e24f6b-1ec2-4c90-993a-dc2d25b00b6c/resourcegroups/defaultresourcegroup-eus/providers/microsoft.operationalinsights/workspaces/defaultworkspace-67e24f6b-1ec2-4c90-993a-dc2d25b00b6c-eus"), - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg-sql-ha/providers/microsoft.compute/virtualmachines/sql-4qqp1"), - // to.Ptr("/subscriptions/a98d6dc5-eb8f-46cf-8938-f1fb08f03706/resourcegroups/databricks-rg-testwsp-xijmsdubneexm/providers/microsoft.compute/disks/488cdb42bf74474a98075415be3f806c-containerrootvolume")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](1409), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-31T07:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-01T07:00:00.000Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/DepartmentDimensionsList.json -func ExampleDimensionsClient_NewListPager_departmentDimensionsListLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/100/departments/123", &armcostmanagement.DimensionsClientListOptions{Filter: nil, - Expand: nil, - Skiptoken: nil, - Top: 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.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceGroup_2018-05-01_2018-05-31"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/100/departments/123/providers/microsoft.CostManagement/dimensions_ResourceGroup_2018-05-01_2018-05-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource group"), - // Category: to.Ptr("ResourceGroup"), - // Data: []*string{ - // to.Ptr("thoroetrg01"), - // to.Ptr("default-notificationhubs-westus"), - // to.Ptr("jedikeyvaultrg"), - // to.Ptr("contosocodeflow8d4a"), - // to.Ptr("noobaa")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](377), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-31T07:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T07:00:00.000Z"); return t}()), - // }, - // }, - // { - // Name: to.Ptr("dimensions_ResourceType_2018-05-01_2018-05-31"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/100/departments/123/providers/microsoft.CostManagement/dimensions_ResourceType_2018-05-01_2018-05-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource type"), - // Category: to.Ptr("ResourceType"), - // Data: []*string{ - // to.Ptr("thoroetrg01"), - // to.Ptr("default-notificationhubs-westus"), - // to.Ptr("jedikeyvaultrg"), - // to.Ptr("contosocodeflow8d4a"), - // to.Ptr("noobaa")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](37), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-31T07:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T07:00:00.000Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/DepartmentDimensionsListExpandAndTop.json -func ExampleDimensionsClient_NewListPager_departmentDimensionsListExpandAndTopLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/100/departments/123", &armcostmanagement.DimensionsClientListOptions{Filter: nil, - Expand: to.Ptr("properties/data"), - Skiptoken: nil, - Top: to.Ptr[int32](5), - }) - 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.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceGroup_2018-05-01_2018-05-31_5"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/100/departments/123/providers/microsoft.CostManagement/dimensions_ResourceGroup_2018-05-01_2018-05-31_5"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource group"), - // Category: to.Ptr("ResourceGroup"), - // Data: []*string{ - // to.Ptr("thoroetrg01"), - // to.Ptr("default-notificationhubs-westus"), - // to.Ptr("jedikeyvaultrg"), - // to.Ptr("contosocodeflow8d4a"), - // to.Ptr("noobaa")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](377), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-31T07:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T07:00:00.000Z"); return t}()), - // }, - // }, - // { - // Name: to.Ptr("dimensions_ResourceType_2018-05-01_2018-05-31_5"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/100/departments/123/providers/microsoft.CostManagement/dimensions_ResourceType_2018-05-01_2018-05-31_5"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource type"), - // Category: to.Ptr("ResourceType"), - // Data: []*string{ - // to.Ptr("microsoft.automation/automationaccounts"), - // to.Ptr("microsoft.databricks/workspaces"), - // to.Ptr("microsoft.dbformysql/servers"), - // to.Ptr("microsoft.containerregistry/registries"), - // to.Ptr("microsoft.search/searchservices")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](37), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-31T07:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T07:00:00.000Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/DepartmentDimensionsListWithFilter.json -func ExampleDimensionsClient_NewListPager_departmentDimensionsListWithFilterLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/100/departments/123", &armcostmanagement.DimensionsClientListOptions{Filter: to.Ptr("properties/category eq 'resourceId'"), - Expand: to.Ptr("properties/data"), - Skiptoken: nil, - Top: to.Ptr[int32](5), - }) - 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.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceId_2018-05-01_2018-05-31_5"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/100/departments/123/providers/microsoft.CostManagement/dimensions_ResourceId_2018-05-01_2018-05-31_5"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource Id"), - // Category: to.Ptr("ResourceId"), - // Data: []*string{ - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/system.orlando/providers/microsoft.storage/storageaccounts/urphealthaccount"), - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/system.orlando/providers/microsoft.storage/storageaccounts/srphytenaccount"), - // to.Ptr("/subscriptions/67e24f6b-1ec2-4c90-993a-dc2d25b00b6c/resourcegroups/defaultresourcegroup-eus/providers/microsoft.operationalinsights/workspaces/defaultworkspace-67e24f6b-1ec2-4c90-993a-dc2d25b00b6c-eus"), - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg-sql-ha/providers/microsoft.compute/virtualmachines/sql-4qqp1"), - // to.Ptr("/subscriptions/a98d6dc5-eb8f-46cf-8938-f1fb08f03706/resourcegroups/databricks-rg-testwsp-xijmsdubneexm/providers/microsoft.compute/disks/488cdb42bf74474a98075415be3f806c-containerrootvolume")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](1409), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-31T07:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T07:00:00.000Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/EnrollmentAccountDimensionsList.json -func ExampleDimensionsClient_NewListPager_enrollmentAccountDimensionsListLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456", &armcostmanagement.DimensionsClientListOptions{Filter: nil, - Expand: nil, - Skiptoken: nil, - Top: 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.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceGroup_2018-05-01_2018-05-31"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456/providers/microsoft.CostManagement/dimensions_ResourceGroup_2018-05-01_2018-05-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource group"), - // Category: to.Ptr("ResourceGroup"), - // Data: []*string{ - // }, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](377), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-31T07:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T07:00:00.000Z"); return t}()), - // }, - // }, - // { - // Name: to.Ptr("dimensions_ResourceType_2018-05-01_2018-05-31"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456/providers/microsoft.CostManagement/dimensions_ResourceType_2018-05-01_2018-05-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource type"), - // Category: to.Ptr("ResourceType"), - // Data: []*string{ - // }, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](37), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-31T07:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T07:00:00.000Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/EnrollmentAccountDimensionsListExpandAndTop.json -func ExampleDimensionsClient_NewListPager_enrollmentAccountDimensionsListExpandAndTopLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456", &armcostmanagement.DimensionsClientListOptions{Filter: nil, - Expand: to.Ptr("properties/data"), - Skiptoken: nil, - Top: to.Ptr[int32](5), - }) - 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.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceGroup_2018-05-01_2018-05-31_5"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456/providers/microsoft.CostManagement/dimensions_ResourceGroup_2018-05-01_2018-05-31_5"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource group"), - // Category: to.Ptr("ResourceGroup"), - // Data: []*string{ - // to.Ptr("thoroetrg01"), - // to.Ptr("default-notificationhubs-westus"), - // to.Ptr("jedikeyvaultrg"), - // to.Ptr("contosocodeflow8d4a"), - // to.Ptr("noobaa")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](377), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-31T07:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T07:00:00.000Z"); return t}()), - // }, - // }, - // { - // Name: to.Ptr("dimensions_ResourceType_2018-05-01_2018-05-31_5"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456/providers/microsoft.CostManagement/dimensions_ResourceType_2018-05-01_2018-05-31_5"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource type"), - // Category: to.Ptr("ResourceType"), - // Data: []*string{ - // to.Ptr("microsoft.automation/automationaccounts"), - // to.Ptr("microsoft.databricks/workspaces"), - // to.Ptr("microsoft.dbformysql/servers"), - // to.Ptr("microsoft.containerregistry/registries"), - // to.Ptr("microsoft.search/searchservices")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](37), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-31T07:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T07:00:00.000Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/EnrollmentAccountDimensionsListWithFilter.json -func ExampleDimensionsClient_NewListPager_enrollmentAccountDimensionsListWithFilterLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456", &armcostmanagement.DimensionsClientListOptions{Filter: to.Ptr("properties/category eq 'resourceId'"), - Expand: to.Ptr("properties/data"), - Skiptoken: nil, - Top: to.Ptr[int32](5), - }) - 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.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceId_2018-05-01_2018-05-31_5"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456/providers/microsoft.CostManagement/dimensions_ResourceId_2018-05-01_2018-05-31_5"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource Id"), - // Category: to.Ptr("ResourceId"), - // Data: []*string{ - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/system.orlando/providers/microsoft.storage/storageaccounts/urphealthaccount"), - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/system.orlando/providers/microsoft.storage/storageaccounts/srphytenaccount"), - // to.Ptr("/subscriptions/67e24f6b-1ec2-4c90-993a-dc2d25b00b6c/resourcegroups/defaultresourcegroup-eus/providers/microsoft.operationalinsights/workspaces/defaultworkspace-67e24f6b-1ec2-4c90-993a-dc2d25b00b6c-eus"), - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg-sql-ha/providers/microsoft.compute/virtualmachines/sql-4qqp1"), - // to.Ptr("/subscriptions/a98d6dc5-eb8f-46cf-8938-f1fb08f03706/resourcegroups/databricks-rg-testwsp-xijmsdubneexm/providers/microsoft.compute/disks/488cdb42bf74474a98075415be3f806c-containerrootvolume")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](1409), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-31T07:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T07:00:00.000Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCAInvoiceSectionDimensionsList.json -func ExampleDimensionsClient_NewListPager_invoiceSectionDimensionsListMca() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876", &armcostmanagement.DimensionsClientListOptions{Filter: nil, - Expand: nil, - Skiptoken: nil, - Top: 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.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceGroup_2019-10-01_2019-10-31"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876/providers/microsoft.CostManagement/dimensions_ResourceGroup_2019-10-01_2019-10-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource group"), - // Category: to.Ptr("ResourceGroup"), - // Data: []*string{ - // }, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](377), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-31T07:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-01T07:00:00.000Z"); return t}()), - // }, - // }, - // { - // Name: to.Ptr("dimensions_ResourceType_2019-10-01_2019-10-31"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876/providers/microsoft.CostManagement/dimensions_ResourceType_2019-10-01_2019-10-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource type"), - // Category: to.Ptr("ResourceType"), - // Data: []*string{ - // }, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](37), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-31T07:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-01T07:00:00.000Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCAInvoiceSectionDimensionsListExpandAndTop.json -func ExampleDimensionsClient_NewListPager_invoiceSectionDimensionsListExpandAndTopMca() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876", &armcostmanagement.DimensionsClientListOptions{Filter: nil, - Expand: to.Ptr("properties/data"), - Skiptoken: nil, - Top: to.Ptr[int32](5), - }) - 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.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceGroup_2019-10-01_2019-10-31"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876/providers/microsoft.CostManagement/dimensions_ResourceGroup_2019-10-01_2019-10-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource group"), - // Category: to.Ptr("ResourceGroup"), - // Data: []*string{ - // to.Ptr("thoroetrg01"), - // to.Ptr("default-notificationhubs-westus"), - // to.Ptr("jedikeyvaultrg"), - // to.Ptr("contosocodeflow8d4a"), - // to.Ptr("noobaa")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](377), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-31T07:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-01T07:00:00.000Z"); return t}()), - // }, - // }, - // { - // Name: to.Ptr("dimensions_ResourceType_2019-10-01_2019-10-31"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876/providers/microsoft.CostManagement/dimensions_ResourceType_2019-10-01_2019-10-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource type"), - // Category: to.Ptr("ResourceType"), - // Data: []*string{ - // to.Ptr("microsoft.automation/automationaccounts"), - // to.Ptr("microsoft.databricks/workspaces"), - // to.Ptr("microsoft.dbformysql/servers"), - // to.Ptr("microsoft.containerregistry/registries"), - // to.Ptr("microsoft.search/searchservices")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](37), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-31T07:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-01T07:00:00.000Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCAInvoiceSectionDimensionsListWithFilter.json -func ExampleDimensionsClient_NewListPager_invoiceSectionDimensionsListWithFilterMca() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876", &armcostmanagement.DimensionsClientListOptions{Filter: to.Ptr("properties/category eq 'resourceId'"), - Expand: to.Ptr("properties/data"), - Skiptoken: nil, - Top: to.Ptr[int32](5), - }) - 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.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceId_2019-10-01_2019-10-31"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876/providers/microsoft.CostManagement/dimensions_ResourceId_2019-10-01_2019-10-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource Id"), - // Category: to.Ptr("ResourceId"), - // Data: []*string{ - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/system.orlando/providers/microsoft.storage/storageaccounts/urphealthaccount"), - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/system.orlando/providers/microsoft.storage/storageaccounts/srphytenaccount"), - // to.Ptr("/subscriptions/67e24f6b-1ec2-4c90-993a-dc2d25b00b6c/resourcegroups/defaultresourcegroup-eus/providers/microsoft.operationalinsights/workspaces/defaultworkspace-67e24f6b-1ec2-4c90-993a-dc2d25b00b6c-eus"), - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg-sql-ha/providers/microsoft.compute/virtualmachines/sql-4qqp1"), - // to.Ptr("/subscriptions/a98d6dc5-eb8f-46cf-8938-f1fb08f03706/resourcegroups/databricks-rg-testwsp-xijmsdubneexm/providers/microsoft.compute/disks/488cdb42bf74474a98075415be3f806c-containerrootvolume")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](1409), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-31T07:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-01T07:00:00.000Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ManagementGroupDimensionsList.json -func ExampleDimensionsClient_NewListPager_managementGroupDimensionsListLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Management/managementGroups/MyMgId", &armcostmanagement.DimensionsClientListOptions{Filter: nil, - Expand: nil, - Skiptoken: nil, - Top: 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.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceGroup_2018-05-01_2018-05-31"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Management/managementGroups/MyMgId/providers/microsoft.CostManagement/dimensions_ResourceGroup_2018-05-01_2018-05-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource group"), - // Category: to.Ptr("ResourceGroup"), - // Data: []*string{ - // }, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](377), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-31T07:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T07:00:00.000Z"); return t}()), - // }, - // }, - // { - // Name: to.Ptr("dimensions_ResourceType_2018-05-01_2018-05-31"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Management/managementGroups/MyMgId/providers/microsoft.CostManagement/dimensions_ResourceType_2018-05-01_2018-05-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource type"), - // Category: to.Ptr("ResourceType"), - // Data: []*string{ - // }, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](37), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-31T07:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T07:00:00.000Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ManagementGroupDimensionsListExpandAndTop.json -func ExampleDimensionsClient_NewListPager_managementGroupDimensionsListExpandAndTopLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Management/managementGroups/MyMgId", &armcostmanagement.DimensionsClientListOptions{Filter: nil, - Expand: to.Ptr("properties/data"), - Skiptoken: nil, - Top: to.Ptr[int32](5), - }) - 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.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceGroup_2018-05-01_2018-05-31_5"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Management/managementGroups/MyMgId/providers/microsoft.CostManagement/dimensions_ResourceGroup_2018-05-01_2018-05-31_5"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource group"), - // Category: to.Ptr("ResourceGroup"), - // Data: []*string{ - // to.Ptr("thoroetrg01"), - // to.Ptr("default-notificationhubs-westus"), - // to.Ptr("jedikeyvaultrg"), - // to.Ptr("contosocodeflow8d4a"), - // to.Ptr("noobaa")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](377), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-31T07:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T07:00:00.000Z"); return t}()), - // }, - // }, - // { - // Name: to.Ptr("dimensions_ResourceType_2018-05-01_2018-05-31_5"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Management/managementGroups/MyMgId/providers/microsoft.CostManagement/dimensions_ResourceType_2018-05-01_2018-05-31_5"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource type"), - // Category: to.Ptr("ResourceType"), - // Data: []*string{ - // to.Ptr("microsoft.automation/automationaccounts"), - // to.Ptr("microsoft.databricks/workspaces"), - // to.Ptr("microsoft.dbformysql/servers"), - // to.Ptr("microsoft.containerregistry/registries"), - // to.Ptr("microsoft.search/searchservices")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](37), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-31T07:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T07:00:00.000Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ManagementGroupDimensionsListWithFilter.json -func ExampleDimensionsClient_NewListPager_managementGroupDimensionsListWithFilterLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Management/managementGroups/MyMgId", &armcostmanagement.DimensionsClientListOptions{Filter: to.Ptr("properties/category eq 'resourceId'"), - Expand: to.Ptr("properties/data"), - Skiptoken: nil, - Top: to.Ptr[int32](5), - }) - 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.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceId_2018-05-01_2018-05-31_5"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Management/managementGroups/MyMgId/providers/microsoft.CostManagement/dimensions_ResourceId_2018-05-01_2018-05-31_5"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource Id"), - // Category: to.Ptr("ResourceId"), - // Data: []*string{ - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/system.orlando/providers/microsoft.storage/storageaccounts/urphealthaccount"), - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/system.orlando/providers/microsoft.storage/storageaccounts/srphytenaccount"), - // to.Ptr("/subscriptions/67e24f6b-1ec2-4c90-993a-dc2d25b00b6c/resourcegroups/defaultresourcegroup-eus/providers/microsoft.operationalinsights/workspaces/defaultworkspace-67e24f6b-1ec2-4c90-993a-dc2d25b00b6c-eus"), - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg-sql-ha/providers/microsoft.compute/virtualmachines/sql-4qqp1"), - // to.Ptr("/subscriptions/a98d6dc5-eb8f-46cf-8938-f1fb08f03706/resourcegroups/databricks-rg-testwsp-xijmsdubneexm/providers/microsoft.compute/disks/488cdb42bf74474a98075415be3f806c-containerrootvolume")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](1409), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-31T07:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T07:00:00.000Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ResourceGroupDimensionsList.json -func ExampleDimensionsClient_NewListPager_resourceGroupDimensionsListLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/system.orlando", &armcostmanagement.DimensionsClientListOptions{Filter: nil, - Expand: to.Ptr("properties/data"), - Skiptoken: nil, - Top: to.Ptr[int32](5), - }) - 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.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceType_2018-05-01_2018-05-31_5"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/system.orlando/providers/microsoft.CostManagement/dimensions_ResourceType_2018-05-01_2018-05-31_5"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource type"), - // Category: to.Ptr("ResourceType"), - // Data: []*string{ - // to.Ptr("microsoft.storage/storageaccounts")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](1), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-31T07:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T07:00:00.000Z"); return t}()), - // }, - // }, - // { - // Name: to.Ptr("dimensions_ResourceId_2018-05-01_2018-05-31_5"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/system.orlando/providers/microsoft.CostManagement/dimensions_ResourceId_2018-05-01_2018-05-31_5"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource Id"), - // Category: to.Ptr("ResourceId"), - // Data: []*string{ - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/system.orlando/providers/microsoft.storage/storageaccounts/authprod"), - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/system.orlando/providers/microsoft.storage/storageaccounts/systemevents"), - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/system.orlando/providers/microsoft.storage/storageaccounts/armadminprod"), - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/system.orlando/providers/microsoft.storage/storageaccounts/srphytenaccount"), - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/system.orlando/providers/microsoft.storage/storageaccounts/publicsystemportal")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](27), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-31T07:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T07:00:00.000Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/SubscriptionDimensionsList.json -func ExampleDimensionsClient_NewListPager_subscriptionDimensionsListLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("subscriptions/00000000-0000-0000-0000-000000000000", &armcostmanagement.DimensionsClientListOptions{Filter: nil, - Expand: to.Ptr("properties/data"), - Skiptoken: nil, - Top: to.Ptr[int32](5), - }) - 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.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceGroup_2018-05-01_2018-05-31_5"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/dimensions_ResourceGroup_2018-05-01_2018-05-31_5"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource group"), - // Category: to.Ptr("ResourceGroup"), - // Data: []*string{ - // to.Ptr("dcrg"), - // to.Ptr("rg"), - // to.Ptr("offlinegalleryrg"), - // to.Ptr("system.orlando.adminkeyvault"), - // to.Ptr("system.orlando.keyvault")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](68), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-31T07:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T07:00:00.000Z"); return t}()), - // }, - // }, - // { - // Name: to.Ptr("dimensions_ResourceType_2018-05-01_2018-05-31_5"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/dimensions_ResourceType_2018-05-01_2018-05-31_5"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource type"), - // Category: to.Ptr("ResourceType"), - // Data: []*string{ - // to.Ptr("microsoft.storage/storageaccounts"), - // to.Ptr("microsoft.web.admin/role"), - // to.Ptr("microsoft.sql/servers"), - // to.Ptr("microsoft.compute/virtualmachines")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](4), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-31T07:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T07:00:00.000Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExternalBillingAccountsDimensions.json -func ExampleDimensionsClient_NewByExternalCloudProviderTypePager_externalBillingAccountDimensionList() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewByExternalCloudProviderTypePager(armcostmanagement.ExternalCloudProviderTypeExternalBillingAccounts, "100", &armcostmanagement.DimensionsClientByExternalCloudProviderTypeOptions{Filter: nil, - Expand: nil, - Skiptoken: nil, - Top: 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.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceType_2019-12-01_2019-12-31"), - // Type: to.Ptr("microsoft.consumption/dimensions"), - // ID: to.Ptr("providers/Microsoft.CostManagement/externalBillingAccounts/100/dimensions_ResourceType_2019-12-01_2019-12-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource type"), - // Category: to.Ptr("ResourceType"), - // Data: []*string{ - // to.Ptr("thoroetrg01"), - // to.Ptr("default-notificationhubs-westus"), - // to.Ptr("jedikeyvaultrg"), - // to.Ptr("contosocodeflow8d4a"), - // to.Ptr("noobaa")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](0), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-12-31T00:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-12-01T00:00:00.000Z"); return t}()), - // }, - // }, - // { - // Name: to.Ptr("dimensions_ResourceId_2019-12-01_2019-12-31"), - // Type: to.Ptr("microsoft.consumption/dimensions"), - // ID: to.Ptr("providers/Microsoft.CostManagement/externalBillingAccounts/100/dimensions_ResourceId_2019-12-01_2019-12-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource ID"), - // Category: to.Ptr("ResourceId"), - // Data: []*string{ - // to.Ptr("thoroetrg01"), - // to.Ptr("default-notificationhubs-westus"), - // to.Ptr("jedikeyvaultrg"), - // to.Ptr("contosocodeflow8d4a"), - // to.Ptr("noobaa")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](0), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-12-31T00:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-12-01T00:00:00.000Z"); return t}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExternalSubscriptionsDimensions.json -func ExampleDimensionsClient_NewByExternalCloudProviderTypePager_externalSubscriptionDimensionList() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewByExternalCloudProviderTypePager(armcostmanagement.ExternalCloudProviderTypeExternalSubscriptions, "100", &armcostmanagement.DimensionsClientByExternalCloudProviderTypeOptions{Filter: nil, - Expand: nil, - Skiptoken: nil, - Top: 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.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceType_2019-12-01_2019-12-31"), - // Type: to.Ptr("microsoft.consumption/dimensions"), - // ID: to.Ptr("providers/Microsoft.CostManagement/externalSubscriptions/123/dimensions_ResourceType_2019-12-01_2019-12-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource type"), - // Category: to.Ptr("ResourceType"), - // Data: []*string{ - // to.Ptr("thoroetrg01"), - // to.Ptr("default-notificationhubs-westus"), - // to.Ptr("jedikeyvaultrg"), - // to.Ptr("contosocodeflow8d4a"), - // to.Ptr("noobaa")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](0), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-12-31T00:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-12-01T00:00:00.000Z"); return t}()), - // }, - // }, - // { - // Name: to.Ptr("dimensions_ResourceId_2019-12-01_2019-12-31"), - // Type: to.Ptr("microsoft.consumption/dimensions"), - // ID: to.Ptr("providers/Microsoft.CostManagement/externalSubscriptions/123/dimensions_ResourceId_2019-12-01_2019-12-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource ID"), - // Category: to.Ptr("ResourceId"), - // Data: []*string{ - // to.Ptr("thoroetrg01"), - // to.Ptr("default-notificationhubs-westus"), - // to.Ptr("jedikeyvaultrg"), - // to.Ptr("contosocodeflow8d4a"), - // to.Ptr("noobaa")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](0), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-12-31T00:00:00.000Z"); return t}()), - // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-12-01T00:00:00.000Z"); return t}()), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/exports_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/exports_client.go index f62913de87c7..b109d2ebbd65 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/exports_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/exports_client.go @@ -45,7 +45,7 @@ func NewExportsClient(credential azcore.TokenCredential, options *arm.ClientOpti // require eTag. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - scope - The scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for subscription // scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for // resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and @@ -94,7 +94,7 @@ func (client *ExportsClient) createOrUpdateCreateRequest(ctx context.Context, sc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -115,7 +115,7 @@ func (client *ExportsClient) createOrUpdateHandleResponse(resp *http.Response) ( // Delete - The operation to delete a export. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - scope - The scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for subscription // scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for // resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and @@ -162,7 +162,7 @@ func (client *ExportsClient) deleteCreateRequest(ctx context.Context, scope stri return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -171,7 +171,7 @@ func (client *ExportsClient) deleteCreateRequest(ctx context.Context, scope stri // Execute - The operation to run an export. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - scope - The scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for subscription // scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for // resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and @@ -218,7 +218,7 @@ func (client *ExportsClient) executeCreateRequest(ctx context.Context, scope str return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -227,7 +227,7 @@ func (client *ExportsClient) executeCreateRequest(ctx context.Context, scope str // Get - The operation to get the export for the defined scope by export name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - scope - The scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for subscription // scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for // resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and @@ -275,10 +275,10 @@ func (client *ExportsClient) getCreateRequest(ctx context.Context, scope string, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") if options != nil && options.Expand != nil { reqQP.Set("$expand", *options.Expand) } + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -296,7 +296,7 @@ func (client *ExportsClient) getHandleResponse(resp *http.Response) (ExportsClie // GetExecutionHistory - The operation to get the run history of an export for the defined scope and export name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - scope - The scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for subscription // scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for // resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and @@ -345,7 +345,7 @@ func (client *ExportsClient) getExecutionHistoryCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -363,7 +363,7 @@ func (client *ExportsClient) getExecutionHistoryHandleResponse(resp *http.Respon // List - The operation to list all exports at the given scope. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - scope - The scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for subscription // scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for // resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and @@ -406,10 +406,10 @@ func (client *ExportsClient) listCreateRequest(ctx context.Context, scope string return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") if options != nil && options.Expand != nil { reqQP.Set("$expand", *options.Expand) } + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/exports_client_example_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/exports_client_example_test.go deleted file mode 100644 index 3c63dd0d0cc9..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/exports_client_example_test.go +++ /dev/null @@ -1,2301 +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 armcostmanagement_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/costmanagement/armcostmanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportsGetByBillingAccount.json -func ExampleExportsClient_List_exportsGetByBillingAccount() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExportsClient().List(ctx, "providers/Microsoft.Billing/billingAccounts/123456", &armcostmanagement.ExportsClientListOptions{Expand: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ExportListResult = armcostmanagement.ExportListResult{ - // Value: []*armcostmanagement.Export{ - // { - // Name: to.Ptr("TestExport1"), - // Type: to.Ptr("Microsoft.CostManagement/exports"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/exports/TestExport1"), - // Properties: &armcostmanagement.ExportProperties{ - // Format: to.Ptr(armcostmanagement.FormatTypeCSV), - // Definition: &armcostmanagement.ExportDefinition{ - // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - // DataSet: &armcostmanagement.ExportDataset{ - // Configuration: &armcostmanagement.ExportDatasetConfiguration{ - // Columns: []*string{ - // to.Ptr("Date"), - // to.Ptr("MeterId"), - // to.Ptr("ResourceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("Quantity")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // TimePeriod: &armcostmanagement.ExportTimePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00.000Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00:00:00.000Z"); return t}()), - // }, - // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeCustom), - // }, - // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - // Destination: &armcostmanagement.ExportDeliveryDestination{ - // Container: to.Ptr("exports"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - // RootFolderPath: to.Ptr("ad-hoc"), - // }, - // }, - // }, - // }, - // { - // Name: to.Ptr("TestExport2"), - // Type: to.Ptr("Microsoft.CostManagement/exports"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/exports/TestExport2"), - // Properties: &armcostmanagement.ExportProperties{ - // Format: to.Ptr(armcostmanagement.FormatTypeCSV), - // Definition: &armcostmanagement.ExportDefinition{ - // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - // DataSet: &armcostmanagement.ExportDataset{ - // Configuration: &armcostmanagement.ExportDatasetConfiguration{ - // Columns: []*string{ - // to.Ptr("Date"), - // to.Ptr("MeterId"), - // to.Ptr("ResourceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("Quantity")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeWeekToDate), - // }, - // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - // Destination: &armcostmanagement.ExportDeliveryDestination{ - // Container: to.Ptr("exports"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - // RootFolderPath: to.Ptr("ad-hoc"), - // }, - // }, - // Schedule: &armcostmanagement.ExportSchedule{ - // Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeWeekly), - // RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00.000Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00:00:00.000Z"); return t}()), - // }, - // Status: to.Ptr(armcostmanagement.StatusTypeActive), - // }, - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportsGetByDepartment.json -func ExampleExportsClient_List_exportsGetByDepartment() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExportsClient().List(ctx, "providers/Microsoft.Billing/billingAccounts/12/departments/123", &armcostmanagement.ExportsClientListOptions{Expand: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ExportListResult = armcostmanagement.ExportListResult{ - // Value: []*armcostmanagement.Export{ - // { - // Name: to.Ptr("TestExport1"), - // Type: to.Ptr("Microsoft.CostManagement/exports"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12/departments/1234/providers/Microsoft.CostManagement/exports/TestExport1"), - // Properties: &armcostmanagement.ExportProperties{ - // Format: to.Ptr(armcostmanagement.FormatTypeCSV), - // Definition: &armcostmanagement.ExportDefinition{ - // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - // DataSet: &armcostmanagement.ExportDataset{ - // Configuration: &armcostmanagement.ExportDatasetConfiguration{ - // Columns: []*string{ - // to.Ptr("Date"), - // to.Ptr("MeterId"), - // to.Ptr("ResourceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("Quantity")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // TimePeriod: &armcostmanagement.ExportTimePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00.000Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00:00:00.000Z"); return t}()), - // }, - // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeCustom), - // }, - // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - // Destination: &armcostmanagement.ExportDeliveryDestination{ - // Container: to.Ptr("exports"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - // RootFolderPath: to.Ptr("ad-hoc"), - // }, - // }, - // }, - // }, - // { - // Name: to.Ptr("TestExport2"), - // Type: to.Ptr("Microsoft.CostManagement/exports"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12/departments/1234/providers/Microsoft.CostManagement/exports/TestExport2"), - // Properties: &armcostmanagement.ExportProperties{ - // Format: to.Ptr(armcostmanagement.FormatTypeCSV), - // Definition: &armcostmanagement.ExportDefinition{ - // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - // DataSet: &armcostmanagement.ExportDataset{ - // Configuration: &armcostmanagement.ExportDatasetConfiguration{ - // Columns: []*string{ - // to.Ptr("Date"), - // to.Ptr("MeterId"), - // to.Ptr("ResourceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("Quantity")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeWeekToDate), - // }, - // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - // Destination: &armcostmanagement.ExportDeliveryDestination{ - // Container: to.Ptr("exports"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - // RootFolderPath: to.Ptr("ad-hoc"), - // }, - // }, - // Schedule: &armcostmanagement.ExportSchedule{ - // Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeWeekly), - // RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00.000Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00:00:00.000Z"); return t}()), - // }, - // Status: to.Ptr(armcostmanagement.StatusTypeActive), - // }, - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportsGetByEnrollmentAccount.json -func ExampleExportsClient_List_exportsGetByEnrollmentAccount() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExportsClient().List(ctx, "providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456", &armcostmanagement.ExportsClientListOptions{Expand: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ExportListResult = armcostmanagement.ExportListResult{ - // Value: []*armcostmanagement.Export{ - // { - // Name: to.Ptr("TestExport1"), - // Type: to.Ptr("Microsoft.CostManagement/exports"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456/providers/Microsoft.CostManagement/exports/TestExport1"), - // Properties: &armcostmanagement.ExportProperties{ - // Format: to.Ptr(armcostmanagement.FormatTypeCSV), - // Definition: &armcostmanagement.ExportDefinition{ - // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - // DataSet: &armcostmanagement.ExportDataset{ - // Configuration: &armcostmanagement.ExportDatasetConfiguration{ - // Columns: []*string{ - // to.Ptr("Date"), - // to.Ptr("MeterId"), - // to.Ptr("ResourceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("Quantity")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // TimePeriod: &armcostmanagement.ExportTimePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00.000Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00:00:00.000Z"); return t}()), - // }, - // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeCustom), - // }, - // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - // Destination: &armcostmanagement.ExportDeliveryDestination{ - // Container: to.Ptr("exports"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - // RootFolderPath: to.Ptr("ad-hoc"), - // }, - // }, - // }, - // }, - // { - // Name: to.Ptr("TestExport2"), - // Type: to.Ptr("Microsoft.CostManagement/exports"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456/providers/Microsoft.CostManagement/exports/TestExport2"), - // Properties: &armcostmanagement.ExportProperties{ - // Format: to.Ptr(armcostmanagement.FormatTypeCSV), - // Definition: &armcostmanagement.ExportDefinition{ - // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - // DataSet: &armcostmanagement.ExportDataset{ - // Configuration: &armcostmanagement.ExportDatasetConfiguration{ - // Columns: []*string{ - // to.Ptr("Date"), - // to.Ptr("MeterId"), - // to.Ptr("ResourceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("Quantity")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeWeekToDate), - // }, - // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - // Destination: &armcostmanagement.ExportDeliveryDestination{ - // Container: to.Ptr("exports"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - // RootFolderPath: to.Ptr("ad-hoc"), - // }, - // }, - // Schedule: &armcostmanagement.ExportSchedule{ - // Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeWeekly), - // RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00.000Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00:00:00.000Z"); return t}()), - // }, - // Status: to.Ptr(armcostmanagement.StatusTypeActive), - // }, - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportsGetByManagementGroup.json -func ExampleExportsClient_List_exportsGetByManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExportsClient().List(ctx, "providers/Microsoft.Management/managementGroups/TestMG", &armcostmanagement.ExportsClientListOptions{Expand: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ExportListResult = armcostmanagement.ExportListResult{ - // Value: []*armcostmanagement.Export{ - // { - // Name: to.Ptr("TestExport1"), - // Type: to.Ptr("Microsoft.CostManagement/exports"), - // ID: to.Ptr("providers/Microsoft.Management/managementGroups/TestMG/providers/Microsoft.CostManagement/exports/TestExport1"), - // Properties: &armcostmanagement.ExportProperties{ - // Format: to.Ptr(armcostmanagement.FormatTypeCSV), - // Definition: &armcostmanagement.ExportDefinition{ - // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - // DataSet: &armcostmanagement.ExportDataset{ - // Configuration: &armcostmanagement.ExportDatasetConfiguration{ - // Columns: []*string{ - // to.Ptr("Date"), - // to.Ptr("MeterId"), - // to.Ptr("ResourceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("Quantity")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // TimePeriod: &armcostmanagement.ExportTimePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00.000Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00:00:00.000Z"); return t}()), - // }, - // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeCustom), - // }, - // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - // Destination: &armcostmanagement.ExportDeliveryDestination{ - // Container: to.Ptr("exports"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - // RootFolderPath: to.Ptr("ad-hoc"), - // }, - // }, - // }, - // }, - // { - // Name: to.Ptr("TestExport2"), - // Type: to.Ptr("Microsoft.CostManagement/exports"), - // ID: to.Ptr("providers/Microsoft.Management/managementGroups/TestMG/providers/Microsoft.CostManagement/exports/TestExport2"), - // Properties: &armcostmanagement.ExportProperties{ - // Format: to.Ptr(armcostmanagement.FormatTypeCSV), - // Definition: &armcostmanagement.ExportDefinition{ - // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - // DataSet: &armcostmanagement.ExportDataset{ - // Configuration: &armcostmanagement.ExportDatasetConfiguration{ - // Columns: []*string{ - // to.Ptr("Date"), - // to.Ptr("MeterId"), - // to.Ptr("ResourceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("Quantity")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeWeekToDate), - // }, - // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - // Destination: &armcostmanagement.ExportDeliveryDestination{ - // Container: to.Ptr("exports"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - // RootFolderPath: to.Ptr("ad-hoc"), - // }, - // }, - // Schedule: &armcostmanagement.ExportSchedule{ - // Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeWeekly), - // RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00.000Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00:00:00.000Z"); return t}()), - // }, - // Status: to.Ptr(armcostmanagement.StatusTypeActive), - // }, - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportsGetByResourceGroup.json -func ExampleExportsClient_List_exportsGetByResourceGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExportsClient().List(ctx, "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG", &armcostmanagement.ExportsClientListOptions{Expand: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ExportListResult = armcostmanagement.ExportListResult{ - // Value: []*armcostmanagement.Export{ - // { - // Name: to.Ptr("TestExport1"), - // Type: to.Ptr("Microsoft.CostManagement/exports"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.CostManagement/exports/TestExport1"), - // Properties: &armcostmanagement.ExportProperties{ - // Format: to.Ptr(armcostmanagement.FormatTypeCSV), - // Definition: &armcostmanagement.ExportDefinition{ - // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - // DataSet: &armcostmanagement.ExportDataset{ - // Configuration: &armcostmanagement.ExportDatasetConfiguration{ - // Columns: []*string{ - // to.Ptr("Date"), - // to.Ptr("MeterId"), - // to.Ptr("ResourceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("Quantity")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // TimePeriod: &armcostmanagement.ExportTimePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00.000Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00:00:00.000Z"); return t}()), - // }, - // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeCustom), - // }, - // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - // Destination: &armcostmanagement.ExportDeliveryDestination{ - // Container: to.Ptr("exports"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - // RootFolderPath: to.Ptr("ad-hoc"), - // }, - // }, - // }, - // }, - // { - // Name: to.Ptr("TestExport2"), - // Type: to.Ptr("Microsoft.CostManagement/exports"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.CostManagement/exports/TestExport2"), - // Properties: &armcostmanagement.ExportProperties{ - // Format: to.Ptr(armcostmanagement.FormatTypeCSV), - // Definition: &armcostmanagement.ExportDefinition{ - // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - // DataSet: &armcostmanagement.ExportDataset{ - // Configuration: &armcostmanagement.ExportDatasetConfiguration{ - // Columns: []*string{ - // to.Ptr("Date"), - // to.Ptr("MeterId"), - // to.Ptr("ResourceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("Quantity")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeWeekToDate), - // }, - // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - // Destination: &armcostmanagement.ExportDeliveryDestination{ - // Container: to.Ptr("exports"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - // RootFolderPath: to.Ptr("ad-hoc"), - // }, - // }, - // Schedule: &armcostmanagement.ExportSchedule{ - // Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeWeekly), - // RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00.000Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00:00:00.000Z"); return t}()), - // }, - // Status: to.Ptr(armcostmanagement.StatusTypeActive), - // }, - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportsGetBySubscription.json -func ExampleExportsClient_List_exportsGetBySubscription() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExportsClient().List(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", &armcostmanagement.ExportsClientListOptions{Expand: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ExportListResult = armcostmanagement.ExportListResult{ - // Value: []*armcostmanagement.Export{ - // { - // Name: to.Ptr("TestExport1"), - // Type: to.Ptr("Microsoft.CostManagement/exports"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/exports/TestExport1"), - // Properties: &armcostmanagement.ExportProperties{ - // Format: to.Ptr(armcostmanagement.FormatTypeCSV), - // Definition: &armcostmanagement.ExportDefinition{ - // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - // DataSet: &armcostmanagement.ExportDataset{ - // Configuration: &armcostmanagement.ExportDatasetConfiguration{ - // Columns: []*string{ - // to.Ptr("Date"), - // to.Ptr("MeterId"), - // to.Ptr("ResourceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("Quantity")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // TimePeriod: &armcostmanagement.ExportTimePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00.000Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00:00:00.000Z"); return t}()), - // }, - // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeCustom), - // }, - // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - // Destination: &armcostmanagement.ExportDeliveryDestination{ - // Container: to.Ptr("exports"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - // RootFolderPath: to.Ptr("ad-hoc"), - // }, - // }, - // }, - // }, - // { - // Name: to.Ptr("TestExport2"), - // Type: to.Ptr("Microsoft.CostManagement/exports"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/exports/TestExport2"), - // Properties: &armcostmanagement.ExportProperties{ - // Format: to.Ptr(armcostmanagement.FormatTypeCSV), - // Definition: &armcostmanagement.ExportDefinition{ - // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - // DataSet: &armcostmanagement.ExportDataset{ - // Configuration: &armcostmanagement.ExportDatasetConfiguration{ - // Columns: []*string{ - // to.Ptr("Date"), - // to.Ptr("MeterId"), - // to.Ptr("ResourceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("Quantity")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeWeekToDate), - // }, - // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - // Destination: &armcostmanagement.ExportDeliveryDestination{ - // Container: to.Ptr("exports"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - // RootFolderPath: to.Ptr("ad-hoc"), - // }, - // }, - // Schedule: &armcostmanagement.ExportSchedule{ - // Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeWeekly), - // RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00.000Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00:00:00.000Z"); return t}()), - // }, - // Status: to.Ptr(armcostmanagement.StatusTypeActive), - // }, - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportGetByBillingAccount.json -func ExampleExportsClient_Get_exportGetByBillingAccount() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExportsClient().Get(ctx, "providers/Microsoft.Billing/billingAccounts/123456", "TestExport", &armcostmanagement.ExportsClientGetOptions{Expand: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Export = armcostmanagement.Export{ - // Name: to.Ptr("TestExport"), - // Type: to.Ptr("Microsoft.CostManagement/exports"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/{billingAccount-Id}/providers/Microsoft.CostManagement/exports/TestExport"), - // Properties: &armcostmanagement.ExportProperties{ - // Format: to.Ptr(armcostmanagement.FormatTypeCSV), - // Definition: &armcostmanagement.ExportDefinition{ - // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - // DataSet: &armcostmanagement.ExportDataset{ - // Configuration: &armcostmanagement.ExportDatasetConfiguration{ - // Columns: []*string{ - // to.Ptr("Date"), - // to.Ptr("MeterId"), - // to.Ptr("ResourceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("Quantity")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // TimePeriod: &armcostmanagement.ExportTimePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T00:00:00.000Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-31T00:00:00.000Z"); return t}()), - // }, - // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeCustom), - // }, - // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - // Destination: &armcostmanagement.ExportDeliveryDestination{ - // Container: to.Ptr("exports"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - // RootFolderPath: to.Ptr("ad-hoc"), - // }, - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportGetByDepartment.json -func ExampleExportsClient_Get_exportGetByDepartment() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExportsClient().Get(ctx, "providers/Microsoft.Billing/billingAccounts/12/departments/1234", "TestExport", &armcostmanagement.ExportsClientGetOptions{Expand: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Export = armcostmanagement.Export{ - // Name: to.Ptr("TestExport"), - // Type: to.Ptr("Microsoft.CostManagement/exports"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12/departments/1234/providers/Microsoft.CostManagement/exports/TestExport"), - // Properties: &armcostmanagement.ExportProperties{ - // Format: to.Ptr(armcostmanagement.FormatTypeCSV), - // Definition: &armcostmanagement.ExportDefinition{ - // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - // DataSet: &armcostmanagement.ExportDataset{ - // Configuration: &armcostmanagement.ExportDatasetConfiguration{ - // Columns: []*string{ - // to.Ptr("Date"), - // to.Ptr("MeterId"), - // to.Ptr("ResourceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("Quantity")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // TimePeriod: &armcostmanagement.ExportTimePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00.000Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00.000Z"); return t}()), - // }, - // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeCustom), - // }, - // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - // Destination: &armcostmanagement.ExportDeliveryDestination{ - // Container: to.Ptr("exports"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - // RootFolderPath: to.Ptr("ad-hoc"), - // }, - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportGetByEnrollmentAccount.json -func ExampleExportsClient_Get_exportGetByEnrollmentAccount() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExportsClient().Get(ctx, "providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456", "TestExport", &armcostmanagement.ExportsClientGetOptions{Expand: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Export = armcostmanagement.Export{ - // Name: to.Ptr("TestExport"), - // Type: to.Ptr("Microsoft.CostManagement/exports"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456/providers/Microsoft.CostManagement/exports/TestExport"), - // Properties: &armcostmanagement.ExportProperties{ - // Format: to.Ptr(armcostmanagement.FormatTypeCSV), - // Definition: &armcostmanagement.ExportDefinition{ - // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - // DataSet: &armcostmanagement.ExportDataset{ - // Configuration: &armcostmanagement.ExportDatasetConfiguration{ - // Columns: []*string{ - // to.Ptr("Date"), - // to.Ptr("MeterId"), - // to.Ptr("ResourceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("Quantity")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // TimePeriod: &armcostmanagement.ExportTimePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-01T00:00:00.000Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-31T00:00:00.000Z"); return t}()), - // }, - // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeCustom), - // }, - // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - // Destination: &armcostmanagement.ExportDeliveryDestination{ - // Container: to.Ptr("exports"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - // RootFolderPath: to.Ptr("ad-hoc"), - // }, - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportGetByManagementGroup.json -func ExampleExportsClient_Get_exportGetByManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExportsClient().Get(ctx, "providers/Microsoft.Management/managementGroups/TestMG", "TestExport", &armcostmanagement.ExportsClientGetOptions{Expand: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Export = armcostmanagement.Export{ - // Name: to.Ptr("TestExport"), - // Type: to.Ptr("Microsoft.CostManagement/exports"), - // ID: to.Ptr("providers/Microsoft.Management/managementGroups/TestMG/providers/Microsoft.CostManagement/exports/TestExport"), - // Properties: &armcostmanagement.ExportProperties{ - // Format: to.Ptr(armcostmanagement.FormatTypeCSV), - // Definition: &armcostmanagement.ExportDefinition{ - // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - // DataSet: &armcostmanagement.ExportDataset{ - // Configuration: &armcostmanagement.ExportDatasetConfiguration{ - // Columns: []*string{ - // to.Ptr("UsageDate"), - // to.Ptr("MeterId"), - // to.Ptr("InstanceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("UsageQuantity")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // TimePeriod: &armcostmanagement.ExportTimePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-01T00:00:00.000Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00:00:00.000Z"); return t}()), - // }, - // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeCustom), - // }, - // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - // Destination: &armcostmanagement.ExportDeliveryDestination{ - // Container: to.Ptr("exports"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - // RootFolderPath: to.Ptr("ad-hoc"), - // }, - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportGetByResourceGroup.json -func ExampleExportsClient_Get_exportGetByResourceGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExportsClient().Get(ctx, "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG", "TestExport", &armcostmanagement.ExportsClientGetOptions{Expand: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Export = armcostmanagement.Export{ - // Name: to.Ptr("TestExport"), - // Type: to.Ptr("Microsoft.CostManagement/exports"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.CostManagement/exports/TestExport"), - // Properties: &armcostmanagement.ExportProperties{ - // Format: to.Ptr(armcostmanagement.FormatTypeCSV), - // Definition: &armcostmanagement.ExportDefinition{ - // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - // DataSet: &armcostmanagement.ExportDataset{ - // Configuration: &armcostmanagement.ExportDatasetConfiguration{ - // Columns: []*string{ - // to.Ptr("Date"), - // to.Ptr("MeterId"), - // to.Ptr("ResourceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("Quantity")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // TimePeriod: &armcostmanagement.ExportTimePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00.000Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00.000Z"); return t}()), - // }, - // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeCustom), - // }, - // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - // Destination: &armcostmanagement.ExportDeliveryDestination{ - // Container: to.Ptr("exports"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - // RootFolderPath: to.Ptr("ad-hoc"), - // }, - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportGetBySubscription.json -func ExampleExportsClient_Get_exportGetBySubscription() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExportsClient().Get(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", "TestExport", &armcostmanagement.ExportsClientGetOptions{Expand: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Export = armcostmanagement.Export{ - // Name: to.Ptr("TestExport"), - // Type: to.Ptr("Microsoft.CostManagement/exports"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/exports/TestExport"), - // Properties: &armcostmanagement.ExportProperties{ - // Format: to.Ptr(armcostmanagement.FormatTypeCSV), - // Definition: &armcostmanagement.ExportDefinition{ - // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - // DataSet: &armcostmanagement.ExportDataset{ - // Configuration: &armcostmanagement.ExportDatasetConfiguration{ - // Columns: []*string{ - // to.Ptr("Date"), - // to.Ptr("MeterId"), - // to.Ptr("ResourceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("Quantity")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // TimePeriod: &armcostmanagement.ExportTimePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-06-01T00:00:00.000Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-07-31T00:00:00.000Z"); return t}()), - // }, - // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeCustom), - // }, - // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - // Destination: &armcostmanagement.ExportDeliveryDestination{ - // Container: to.Ptr("exports"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - // RootFolderPath: to.Ptr("ad-hoc"), - // }, - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportCreateOrUpdateByBillingAccount.json -func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateByBillingAccount() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExportsClient().CreateOrUpdate(ctx, "providers/Microsoft.Billing/billingAccounts/123456", "TestExport", armcostmanagement.Export{ - Properties: &armcostmanagement.ExportProperties{ - Format: to.Ptr(armcostmanagement.FormatTypeCSV), - Definition: &armcostmanagement.ExportDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - DataSet: &armcostmanagement.ExportDataset{ - Configuration: &armcostmanagement.ExportDatasetConfiguration{ - Columns: []*string{ - to.Ptr("Date"), - to.Ptr("MeterId"), - to.Ptr("ResourceId"), - to.Ptr("ResourceLocation"), - to.Ptr("Quantity")}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - }, - DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - Destination: &armcostmanagement.ExportDeliveryDestination{ - Container: to.Ptr("exports"), - ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - RootFolderPath: to.Ptr("ad-hoc"), - }, - }, - Schedule: &armcostmanagement.ExportSchedule{ - Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeWeekly), - RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{ - From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00.000Z"); return t }()), - To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00:00:00.000Z"); return t }()), - }, - Status: to.Ptr(armcostmanagement.StatusTypeActive), - }, - }, - }, 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.Export = armcostmanagement.Export{ - // Name: to.Ptr("TestExport"), - // Type: to.Ptr("Microsoft.CostManagement/exports"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/exports/TestExport"), - // Properties: &armcostmanagement.ExportProperties{ - // Format: to.Ptr(armcostmanagement.FormatTypeCSV), - // Definition: &armcostmanagement.ExportDefinition{ - // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - // DataSet: &armcostmanagement.ExportDataset{ - // Configuration: &armcostmanagement.ExportDatasetConfiguration{ - // Columns: []*string{ - // to.Ptr("Date"), - // to.Ptr("MeterId"), - // to.Ptr("ResourceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("Quantity")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - // }, - // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - // Destination: &armcostmanagement.ExportDeliveryDestination{ - // Container: to.Ptr("exports"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - // RootFolderPath: to.Ptr("ad-hoc"), - // }, - // }, - // Schedule: &armcostmanagement.ExportSchedule{ - // Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeWeekly), - // RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00.000Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00:00:00.000Z"); return t}()), - // }, - // Status: to.Ptr(armcostmanagement.StatusTypeActive), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportCreateOrUpdateByDepartment.json -func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateByDepartment() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExportsClient().CreateOrUpdate(ctx, "providers/Microsoft.Billing/billingAccounts/12/departments/1234", "TestExport", armcostmanagement.Export{ - Properties: &armcostmanagement.ExportProperties{ - Format: to.Ptr(armcostmanagement.FormatTypeCSV), - Definition: &armcostmanagement.ExportDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - DataSet: &armcostmanagement.ExportDataset{ - Configuration: &armcostmanagement.ExportDatasetConfiguration{ - Columns: []*string{ - to.Ptr("Date"), - to.Ptr("MeterId"), - to.Ptr("ResourceId"), - to.Ptr("ResourceLocation"), - to.Ptr("Quantity")}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - }, - DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - Destination: &armcostmanagement.ExportDeliveryDestination{ - Container: to.Ptr("exports"), - ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - RootFolderPath: to.Ptr("ad-hoc"), - }, - }, - Schedule: &armcostmanagement.ExportSchedule{ - Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeWeekly), - RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{ - From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00.000Z"); return t }()), - To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00:00:00.000Z"); return t }()), - }, - Status: to.Ptr(armcostmanagement.StatusTypeActive), - }, - }, - }, 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.Export = armcostmanagement.Export{ - // Name: to.Ptr("TestExport"), - // Type: to.Ptr("Microsoft.CostManagement/exports"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12/departments/1234/providers/Microsoft.CostManagement/exports/TestExport"), - // Properties: &armcostmanagement.ExportProperties{ - // Format: to.Ptr(armcostmanagement.FormatTypeCSV), - // Definition: &armcostmanagement.ExportDefinition{ - // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - // DataSet: &armcostmanagement.ExportDataset{ - // Configuration: &armcostmanagement.ExportDatasetConfiguration{ - // Columns: []*string{ - // to.Ptr("Date"), - // to.Ptr("MeterId"), - // to.Ptr("ResourceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("Quantity")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - // }, - // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - // Destination: &armcostmanagement.ExportDeliveryDestination{ - // Container: to.Ptr("exports"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - // RootFolderPath: to.Ptr("ad-hoc"), - // }, - // }, - // Schedule: &armcostmanagement.ExportSchedule{ - // Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeWeekly), - // RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00.000Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00:00:00.000Z"); return t}()), - // }, - // Status: to.Ptr(armcostmanagement.StatusTypeActive), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportCreateOrUpdateByEnrollmentAccount.json -func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateByEnrollmentAccount() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExportsClient().CreateOrUpdate(ctx, "providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456", "TestExport", armcostmanagement.Export{ - Properties: &armcostmanagement.ExportProperties{ - Format: to.Ptr(armcostmanagement.FormatTypeCSV), - Definition: &armcostmanagement.ExportDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - DataSet: &armcostmanagement.ExportDataset{ - Configuration: &armcostmanagement.ExportDatasetConfiguration{ - Columns: []*string{ - to.Ptr("Date"), - to.Ptr("MeterId"), - to.Ptr("ResourceId"), - to.Ptr("ResourceLocation"), - to.Ptr("Quantity")}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - }, - DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - Destination: &armcostmanagement.ExportDeliveryDestination{ - Container: to.Ptr("exports"), - ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - RootFolderPath: to.Ptr("ad-hoc"), - }, - }, - Schedule: &armcostmanagement.ExportSchedule{ - Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeWeekly), - RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{ - From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00.000Z"); return t }()), - To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00:00:00.000Z"); return t }()), - }, - Status: to.Ptr(armcostmanagement.StatusTypeActive), - }, - }, - }, 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.Export = armcostmanagement.Export{ - // Name: to.Ptr("TestExport"), - // Type: to.Ptr("Microsoft.CostManagement/exports"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456/providers/Microsoft.CostManagement/exports/TestExport"), - // Properties: &armcostmanagement.ExportProperties{ - // Format: to.Ptr(armcostmanagement.FormatTypeCSV), - // Definition: &armcostmanagement.ExportDefinition{ - // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - // DataSet: &armcostmanagement.ExportDataset{ - // Configuration: &armcostmanagement.ExportDatasetConfiguration{ - // Columns: []*string{ - // to.Ptr("Date"), - // to.Ptr("MeterId"), - // to.Ptr("ResourceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("Quantity")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - // }, - // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - // Destination: &armcostmanagement.ExportDeliveryDestination{ - // Container: to.Ptr("exports"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - // RootFolderPath: to.Ptr("ad-hoc"), - // }, - // }, - // Schedule: &armcostmanagement.ExportSchedule{ - // Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeWeekly), - // RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00.000Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00:00:00.000Z"); return t}()), - // }, - // Status: to.Ptr(armcostmanagement.StatusTypeActive), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportCreateOrUpdateByManagementGroup.json -func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateByManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExportsClient().CreateOrUpdate(ctx, "providers/Microsoft.Management/managementGroups/TestMG", "TestExport", armcostmanagement.Export{ - Properties: &armcostmanagement.ExportProperties{ - Format: to.Ptr(armcostmanagement.FormatTypeCSV), - Definition: &armcostmanagement.ExportDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - DataSet: &armcostmanagement.ExportDataset{ - Configuration: &armcostmanagement.ExportDatasetConfiguration{ - Columns: []*string{ - to.Ptr("Date"), - to.Ptr("MeterId"), - to.Ptr("ResourceId"), - to.Ptr("ResourceLocation"), - to.Ptr("Quantity")}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - }, - DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - Destination: &armcostmanagement.ExportDeliveryDestination{ - Container: to.Ptr("exports"), - ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - RootFolderPath: to.Ptr("ad-hoc"), - }, - }, - Schedule: &armcostmanagement.ExportSchedule{ - Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeWeekly), - RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{ - From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00.000Z"); return t }()), - To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00:00:00.000Z"); return t }()), - }, - Status: to.Ptr(armcostmanagement.StatusTypeActive), - }, - }, - }, 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.Export = armcostmanagement.Export{ - // Name: to.Ptr("TestExport"), - // Type: to.Ptr("Microsoft.CostManagement/exports"), - // ID: to.Ptr("providers/Microsoft.Management/managementGroups/TestMG/providers/Microsoft.CostManagement/exports/TestExport"), - // Properties: &armcostmanagement.ExportProperties{ - // Format: to.Ptr(armcostmanagement.FormatTypeCSV), - // Definition: &armcostmanagement.ExportDefinition{ - // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - // DataSet: &armcostmanagement.ExportDataset{ - // Configuration: &armcostmanagement.ExportDatasetConfiguration{ - // Columns: []*string{ - // to.Ptr("Date"), - // to.Ptr("MeterId"), - // to.Ptr("ResourceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("Quantity")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - // }, - // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - // Destination: &armcostmanagement.ExportDeliveryDestination{ - // Container: to.Ptr("exports"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - // RootFolderPath: to.Ptr("ad-hoc"), - // }, - // }, - // Schedule: &armcostmanagement.ExportSchedule{ - // Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeWeekly), - // RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00.000Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00:00:00.000Z"); return t}()), - // }, - // Status: to.Ptr(armcostmanagement.StatusTypeActive), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportCreateOrUpdateByResourceGroup.json -func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateByResourceGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExportsClient().CreateOrUpdate(ctx, "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG", "TestExport", armcostmanagement.Export{ - Properties: &armcostmanagement.ExportProperties{ - Format: to.Ptr(armcostmanagement.FormatTypeCSV), - Definition: &armcostmanagement.ExportDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - DataSet: &armcostmanagement.ExportDataset{ - Configuration: &armcostmanagement.ExportDatasetConfiguration{ - Columns: []*string{ - to.Ptr("Date"), - to.Ptr("MeterId"), - to.Ptr("ResourceId"), - to.Ptr("ResourceLocation"), - to.Ptr("Quantity")}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - }, - DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - Destination: &armcostmanagement.ExportDeliveryDestination{ - Container: to.Ptr("exports"), - ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - RootFolderPath: to.Ptr("ad-hoc"), - }, - }, - Schedule: &armcostmanagement.ExportSchedule{ - Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeWeekly), - RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{ - From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00.000Z"); return t }()), - To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00:00:00.000Z"); return t }()), - }, - Status: to.Ptr(armcostmanagement.StatusTypeActive), - }, - }, - }, 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.Export = armcostmanagement.Export{ - // Name: to.Ptr("TestExport"), - // Type: to.Ptr("Microsoft.CostManagement/exports"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.CostManagement/exports/TestExport"), - // Properties: &armcostmanagement.ExportProperties{ - // Format: to.Ptr(armcostmanagement.FormatTypeCSV), - // Definition: &armcostmanagement.ExportDefinition{ - // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - // DataSet: &armcostmanagement.ExportDataset{ - // Configuration: &armcostmanagement.ExportDatasetConfiguration{ - // Columns: []*string{ - // to.Ptr("Date"), - // to.Ptr("MeterId"), - // to.Ptr("ResourceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("Quantity")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - // }, - // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - // Destination: &armcostmanagement.ExportDeliveryDestination{ - // Container: to.Ptr("exports"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - // RootFolderPath: to.Ptr("ad-hoc"), - // }, - // }, - // Schedule: &armcostmanagement.ExportSchedule{ - // Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeWeekly), - // RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00.000Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00:00:00.000Z"); return t}()), - // }, - // Status: to.Ptr(armcostmanagement.StatusTypeActive), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportCreateOrUpdateBySubscription.json -func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateBySubscription() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExportsClient().CreateOrUpdate(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", "TestExport", armcostmanagement.Export{ - Properties: &armcostmanagement.ExportProperties{ - Format: to.Ptr(armcostmanagement.FormatTypeCSV), - Definition: &armcostmanagement.ExportDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - DataSet: &armcostmanagement.ExportDataset{ - Configuration: &armcostmanagement.ExportDatasetConfiguration{ - Columns: []*string{ - to.Ptr("Date"), - to.Ptr("MeterId"), - to.Ptr("ResourceId"), - to.Ptr("ResourceLocation"), - to.Ptr("Quantity")}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - }, - DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - Destination: &armcostmanagement.ExportDeliveryDestination{ - Container: to.Ptr("exports"), - ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - RootFolderPath: to.Ptr("ad-hoc"), - }, - }, - Schedule: &armcostmanagement.ExportSchedule{ - Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeWeekly), - RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{ - From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00.000Z"); return t }()), - To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00:00:00.000Z"); return t }()), - }, - Status: to.Ptr(armcostmanagement.StatusTypeActive), - }, - }, - }, 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.Export = armcostmanagement.Export{ - // Name: to.Ptr("TestExport"), - // Type: to.Ptr("Microsoft.CostManagement/exports"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/exports/TestExport"), - // Properties: &armcostmanagement.ExportProperties{ - // Format: to.Ptr(armcostmanagement.FormatTypeCSV), - // Definition: &armcostmanagement.ExportDefinition{ - // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - // DataSet: &armcostmanagement.ExportDataset{ - // Configuration: &armcostmanagement.ExportDatasetConfiguration{ - // Columns: []*string{ - // to.Ptr("Date"), - // to.Ptr("MeterId"), - // to.Ptr("ResourceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("Quantity")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - // }, - // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - // Destination: &armcostmanagement.ExportDeliveryDestination{ - // Container: to.Ptr("exports"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - // RootFolderPath: to.Ptr("ad-hoc"), - // }, - // }, - // Schedule: &armcostmanagement.ExportSchedule{ - // Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeWeekly), - // RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00.000Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00:00:00.000Z"); return t}()), - // }, - // Status: to.Ptr(armcostmanagement.StatusTypeActive), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportDeleteByBillingAccount.json -func ExampleExportsClient_Delete_exportDeleteByBillingAccount() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewExportsClient().Delete(ctx, "providers/Microsoft.Billing/billingAccounts/123456", "TestExport", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportDeleteByDepartment.json -func ExampleExportsClient_Delete_exportDeleteByDepartment() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewExportsClient().Delete(ctx, "providers/Microsoft.Billing/billingAccounts/12/departments/1234", "TestExport", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportDeleteByEnrollmentAccount.json -func ExampleExportsClient_Delete_exportDeleteByEnrollmentAccount() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewExportsClient().Delete(ctx, "providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456", "TestExport", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportDeleteByManagementGroup.json -func ExampleExportsClient_Delete_exportDeleteByManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewExportsClient().Delete(ctx, "providers/Microsoft.Management/managementGroups/TestMG", "TestExport", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportDeleteByResourceGroup.json -func ExampleExportsClient_Delete_exportDeleteByResourceGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewExportsClient().Delete(ctx, "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG", "TestExport", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportDeleteBySubscription.json -func ExampleExportsClient_Delete_exportDeleteBySubscription() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewExportsClient().Delete(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", "TestExport", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportRunByBillingAccount.json -func ExampleExportsClient_Execute_exportRunByBillingAccount() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewExportsClient().Execute(ctx, "providers/Microsoft.Billing/billingAccounts/123456", "TestExport", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportRunByDepartment.json -func ExampleExportsClient_Execute_exportRunByDepartment() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewExportsClient().Execute(ctx, "providers/Microsoft.Billing/billingAccounts/12/departments/1234", "TestExport", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportRunByEnrollmentAccount.json -func ExampleExportsClient_Execute_exportRunByEnrollmentAccount() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewExportsClient().Execute(ctx, "providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456", "TestExport", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportRunByManagementGroup.json -func ExampleExportsClient_Execute_exportRunByManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewExportsClient().Execute(ctx, "providers/Microsoft.Management/managementGroups/TestMG", "TestExport", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportRunByResourceGroup.json -func ExampleExportsClient_Execute_exportRunByResourceGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewExportsClient().Execute(ctx, "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG", "TestExport", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportRunBySubscription.json -func ExampleExportsClient_Execute_exportRunBySubscription() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewExportsClient().Execute(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", "TestExport", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportRunHistoryGetByBillingAccount.json -func ExampleExportsClient_GetExecutionHistory_exportRunHistoryGetByBillingAccount() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExportsClient().GetExecutionHistory(ctx, "providers/Microsoft.Billing/billingAccounts/123456", "TestExport", 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.ExportExecutionListResult = armcostmanagement.ExportExecutionListResult{ - // Value: []*armcostmanagement.ExportRun{ - // { - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/{billingAccount-id}/providers/Microsoft.CostManagement/exports/JohnDoeSchedule/Run/1e25d58a-a3b0-4916-9542-6e04a89bc100"), - // Properties: &armcostmanagement.ExportRunProperties{ - // ExecutionType: to.Ptr(armcostmanagement.ExecutionTypeOnDemand), - // FileName: to.Ptr("ScheduledTestsForJohnDoe/JohnDoeSchedule/20180729-20180804/JohnDoeSchedule_1e25d58a-a3b0-4916-9542-6e04a89bc100.csv"), - // ProcessingEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:28.037Z"); return t}()), - // ProcessingStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:16.912Z"); return t}()), - // RunSettings: &armcostmanagement.CommonExportProperties{ - // Format: to.Ptr(armcostmanagement.FormatTypeCSV), - // Definition: &armcostmanagement.ExportDefinition{ - // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - // DataSet: &armcostmanagement.ExportDataset{ - // Configuration: &armcostmanagement.ExportDatasetConfiguration{ - // Columns: []*string{ - // to.Ptr("Date"), - // to.Ptr("MeterId"), - // to.Ptr("ResourceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("Quantity")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // TimePeriod: &armcostmanagement.ExportTimePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00.000Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00:00:00.000Z"); return t}()), - // }, - // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeCustom), - // }, - // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - // Destination: &armcostmanagement.ExportDeliveryDestination{ - // Container: to.Ptr("exports"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - // RootFolderPath: to.Ptr("ScheduledTestsForJohnDoe"), - // }, - // }, - // }, - // Status: to.Ptr(armcostmanagement.ExecutionStatusCompleted), - // SubmittedBy: to.Ptr("john.doe@gmail.com"), - // SubmittedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:15.601Z"); return t}()), - // }, - // }, - // { - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/{billingAccount-id}/providers/Microsoft.CostManagement/exports/JohnDoeSchedule/Run/11ac6811-dca3-46ad-b326-4704cf0c58ef"), - // Properties: &armcostmanagement.ExportRunProperties{ - // ExecutionType: to.Ptr(armcostmanagement.ExecutionTypeScheduled), - // FileName: to.Ptr("ScheduledTestsForJohnDoe/JohnDoeSchedule/20180729-20180804/JohnDoeSchedule_11ac6811-dca3-46ad-b326-4704cf0c58ef.csv"), - // ProcessingEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T09:04:19.722Z"); return t}()), - // ProcessingStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T09:03:58.571Z"); return t}()), - // RunSettings: &armcostmanagement.CommonExportProperties{ - // Format: to.Ptr(armcostmanagement.FormatTypeCSV), - // Definition: &armcostmanagement.ExportDefinition{ - // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - // DataSet: &armcostmanagement.ExportDataset{ - // Configuration: &armcostmanagement.ExportDatasetConfiguration{ - // Columns: []*string{ - // to.Ptr("Date"), - // to.Ptr("MeterId"), - // to.Ptr("ResourceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("Quantity")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // TimePeriod: &armcostmanagement.ExportTimePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00.000Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00:00:00.000Z"); return t}()), - // }, - // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeCustom), - // }, - // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - // Destination: &armcostmanagement.ExportDeliveryDestination{ - // Container: to.Ptr("exports"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - // RootFolderPath: to.Ptr("ScheduledTestsForJohnDoe"), - // }, - // }, - // }, - // Status: to.Ptr(armcostmanagement.ExecutionStatusCompleted), - // SubmittedBy: to.Ptr("System"), - // SubmittedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T09:03:58.571Z"); return t}()), - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportRunHistoryGetByDepartment.json -func ExampleExportsClient_GetExecutionHistory_exportRunHistoryGetByDepartment() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExportsClient().GetExecutionHistory(ctx, "providers/Microsoft.Billing/billingAccounts/12/departments/1234", "TestExport", 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.ExportExecutionListResult = armcostmanagement.ExportExecutionListResult{ - // Value: []*armcostmanagement.ExportRun{ - // { - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12/departments/1234/providers/Microsoft.CostManagement/exports/JohnDoeSchedule/Run/1e25d58a-a3b0-4916-9542-6e04a89bc100"), - // Properties: &armcostmanagement.ExportRunProperties{ - // ExecutionType: to.Ptr(armcostmanagement.ExecutionTypeOnDemand), - // FileName: to.Ptr("ScheduledTestsForJohnDoe/JohnDoeSchedule/20180729-20180804/JohnDoeSchedule_1e25d58a-a3b0-4916-9542-6e04a89bc100.csv"), - // ProcessingEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:28.037Z"); return t}()), - // ProcessingStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:16.912Z"); return t}()), - // RunSettings: &armcostmanagement.CommonExportProperties{ - // Format: to.Ptr(armcostmanagement.FormatTypeCSV), - // Definition: &armcostmanagement.ExportDefinition{ - // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - // DataSet: &armcostmanagement.ExportDataset{ - // Configuration: &armcostmanagement.ExportDatasetConfiguration{ - // Columns: []*string{ - // to.Ptr("Date"), - // to.Ptr("MeterId"), - // to.Ptr("ResourceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("Quantity")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // TimePeriod: &armcostmanagement.ExportTimePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00.000Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00:00:00.000Z"); return t}()), - // }, - // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeCustom), - // }, - // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - // Destination: &armcostmanagement.ExportDeliveryDestination{ - // Container: to.Ptr("exports"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - // RootFolderPath: to.Ptr("ScheduledTestsForJohnDoe"), - // }, - // }, - // }, - // Status: to.Ptr(armcostmanagement.ExecutionStatusCompleted), - // SubmittedBy: to.Ptr("john.doe@gmail.com"), - // SubmittedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:15.601Z"); return t}()), - // }, - // }, - // { - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12/departments/1234/providers/Microsoft.CostManagement/exports/JohnDoeSchedule/Run/11ac6811-dca3-46ad-b326-4704cf0c58ef"), - // Properties: &armcostmanagement.ExportRunProperties{ - // ExecutionType: to.Ptr(armcostmanagement.ExecutionTypeScheduled), - // FileName: to.Ptr("ScheduledTestsForJohnDoe/JohnDoeSchedule/20180729-20180804/JohnDoeSchedule_11ac6811-dca3-46ad-b326-4704cf0c58ef.csv"), - // ProcessingEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T09:04:19.722Z"); return t}()), - // ProcessingStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T09:03:58.571Z"); return t}()), - // RunSettings: &armcostmanagement.CommonExportProperties{ - // Format: to.Ptr(armcostmanagement.FormatTypeCSV), - // Definition: &armcostmanagement.ExportDefinition{ - // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - // DataSet: &armcostmanagement.ExportDataset{ - // Configuration: &armcostmanagement.ExportDatasetConfiguration{ - // Columns: []*string{ - // to.Ptr("Date"), - // to.Ptr("MeterId"), - // to.Ptr("ResourceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("Quantity")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // TimePeriod: &armcostmanagement.ExportTimePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00.000Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00:00:00.000Z"); return t}()), - // }, - // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeCustom), - // }, - // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - // Destination: &armcostmanagement.ExportDeliveryDestination{ - // Container: to.Ptr("exports"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - // RootFolderPath: to.Ptr("ScheduledTestsForJohnDoe"), - // }, - // }, - // }, - // Status: to.Ptr(armcostmanagement.ExecutionStatusCompleted), - // SubmittedBy: to.Ptr("System"), - // SubmittedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T09:03:58.571Z"); return t}()), - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportRunHistoryGetByEnrollmentAccount.json -func ExampleExportsClient_GetExecutionHistory_exportRunHistoryGetByEnrollmentAccount() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExportsClient().GetExecutionHistory(ctx, "providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456", "TestExport", 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.ExportExecutionListResult = armcostmanagement.ExportExecutionListResult{ - // Value: []*armcostmanagement.ExportRun{ - // { - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456/providers/Microsoft.CostManagement/exports/JohnDoeSchedule/Run/1e25d58a-a3b0-4916-9542-6e04a89bc100"), - // Properties: &armcostmanagement.ExportRunProperties{ - // ExecutionType: to.Ptr(armcostmanagement.ExecutionTypeOnDemand), - // FileName: to.Ptr("ScheduledTestsForJohnDoe/JohnDoeSchedule/20180729-20180804/JohnDoeSchedule_1e25d58a-a3b0-4916-9542-6e04a89bc100.csv"), - // ProcessingEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:28.037Z"); return t}()), - // ProcessingStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:16.912Z"); return t}()), - // RunSettings: &armcostmanagement.CommonExportProperties{ - // Format: to.Ptr(armcostmanagement.FormatTypeCSV), - // Definition: &armcostmanagement.ExportDefinition{ - // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - // DataSet: &armcostmanagement.ExportDataset{ - // Configuration: &armcostmanagement.ExportDatasetConfiguration{ - // Columns: []*string{ - // to.Ptr("Date"), - // to.Ptr("MeterId"), - // to.Ptr("ResourceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("Quantity")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // TimePeriod: &armcostmanagement.ExportTimePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00.000Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00:00:00.000Z"); return t}()), - // }, - // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeCustom), - // }, - // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - // Destination: &armcostmanagement.ExportDeliveryDestination{ - // Container: to.Ptr("exports"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - // RootFolderPath: to.Ptr("ScheduledTestsForJohnDoe"), - // }, - // }, - // }, - // Status: to.Ptr(armcostmanagement.ExecutionStatusCompleted), - // SubmittedBy: to.Ptr("john.doe@gmail.com"), - // SubmittedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:15.601Z"); return t}()), - // }, - // }, - // { - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456/providers/Microsoft.CostManagement/exports/JohnDoeSchedule/Run/11ac6811-dca3-46ad-b326-4704cf0c58ef"), - // Properties: &armcostmanagement.ExportRunProperties{ - // ExecutionType: to.Ptr(armcostmanagement.ExecutionTypeScheduled), - // FileName: to.Ptr("ScheduledTestsForJohnDoe/JohnDoeSchedule/20180729-20180804/JohnDoeSchedule_11ac6811-dca3-46ad-b326-4704cf0c58ef.csv"), - // ProcessingEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T09:04:19.722Z"); return t}()), - // ProcessingStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T09:03:58.571Z"); return t}()), - // RunSettings: &armcostmanagement.CommonExportProperties{ - // Format: to.Ptr(armcostmanagement.FormatTypeCSV), - // Definition: &armcostmanagement.ExportDefinition{ - // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - // DataSet: &armcostmanagement.ExportDataset{ - // Configuration: &armcostmanagement.ExportDatasetConfiguration{ - // Columns: []*string{ - // to.Ptr("Date"), - // to.Ptr("MeterId"), - // to.Ptr("ResourceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("Quantity")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // TimePeriod: &armcostmanagement.ExportTimePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00.000Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00:00:00.000Z"); return t}()), - // }, - // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeCustom), - // }, - // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - // Destination: &armcostmanagement.ExportDeliveryDestination{ - // Container: to.Ptr("exports"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - // RootFolderPath: to.Ptr("ScheduledTestsForJohnDoe"), - // }, - // }, - // }, - // Status: to.Ptr(armcostmanagement.ExecutionStatusCompleted), - // SubmittedBy: to.Ptr("System"), - // SubmittedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T09:03:58.571Z"); return t}()), - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportRunHistoryGetByManagementGroup.json -func ExampleExportsClient_GetExecutionHistory_exportRunHistoryGetByManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExportsClient().GetExecutionHistory(ctx, "providers/Microsoft.Management/managementGroups/TestMG", "TestExport", 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.ExportExecutionListResult = armcostmanagement.ExportExecutionListResult{ - // Value: []*armcostmanagement.ExportRun{ - // { - // ID: to.Ptr("providers/Microsoft.Management/managementGroups/TestMG/providers/Microsoft.CostManagement/exports/TestExport/Run/1e25d58a-a3b0-4916-9542-6e04a89bc100"), - // Properties: &armcostmanagement.ExportRunProperties{ - // ExecutionType: to.Ptr(armcostmanagement.ExecutionTypeOnDemand), - // FileName: to.Ptr("ScheduledForTestExport/TestExportSchedule/20180729-20180804/TestExportSchedule_1e25d58a-a3b0-4916-9542-6e04a89bc100.csv"), - // ProcessingEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:28.037Z"); return t}()), - // ProcessingStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:16.912Z"); return t}()), - // RunSettings: &armcostmanagement.CommonExportProperties{ - // Format: to.Ptr(armcostmanagement.FormatTypeCSV), - // Definition: &armcostmanagement.ExportDefinition{ - // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - // DataSet: &armcostmanagement.ExportDataset{ - // Configuration: &armcostmanagement.ExportDatasetConfiguration{ - // Columns: []*string{ - // to.Ptr("Date"), - // to.Ptr("MeterId"), - // to.Ptr("ResourceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("Quantity")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // TimePeriod: &armcostmanagement.ExportTimePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00.000Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00:00:00.000Z"); return t}()), - // }, - // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeCustom), - // }, - // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - // Destination: &armcostmanagement.ExportDeliveryDestination{ - // Container: to.Ptr("exports"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - // RootFolderPath: to.Ptr("ScheduledTestsForJohnDoe"), - // }, - // }, - // }, - // Status: to.Ptr(armcostmanagement.ExecutionStatusCompleted), - // SubmittedBy: to.Ptr("john.doe@gmail.com"), - // SubmittedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:15.601Z"); return t}()), - // }, - // }, - // { - // ID: to.Ptr("providers/Microsoft.Management/managementGroups/TestMG/providers/Microsoft.CostManagement/exports/TestExport/Run/11ac6811-dca3-46ad-b326-4704cf0c58ef"), - // Properties: &armcostmanagement.ExportRunProperties{ - // ExecutionType: to.Ptr(armcostmanagement.ExecutionTypeScheduled), - // FileName: to.Ptr("ScheduledForTestExport/TestExportSchedule/20180729-20180804/TestExportSchedule_11ac6811-dca3-46ad-b326-4704cf0c58ef.csv"), - // ProcessingEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T09:04:19.722Z"); return t}()), - // ProcessingStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T09:03:58.571Z"); return t}()), - // RunSettings: &armcostmanagement.CommonExportProperties{ - // Format: to.Ptr(armcostmanagement.FormatTypeCSV), - // Definition: &armcostmanagement.ExportDefinition{ - // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - // DataSet: &armcostmanagement.ExportDataset{ - // Configuration: &armcostmanagement.ExportDatasetConfiguration{ - // Columns: []*string{ - // to.Ptr("Date"), - // to.Ptr("MeterId"), - // to.Ptr("ResourceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("Quantity")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // TimePeriod: &armcostmanagement.ExportTimePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00.000Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00:00:00.000Z"); return t}()), - // }, - // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeCustom), - // }, - // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - // Destination: &armcostmanagement.ExportDeliveryDestination{ - // Container: to.Ptr("exports"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - // RootFolderPath: to.Ptr("ScheduledTestsForJohnDoe"), - // }, - // }, - // }, - // Status: to.Ptr(armcostmanagement.ExecutionStatusCompleted), - // SubmittedBy: to.Ptr("System"), - // SubmittedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T09:03:58.571Z"); return t}()), - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportRunHistoryGetByResourceGroup.json -func ExampleExportsClient_GetExecutionHistory_exportRunHistoryGetByResourceGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExportsClient().GetExecutionHistory(ctx, "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG", "TestExport", 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.ExportExecutionListResult = armcostmanagement.ExportExecutionListResult{ - // Value: []*armcostmanagement.ExportRun{ - // { - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.CostManagement/exports/JohnDoeSchedule/Run/1e25d58a-a3b0-4916-9542-6e04a89bc100"), - // Properties: &armcostmanagement.ExportRunProperties{ - // ExecutionType: to.Ptr(armcostmanagement.ExecutionTypeOnDemand), - // FileName: to.Ptr("ScheduledTestsForJohnDoe/JohnDoeSchedule/20180729-20180804/JohnDoeSchedule_1e25d58a-a3b0-4916-9542-6e04a89bc100.csv"), - // ProcessingEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:28.037Z"); return t}()), - // ProcessingStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:16.912Z"); return t}()), - // RunSettings: &armcostmanagement.CommonExportProperties{ - // Format: to.Ptr(armcostmanagement.FormatTypeCSV), - // Definition: &armcostmanagement.ExportDefinition{ - // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - // DataSet: &armcostmanagement.ExportDataset{ - // Configuration: &armcostmanagement.ExportDatasetConfiguration{ - // Columns: []*string{ - // to.Ptr("Date"), - // to.Ptr("MeterId"), - // to.Ptr("ResourceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("Quantity")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // TimePeriod: &armcostmanagement.ExportTimePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00.000Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00:00:00.000Z"); return t}()), - // }, - // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeCustom), - // }, - // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - // Destination: &armcostmanagement.ExportDeliveryDestination{ - // Container: to.Ptr("exports"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - // RootFolderPath: to.Ptr("ScheduledTestsForJohnDoe"), - // }, - // }, - // }, - // Status: to.Ptr(armcostmanagement.ExecutionStatusCompleted), - // SubmittedBy: to.Ptr("john.doe@gmail.com"), - // SubmittedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:15.601Z"); return t}()), - // }, - // }, - // { - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.CostManagement/exports/JohnDoeSchedule/Run/11ac6811-dca3-46ad-b326-4704cf0c58ef"), - // Properties: &armcostmanagement.ExportRunProperties{ - // ExecutionType: to.Ptr(armcostmanagement.ExecutionTypeScheduled), - // FileName: to.Ptr("ScheduledTestsForJohnDoe/JohnDoeSchedule/20180729-20180804/JohnDoeSchedule_11ac6811-dca3-46ad-b326-4704cf0c58ef.csv"), - // ProcessingEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T09:04:19.722Z"); return t}()), - // ProcessingStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T09:03:58.571Z"); return t}()), - // RunSettings: &armcostmanagement.CommonExportProperties{ - // Format: to.Ptr(armcostmanagement.FormatTypeCSV), - // Definition: &armcostmanagement.ExportDefinition{ - // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - // DataSet: &armcostmanagement.ExportDataset{ - // Configuration: &armcostmanagement.ExportDatasetConfiguration{ - // Columns: []*string{ - // to.Ptr("Date"), - // to.Ptr("MeterId"), - // to.Ptr("ResourceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("Quantity")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // TimePeriod: &armcostmanagement.ExportTimePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00.000Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00:00:00.000Z"); return t}()), - // }, - // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeCustom), - // }, - // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - // Destination: &armcostmanagement.ExportDeliveryDestination{ - // Container: to.Ptr("exports"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - // RootFolderPath: to.Ptr("ScheduledTestsForJohnDoe"), - // }, - // }, - // }, - // Status: to.Ptr(armcostmanagement.ExecutionStatusCompleted), - // SubmittedBy: to.Ptr("System"), - // SubmittedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T09:03:58.571Z"); return t}()), - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportRunHistoryGetBySubscription.json -func ExampleExportsClient_GetExecutionHistory_exportRunHistoryGetBySubscription() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExportsClient().GetExecutionHistory(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", "TestExport", 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.ExportExecutionListResult = armcostmanagement.ExportExecutionListResult{ - // Value: []*armcostmanagement.ExportRun{ - // { - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/exports/JohnDoeSchedule/Run/1e25d58a-a3b0-4916-9542-6e04a89bc100"), - // Properties: &armcostmanagement.ExportRunProperties{ - // ExecutionType: to.Ptr(armcostmanagement.ExecutionTypeOnDemand), - // FileName: to.Ptr("ScheduledTestsForJohnDoe/JohnDoeSchedule/20180729-20180804/JohnDoeSchedule_1e25d58a-a3b0-4916-9542-6e04a89bc100.csv"), - // ProcessingEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:28.037Z"); return t}()), - // ProcessingStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:16.912Z"); return t}()), - // RunSettings: &armcostmanagement.CommonExportProperties{ - // Format: to.Ptr(armcostmanagement.FormatTypeCSV), - // Definition: &armcostmanagement.ExportDefinition{ - // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - // DataSet: &armcostmanagement.ExportDataset{ - // Configuration: &armcostmanagement.ExportDatasetConfiguration{ - // Columns: []*string{ - // to.Ptr("Date"), - // to.Ptr("MeterId"), - // to.Ptr("ResourceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("Quantity")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // TimePeriod: &armcostmanagement.ExportTimePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00.000Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00:00:00.000Z"); return t}()), - // }, - // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeCustom), - // }, - // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - // Destination: &armcostmanagement.ExportDeliveryDestination{ - // Container: to.Ptr("exports"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - // RootFolderPath: to.Ptr("ScheduledTestsForJohnDoe"), - // }, - // }, - // }, - // Status: to.Ptr(armcostmanagement.ExecutionStatusCompleted), - // SubmittedBy: to.Ptr("john.doe@gmail.com"), - // SubmittedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:15.601Z"); return t}()), - // }, - // }, - // { - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/exports/JohnDoeSchedule/Run/11ac6811-dca3-46ad-b326-4704cf0c58ef"), - // Properties: &armcostmanagement.ExportRunProperties{ - // ExecutionType: to.Ptr(armcostmanagement.ExecutionTypeScheduled), - // FileName: to.Ptr("ScheduledTestsForJohnDoe/JohnDoeSchedule/20180729-20180804/JohnDoeSchedule_11ac6811-dca3-46ad-b326-4704cf0c58ef.csv"), - // ProcessingEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T09:04:19.722Z"); return t}()), - // ProcessingStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T09:03:58.571Z"); return t}()), - // RunSettings: &armcostmanagement.CommonExportProperties{ - // Format: to.Ptr(armcostmanagement.FormatTypeCSV), - // Definition: &armcostmanagement.ExportDefinition{ - // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - // DataSet: &armcostmanagement.ExportDataset{ - // Configuration: &armcostmanagement.ExportDatasetConfiguration{ - // Columns: []*string{ - // to.Ptr("Date"), - // to.Ptr("MeterId"), - // to.Ptr("ResourceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("Quantity")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // TimePeriod: &armcostmanagement.ExportTimePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00.000Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00:00:00.000Z"); return t}()), - // }, - // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeCustom), - // }, - // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - // Destination: &armcostmanagement.ExportDeliveryDestination{ - // Container: to.Ptr("exports"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - // RootFolderPath: to.Ptr("ScheduledTestsForJohnDoe"), - // }, - // }, - // }, - // Status: to.Ptr(armcostmanagement.ExecutionStatusCompleted), - // SubmittedBy: to.Ptr("System"), - // SubmittedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T09:03:58.571Z"); return t}()), - // }, - // }}, - // } -} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/alerts_server.go b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/alerts_server.go index 8f0b82ec1a78..e736593213c0 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/alerts_server.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/alerts_server.go @@ -15,7 +15,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/costmanagement/armcostmanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v3" "net/http" "net/url" "regexp" diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/benefitrecommendations_server.go b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/benefitrecommendations_server.go index e7e500ab314d..8f0cb3ff8fbc 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/benefitrecommendations_server.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/benefitrecommendations_server.go @@ -15,7 +15,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/costmanagement/armcostmanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v3" "net/http" "net/url" "regexp" diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/benefitutilizationsummaries_server.go b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/benefitutilizationsummaries_server.go index 2f824aed6747..70c3360df84d 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/benefitutilizationsummaries_server.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/benefitutilizationsummaries_server.go @@ -15,7 +15,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/costmanagement/armcostmanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v3" "net/http" "net/url" "regexp" diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/budgets_server.go b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/budgets_server.go new file mode 100644 index 000000000000..b899b3584eca --- /dev/null +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/budgets_server.go @@ -0,0 +1,242 @@ +//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 ( + "context" + "errors" + "fmt" + 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/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v3" + "net/http" + "net/url" + "regexp" +) + +// BudgetsServer is a fake server for instances of the armcostmanagement.BudgetsClient type. +type BudgetsServer struct { + // CreateOrUpdate is the fake for method BudgetsClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, scope string, budgetName string, parameters armcostmanagement.Budget, options *armcostmanagement.BudgetsClientCreateOrUpdateOptions) (resp azfake.Responder[armcostmanagement.BudgetsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method BudgetsClient.Delete + // HTTP status codes to indicate success: http.StatusOK + Delete func(ctx context.Context, scope string, budgetName string, options *armcostmanagement.BudgetsClientDeleteOptions) (resp azfake.Responder[armcostmanagement.BudgetsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method BudgetsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, scope string, budgetName string, options *armcostmanagement.BudgetsClientGetOptions) (resp azfake.Responder[armcostmanagement.BudgetsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method BudgetsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(scope string, options *armcostmanagement.BudgetsClientListOptions) (resp azfake.PagerResponder[armcostmanagement.BudgetsClientListResponse]) +} + +// NewBudgetsServerTransport creates a new instance of BudgetsServerTransport with the provided implementation. +// The returned BudgetsServerTransport instance is connected to an instance of armcostmanagement.BudgetsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewBudgetsServerTransport(srv *BudgetsServer) *BudgetsServerTransport { + return &BudgetsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armcostmanagement.BudgetsClientListResponse]](), + } +} + +// BudgetsServerTransport connects instances of armcostmanagement.BudgetsClient to instances of BudgetsServer. +// Don't use this type directly, use NewBudgetsServerTransport instead. +type BudgetsServerTransport struct { + srv *BudgetsServer + newListPager *tracker[azfake.PagerResponder[armcostmanagement.BudgetsClientListResponse]] +} + +// Do implements the policy.Transporter interface for BudgetsServerTransport. +func (b *BudgetsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + 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) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (b *BudgetsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if b.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/budgets/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + 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) + } + body, err := server.UnmarshalRequestAsJSON[armcostmanagement.Budget](req) + if err != nil { + return nil, err + } + scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) + if err != nil { + return nil, err + } + budgetNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("budgetName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.CreateOrUpdate(req.Context(), scopeParam, budgetNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Budget, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (b *BudgetsServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if b.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/budgets/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + 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) + } + scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) + if err != nil { + return nil, err + } + budgetNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("budgetName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.Delete(req.Context(), scopeParam, budgetNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (b *BudgetsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if b.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/budgets/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + 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) + } + scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) + if err != nil { + return nil, err + } + budgetNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("budgetName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.Get(req.Context(), scopeParam, budgetNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Budget, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (b *BudgetsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if b.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := b.newListPager.get(req) + if newListPager == nil { + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/budgets` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + var options *armcostmanagement.BudgetsClientListOptions + if filterParam != nil { + options = &armcostmanagement.BudgetsClientListOptions{ + Filter: filterParam, + } + } + resp := b.srv.NewListPager(scopeParam, options) + newListPager = &resp + b.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armcostmanagement.BudgetsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + b.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + b.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/costallocationrules_server.go b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/costallocationrules_server.go new file mode 100644 index 000000000000..60ae5ad7560f --- /dev/null +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/costallocationrules_server.go @@ -0,0 +1,269 @@ +//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 ( + "context" + "errors" + "fmt" + 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/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v3" + "net/http" + "net/url" + "regexp" +) + +// CostAllocationRulesServer is a fake server for instances of the armcostmanagement.CostAllocationRulesClient type. +type CostAllocationRulesServer struct { + // CheckNameAvailability is the fake for method CostAllocationRulesClient.CheckNameAvailability + // HTTP status codes to indicate success: http.StatusOK + CheckNameAvailability func(ctx context.Context, billingAccountID string, costAllocationRuleCheckNameAvailabilityRequest armcostmanagement.CostAllocationRuleCheckNameAvailabilityRequest, options *armcostmanagement.CostAllocationRulesClientCheckNameAvailabilityOptions) (resp azfake.Responder[armcostmanagement.CostAllocationRulesClientCheckNameAvailabilityResponse], errResp azfake.ErrorResponder) + + // CreateOrUpdate is the fake for method CostAllocationRulesClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, billingAccountID string, ruleName string, costAllocationRule armcostmanagement.CostAllocationRuleDefinition, options *armcostmanagement.CostAllocationRulesClientCreateOrUpdateOptions) (resp azfake.Responder[armcostmanagement.CostAllocationRulesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method CostAllocationRulesClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, billingAccountID string, ruleName string, options *armcostmanagement.CostAllocationRulesClientDeleteOptions) (resp azfake.Responder[armcostmanagement.CostAllocationRulesClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method CostAllocationRulesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, billingAccountID string, ruleName string, options *armcostmanagement.CostAllocationRulesClientGetOptions) (resp azfake.Responder[armcostmanagement.CostAllocationRulesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method CostAllocationRulesClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(billingAccountID string, options *armcostmanagement.CostAllocationRulesClientListOptions) (resp azfake.PagerResponder[armcostmanagement.CostAllocationRulesClientListResponse]) +} + +// NewCostAllocationRulesServerTransport creates a new instance of CostAllocationRulesServerTransport with the provided implementation. +// The returned CostAllocationRulesServerTransport instance is connected to an instance of armcostmanagement.CostAllocationRulesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewCostAllocationRulesServerTransport(srv *CostAllocationRulesServer) *CostAllocationRulesServerTransport { + return &CostAllocationRulesServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armcostmanagement.CostAllocationRulesClientListResponse]](), + } +} + +// CostAllocationRulesServerTransport connects instances of armcostmanagement.CostAllocationRulesClient to instances of CostAllocationRulesServer. +// Don't use this type directly, use NewCostAllocationRulesServerTransport instead. +type CostAllocationRulesServerTransport struct { + srv *CostAllocationRulesServer + newListPager *tracker[azfake.PagerResponder[armcostmanagement.CostAllocationRulesClientListResponse]] +} + +// Do implements the policy.Transporter interface for CostAllocationRulesServerTransport. +func (c *CostAllocationRulesServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "CostAllocationRulesClient.CheckNameAvailability": + resp, err = c.dispatchCheckNameAvailability(req) + case "CostAllocationRulesClient.CreateOrUpdate": + resp, err = c.dispatchCreateOrUpdate(req) + case "CostAllocationRulesClient.Delete": + resp, err = c.dispatchDelete(req) + case "CostAllocationRulesClient.Get": + resp, err = c.dispatchGet(req) + case "CostAllocationRulesClient.NewListPager": + resp, err = c.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (c *CostAllocationRulesServerTransport) dispatchCheckNameAvailability(req *http.Request) (*http.Response, error) { + if c.srv.CheckNameAvailability == nil { + return nil, &nonRetriableError{errors.New("fake for method CheckNameAvailability not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/costAllocationRules/checkNameAvailability` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcostmanagement.CostAllocationRuleCheckNameAvailabilityRequest](req) + if err != nil { + return nil, err + } + billingAccountIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountId")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.CheckNameAvailability(req.Context(), billingAccountIDParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).CostAllocationRuleCheckNameAvailabilityResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *CostAllocationRulesServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if c.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/costAllocationRules/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + 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) + } + body, err := server.UnmarshalRequestAsJSON[armcostmanagement.CostAllocationRuleDefinition](req) + if err != nil { + return nil, err + } + billingAccountIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountId")]) + if err != nil { + return nil, err + } + ruleNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("ruleName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.CreateOrUpdate(req.Context(), billingAccountIDParam, ruleNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).CostAllocationRuleDefinition, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *CostAllocationRulesServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if c.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/costAllocationRules/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + 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 + } + ruleNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("ruleName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.Delete(req.Context(), billingAccountIDParam, ruleNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *CostAllocationRulesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if c.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/costAllocationRules/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + 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 + } + ruleNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("ruleName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.Get(req.Context(), billingAccountIDParam, ruleNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).CostAllocationRuleDefinition, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *CostAllocationRulesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if c.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := c.newListPager.get(req) + if newListPager == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/costAllocationRules` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + 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 + } + resp := c.srv.NewListPager(billingAccountIDParam, nil) + newListPager = &resp + c.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armcostmanagement.CostAllocationRulesClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + c.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + c.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/dimensions_server.go b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/dimensions_server.go index 34ddbbd99b03..bba4c1029b28 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/dimensions_server.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/dimensions_server.go @@ -14,7 +14,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/costmanagement/armcostmanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v3" "net/http" "net/url" "regexp" diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/exports_server.go b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/exports_server.go index e509b0f5ca51..b2bd80bc166d 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/exports_server.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/exports_server.go @@ -15,7 +15,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/costmanagement/armcostmanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v3" "net/http" "net/url" "regexp" diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/forecast_server.go b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/forecast_server.go index 0f5b43feaa47..64dfc98182e3 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/forecast_server.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/forecast_server.go @@ -15,7 +15,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/costmanagement/armcostmanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v3" "net/http" "net/url" "regexp" diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatebenefitutilizationsummariesreport_server.go b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatebenefitutilizationsummariesreport_server.go new file mode 100644 index 000000000000..676e7a5ba69f --- /dev/null +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatebenefitutilizationsummariesreport_server.go @@ -0,0 +1,387 @@ +//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 ( + "context" + "errors" + "fmt" + 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/costmanagement/armcostmanagement/v3" + "net/http" + "net/url" + "regexp" +) + +// GenerateBenefitUtilizationSummariesReportServer is a fake server for instances of the armcostmanagement.GenerateBenefitUtilizationSummariesReportClient type. +type GenerateBenefitUtilizationSummariesReportServer struct { + // BeginGenerateByBillingAccount is the fake for method GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByBillingAccount + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginGenerateByBillingAccount func(ctx context.Context, billingAccountID string, benefitUtilizationSummariesRequest armcostmanagement.BenefitUtilizationSummariesRequest, options *armcostmanagement.GenerateBenefitUtilizationSummariesReportClientBeginGenerateByBillingAccountOptions) (resp azfake.PollerResponder[armcostmanagement.GenerateBenefitUtilizationSummariesReportClientGenerateByBillingAccountResponse], errResp azfake.ErrorResponder) + + // BeginGenerateByBillingProfile is the fake for method GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByBillingProfile + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginGenerateByBillingProfile func(ctx context.Context, billingAccountID string, billingProfileID string, benefitUtilizationSummariesRequest armcostmanagement.BenefitUtilizationSummariesRequest, options *armcostmanagement.GenerateBenefitUtilizationSummariesReportClientBeginGenerateByBillingProfileOptions) (resp azfake.PollerResponder[armcostmanagement.GenerateBenefitUtilizationSummariesReportClientGenerateByBillingProfileResponse], errResp azfake.ErrorResponder) + + // BeginGenerateByReservationID is the fake for method GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByReservationID + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginGenerateByReservationID func(ctx context.Context, reservationOrderID string, reservationID string, benefitUtilizationSummariesRequest armcostmanagement.BenefitUtilizationSummariesRequest, options *armcostmanagement.GenerateBenefitUtilizationSummariesReportClientBeginGenerateByReservationIDOptions) (resp azfake.PollerResponder[armcostmanagement.GenerateBenefitUtilizationSummariesReportClientGenerateByReservationIDResponse], errResp azfake.ErrorResponder) + + // BeginGenerateByReservationOrderID is the fake for method GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByReservationOrderID + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginGenerateByReservationOrderID func(ctx context.Context, reservationOrderID string, benefitUtilizationSummariesRequest armcostmanagement.BenefitUtilizationSummariesRequest, options *armcostmanagement.GenerateBenefitUtilizationSummariesReportClientBeginGenerateByReservationOrderIDOptions) (resp azfake.PollerResponder[armcostmanagement.GenerateBenefitUtilizationSummariesReportClientGenerateByReservationOrderIDResponse], errResp azfake.ErrorResponder) + + // BeginGenerateBySavingsPlanID is the fake for method GenerateBenefitUtilizationSummariesReportClient.BeginGenerateBySavingsPlanID + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginGenerateBySavingsPlanID func(ctx context.Context, savingsPlanOrderID string, savingsPlanID string, benefitUtilizationSummariesRequest armcostmanagement.BenefitUtilizationSummariesRequest, options *armcostmanagement.GenerateBenefitUtilizationSummariesReportClientBeginGenerateBySavingsPlanIDOptions) (resp azfake.PollerResponder[armcostmanagement.GenerateBenefitUtilizationSummariesReportClientGenerateBySavingsPlanIDResponse], errResp azfake.ErrorResponder) + + // BeginGenerateBySavingsPlanOrderID is the fake for method GenerateBenefitUtilizationSummariesReportClient.BeginGenerateBySavingsPlanOrderID + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginGenerateBySavingsPlanOrderID func(ctx context.Context, savingsPlanOrderID string, benefitUtilizationSummariesRequest armcostmanagement.BenefitUtilizationSummariesRequest, options *armcostmanagement.GenerateBenefitUtilizationSummariesReportClientBeginGenerateBySavingsPlanOrderIDOptions) (resp azfake.PollerResponder[armcostmanagement.GenerateBenefitUtilizationSummariesReportClientGenerateBySavingsPlanOrderIDResponse], errResp azfake.ErrorResponder) +} + +// NewGenerateBenefitUtilizationSummariesReportServerTransport creates a new instance of GenerateBenefitUtilizationSummariesReportServerTransport with the provided implementation. +// The returned GenerateBenefitUtilizationSummariesReportServerTransport instance is connected to an instance of armcostmanagement.GenerateBenefitUtilizationSummariesReportClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewGenerateBenefitUtilizationSummariesReportServerTransport(srv *GenerateBenefitUtilizationSummariesReportServer) *GenerateBenefitUtilizationSummariesReportServerTransport { + return &GenerateBenefitUtilizationSummariesReportServerTransport{ + srv: srv, + beginGenerateByBillingAccount: newTracker[azfake.PollerResponder[armcostmanagement.GenerateBenefitUtilizationSummariesReportClientGenerateByBillingAccountResponse]](), + beginGenerateByBillingProfile: newTracker[azfake.PollerResponder[armcostmanagement.GenerateBenefitUtilizationSummariesReportClientGenerateByBillingProfileResponse]](), + beginGenerateByReservationID: newTracker[azfake.PollerResponder[armcostmanagement.GenerateBenefitUtilizationSummariesReportClientGenerateByReservationIDResponse]](), + beginGenerateByReservationOrderID: newTracker[azfake.PollerResponder[armcostmanagement.GenerateBenefitUtilizationSummariesReportClientGenerateByReservationOrderIDResponse]](), + beginGenerateBySavingsPlanID: newTracker[azfake.PollerResponder[armcostmanagement.GenerateBenefitUtilizationSummariesReportClientGenerateBySavingsPlanIDResponse]](), + beginGenerateBySavingsPlanOrderID: newTracker[azfake.PollerResponder[armcostmanagement.GenerateBenefitUtilizationSummariesReportClientGenerateBySavingsPlanOrderIDResponse]](), + } +} + +// GenerateBenefitUtilizationSummariesReportServerTransport connects instances of armcostmanagement.GenerateBenefitUtilizationSummariesReportClient to instances of GenerateBenefitUtilizationSummariesReportServer. +// Don't use this type directly, use NewGenerateBenefitUtilizationSummariesReportServerTransport instead. +type GenerateBenefitUtilizationSummariesReportServerTransport struct { + srv *GenerateBenefitUtilizationSummariesReportServer + beginGenerateByBillingAccount *tracker[azfake.PollerResponder[armcostmanagement.GenerateBenefitUtilizationSummariesReportClientGenerateByBillingAccountResponse]] + beginGenerateByBillingProfile *tracker[azfake.PollerResponder[armcostmanagement.GenerateBenefitUtilizationSummariesReportClientGenerateByBillingProfileResponse]] + beginGenerateByReservationID *tracker[azfake.PollerResponder[armcostmanagement.GenerateBenefitUtilizationSummariesReportClientGenerateByReservationIDResponse]] + beginGenerateByReservationOrderID *tracker[azfake.PollerResponder[armcostmanagement.GenerateBenefitUtilizationSummariesReportClientGenerateByReservationOrderIDResponse]] + beginGenerateBySavingsPlanID *tracker[azfake.PollerResponder[armcostmanagement.GenerateBenefitUtilizationSummariesReportClientGenerateBySavingsPlanIDResponse]] + beginGenerateBySavingsPlanOrderID *tracker[azfake.PollerResponder[armcostmanagement.GenerateBenefitUtilizationSummariesReportClientGenerateBySavingsPlanOrderIDResponse]] +} + +// Do implements the policy.Transporter interface for GenerateBenefitUtilizationSummariesReportServerTransport. +func (g *GenerateBenefitUtilizationSummariesReportServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByBillingAccount": + resp, err = g.dispatchBeginGenerateByBillingAccount(req) + case "GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByBillingProfile": + resp, err = g.dispatchBeginGenerateByBillingProfile(req) + case "GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByReservationID": + resp, err = g.dispatchBeginGenerateByReservationID(req) + case "GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByReservationOrderID": + resp, err = g.dispatchBeginGenerateByReservationOrderID(req) + case "GenerateBenefitUtilizationSummariesReportClient.BeginGenerateBySavingsPlanID": + resp, err = g.dispatchBeginGenerateBySavingsPlanID(req) + case "GenerateBenefitUtilizationSummariesReportClient.BeginGenerateBySavingsPlanOrderID": + resp, err = g.dispatchBeginGenerateBySavingsPlanOrderID(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (g *GenerateBenefitUtilizationSummariesReportServerTransport) dispatchBeginGenerateByBillingAccount(req *http.Request) (*http.Response, error) { + if g.srv.BeginGenerateByBillingAccount == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginGenerateByBillingAccount not implemented")} + } + beginGenerateByBillingAccount := g.beginGenerateByBillingAccount.get(req) + if beginGenerateByBillingAccount == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/generateBenefitUtilizationSummariesReport` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcostmanagement.BenefitUtilizationSummariesRequest](req) + if err != nil { + return nil, err + } + billingAccountIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountId")]) + if err != nil { + return nil, err + } + respr, errRespr := g.srv.BeginGenerateByBillingAccount(req.Context(), billingAccountIDParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginGenerateByBillingAccount = &respr + g.beginGenerateByBillingAccount.add(req, beginGenerateByBillingAccount) + } + + resp, err := server.PollerResponderNext(beginGenerateByBillingAccount, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + g.beginGenerateByBillingAccount.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginGenerateByBillingAccount) { + g.beginGenerateByBillingAccount.remove(req) + } + + return resp, nil +} + +func (g *GenerateBenefitUtilizationSummariesReportServerTransport) dispatchBeginGenerateByBillingProfile(req *http.Request) (*http.Response, error) { + if g.srv.BeginGenerateByBillingProfile == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginGenerateByBillingProfile not implemented")} + } + beginGenerateByBillingProfile := g.beginGenerateByBillingProfile.get(req) + if beginGenerateByBillingProfile == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/generateBenefitUtilizationSummariesReport` + 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) + } + body, err := server.UnmarshalRequestAsJSON[armcostmanagement.BenefitUtilizationSummariesRequest](req) + if err != nil { + return nil, err + } + billingAccountIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountId")]) + if err != nil { + return nil, err + } + billingProfileIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileId")]) + if err != nil { + return nil, err + } + respr, errRespr := g.srv.BeginGenerateByBillingProfile(req.Context(), billingAccountIDParam, billingProfileIDParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginGenerateByBillingProfile = &respr + g.beginGenerateByBillingProfile.add(req, beginGenerateByBillingProfile) + } + + resp, err := server.PollerResponderNext(beginGenerateByBillingProfile, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + g.beginGenerateByBillingProfile.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginGenerateByBillingProfile) { + g.beginGenerateByBillingProfile.remove(req) + } + + return resp, nil +} + +func (g *GenerateBenefitUtilizationSummariesReportServerTransport) dispatchBeginGenerateByReservationID(req *http.Request) (*http.Response, error) { + if g.srv.BeginGenerateByReservationID == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginGenerateByReservationID not implemented")} + } + beginGenerateByReservationID := g.beginGenerateByReservationID.get(req) + if beginGenerateByReservationID == nil { + const regexStr = `/providers/Microsoft\.Capacity/reservationorders/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/reservations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/generateBenefitUtilizationSummariesReport` + 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) + } + body, err := server.UnmarshalRequestAsJSON[armcostmanagement.BenefitUtilizationSummariesRequest](req) + if err != nil { + return nil, err + } + reservationOrderIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("reservationOrderId")]) + if err != nil { + return nil, err + } + reservationIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("reservationId")]) + if err != nil { + return nil, err + } + respr, errRespr := g.srv.BeginGenerateByReservationID(req.Context(), reservationOrderIDParam, reservationIDParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginGenerateByReservationID = &respr + g.beginGenerateByReservationID.add(req, beginGenerateByReservationID) + } + + resp, err := server.PollerResponderNext(beginGenerateByReservationID, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + g.beginGenerateByReservationID.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginGenerateByReservationID) { + g.beginGenerateByReservationID.remove(req) + } + + return resp, nil +} + +func (g *GenerateBenefitUtilizationSummariesReportServerTransport) dispatchBeginGenerateByReservationOrderID(req *http.Request) (*http.Response, error) { + if g.srv.BeginGenerateByReservationOrderID == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginGenerateByReservationOrderID not implemented")} + } + beginGenerateByReservationOrderID := g.beginGenerateByReservationOrderID.get(req) + if beginGenerateByReservationOrderID == nil { + const regexStr = `/providers/Microsoft\.Capacity/reservationorders/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/generateBenefitUtilizationSummariesReport` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcostmanagement.BenefitUtilizationSummariesRequest](req) + if err != nil { + return nil, err + } + reservationOrderIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("reservationOrderId")]) + if err != nil { + return nil, err + } + respr, errRespr := g.srv.BeginGenerateByReservationOrderID(req.Context(), reservationOrderIDParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginGenerateByReservationOrderID = &respr + g.beginGenerateByReservationOrderID.add(req, beginGenerateByReservationOrderID) + } + + resp, err := server.PollerResponderNext(beginGenerateByReservationOrderID, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + g.beginGenerateByReservationOrderID.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginGenerateByReservationOrderID) { + g.beginGenerateByReservationOrderID.remove(req) + } + + return resp, nil +} + +func (g *GenerateBenefitUtilizationSummariesReportServerTransport) dispatchBeginGenerateBySavingsPlanID(req *http.Request) (*http.Response, error) { + if g.srv.BeginGenerateBySavingsPlanID == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginGenerateBySavingsPlanID not implemented")} + } + beginGenerateBySavingsPlanID := g.beginGenerateBySavingsPlanID.get(req) + if beginGenerateBySavingsPlanID == nil { + const regexStr = `/providers/Microsoft\.BillingBenefits/savingsPlanOrders/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/savingsPlans/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/generateBenefitUtilizationSummariesReport` + 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) + } + body, err := server.UnmarshalRequestAsJSON[armcostmanagement.BenefitUtilizationSummariesRequest](req) + if err != nil { + return nil, err + } + savingsPlanOrderIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("savingsPlanOrderId")]) + if err != nil { + return nil, err + } + savingsPlanIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("savingsPlanId")]) + if err != nil { + return nil, err + } + respr, errRespr := g.srv.BeginGenerateBySavingsPlanID(req.Context(), savingsPlanOrderIDParam, savingsPlanIDParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginGenerateBySavingsPlanID = &respr + g.beginGenerateBySavingsPlanID.add(req, beginGenerateBySavingsPlanID) + } + + resp, err := server.PollerResponderNext(beginGenerateBySavingsPlanID, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + g.beginGenerateBySavingsPlanID.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginGenerateBySavingsPlanID) { + g.beginGenerateBySavingsPlanID.remove(req) + } + + return resp, nil +} + +func (g *GenerateBenefitUtilizationSummariesReportServerTransport) dispatchBeginGenerateBySavingsPlanOrderID(req *http.Request) (*http.Response, error) { + if g.srv.BeginGenerateBySavingsPlanOrderID == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginGenerateBySavingsPlanOrderID not implemented")} + } + beginGenerateBySavingsPlanOrderID := g.beginGenerateBySavingsPlanOrderID.get(req) + if beginGenerateBySavingsPlanOrderID == nil { + const regexStr = `/providers/Microsoft\.BillingBenefits/savingsPlanOrders/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/generateBenefitUtilizationSummariesReport` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armcostmanagement.BenefitUtilizationSummariesRequest](req) + if err != nil { + return nil, err + } + savingsPlanOrderIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("savingsPlanOrderId")]) + if err != nil { + return nil, err + } + respr, errRespr := g.srv.BeginGenerateBySavingsPlanOrderID(req.Context(), savingsPlanOrderIDParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginGenerateBySavingsPlanOrderID = &respr + g.beginGenerateBySavingsPlanOrderID.add(req, beginGenerateBySavingsPlanOrderID) + } + + resp, err := server.PollerResponderNext(beginGenerateBySavingsPlanOrderID, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + g.beginGenerateBySavingsPlanOrderID.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginGenerateBySavingsPlanOrderID) { + g.beginGenerateBySavingsPlanOrderID.remove(req) + } + + return resp, nil +} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatecostdetailsreport_server.go b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatecostdetailsreport_server.go index b382a25c14ae..86fa1b0be9d0 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatecostdetailsreport_server.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatecostdetailsreport_server.go @@ -15,7 +15,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/costmanagement/armcostmanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v3" "net/http" "net/url" "regexp" diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatedetailedcostreport_server.go b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatedetailedcostreport_server.go index b84142120270..a27e8636830c 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatedetailedcostreport_server.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatedetailedcostreport_server.go @@ -15,7 +15,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/costmanagement/armcostmanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v3" "net/http" "net/url" "regexp" diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatedetailedcostreportoperationresults_server.go b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatedetailedcostreportoperationresults_server.go index 24c6fb7c2699..f3c6c13d5063 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatedetailedcostreportoperationresults_server.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatedetailedcostreportoperationresults_server.go @@ -15,7 +15,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/costmanagement/armcostmanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v3" "net/http" "net/url" "regexp" diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatedetailedcostreportoperationstatus_server.go b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatedetailedcostreportoperationstatus_server.go index 365cc0350d36..f07d985080cb 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatedetailedcostreportoperationstatus_server.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatedetailedcostreportoperationstatus_server.go @@ -15,7 +15,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/costmanagement/armcostmanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v3" "net/http" "net/url" "regexp" diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatereservationdetailsreport_server.go b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatereservationdetailsreport_server.go index b5e92cd54f0e..881aade6a2d8 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatereservationdetailsreport_server.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatereservationdetailsreport_server.go @@ -15,7 +15,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/costmanagement/armcostmanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v3" "net/http" "net/url" "regexp" diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/internal.go b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/internal.go index 96339f26b377..e8e13192f75e 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/internal.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/internal.go @@ -10,6 +10,7 @@ package fake import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "io" "net/http" "reflect" "sync" @@ -66,6 +67,18 @@ func parseWithCast[T any](v string, parse func(v string) (T, error)) (T, error) return t, err } +func readRequestBody(req *http.Request) ([]byte, error) { + if req.Body == nil { + return nil, nil + } + body, err := io.ReadAll(req.Body) + if err != nil { + return nil, err + } + req.Body.Close() + return body, nil +} + func newTracker[T any]() *tracker[T] { return &tracker[T]{ items: map[string]*T{}, diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/operations_server.go b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/operations_server.go index a8eaed5ab081..3124da5c7d32 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/operations_server.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/operations_server.go @@ -15,7 +15,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/costmanagement/armcostmanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v3" "net/http" ) diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/polymorphic_helpers.go b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/polymorphic_helpers.go new file mode 100644 index 000000000000..eb9e70780490 --- /dev/null +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/polymorphic_helpers.go @@ -0,0 +1,35 @@ +//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" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v3" +) + +func unmarshalSettingClassification(rawMsg json.RawMessage) (armcostmanagement.SettingClassification, 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 armcostmanagement.SettingClassification + switch m["kind"] { + case string(armcostmanagement.SettingsKindTaginheritance): + b = &armcostmanagement.TagInheritanceSetting{} + default: + b = &armcostmanagement.Setting{} + } + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil +} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/pricesheet_server.go b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/pricesheet_server.go index 59d54edaf828..d1dc52eda15e 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/pricesheet_server.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/pricesheet_server.go @@ -15,7 +15,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/costmanagement/armcostmanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v3" "net/http" "net/url" "regexp" @@ -23,13 +23,17 @@ import ( // PriceSheetServer is a fake server for instances of the armcostmanagement.PriceSheetClient type. type PriceSheetServer struct { - // BeginDownload is the fake for method PriceSheetClient.BeginDownload + // BeginDownloadByBillingAccount is the fake for method PriceSheetClient.BeginDownloadByBillingAccount // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted - BeginDownload func(ctx context.Context, billingAccountName string, billingProfileName string, invoiceName string, options *armcostmanagement.PriceSheetClientBeginDownloadOptions) (resp azfake.PollerResponder[armcostmanagement.PriceSheetClientDownloadResponse], errResp azfake.ErrorResponder) + BeginDownloadByBillingAccount func(ctx context.Context, billingAccountID string, billingPeriodName string, options *armcostmanagement.PriceSheetClientBeginDownloadByBillingAccountOptions) (resp azfake.PollerResponder[armcostmanagement.PriceSheetClientDownloadByBillingAccountResponse], errResp azfake.ErrorResponder) // BeginDownloadByBillingProfile is the fake for method PriceSheetClient.BeginDownloadByBillingProfile // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted BeginDownloadByBillingProfile func(ctx context.Context, billingAccountName string, billingProfileName string, options *armcostmanagement.PriceSheetClientBeginDownloadByBillingProfileOptions) (resp azfake.PollerResponder[armcostmanagement.PriceSheetClientDownloadByBillingProfileResponse], errResp azfake.ErrorResponder) + + // BeginDownloadByInvoice is the fake for method PriceSheetClient.BeginDownloadByInvoice + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginDownloadByInvoice func(ctx context.Context, billingAccountName string, billingProfileName string, invoiceName string, options *armcostmanagement.PriceSheetClientBeginDownloadByInvoiceOptions) (resp azfake.PollerResponder[armcostmanagement.PriceSheetClientDownloadByInvoiceResponse], errResp azfake.ErrorResponder) } // NewPriceSheetServerTransport creates a new instance of PriceSheetServerTransport with the provided implementation. @@ -38,8 +42,9 @@ type PriceSheetServer struct { func NewPriceSheetServerTransport(srv *PriceSheetServer) *PriceSheetServerTransport { return &PriceSheetServerTransport{ srv: srv, - beginDownload: newTracker[azfake.PollerResponder[armcostmanagement.PriceSheetClientDownloadResponse]](), + beginDownloadByBillingAccount: newTracker[azfake.PollerResponder[armcostmanagement.PriceSheetClientDownloadByBillingAccountResponse]](), beginDownloadByBillingProfile: newTracker[azfake.PollerResponder[armcostmanagement.PriceSheetClientDownloadByBillingProfileResponse]](), + beginDownloadByInvoice: newTracker[azfake.PollerResponder[armcostmanagement.PriceSheetClientDownloadByInvoiceResponse]](), } } @@ -47,8 +52,9 @@ func NewPriceSheetServerTransport(srv *PriceSheetServer) *PriceSheetServerTransp // Don't use this type directly, use NewPriceSheetServerTransport instead. type PriceSheetServerTransport struct { srv *PriceSheetServer - beginDownload *tracker[azfake.PollerResponder[armcostmanagement.PriceSheetClientDownloadResponse]] + beginDownloadByBillingAccount *tracker[azfake.PollerResponder[armcostmanagement.PriceSheetClientDownloadByBillingAccountResponse]] beginDownloadByBillingProfile *tracker[azfake.PollerResponder[armcostmanagement.PriceSheetClientDownloadByBillingProfileResponse]] + beginDownloadByInvoice *tracker[azfake.PollerResponder[armcostmanagement.PriceSheetClientDownloadByInvoiceResponse]] } // Do implements the policy.Transporter interface for PriceSheetServerTransport. @@ -63,10 +69,12 @@ func (p *PriceSheetServerTransport) Do(req *http.Request) (*http.Response, error var err error switch method { - case "PriceSheetClient.BeginDownload": - resp, err = p.dispatchBeginDownload(req) + case "PriceSheetClient.BeginDownloadByBillingAccount": + resp, err = p.dispatchBeginDownloadByBillingAccount(req) case "PriceSheetClient.BeginDownloadByBillingProfile": resp, err = p.dispatchBeginDownloadByBillingProfile(req) + case "PriceSheetClient.BeginDownloadByInvoice": + resp, err = p.dispatchBeginDownloadByInvoice(req) default: err = fmt.Errorf("unhandled API %s", method) } @@ -78,49 +86,45 @@ func (p *PriceSheetServerTransport) Do(req *http.Request) (*http.Response, error return resp, nil } -func (p *PriceSheetServerTransport) dispatchBeginDownload(req *http.Request) (*http.Response, error) { - if p.srv.BeginDownload == nil { - return nil, &nonRetriableError{errors.New("fake for method BeginDownload not implemented")} +func (p *PriceSheetServerTransport) dispatchBeginDownloadByBillingAccount(req *http.Request) (*http.Response, error) { + if p.srv.BeginDownloadByBillingAccount == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDownloadByBillingAccount not implemented")} } - beginDownload := p.beginDownload.get(req) - if beginDownload == nil { - const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/invoices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/pricesheets/default/download` + beginDownloadByBillingAccount := p.beginDownloadByBillingAccount.get(req) + if beginDownloadByBillingAccount == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingPeriods/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/pricesheets/default/download` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { + if matches == nil || len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } - billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) - if err != nil { - return nil, err - } - billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + billingAccountIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountId")]) if err != nil { return nil, err } - invoiceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("invoiceName")]) + billingPeriodNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingPeriodName")]) if err != nil { return nil, err } - respr, errRespr := p.srv.BeginDownload(req.Context(), billingAccountNameParam, billingProfileNameParam, invoiceNameParam, nil) + respr, errRespr := p.srv.BeginDownloadByBillingAccount(req.Context(), billingAccountIDParam, billingPeriodNameParam, nil) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } - beginDownload = &respr - p.beginDownload.add(req, beginDownload) + beginDownloadByBillingAccount = &respr + p.beginDownloadByBillingAccount.add(req, beginDownloadByBillingAccount) } - resp, err := server.PollerResponderNext(beginDownload, req) + resp, err := server.PollerResponderNext(beginDownloadByBillingAccount, req) if err != nil { return nil, err } if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { - p.beginDownload.remove(req) + p.beginDownloadByBillingAccount.remove(req) return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} } - if !server.PollerResponderMore(beginDownload) { - p.beginDownload.remove(req) + if !server.PollerResponderMore(beginDownloadByBillingAccount) { + p.beginDownloadByBillingAccount.remove(req) } return resp, nil @@ -169,3 +173,51 @@ func (p *PriceSheetServerTransport) dispatchBeginDownloadByBillingProfile(req *h return resp, nil } + +func (p *PriceSheetServerTransport) dispatchBeginDownloadByInvoice(req *http.Request) (*http.Response, error) { + if p.srv.BeginDownloadByInvoice == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDownloadByInvoice not implemented")} + } + beginDownloadByInvoice := p.beginDownloadByInvoice.get(req) + if beginDownloadByInvoice == nil { + const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/invoices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/pricesheets/default/download` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) + if err != nil { + return nil, err + } + billingProfileNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingProfileName")]) + if err != nil { + return nil, err + } + invoiceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("invoiceName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.BeginDownloadByInvoice(req.Context(), billingAccountNameParam, billingProfileNameParam, invoiceNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDownloadByInvoice = &respr + p.beginDownloadByInvoice.add(req, beginDownloadByInvoice) + } + + resp, err := server.PollerResponderNext(beginDownloadByInvoice, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + p.beginDownloadByInvoice.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDownloadByInvoice) { + p.beginDownloadByInvoice.remove(req) + } + + return resp, nil +} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/query_server.go b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/query_server.go index e159998c84bd..215661518e8b 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/query_server.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/query_server.go @@ -15,7 +15,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/costmanagement/armcostmanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v3" "net/http" "net/url" "regexp" diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/scheduledactions_server.go b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/scheduledactions_server.go index aa386d385595..7dc57283c059 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/scheduledactions_server.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/scheduledactions_server.go @@ -16,7 +16,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/costmanagement/armcostmanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v3" "net/http" "net/url" "regexp" diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/server_factory.go b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/server_factory.go index a815db0fdb2a..6f1b25dd504d 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/server_factory.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/server_factory.go @@ -22,9 +22,12 @@ type ServerFactory struct { AlertsServer AlertsServer BenefitRecommendationsServer BenefitRecommendationsServer BenefitUtilizationSummariesServer BenefitUtilizationSummariesServer + BudgetsServer BudgetsServer + CostAllocationRulesServer CostAllocationRulesServer DimensionsServer DimensionsServer ExportsServer ExportsServer ForecastServer ForecastServer + GenerateBenefitUtilizationSummariesReportServer GenerateBenefitUtilizationSummariesReportServer GenerateCostDetailsReportServer GenerateCostDetailsReportServer GenerateDetailedCostReportServer GenerateDetailedCostReportServer GenerateDetailedCostReportOperationResultsServer GenerateDetailedCostReportOperationResultsServer @@ -34,6 +37,7 @@ type ServerFactory struct { PriceSheetServer PriceSheetServer QueryServer QueryServer ScheduledActionsServer ScheduledActionsServer + SettingsServer SettingsServer ViewsServer ViewsServer } @@ -54,9 +58,12 @@ type ServerFactoryTransport struct { trAlertsServer *AlertsServerTransport trBenefitRecommendationsServer *BenefitRecommendationsServerTransport trBenefitUtilizationSummariesServer *BenefitUtilizationSummariesServerTransport + trBudgetsServer *BudgetsServerTransport + trCostAllocationRulesServer *CostAllocationRulesServerTransport trDimensionsServer *DimensionsServerTransport trExportsServer *ExportsServerTransport trForecastServer *ForecastServerTransport + trGenerateBenefitUtilizationSummariesReportServer *GenerateBenefitUtilizationSummariesReportServerTransport trGenerateCostDetailsReportServer *GenerateCostDetailsReportServerTransport trGenerateDetailedCostReportServer *GenerateDetailedCostReportServerTransport trGenerateDetailedCostReportOperationResultsServer *GenerateDetailedCostReportOperationResultsServerTransport @@ -66,6 +73,7 @@ type ServerFactoryTransport struct { trPriceSheetServer *PriceSheetServerTransport trQueryServer *QueryServerTransport trScheduledActionsServer *ScheduledActionsServerTransport + trSettingsServer *SettingsServerTransport trViewsServer *ViewsServerTransport } @@ -95,6 +103,14 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { return NewBenefitUtilizationSummariesServerTransport(&s.srv.BenefitUtilizationSummariesServer) }) resp, err = s.trBenefitUtilizationSummariesServer.Do(req) + case "BudgetsClient": + initServer(s, &s.trBudgetsServer, func() *BudgetsServerTransport { return NewBudgetsServerTransport(&s.srv.BudgetsServer) }) + resp, err = s.trBudgetsServer.Do(req) + case "CostAllocationRulesClient": + initServer(s, &s.trCostAllocationRulesServer, func() *CostAllocationRulesServerTransport { + return NewCostAllocationRulesServerTransport(&s.srv.CostAllocationRulesServer) + }) + resp, err = s.trCostAllocationRulesServer.Do(req) case "DimensionsClient": initServer(s, &s.trDimensionsServer, func() *DimensionsServerTransport { return NewDimensionsServerTransport(&s.srv.DimensionsServer) }) resp, err = s.trDimensionsServer.Do(req) @@ -104,6 +120,11 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { case "ForecastClient": initServer(s, &s.trForecastServer, func() *ForecastServerTransport { return NewForecastServerTransport(&s.srv.ForecastServer) }) resp, err = s.trForecastServer.Do(req) + case "GenerateBenefitUtilizationSummariesReportClient": + initServer(s, &s.trGenerateBenefitUtilizationSummariesReportServer, func() *GenerateBenefitUtilizationSummariesReportServerTransport { + return NewGenerateBenefitUtilizationSummariesReportServerTransport(&s.srv.GenerateBenefitUtilizationSummariesReportServer) + }) + resp, err = s.trGenerateBenefitUtilizationSummariesReportServer.Do(req) case "GenerateCostDetailsReportClient": initServer(s, &s.trGenerateCostDetailsReportServer, func() *GenerateCostDetailsReportServerTransport { return NewGenerateCostDetailsReportServerTransport(&s.srv.GenerateCostDetailsReportServer) @@ -143,6 +164,9 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { return NewScheduledActionsServerTransport(&s.srv.ScheduledActionsServer) }) resp, err = s.trScheduledActionsServer.Do(req) + case "SettingsClient": + initServer(s, &s.trSettingsServer, func() *SettingsServerTransport { return NewSettingsServerTransport(&s.srv.SettingsServer) }) + resp, err = s.trSettingsServer.Do(req) case "ViewsClient": initServer(s, &s.trViewsServer, func() *ViewsServerTransport { return NewViewsServerTransport(&s.srv.ViewsServer) }) resp, err = s.trViewsServer.Do(req) diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/settings_server.go b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/settings_server.go new file mode 100644 index 000000000000..6e2bb028d7b3 --- /dev/null +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/settings_server.go @@ -0,0 +1,239 @@ +//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 ( + "context" + "errors" + "fmt" + 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/costmanagement/armcostmanagement/v3" + "net/http" + "net/url" + "regexp" +) + +// SettingsServer is a fake server for instances of the armcostmanagement.SettingsClient type. +type SettingsServer struct { + // CreateOrUpdateByScope is the fake for method SettingsClient.CreateOrUpdateByScope + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdateByScope func(ctx context.Context, scope string, typeParam armcostmanagement.SettingType, setting armcostmanagement.SettingClassification, options *armcostmanagement.SettingsClientCreateOrUpdateByScopeOptions) (resp azfake.Responder[armcostmanagement.SettingsClientCreateOrUpdateByScopeResponse], errResp azfake.ErrorResponder) + + // DeleteByScope is the fake for method SettingsClient.DeleteByScope + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + DeleteByScope func(ctx context.Context, scope string, typeParam armcostmanagement.SettingType, options *armcostmanagement.SettingsClientDeleteByScopeOptions) (resp azfake.Responder[armcostmanagement.SettingsClientDeleteByScopeResponse], errResp azfake.ErrorResponder) + + // GetByScope is the fake for method SettingsClient.GetByScope + // HTTP status codes to indicate success: http.StatusOK + GetByScope func(ctx context.Context, scope string, typeParam armcostmanagement.SettingType, options *armcostmanagement.SettingsClientGetByScopeOptions) (resp azfake.Responder[armcostmanagement.SettingsClientGetByScopeResponse], errResp azfake.ErrorResponder) + + // List is the fake for method SettingsClient.List + // HTTP status codes to indicate success: http.StatusOK + List func(ctx context.Context, scope string, options *armcostmanagement.SettingsClientListOptions) (resp azfake.Responder[armcostmanagement.SettingsClientListResponse], errResp azfake.ErrorResponder) +} + +// NewSettingsServerTransport creates a new instance of SettingsServerTransport with the provided implementation. +// The returned SettingsServerTransport instance is connected to an instance of armcostmanagement.SettingsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewSettingsServerTransport(srv *SettingsServer) *SettingsServerTransport { + return &SettingsServerTransport{srv: srv} +} + +// SettingsServerTransport connects instances of armcostmanagement.SettingsClient to instances of SettingsServer. +// Don't use this type directly, use NewSettingsServerTransport instead. +type SettingsServerTransport struct { + srv *SettingsServer +} + +// Do implements the policy.Transporter interface for SettingsServerTransport. +func (s *SettingsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "SettingsClient.CreateOrUpdateByScope": + resp, err = s.dispatchCreateOrUpdateByScope(req) + case "SettingsClient.DeleteByScope": + resp, err = s.dispatchDeleteByScope(req) + case "SettingsClient.GetByScope": + resp, err = s.dispatchGetByScope(req) + case "SettingsClient.List": + resp, err = s.dispatchList(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (s *SettingsServerTransport) dispatchCreateOrUpdateByScope(req *http.Request) (*http.Response, error) { + if s.srv.CreateOrUpdateByScope == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdateByScope not implemented")} + } + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/settings/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + 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) + } + raw, err := readRequestBody(req) + if err != nil { + return nil, err + } + body, err := unmarshalSettingClassification(raw) + if err != nil { + return nil, err + } + scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) + if err != nil { + return nil, err + } + typeParamParam, err := parseWithCast(matches[regex.SubexpIndex("type")], func(v string) (armcostmanagement.SettingType, error) { + p, unescapeErr := url.PathUnescape(v) + if unescapeErr != nil { + return "", unescapeErr + } + return armcostmanagement.SettingType(p), nil + }) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.CreateOrUpdateByScope(req.Context(), scopeParam, typeParamParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).SettingClassification, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SettingsServerTransport) dispatchDeleteByScope(req *http.Request) (*http.Response, error) { + if s.srv.DeleteByScope == nil { + return nil, &nonRetriableError{errors.New("fake for method DeleteByScope not implemented")} + } + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/settings/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + 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) + } + scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) + if err != nil { + return nil, err + } + typeParamParam, err := parseWithCast(matches[regex.SubexpIndex("type")], func(v string) (armcostmanagement.SettingType, error) { + p, unescapeErr := url.PathUnescape(v) + if unescapeErr != nil { + return "", unescapeErr + } + return armcostmanagement.SettingType(p), nil + }) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.DeleteByScope(req.Context(), scopeParam, typeParamParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SettingsServerTransport) dispatchGetByScope(req *http.Request) (*http.Response, error) { + if s.srv.GetByScope == nil { + return nil, &nonRetriableError{errors.New("fake for method GetByScope not implemented")} + } + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/settings/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + 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) + } + scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) + if err != nil { + return nil, err + } + typeParamParam, err := parseWithCast(matches[regex.SubexpIndex("type")], func(v string) (armcostmanagement.SettingType, error) { + p, unescapeErr := url.PathUnescape(v) + if unescapeErr != nil { + return "", unescapeErr + } + return armcostmanagement.SettingType(p), nil + }) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.GetByScope(req.Context(), scopeParam, typeParamParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).SettingClassification, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SettingsServerTransport) dispatchList(req *http.Request) (*http.Response, error) { + if s.srv.List == nil { + return nil, &nonRetriableError{errors.New("fake for method List not implemented")} + } + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/settings` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.List(req.Context(), scopeParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).SettingsListResult, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/time_rfc3339.go b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/time_rfc3339.go index b0535a7b63e6..81f308b0d343 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/time_rfc3339.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/time_rfc3339.go @@ -19,12 +19,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 +44,33 @@ 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) { + 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/costmanagement/armcostmanagement/fake/views_server.go b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/views_server.go index c17bc3b759b2..f66033d3e6d2 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/views_server.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/views_server.go @@ -16,7 +16,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/costmanagement/armcostmanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v3" "net/http" "net/url" "regexp" diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/forecast_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/forecast_client.go index 5ad60bd56c27..d79b90721af1 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/forecast_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/forecast_client.go @@ -43,7 +43,7 @@ func NewForecastClient(credential azcore.TokenCredential, options *arm.ClientOpt // ExternalCloudProviderUsage - Lists the forecast charges for external cloud provider type defined. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - externalCloudProviderType - The external cloud provider type associated with dimension/query operations. This includes // 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account. // - externalCloudProviderID - This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' for @@ -92,7 +92,7 @@ func (client *ForecastClient) externalCloudProviderUsageCreateRequest(ctx contex if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -113,7 +113,7 @@ func (client *ForecastClient) externalCloudProviderUsageHandleResponse(resp *htt // Usage - Lists the forecast charges for scope defined. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - scope - The scope associated with forecast operations. This includes '/subscriptions/{subscriptionId}/' for subscription // scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for // resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and @@ -160,7 +160,7 @@ func (client *ForecastClient) usageCreateRequest(ctx context.Context, scope stri if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/forecast_client_example_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/forecast_client_example_test.go deleted file mode 100644 index 3eff28f651bd..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/forecast_client_example_test.go +++ /dev/null @@ -1,1010 +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 armcostmanagement_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/costmanagement/armcostmanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BillingAccountForecast.json -func ExampleForecastClient_Usage_billingAccountForecast() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewForecastClient().Usage(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789", armcostmanagement.ForecastDefinition{ - Type: to.Ptr(armcostmanagement.ForecastTypeUsage), - Dataset: &armcostmanagement.ForecastDataset{ - Aggregation: map[string]*armcostmanagement.ForecastAggregation{ - "totalCost": { - Name: to.Ptr(armcostmanagement.FunctionNameCost), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), - }, - }, - Filter: &armcostmanagement.ForecastFilter{ - And: []*armcostmanagement.ForecastFilter{ - { - Or: []*armcostmanagement.ForecastFilter{ - { - Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("East US"), - to.Ptr("West Europe")}, - }, - }, - { - Tags: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("UAT"), - to.Ptr("Prod")}, - }, - }}, - }, - { - Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("API")}, - }, - }}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - IncludeActualCost: to.Ptr(false), - IncludeFreshPartialCost: to.Ptr(false), - TimePeriod: &armcostmanagement.ForecastTimePeriod{ - From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T00:00:00.000Z"); return t }()), - To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-31T23:59:59.000Z"); return t }()), - }, - Timeframe: to.Ptr(armcostmanagement.ForecastTimeframeCustom), - }, &armcostmanagement.ForecastClientUsageOptions{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.ForecastResult = armcostmanagement.ForecastResult{ - // Name: to.Ptr("ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Type: to.Ptr("Microsoft.CostManagement/query"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/providers/Microsoft.CostManagement/query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Properties: &armcostmanagement.ForecastProperties{ - // Columns: []*armcostmanagement.ForecastColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("UsageDate"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("CostStatus"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(2.10333307059661), - // float64(20180331), - // "Forecast", - // "USD"}, - // []any{ - // float64(218.68795741935486), - // float64(20180331), - // "Forecast", - // "USD"}, - // []any{ - // float64(0.14384913581657052), - // float64(20180401), - // "Forecast", - // "USD"}, - // []any{ - // float64(0.009865586851323632), - // float64(20180429), - // "Forecast", - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BillingProfileForecast.json -func ExampleForecastClient_Usage_billingProfileForecast() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewForecastClient().Usage(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579", armcostmanagement.ForecastDefinition{ - Type: to.Ptr(armcostmanagement.ForecastTypeUsage), - Dataset: &armcostmanagement.ForecastDataset{ - Aggregation: map[string]*armcostmanagement.ForecastAggregation{ - "totalCost": { - Name: to.Ptr(armcostmanagement.FunctionNameCost), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), - }, - }, - Filter: &armcostmanagement.ForecastFilter{ - And: []*armcostmanagement.ForecastFilter{ - { - Or: []*armcostmanagement.ForecastFilter{ - { - Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("East US"), - to.Ptr("West Europe")}, - }, - }, - { - Tags: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("UAT"), - to.Ptr("Prod")}, - }, - }}, - }, - { - Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("API")}, - }, - }}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - IncludeActualCost: to.Ptr(false), - IncludeFreshPartialCost: to.Ptr(false), - TimePeriod: &armcostmanagement.ForecastTimePeriod{ - From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T00:00:00.000Z"); return t }()), - To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-31T23:59:59.000Z"); return t }()), - }, - Timeframe: to.Ptr(armcostmanagement.ForecastTimeframeCustom), - }, &armcostmanagement.ForecastClientUsageOptions{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.ForecastResult = armcostmanagement.ForecastResult{ - // Name: to.Ptr("ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Type: to.Ptr("Microsoft.CostManagement/query"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/providers/Microsoft.CostManagement/query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Properties: &armcostmanagement.ForecastProperties{ - // Columns: []*armcostmanagement.ForecastColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("UsageDate"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("CostStatus"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(2.10333307059661), - // float64(20180331), - // "Forecast", - // "USD"}, - // []any{ - // float64(218.68795741935486), - // float64(20180331), - // "Forecast", - // "USD"}, - // []any{ - // float64(0.14384913581657052), - // float64(20180401), - // "Forecast", - // "USD"}, - // []any{ - // float64(0.009865586851323632), - // float64(20180429), - // "Forecast", - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/DepartmentForecast.json -func ExampleForecastClient_Usage_departmentForecast() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewForecastClient().Usage(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789/departments/123", armcostmanagement.ForecastDefinition{ - Type: to.Ptr(armcostmanagement.ForecastTypeUsage), - Dataset: &armcostmanagement.ForecastDataset{ - Aggregation: map[string]*armcostmanagement.ForecastAggregation{ - "totalCost": { - Name: to.Ptr(armcostmanagement.FunctionNameCost), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), - }, - }, - Filter: &armcostmanagement.ForecastFilter{ - And: []*armcostmanagement.ForecastFilter{ - { - Or: []*armcostmanagement.ForecastFilter{ - { - Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("East US"), - to.Ptr("West Europe")}, - }, - }, - { - Tags: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("UAT"), - to.Ptr("Prod")}, - }, - }}, - }, - { - Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("API")}, - }, - }}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - IncludeActualCost: to.Ptr(false), - IncludeFreshPartialCost: to.Ptr(false), - TimePeriod: &armcostmanagement.ForecastTimePeriod{ - From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T00:00:00.000Z"); return t }()), - To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-31T23:59:59.000Z"); return t }()), - }, - Timeframe: to.Ptr(armcostmanagement.ForecastTimeframeCustom), - }, &armcostmanagement.ForecastClientUsageOptions{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.ForecastResult = armcostmanagement.ForecastResult{ - // Name: to.Ptr("ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Type: to.Ptr("Microsoft.CostManagement/query"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/departments/123/providers/Microsoft.CostManagement/query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Properties: &armcostmanagement.ForecastProperties{ - // Columns: []*armcostmanagement.ForecastColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("UsageDate"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("CostStatus"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(2.10333307059661), - // float64(20180331), - // "Forecast", - // "USD"}, - // []any{ - // float64(218.68795741935486), - // float64(20180331), - // "Forecast", - // "USD"}, - // []any{ - // float64(0.14384913581657052), - // float64(20180401), - // "Forecast", - // "USD"}, - // []any{ - // float64(0.009865586851323632), - // float64(20180429), - // "Forecast", - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/EnrollmentAccountForecast.json -func ExampleForecastClient_Usage_enrollmentAccountForecast() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewForecastClient().Usage(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789/enrollmentAccounts/456", armcostmanagement.ForecastDefinition{ - Type: to.Ptr(armcostmanagement.ForecastTypeUsage), - Dataset: &armcostmanagement.ForecastDataset{ - Aggregation: map[string]*armcostmanagement.ForecastAggregation{ - "totalCost": { - Name: to.Ptr(armcostmanagement.FunctionNameCost), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), - }, - }, - Filter: &armcostmanagement.ForecastFilter{ - And: []*armcostmanagement.ForecastFilter{ - { - Or: []*armcostmanagement.ForecastFilter{ - { - Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("East US"), - to.Ptr("West Europe")}, - }, - }, - { - Tags: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("UAT"), - to.Ptr("Prod")}, - }, - }}, - }, - { - Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("API")}, - }, - }}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - IncludeActualCost: to.Ptr(false), - IncludeFreshPartialCost: to.Ptr(false), - TimePeriod: &armcostmanagement.ForecastTimePeriod{ - From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T00:00:00.000Z"); return t }()), - To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-31T23:59:59.000Z"); return t }()), - }, - Timeframe: to.Ptr(armcostmanagement.ForecastTimeframeCustom), - }, &armcostmanagement.ForecastClientUsageOptions{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.ForecastResult = armcostmanagement.ForecastResult{ - // Name: to.Ptr("ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Type: to.Ptr("Microsoft.CostManagement/query"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/enrollmentAccounts/456/providers/Microsoft.CostManagement/query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Properties: &armcostmanagement.ForecastProperties{ - // Columns: []*armcostmanagement.ForecastColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("UsageDate"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("CostStatus"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(2.10333307059661), - // float64(20180331), - // "Forecast", - // "USD"}, - // []any{ - // float64(218.68795741935486), - // float64(20180331), - // "Forecast", - // "USD"}, - // []any{ - // float64(0.14384913581657052), - // float64(20180401), - // "Forecast", - // "USD"}, - // []any{ - // float64(0.009865586851323632), - // float64(20180429), - // "Forecast", - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/InvoiceSectionForecast.json -func ExampleForecastClient_Usage_invoiceSectionForecast() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewForecastClient().Usage(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876", armcostmanagement.ForecastDefinition{ - Type: to.Ptr(armcostmanagement.ForecastTypeUsage), - Dataset: &armcostmanagement.ForecastDataset{ - Aggregation: map[string]*armcostmanagement.ForecastAggregation{ - "totalCost": { - Name: to.Ptr(armcostmanagement.FunctionNameCost), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), - }, - }, - Filter: &armcostmanagement.ForecastFilter{ - And: []*armcostmanagement.ForecastFilter{ - { - Or: []*armcostmanagement.ForecastFilter{ - { - Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("East US"), - to.Ptr("West Europe")}, - }, - }, - { - Tags: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("UAT"), - to.Ptr("Prod")}, - }, - }}, - }, - { - Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("API")}, - }, - }}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - IncludeActualCost: to.Ptr(false), - IncludeFreshPartialCost: to.Ptr(false), - TimePeriod: &armcostmanagement.ForecastTimePeriod{ - From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T00:00:00.000Z"); return t }()), - To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-31T23:59:59.000Z"); return t }()), - }, - Timeframe: to.Ptr(armcostmanagement.ForecastTimeframeCustom), - }, &armcostmanagement.ForecastClientUsageOptions{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.ForecastResult = armcostmanagement.ForecastResult{ - // Name: to.Ptr("ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Type: to.Ptr("Microsoft.CostManagement/query"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876/providers/Microsoft.CostManagement/query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Properties: &armcostmanagement.ForecastProperties{ - // Columns: []*armcostmanagement.ForecastColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("UsageDate"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("CostStatus"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(2.10333307059661), - // float64(20180331), - // "Forecast", - // "USD"}, - // []any{ - // float64(218.68795741935486), - // float64(20180331), - // "Forecast", - // "USD"}, - // []any{ - // float64(0.14384913581657052), - // float64(20180401), - // "Forecast", - // "USD"}, - // []any{ - // float64(0.009865586851323632), - // float64(20180429), - // "Forecast", - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ResourceGroupForecast.json -func ExampleForecastClient_Usage_resourceGroupForecast() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewForecastClient().Usage(ctx, "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ScreenSharingTest-peer", armcostmanagement.ForecastDefinition{ - Type: to.Ptr(armcostmanagement.ForecastTypeUsage), - Dataset: &armcostmanagement.ForecastDataset{ - Aggregation: map[string]*armcostmanagement.ForecastAggregation{ - "totalCost": { - Name: to.Ptr(armcostmanagement.FunctionNameCost), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), - }, - }, - Filter: &armcostmanagement.ForecastFilter{ - And: []*armcostmanagement.ForecastFilter{ - { - Or: []*armcostmanagement.ForecastFilter{ - { - Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("East US"), - to.Ptr("West Europe")}, - }, - }, - { - Tags: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("UAT"), - to.Ptr("Prod")}, - }, - }}, - }, - { - Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("API")}, - }, - }}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - IncludeActualCost: to.Ptr(false), - IncludeFreshPartialCost: to.Ptr(false), - TimePeriod: &armcostmanagement.ForecastTimePeriod{ - From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T00:00:00.000Z"); return t }()), - To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-31T23:59:59.000Z"); return t }()), - }, - Timeframe: to.Ptr(armcostmanagement.ForecastTimeframeCustom), - }, &armcostmanagement.ForecastClientUsageOptions{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.ForecastResult = armcostmanagement.ForecastResult{ - // Name: to.Ptr("55312978-ba1b-415c-9304-cfd9c43c0481"), - // Type: to.Ptr("Microsoft.CostManagement/query"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ScreenSharingTest-peer/providers/Microsoft.CostManagement/query/00000000-0000-0000-0000-000000000000"), - // Properties: &armcostmanagement.ForecastProperties{ - // Columns: []*armcostmanagement.ForecastColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("UsageDate"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("CostStatus"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(2.10333307059661), - // float64(20180331), - // "Forecast", - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/SubscriptionForecast.json -func ExampleForecastClient_Usage_subscriptionForecast() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewForecastClient().Usage(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", armcostmanagement.ForecastDefinition{ - Type: to.Ptr(armcostmanagement.ForecastTypeUsage), - Dataset: &armcostmanagement.ForecastDataset{ - Aggregation: map[string]*armcostmanagement.ForecastAggregation{ - "totalCost": { - Name: to.Ptr(armcostmanagement.FunctionNameCost), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), - }, - }, - Filter: &armcostmanagement.ForecastFilter{ - And: []*armcostmanagement.ForecastFilter{ - { - Or: []*armcostmanagement.ForecastFilter{ - { - Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("East US"), - to.Ptr("West Europe")}, - }, - }, - { - Tags: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("UAT"), - to.Ptr("Prod")}, - }, - }}, - }, - { - Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("API")}, - }, - }}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - IncludeActualCost: to.Ptr(false), - IncludeFreshPartialCost: to.Ptr(false), - TimePeriod: &armcostmanagement.ForecastTimePeriod{ - From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T00:00:00.000Z"); return t }()), - To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-31T23:59:59.000Z"); return t }()), - }, - Timeframe: to.Ptr(armcostmanagement.ForecastTimeframeCustom), - }, &armcostmanagement.ForecastClientUsageOptions{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.ForecastResult = armcostmanagement.ForecastResult{ - // Name: to.Ptr("55312978-ba1b-415c-9304-cfd9c43c0481"), - // Type: to.Ptr("Microsoft.CostManagement/query"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/query/00000000-0000-0000-0000-000000000000"), - // Properties: &armcostmanagement.ForecastProperties{ - // Columns: []*armcostmanagement.ForecastColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("UsageDate"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("CostStatus"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(2.10333307059661), - // float64(20180331), - // "Forecast", - // "USD"}, - // []any{ - // float64(218.68795741935486), - // float64(20180331), - // "Forecast", - // "USD"}, - // []any{ - // float64(0.14384913581657052), - // float64(20180401), - // "Forecast", - // "USD"}, - // []any{ - // float64(0.009865586851323632), - // float64(20180429), - // "Forecast", - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExternalBillingAccountForecast.json -func ExampleForecastClient_ExternalCloudProviderUsage_externalBillingAccountForecast() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewForecastClient().ExternalCloudProviderUsage(ctx, armcostmanagement.ExternalCloudProviderTypeExternalBillingAccounts, "100", armcostmanagement.ForecastDefinition{ - Type: to.Ptr(armcostmanagement.ForecastTypeUsage), - Dataset: &armcostmanagement.ForecastDataset{ - Aggregation: map[string]*armcostmanagement.ForecastAggregation{ - "totalCost": { - Name: to.Ptr(armcostmanagement.FunctionNameCost), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), - }, - }, - Filter: &armcostmanagement.ForecastFilter{ - And: []*armcostmanagement.ForecastFilter{ - { - Or: []*armcostmanagement.ForecastFilter{ - { - Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("East US"), - to.Ptr("West Europe")}, - }, - }, - { - Tags: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("UAT"), - to.Ptr("Prod")}, - }, - }}, - }, - { - Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("API")}, - }, - }}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - TimePeriod: &armcostmanagement.ForecastTimePeriod{ - From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T00:00:00.000Z"); return t }()), - To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-31T23:59:59.000Z"); return t }()), - }, - Timeframe: to.Ptr(armcostmanagement.ForecastTimeframeCustom), - }, &armcostmanagement.ForecastClientExternalCloudProviderUsageOptions{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.ForecastResult = armcostmanagement.ForecastResult{ - // Name: to.Ptr("6dc7b06a-d90a-4df5-b655-ce6cf1c0814d"), - // Type: to.Ptr("Microsoft.CostManagement/query"), - // ID: to.Ptr("providers/Microsoft.CostManagement/externalBillingAccounts/100/query/6dc7b06a-d90a-4df5-b655-ce6cf1c0814d"), - // Properties: &armcostmanagement.ForecastProperties{ - // Columns: []*armcostmanagement.ForecastColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("CostStatus"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(0), - // "Forecast", - // "USD"}, - // []any{ - // float64(30.2572751438), - // "Forecast", - // "USD"}, - // []any{ - // float64(0.07675760200000002), - // "Forecast", - // "USD"}, - // []any{ - // float64(50.43096419040001), - // "Forecast", - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExternalSubscriptionForecast.json -func ExampleForecastClient_ExternalCloudProviderUsage_externalSubscriptionForecast() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewForecastClient().ExternalCloudProviderUsage(ctx, armcostmanagement.ExternalCloudProviderTypeExternalSubscriptions, "100", armcostmanagement.ForecastDefinition{ - Type: to.Ptr(armcostmanagement.ForecastTypeUsage), - Dataset: &armcostmanagement.ForecastDataset{ - Aggregation: map[string]*armcostmanagement.ForecastAggregation{ - "totalCost": { - Name: to.Ptr(armcostmanagement.FunctionNameCost), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), - }, - }, - Filter: &armcostmanagement.ForecastFilter{ - And: []*armcostmanagement.ForecastFilter{ - { - Or: []*armcostmanagement.ForecastFilter{ - { - Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("East US"), - to.Ptr("West Europe")}, - }, - }, - { - Tags: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("UAT"), - to.Ptr("Prod")}, - }, - }}, - }, - { - Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("API")}, - }, - }}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - TimePeriod: &armcostmanagement.ForecastTimePeriod{ - From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T00:00:00.000Z"); return t }()), - To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-31T23:59:59.000Z"); return t }()), - }, - Timeframe: to.Ptr(armcostmanagement.ForecastTimeframeCustom), - }, &armcostmanagement.ForecastClientExternalCloudProviderUsageOptions{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.ForecastResult = armcostmanagement.ForecastResult{ - // Name: to.Ptr("d99477af-7510-40ee-aca2-e59bdca0d10d"), - // Type: to.Ptr("Microsoft.CostManagement/query"), - // ID: to.Ptr("providers/Microsoft.CostManagement/externalSubscriptions/100/query/d99477af-7510-40ee-aca2-e59bdca0d10d"), - // Properties: &armcostmanagement.ForecastProperties{ - // Columns: []*armcostmanagement.ForecastColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("UsageDate"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("CostStatus"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // }, - // }, - // } -} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/generatebenefitutilizationsummariesreport_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/generatebenefitutilizationsummariesreport_client.go new file mode 100644 index 000000000000..7e56dbc949f1 --- /dev/null +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/generatebenefitutilizationsummariesreport_client.go @@ -0,0 +1,496 @@ +//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 armcostmanagement + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// GenerateBenefitUtilizationSummariesReportClient contains the methods for the GenerateBenefitUtilizationSummariesReport group. +// Don't use this type directly, use NewGenerateBenefitUtilizationSummariesReportClient() instead. +type GenerateBenefitUtilizationSummariesReportClient struct { + internal *arm.Client +} + +// NewGenerateBenefitUtilizationSummariesReportClient creates a new instance of GenerateBenefitUtilizationSummariesReportClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewGenerateBenefitUtilizationSummariesReportClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*GenerateBenefitUtilizationSummariesReportClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &GenerateBenefitUtilizationSummariesReportClient{ + internal: cl, + } + return client, nil +} + +// BeginGenerateByBillingAccount - Triggers generation of a benefit utilization summaries report for the provided billing +// account. This API supports only enrollment accounts. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +// - billingAccountID - Billing account ID +// - benefitUtilizationSummariesRequest - Async Benefit Utilization Summary report to be created. +// - options - GenerateBenefitUtilizationSummariesReportClientBeginGenerateByBillingAccountOptions contains the optional parameters +// for the GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByBillingAccount method. +func (client *GenerateBenefitUtilizationSummariesReportClient) BeginGenerateByBillingAccount(ctx context.Context, billingAccountID string, benefitUtilizationSummariesRequest BenefitUtilizationSummariesRequest, options *GenerateBenefitUtilizationSummariesReportClientBeginGenerateByBillingAccountOptions) (*runtime.Poller[GenerateBenefitUtilizationSummariesReportClientGenerateByBillingAccountResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.generateByBillingAccount(ctx, billingAccountID, benefitUtilizationSummariesRequest, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[GenerateBenefitUtilizationSummariesReportClientGenerateByBillingAccountResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[GenerateBenefitUtilizationSummariesReportClientGenerateByBillingAccountResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// GenerateByBillingAccount - Triggers generation of a benefit utilization summaries report for the provided billing account. +// This API supports only enrollment accounts. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +func (client *GenerateBenefitUtilizationSummariesReportClient) generateByBillingAccount(ctx context.Context, billingAccountID string, benefitUtilizationSummariesRequest BenefitUtilizationSummariesRequest, options *GenerateBenefitUtilizationSummariesReportClientBeginGenerateByBillingAccountOptions) (*http.Response, error) { + var err error + const operationName = "GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByBillingAccount" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.generateByBillingAccountCreateRequest(ctx, billingAccountID, benefitUtilizationSummariesRequest, 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 +} + +// generateByBillingAccountCreateRequest creates the GenerateByBillingAccount request. +func (client *GenerateBenefitUtilizationSummariesReportClient) generateByBillingAccountCreateRequest(ctx context.Context, billingAccountID string, benefitUtilizationSummariesRequest BenefitUtilizationSummariesRequest, options *GenerateBenefitUtilizationSummariesReportClientBeginGenerateByBillingAccountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.CostManagement/generateBenefitUtilizationSummariesReport" + if billingAccountID == "" { + return nil, errors.New("parameter billingAccountID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountId}", url.PathEscape(billingAccountID)) + 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", "2023-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, benefitUtilizationSummariesRequest); err != nil { + return nil, err + } + return req, nil +} + +// BeginGenerateByBillingProfile - Triggers generation of a benefit utilization summaries report for the provided billing +// account and billing profile. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +// - billingAccountID - Billing account ID +// - billingProfileID - Billing profile ID. +// - benefitUtilizationSummariesRequest - Async Benefit Utilization Summary report to be created. +// - options - GenerateBenefitUtilizationSummariesReportClientBeginGenerateByBillingProfileOptions contains the optional parameters +// for the GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByBillingProfile method. +func (client *GenerateBenefitUtilizationSummariesReportClient) BeginGenerateByBillingProfile(ctx context.Context, billingAccountID string, billingProfileID string, benefitUtilizationSummariesRequest BenefitUtilizationSummariesRequest, options *GenerateBenefitUtilizationSummariesReportClientBeginGenerateByBillingProfileOptions) (*runtime.Poller[GenerateBenefitUtilizationSummariesReportClientGenerateByBillingProfileResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.generateByBillingProfile(ctx, billingAccountID, billingProfileID, benefitUtilizationSummariesRequest, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[GenerateBenefitUtilizationSummariesReportClientGenerateByBillingProfileResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[GenerateBenefitUtilizationSummariesReportClientGenerateByBillingProfileResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// GenerateByBillingProfile - Triggers generation of a benefit utilization summaries report for the provided billing account +// and billing profile. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +func (client *GenerateBenefitUtilizationSummariesReportClient) generateByBillingProfile(ctx context.Context, billingAccountID string, billingProfileID string, benefitUtilizationSummariesRequest BenefitUtilizationSummariesRequest, options *GenerateBenefitUtilizationSummariesReportClientBeginGenerateByBillingProfileOptions) (*http.Response, error) { + var err error + const operationName = "GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByBillingProfile" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.generateByBillingProfileCreateRequest(ctx, billingAccountID, billingProfileID, benefitUtilizationSummariesRequest, 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 +} + +// generateByBillingProfileCreateRequest creates the GenerateByBillingProfile request. +func (client *GenerateBenefitUtilizationSummariesReportClient) generateByBillingProfileCreateRequest(ctx context.Context, billingAccountID string, billingProfileID string, benefitUtilizationSummariesRequest BenefitUtilizationSummariesRequest, options *GenerateBenefitUtilizationSummariesReportClientBeginGenerateByBillingProfileOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.CostManagement/generateBenefitUtilizationSummariesReport" + if billingAccountID == "" { + return nil, errors.New("parameter billingAccountID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountId}", url.PathEscape(billingAccountID)) + if billingProfileID == "" { + return nil, errors.New("parameter billingProfileID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileId}", url.PathEscape(billingProfileID)) + 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", "2023-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, benefitUtilizationSummariesRequest); err != nil { + return nil, err + } + return req, nil +} + +// BeginGenerateByReservationID - Triggers generation of a benefit utilization summaries report for the provided reservation. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +// - reservationOrderID - Reservation Order ID +// - reservationID - Reservation ID +// - benefitUtilizationSummariesRequest - Async Benefit Utilization Summary report to be created. +// - options - GenerateBenefitUtilizationSummariesReportClientBeginGenerateByReservationIDOptions contains the optional parameters +// for the GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByReservationID method. +func (client *GenerateBenefitUtilizationSummariesReportClient) BeginGenerateByReservationID(ctx context.Context, reservationOrderID string, reservationID string, benefitUtilizationSummariesRequest BenefitUtilizationSummariesRequest, options *GenerateBenefitUtilizationSummariesReportClientBeginGenerateByReservationIDOptions) (*runtime.Poller[GenerateBenefitUtilizationSummariesReportClientGenerateByReservationIDResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.generateByReservationID(ctx, reservationOrderID, reservationID, benefitUtilizationSummariesRequest, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[GenerateBenefitUtilizationSummariesReportClientGenerateByReservationIDResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[GenerateBenefitUtilizationSummariesReportClientGenerateByReservationIDResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// GenerateByReservationID - Triggers generation of a benefit utilization summaries report for the provided reservation. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +func (client *GenerateBenefitUtilizationSummariesReportClient) generateByReservationID(ctx context.Context, reservationOrderID string, reservationID string, benefitUtilizationSummariesRequest BenefitUtilizationSummariesRequest, options *GenerateBenefitUtilizationSummariesReportClientBeginGenerateByReservationIDOptions) (*http.Response, error) { + var err error + const operationName = "GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByReservationID" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.generateByReservationIDCreateRequest(ctx, reservationOrderID, reservationID, benefitUtilizationSummariesRequest, 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 +} + +// generateByReservationIDCreateRequest creates the GenerateByReservationID request. +func (client *GenerateBenefitUtilizationSummariesReportClient) generateByReservationIDCreateRequest(ctx context.Context, reservationOrderID string, reservationID string, benefitUtilizationSummariesRequest BenefitUtilizationSummariesRequest, options *GenerateBenefitUtilizationSummariesReportClientBeginGenerateByReservationIDOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/reservations/{reservationId}/providers/Microsoft.CostManagement/generateBenefitUtilizationSummariesReport" + if reservationOrderID == "" { + return nil, errors.New("parameter reservationOrderID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reservationOrderId}", url.PathEscape(reservationOrderID)) + if reservationID == "" { + return nil, errors.New("parameter reservationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reservationId}", url.PathEscape(reservationID)) + 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", "2023-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, benefitUtilizationSummariesRequest); err != nil { + return nil, err + } + return req, nil +} + +// BeginGenerateByReservationOrderID - Triggers generation of a benefit utilization summaries report for the provided reservation +// order. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +// - reservationOrderID - Reservation Order ID +// - benefitUtilizationSummariesRequest - Async Benefit Utilization Summary report to be created. +// - options - GenerateBenefitUtilizationSummariesReportClientBeginGenerateByReservationOrderIDOptions contains the optional +// parameters for the GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByReservationOrderID method. +func (client *GenerateBenefitUtilizationSummariesReportClient) BeginGenerateByReservationOrderID(ctx context.Context, reservationOrderID string, benefitUtilizationSummariesRequest BenefitUtilizationSummariesRequest, options *GenerateBenefitUtilizationSummariesReportClientBeginGenerateByReservationOrderIDOptions) (*runtime.Poller[GenerateBenefitUtilizationSummariesReportClientGenerateByReservationOrderIDResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.generateByReservationOrderID(ctx, reservationOrderID, benefitUtilizationSummariesRequest, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[GenerateBenefitUtilizationSummariesReportClientGenerateByReservationOrderIDResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[GenerateBenefitUtilizationSummariesReportClientGenerateByReservationOrderIDResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// GenerateByReservationOrderID - Triggers generation of a benefit utilization summaries report for the provided reservation +// order. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +func (client *GenerateBenefitUtilizationSummariesReportClient) generateByReservationOrderID(ctx context.Context, reservationOrderID string, benefitUtilizationSummariesRequest BenefitUtilizationSummariesRequest, options *GenerateBenefitUtilizationSummariesReportClientBeginGenerateByReservationOrderIDOptions) (*http.Response, error) { + var err error + const operationName = "GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByReservationOrderID" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.generateByReservationOrderIDCreateRequest(ctx, reservationOrderID, benefitUtilizationSummariesRequest, 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 +} + +// generateByReservationOrderIDCreateRequest creates the GenerateByReservationOrderID request. +func (client *GenerateBenefitUtilizationSummariesReportClient) generateByReservationOrderIDCreateRequest(ctx context.Context, reservationOrderID string, benefitUtilizationSummariesRequest BenefitUtilizationSummariesRequest, options *GenerateBenefitUtilizationSummariesReportClientBeginGenerateByReservationOrderIDOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/providers/Microsoft.CostManagement/generateBenefitUtilizationSummariesReport" + if reservationOrderID == "" { + return nil, errors.New("parameter reservationOrderID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reservationOrderId}", url.PathEscape(reservationOrderID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, benefitUtilizationSummariesRequest); err != nil { + return nil, err + } + return req, nil +} + +// BeginGenerateBySavingsPlanID - Triggers generation of a benefit utilization summaries report for the provided savings plan. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +// - savingsPlanOrderID - Savings plan order ID. +// - savingsPlanID - Savings plan ID. +// - benefitUtilizationSummariesRequest - Async Benefit Utilization Summary report to be created. +// - options - GenerateBenefitUtilizationSummariesReportClientBeginGenerateBySavingsPlanIDOptions contains the optional parameters +// for the GenerateBenefitUtilizationSummariesReportClient.BeginGenerateBySavingsPlanID method. +func (client *GenerateBenefitUtilizationSummariesReportClient) BeginGenerateBySavingsPlanID(ctx context.Context, savingsPlanOrderID string, savingsPlanID string, benefitUtilizationSummariesRequest BenefitUtilizationSummariesRequest, options *GenerateBenefitUtilizationSummariesReportClientBeginGenerateBySavingsPlanIDOptions) (*runtime.Poller[GenerateBenefitUtilizationSummariesReportClientGenerateBySavingsPlanIDResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.generateBySavingsPlanID(ctx, savingsPlanOrderID, savingsPlanID, benefitUtilizationSummariesRequest, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[GenerateBenefitUtilizationSummariesReportClientGenerateBySavingsPlanIDResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[GenerateBenefitUtilizationSummariesReportClientGenerateBySavingsPlanIDResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// GenerateBySavingsPlanID - Triggers generation of a benefit utilization summaries report for the provided savings plan. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +func (client *GenerateBenefitUtilizationSummariesReportClient) generateBySavingsPlanID(ctx context.Context, savingsPlanOrderID string, savingsPlanID string, benefitUtilizationSummariesRequest BenefitUtilizationSummariesRequest, options *GenerateBenefitUtilizationSummariesReportClientBeginGenerateBySavingsPlanIDOptions) (*http.Response, error) { + var err error + const operationName = "GenerateBenefitUtilizationSummariesReportClient.BeginGenerateBySavingsPlanID" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.generateBySavingsPlanIDCreateRequest(ctx, savingsPlanOrderID, savingsPlanID, benefitUtilizationSummariesRequest, 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 +} + +// generateBySavingsPlanIDCreateRequest creates the GenerateBySavingsPlanID request. +func (client *GenerateBenefitUtilizationSummariesReportClient) generateBySavingsPlanIDCreateRequest(ctx context.Context, savingsPlanOrderID string, savingsPlanID string, benefitUtilizationSummariesRequest BenefitUtilizationSummariesRequest, options *GenerateBenefitUtilizationSummariesReportClientBeginGenerateBySavingsPlanIDOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.BillingBenefits/savingsPlanOrders/{savingsPlanOrderId}/savingsPlans/{savingsPlanId}/providers/Microsoft.CostManagement/generateBenefitUtilizationSummariesReport" + if savingsPlanOrderID == "" { + return nil, errors.New("parameter savingsPlanOrderID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{savingsPlanOrderId}", url.PathEscape(savingsPlanOrderID)) + if savingsPlanID == "" { + return nil, errors.New("parameter savingsPlanID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{savingsPlanId}", url.PathEscape(savingsPlanID)) + 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", "2023-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, benefitUtilizationSummariesRequest); err != nil { + return nil, err + } + return req, nil +} + +// BeginGenerateBySavingsPlanOrderID - Triggers generation of a benefit utilization summaries report for the provided savings +// plan order. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +// - savingsPlanOrderID - Savings plan order ID. +// - benefitUtilizationSummariesRequest - Async Benefit Utilization Summary report to be created. +// - options - GenerateBenefitUtilizationSummariesReportClientBeginGenerateBySavingsPlanOrderIDOptions contains the optional +// parameters for the GenerateBenefitUtilizationSummariesReportClient.BeginGenerateBySavingsPlanOrderID method. +func (client *GenerateBenefitUtilizationSummariesReportClient) BeginGenerateBySavingsPlanOrderID(ctx context.Context, savingsPlanOrderID string, benefitUtilizationSummariesRequest BenefitUtilizationSummariesRequest, options *GenerateBenefitUtilizationSummariesReportClientBeginGenerateBySavingsPlanOrderIDOptions) (*runtime.Poller[GenerateBenefitUtilizationSummariesReportClientGenerateBySavingsPlanOrderIDResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.generateBySavingsPlanOrderID(ctx, savingsPlanOrderID, benefitUtilizationSummariesRequest, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[GenerateBenefitUtilizationSummariesReportClientGenerateBySavingsPlanOrderIDResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[GenerateBenefitUtilizationSummariesReportClientGenerateBySavingsPlanOrderIDResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// GenerateBySavingsPlanOrderID - Triggers generation of a benefit utilization summaries report for the provided savings plan +// order. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +func (client *GenerateBenefitUtilizationSummariesReportClient) generateBySavingsPlanOrderID(ctx context.Context, savingsPlanOrderID string, benefitUtilizationSummariesRequest BenefitUtilizationSummariesRequest, options *GenerateBenefitUtilizationSummariesReportClientBeginGenerateBySavingsPlanOrderIDOptions) (*http.Response, error) { + var err error + const operationName = "GenerateBenefitUtilizationSummariesReportClient.BeginGenerateBySavingsPlanOrderID" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.generateBySavingsPlanOrderIDCreateRequest(ctx, savingsPlanOrderID, benefitUtilizationSummariesRequest, 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 +} + +// generateBySavingsPlanOrderIDCreateRequest creates the GenerateBySavingsPlanOrderID request. +func (client *GenerateBenefitUtilizationSummariesReportClient) generateBySavingsPlanOrderIDCreateRequest(ctx context.Context, savingsPlanOrderID string, benefitUtilizationSummariesRequest BenefitUtilizationSummariesRequest, options *GenerateBenefitUtilizationSummariesReportClientBeginGenerateBySavingsPlanOrderIDOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.BillingBenefits/savingsPlanOrders/{savingsPlanOrderId}/providers/Microsoft.CostManagement/generateBenefitUtilizationSummariesReport" + if savingsPlanOrderID == "" { + return nil, errors.New("parameter savingsPlanOrderID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{savingsPlanOrderId}", url.PathEscape(savingsPlanOrderID)) + 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", "2023-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, benefitUtilizationSummariesRequest); err != nil { + return nil, err + } + return req, nil +} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/generatecostdetailsreport_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/generatecostdetailsreport_client.go index 6a7ec78a6680..329892f35cd3 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/generatecostdetailsreport_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/generatecostdetailsreport_client.go @@ -53,9 +53,9 @@ func NewGenerateCostDetailsReportClient(credential azcore.TokenCredential, optio // in files ,see https://learn.microsoft.com/en-us/azure/cost-management-billing/automate/understand-usage-details-fields // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 -// - scope - The ARM Resource ID for subscription, resource group, billing account, or other billing scopes. For details, see -// https://aka.ms/costmgmt/scopes. +// Generated from API version 2023-11-01 +// - scope - The ARM Resource ID for subscription, billing account, or other billing scopes.Currently Resource Group and Management +// Group are not supported. For details, see https://aka.ms/costmgmt/scopes. // - parameters - Parameters supplied to the Create cost details operation. // - options - GenerateCostDetailsReportClientBeginCreateOperationOptions contains the optional parameters for the GenerateCostDetailsReportClient.BeginCreateOperation // method. @@ -90,7 +90,7 @@ func (client *GenerateCostDetailsReportClient) BeginCreateOperation(ctx context. // in files ,see https://learn.microsoft.com/en-us/azure/cost-management-billing/automate/understand-usage-details-fields // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 func (client *GenerateCostDetailsReportClient) createOperation(ctx context.Context, scope string, parameters GenerateCostDetailsReportRequestDefinition, options *GenerateCostDetailsReportClientBeginCreateOperationOptions) (*http.Response, error) { var err error const operationName = "GenerateCostDetailsReportClient.BeginCreateOperation" @@ -121,7 +121,7 @@ func (client *GenerateCostDetailsReportClient) createOperationCreateRequest(ctx return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -134,9 +134,9 @@ func (client *GenerateCostDetailsReportClient) createOperationCreateRequest(ctx // request response Location header. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 -// - scope - The ARM Resource ID for subscription, resource group, billing account, or other billing scopes. For details, see -// https://aka.ms/costmgmt/scopes. +// Generated from API version 2023-11-01 +// - scope - The ARM Resource ID for subscription, billing account, or other billing scopes.Currently Resource Group and Management +// Group are not supported. For details, see https://aka.ms/costmgmt/scopes. // - operationID - The target operation Id. // - options - GenerateCostDetailsReportClientBeginGetOperationResultsOptions contains the optional parameters for the GenerateCostDetailsReportClient.BeginGetOperationResults // method. @@ -162,7 +162,7 @@ func (client *GenerateCostDetailsReportClient) BeginGetOperationResults(ctx cont // response Location header. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 func (client *GenerateCostDetailsReportClient) getOperationResults(ctx context.Context, scope string, operationID string, options *GenerateCostDetailsReportClientBeginGetOperationResultsOptions) (*http.Response, error) { var err error const operationName = "GenerateCostDetailsReportClient.BeginGetOperationResults" @@ -197,7 +197,7 @@ func (client *GenerateCostDetailsReportClient) getOperationResultsCreateRequest( return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/generatecostdetailsreport_client_example_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/generatecostdetailsreport_client_example_test.go deleted file mode 100644 index 7f05500c19a2..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/generatecostdetailsreport_client_example_test.go +++ /dev/null @@ -1,459 +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 armcostmanagement_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/costmanagement/armcostmanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateCostDetailsReportByBillingAccountEnterpriseAgreementCustomerAndBillingPeriod.json -func ExampleGenerateCostDetailsReportClient_BeginCreateOperation_generateCostDetailsReportByBillingAccountEnterpriseAgreementCustomerAndBillingPeriod() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewGenerateCostDetailsReportClient().BeginCreateOperation(ctx, "providers/Microsoft.Billing/billingAccounts/12345", armcostmanagement.GenerateCostDetailsReportRequestDefinition{ - BillingPeriod: to.Ptr("202205"), - Metric: to.Ptr(armcostmanagement.CostDetailsMetricTypeActualCostCostDetailsMetricType), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.CostDetailsOperationResults = armcostmanagement.CostDetailsOperationResults{ - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345/providers/Microsoft.CostManagement/costDetailsOperationResults/00000000-0000-0000-0000-000000000000"), - // Manifest: &armcostmanagement.ReportManifest{ - // BlobCount: to.Ptr[int32](1), - // Blobs: []*armcostmanagement.BlobInfo{ - // { - // BlobLink: to.Ptr("https://ccmreportstorageeastus.blob.core.windows.net/armreports/00000/00000000-0000-0000-0000-000000000000?sv=2020-05-31&sr=b&sig=abcd"), - // ByteCount: to.Ptr[int64](32741), - // }}, - // ByteCount: to.Ptr[int64](32741), - // CompressData: to.Ptr(false), - // DataFormat: to.Ptr(armcostmanagement.CostDetailsDataFormatCSVCostDetailsDataFormat), - // ManifestVersion: to.Ptr("2022-10-01"), - // RequestContext: &armcostmanagement.RequestContext{ - // RequestBody: &armcostmanagement.GenerateCostDetailsReportRequestDefinition{ - // BillingPeriod: to.Ptr("202205"), - // Metric: to.Ptr(armcostmanagement.CostDetailsMetricTypeActualCostCostDetailsMetricType), - // }, - // RequestScope: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345"), - // }, - // }, - // Status: to.Ptr(armcostmanagement.CostDetailsStatusTypeCompletedCostDetailsStatusType), - // ValidTill: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-05-10T08:08:46.197Z"); return t}()), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateCostDetailsReportByBillingProfileAndInvoiceId.json -func ExampleGenerateCostDetailsReportClient_BeginCreateOperation_generateCostDetailsReportByBillingProfileAndInvoiceId() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewGenerateCostDetailsReportClient().BeginCreateOperation(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579", armcostmanagement.GenerateCostDetailsReportRequestDefinition{ - InvoiceID: to.Ptr("M1234567"), - Metric: to.Ptr(armcostmanagement.CostDetailsMetricTypeActualCostCostDetailsMetricType), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.CostDetailsOperationResults = armcostmanagement.CostDetailsOperationResults{ - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/providers/Microsoft.CostManagement/costDetailsOperationResults/00000000-0000-0000-0000-000000000000"), - // Manifest: &armcostmanagement.ReportManifest{ - // BlobCount: to.Ptr[int32](1), - // Blobs: []*armcostmanagement.BlobInfo{ - // { - // BlobLink: to.Ptr("https://ccmreportstorageeastus.blob.core.windows.net/armreports/00000/00000000-0000-0000-0000-000000000000?sv=2020-05-31&sr=b&sig=abcd"), - // ByteCount: to.Ptr[int64](32741), - // }}, - // ByteCount: to.Ptr[int64](32741), - // CompressData: to.Ptr(false), - // DataFormat: to.Ptr(armcostmanagement.CostDetailsDataFormatCSVCostDetailsDataFormat), - // ManifestVersion: to.Ptr("2022-10-01"), - // RequestContext: &armcostmanagement.RequestContext{ - // RequestBody: &armcostmanagement.GenerateCostDetailsReportRequestDefinition{ - // BillingPeriod: to.Ptr("202205"), - // Metric: to.Ptr(armcostmanagement.CostDetailsMetricTypeActualCostCostDetailsMetricType), - // }, - // RequestScope: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579"), - // }, - // }, - // Status: to.Ptr(armcostmanagement.CostDetailsStatusTypeCompletedCostDetailsStatusType), - // ValidTill: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-05-10T08:08:46.197Z"); return t}()), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateCostDetailsReportByBillingProfileAndInvoiceIdAndCustomerId.json -func ExampleGenerateCostDetailsReportClient_BeginCreateOperation_generateCostDetailsReportByBillingProfileAndInvoiceIdAndCustomerId() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewGenerateCostDetailsReportClient().BeginCreateOperation(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789/customers/13579", armcostmanagement.GenerateCostDetailsReportRequestDefinition{ - InvoiceID: to.Ptr("M1234567"), - Metric: to.Ptr(armcostmanagement.CostDetailsMetricTypeActualCostCostDetailsMetricType), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.CostDetailsOperationResults = armcostmanagement.CostDetailsOperationResults{ - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/customers/13579/providers/Microsoft.CostManagement/costDetailsOperationResults/00000000-0000-0000-0000-000000000000"), - // Manifest: &armcostmanagement.ReportManifest{ - // BlobCount: to.Ptr[int32](1), - // Blobs: []*armcostmanagement.BlobInfo{ - // { - // BlobLink: to.Ptr("https://ccmreportstorageeastus.blob.core.windows.net/armreports/00000/00000000-0000-0000-0000-000000000000?sv=2020-05-31&sr=b&sig=abcd"), - // ByteCount: to.Ptr[int64](32741), - // }}, - // ByteCount: to.Ptr[int64](32741), - // CompressData: to.Ptr(false), - // DataFormat: to.Ptr(armcostmanagement.CostDetailsDataFormatCSVCostDetailsDataFormat), - // ManifestVersion: to.Ptr("2022-10-01"), - // RequestContext: &armcostmanagement.RequestContext{ - // RequestBody: &armcostmanagement.GenerateCostDetailsReportRequestDefinition{ - // BillingPeriod: to.Ptr("202205"), - // Metric: to.Ptr(armcostmanagement.CostDetailsMetricTypeActualCostCostDetailsMetricType), - // }, - // RequestScope: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/customers/13579"), - // }, - // }, - // Status: to.Ptr(armcostmanagement.CostDetailsStatusTypeCompletedCostDetailsStatusType), - // ValidTill: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-05-10T08:08:46.197Z"); return t}()), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateCostDetailsReportByCustomerAndTimePeriod.json -func ExampleGenerateCostDetailsReportClient_BeginCreateOperation_generateCostDetailsReportByCustomerAndTimePeriod() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewGenerateCostDetailsReportClient().BeginCreateOperation(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789/customers/13579", armcostmanagement.GenerateCostDetailsReportRequestDefinition{ - Metric: to.Ptr(armcostmanagement.CostDetailsMetricTypeActualCostCostDetailsMetricType), - TimePeriod: &armcostmanagement.CostDetailsTimePeriod{ - End: to.Ptr("2020-03-15"), - Start: to.Ptr("2020-03-01"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.CostDetailsOperationResults = armcostmanagement.CostDetailsOperationResults{ - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/customers/13579/providers/Microsoft.CostManagement/costDetailsOperationResults/00000000-0000-0000-0000-000000000000"), - // Manifest: &armcostmanagement.ReportManifest{ - // BlobCount: to.Ptr[int32](1), - // Blobs: []*armcostmanagement.BlobInfo{ - // { - // BlobLink: to.Ptr("https://ccmreportstorageeastus.blob.core.windows.net/armreports/00000/00000000-0000-0000-0000-000000000000?sv=2020-05-31&sr=b&sig=abcd"), - // ByteCount: to.Ptr[int64](32741), - // }}, - // ByteCount: to.Ptr[int64](32741), - // CompressData: to.Ptr(false), - // DataFormat: to.Ptr(armcostmanagement.CostDetailsDataFormatCSVCostDetailsDataFormat), - // ManifestVersion: to.Ptr("2022-10-01"), - // RequestContext: &armcostmanagement.RequestContext{ - // RequestBody: &armcostmanagement.GenerateCostDetailsReportRequestDefinition{ - // Metric: to.Ptr(armcostmanagement.CostDetailsMetricTypeActualCostCostDetailsMetricType), - // TimePeriod: &armcostmanagement.CostDetailsTimePeriod{ - // End: to.Ptr("2020-03-15"), - // Start: to.Ptr("2020-03-01"), - // }, - // }, - // RequestScope: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/customers/13579"), - // }, - // }, - // Status: to.Ptr(armcostmanagement.CostDetailsStatusTypeCompletedCostDetailsStatusType), - // ValidTill: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-05-10T08:08:46.197Z"); return t}()), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateCostDetailsReportByDepartmentsAndTimePeriod.json -func ExampleGenerateCostDetailsReportClient_BeginCreateOperation_generateCostDetailsReportByDepartmentsAndTimePeriod() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewGenerateCostDetailsReportClient().BeginCreateOperation(ctx, "providers/Microsoft.Billing/departments/12345", armcostmanagement.GenerateCostDetailsReportRequestDefinition{ - Metric: to.Ptr(armcostmanagement.CostDetailsMetricTypeActualCostCostDetailsMetricType), - TimePeriod: &armcostmanagement.CostDetailsTimePeriod{ - End: to.Ptr("2020-03-15"), - Start: to.Ptr("2020-03-01"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.CostDetailsOperationResults = armcostmanagement.CostDetailsOperationResults{ - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ID: to.Ptr("providers/Microsoft.Billing/departments/12345/providers/Microsoft.CostManagement/costDetailsOperationResults/00000000-0000-0000-0000-000000000000"), - // Manifest: &armcostmanagement.ReportManifest{ - // BlobCount: to.Ptr[int32](1), - // Blobs: []*armcostmanagement.BlobInfo{ - // { - // BlobLink: to.Ptr("https://ccmreportstorageeastus.blob.core.windows.net/armreports/00000/00000000-0000-0000-0000-000000000000?sv=2020-05-31&sr=b&sig=abcd"), - // ByteCount: to.Ptr[int64](32741), - // }}, - // ByteCount: to.Ptr[int64](32741), - // CompressData: to.Ptr(false), - // DataFormat: to.Ptr(armcostmanagement.CostDetailsDataFormatCSVCostDetailsDataFormat), - // ManifestVersion: to.Ptr("2022-10-01"), - // RequestContext: &armcostmanagement.RequestContext{ - // RequestBody: &armcostmanagement.GenerateCostDetailsReportRequestDefinition{ - // Metric: to.Ptr(armcostmanagement.CostDetailsMetricTypeActualCostCostDetailsMetricType), - // TimePeriod: &armcostmanagement.CostDetailsTimePeriod{ - // End: to.Ptr("2020-03-15"), - // Start: to.Ptr("2020-03-01"), - // }, - // }, - // RequestScope: to.Ptr("providers/Microsoft.Billing/departments/12345"), - // }, - // }, - // Status: to.Ptr(armcostmanagement.CostDetailsStatusTypeCompletedCostDetailsStatusType), - // ValidTill: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-05-10T08:08:46.197Z"); return t}()), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateCostDetailsReportByEnrollmentAccountsAndTimePeriod.json -func ExampleGenerateCostDetailsReportClient_BeginCreateOperation_generateCostDetailsReportByEnrollmentAccountsAndTimePeriod() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewGenerateCostDetailsReportClient().BeginCreateOperation(ctx, "providers/Microsoft.Billing/enrollmentAccounts/1234", armcostmanagement.GenerateCostDetailsReportRequestDefinition{ - Metric: to.Ptr(armcostmanagement.CostDetailsMetricTypeActualCostCostDetailsMetricType), - TimePeriod: &armcostmanagement.CostDetailsTimePeriod{ - End: to.Ptr("2020-03-15"), - Start: to.Ptr("2020-03-01"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.CostDetailsOperationResults = armcostmanagement.CostDetailsOperationResults{ - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ID: to.Ptr("providers/Microsoft.Billing/enrollmentAccounts/1234/providers/Microsoft.CostManagement/costDetailsOperationResults/00000000-0000-0000-0000-000000000000"), - // Manifest: &armcostmanagement.ReportManifest{ - // BlobCount: to.Ptr[int32](1), - // Blobs: []*armcostmanagement.BlobInfo{ - // { - // BlobLink: to.Ptr("https://ccmreportstorageeastus.blob.core.windows.net/armreports/00000/00000000-0000-0000-0000-000000000000?sv=2020-05-31&sr=b&sig=abcd"), - // ByteCount: to.Ptr[int64](32741), - // }}, - // ByteCount: to.Ptr[int64](32741), - // CompressData: to.Ptr(false), - // DataFormat: to.Ptr(armcostmanagement.CostDetailsDataFormatCSVCostDetailsDataFormat), - // ManifestVersion: to.Ptr("2022-10-01"), - // RequestContext: &armcostmanagement.RequestContext{ - // RequestBody: &armcostmanagement.GenerateCostDetailsReportRequestDefinition{ - // Metric: to.Ptr(armcostmanagement.CostDetailsMetricTypeActualCostCostDetailsMetricType), - // TimePeriod: &armcostmanagement.CostDetailsTimePeriod{ - // End: to.Ptr("2020-03-15"), - // Start: to.Ptr("2020-03-01"), - // }, - // }, - // RequestScope: to.Ptr("providers/Microsoft.Billing/enrollmentAccounts/1234"), - // }, - // }, - // Status: to.Ptr(armcostmanagement.CostDetailsStatusTypeCompletedCostDetailsStatusType), - // ValidTill: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-05-10T08:08:46.197Z"); return t}()), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateCostDetailsReportBySubscriptionAndTimePeriod.json -func ExampleGenerateCostDetailsReportClient_BeginCreateOperation_generateCostDetailsReportBySubscriptionAndTimePeriod() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewGenerateCostDetailsReportClient().BeginCreateOperation(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", armcostmanagement.GenerateCostDetailsReportRequestDefinition{ - Metric: to.Ptr(armcostmanagement.CostDetailsMetricTypeActualCostCostDetailsMetricType), - TimePeriod: &armcostmanagement.CostDetailsTimePeriod{ - End: to.Ptr("2020-03-15"), - Start: to.Ptr("2020-03-01"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.CostDetailsOperationResults = armcostmanagement.CostDetailsOperationResults{ - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/costDetailsOperationResults/00000000-0000-0000-0000-000000000000"), - // Manifest: &armcostmanagement.ReportManifest{ - // BlobCount: to.Ptr[int32](1), - // Blobs: []*armcostmanagement.BlobInfo{ - // { - // BlobLink: to.Ptr("https://ccmreportstorageeastus.blob.core.windows.net/armreports/00000/00000000-0000-0000-0000-000000000000?sv=2020-05-31&sr=b&sig=abcd"), - // ByteCount: to.Ptr[int64](32741), - // }}, - // ByteCount: to.Ptr[int64](32741), - // CompressData: to.Ptr(false), - // DataFormat: to.Ptr(armcostmanagement.CostDetailsDataFormatCSVCostDetailsDataFormat), - // ManifestVersion: to.Ptr("2022-10-01"), - // RequestContext: &armcostmanagement.RequestContext{ - // RequestBody: &armcostmanagement.GenerateCostDetailsReportRequestDefinition{ - // Metric: to.Ptr(armcostmanagement.CostDetailsMetricTypeActualCostCostDetailsMetricType), - // TimePeriod: &armcostmanagement.CostDetailsTimePeriod{ - // End: to.Ptr("2020-03-15"), - // Start: to.Ptr("2020-03-01"), - // }, - // }, - // RequestScope: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000"), - // }, - // }, - // Status: to.Ptr(armcostmanagement.CostDetailsStatusTypeCompletedCostDetailsStatusType), - // ValidTill: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-05-10T08:08:46.197Z"); return t}()), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/CostDetailsOperationResultsBySubscriptionScope.json -func ExampleGenerateCostDetailsReportClient_BeginGetOperationResults() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewGenerateCostDetailsReportClient().BeginGetOperationResults(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", "00000000-0000-0000-0000-000000000000", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.CostDetailsOperationResults = armcostmanagement.CostDetailsOperationResults{ - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/costDetailsOperationResults/00000000-0000-0000-0000-000000000000"), - // Manifest: &armcostmanagement.ReportManifest{ - // BlobCount: to.Ptr[int32](1), - // Blobs: []*armcostmanagement.BlobInfo{ - // { - // BlobLink: to.Ptr("https://ccmreportstorageeastus.blob.core.windows.net/armreports/00000/00000000-0000-0000-0000-000000000000?sv=2020-05-31&sr=b&sig=abcd"), - // ByteCount: to.Ptr[int64](32741), - // }}, - // ByteCount: to.Ptr[int64](32741), - // CompressData: to.Ptr(false), - // DataFormat: to.Ptr(armcostmanagement.CostDetailsDataFormatCSVCostDetailsDataFormat), - // ManifestVersion: to.Ptr("2022-10-01"), - // RequestContext: &armcostmanagement.RequestContext{ - // RequestBody: &armcostmanagement.GenerateCostDetailsReportRequestDefinition{ - // Metric: to.Ptr(armcostmanagement.CostDetailsMetricTypeActualCostCostDetailsMetricType), - // TimePeriod: &armcostmanagement.CostDetailsTimePeriod{ - // End: to.Ptr("2020-03-15"), - // Start: to.Ptr("2020-03-01"), - // }, - // }, - // RequestScope: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000"), - // }, - // }, - // Status: to.Ptr(armcostmanagement.CostDetailsStatusTypeCompletedCostDetailsStatusType), - // ValidTill: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-05-10T08:08:46.197Z"); return t}()), - // } -} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreport_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreport_client.go index 2e998f29e328..0dfce2913e54 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreport_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreport_client.go @@ -45,7 +45,7 @@ func NewGenerateDetailedCostReportClient(credential azcore.TokenCredential, opti // cost report is being stored. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - scope - The ARM Resource ID for subscription, resource group, billing account, or other billing scopes. For details, see // https://aka.ms/costmgmt/scopes. // - parameters - Parameters supplied to the Create detailed cost report operation. @@ -76,7 +76,7 @@ func (client *GenerateDetailedCostReportClient) BeginCreateOperation(ctx context // cost report is being stored. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 func (client *GenerateDetailedCostReportClient) createOperation(ctx context.Context, scope string, parameters GenerateDetailedCostReportDefinition, options *GenerateDetailedCostReportClientBeginCreateOperationOptions) (*http.Response, error) { var err error const operationName = "GenerateDetailedCostReportClient.BeginCreateOperation" @@ -107,7 +107,7 @@ func (client *GenerateDetailedCostReportClient) createOperationCreateRequest(ctx return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreport_client_example_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreport_client_example_test.go deleted file mode 100644 index d0bdb067bf68..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreport_client_example_test.go +++ /dev/null @@ -1,206 +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 armcostmanagement_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/costmanagement/armcostmanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateDetailedCostReportByBillingAccountLegacyAndBillingPeriod.json -func ExampleGenerateDetailedCostReportClient_BeginCreateOperation_generateDetailedCostReportByBillingAccountLegacyAndBillingPeriod() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewGenerateDetailedCostReportClient().BeginCreateOperation(ctx, "providers/Microsoft.Billing/billingAccounts/12345", armcostmanagement.GenerateDetailedCostReportDefinition{ - BillingPeriod: to.Ptr("202008"), - Metric: to.Ptr(armcostmanagement.GenerateDetailedCostReportMetricTypeActualCost), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.GenerateDetailedCostReportOperationResult = armcostmanagement.GenerateDetailedCostReportOperationResult{ - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.Consumption/operationResult"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/operationResults/00000000-0000-0000-0000-000000000000"), - // Properties: &armcostmanagement.DownloadURL{ - // DownloadURL: to.Ptr("https://ccmreportstorageeastus.blob.core.windows.net/armreports/20201207/00000000-0000-0000-0000-000000000000?sv=2020-05-31&sr=b&sig=abcd"), - // ValidTill: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-08T05:55:59.439Z"); return t}()), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateDetailedCostReportByBillingProfileAndInvoiceId.json -func ExampleGenerateDetailedCostReportClient_BeginCreateOperation_generateDetailedCostReportByBillingProfileAndInvoiceId() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewGenerateDetailedCostReportClient().BeginCreateOperation(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579", armcostmanagement.GenerateDetailedCostReportDefinition{ - InvoiceID: to.Ptr("M1234567"), - Metric: to.Ptr(armcostmanagement.GenerateDetailedCostReportMetricTypeActualCost), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.GenerateDetailedCostReportOperationResult = armcostmanagement.GenerateDetailedCostReportOperationResult{ - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.Consumption/operationResult"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/operationResults/00000000-0000-0000-0000-000000000000"), - // Properties: &armcostmanagement.DownloadURL{ - // DownloadURL: to.Ptr("https://ccmreportstorageeastus.blob.core.windows.net/armreports/20201207/00000000-0000-0000-0000-000000000000?sv=2020-05-31&sr=b&sig=abcd"), - // ValidTill: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-08T05:55:59.439Z"); return t}()), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateDetailedCostReportByBillingProfileAndInvoiceIdAndCustomerId.json -func ExampleGenerateDetailedCostReportClient_BeginCreateOperation_generateDetailedCostReportByBillingProfileAndInvoiceIdAndCustomerId() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewGenerateDetailedCostReportClient().BeginCreateOperation(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579", armcostmanagement.GenerateDetailedCostReportDefinition{ - CustomerID: to.Ptr("456789"), - InvoiceID: to.Ptr("M1234567"), - Metric: to.Ptr(armcostmanagement.GenerateDetailedCostReportMetricTypeActualCost), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.GenerateDetailedCostReportOperationResult = armcostmanagement.GenerateDetailedCostReportOperationResult{ - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.Consumption/operationResult"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/operationResults/00000000-0000-0000-0000-000000000000"), - // Properties: &armcostmanagement.DownloadURL{ - // DownloadURL: to.Ptr("https://ccmreportstorageeastus.blob.core.windows.net/armreports/20201207/00000000-0000-0000-0000-000000000000?sv=2020-05-31&sr=b&sig=abcd"), - // ValidTill: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-08T05:55:59.439Z"); return t}()), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateDetailedCostReportByCustomerAndTimePeriod.json -func ExampleGenerateDetailedCostReportClient_BeginCreateOperation_generateDetailedCostReportByCustomerAndTimePeriod() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewGenerateDetailedCostReportClient().BeginCreateOperation(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789/customers/13579", armcostmanagement.GenerateDetailedCostReportDefinition{ - Metric: to.Ptr(armcostmanagement.GenerateDetailedCostReportMetricTypeActualCost), - TimePeriod: &armcostmanagement.GenerateDetailedCostReportTimePeriod{ - End: to.Ptr("2020-03-15"), - Start: to.Ptr("2020-03-01"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.GenerateDetailedCostReportOperationResult = armcostmanagement.GenerateDetailedCostReportOperationResult{ - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.Consumption/operationResult"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/operationResults/00000000-0000-0000-0000-000000000000"), - // Properties: &armcostmanagement.DownloadURL{ - // DownloadURL: to.Ptr("https://ccmreportstorageeastus.blob.core.windows.net/armreports/20201207/00000000-0000-0000-0000-000000000000?sv=2020-05-31&sr=b&sig=abcd"), - // ValidTill: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-08T05:55:59.439Z"); return t}()), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateDetailedCostReportBySubscriptionAndTimePeriod.json -func ExampleGenerateDetailedCostReportClient_BeginCreateOperation_generateDetailedCostReportBySubscriptionAndTimePeriod() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewGenerateDetailedCostReportClient().BeginCreateOperation(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", armcostmanagement.GenerateDetailedCostReportDefinition{ - Metric: to.Ptr(armcostmanagement.GenerateDetailedCostReportMetricTypeActualCost), - TimePeriod: &armcostmanagement.GenerateDetailedCostReportTimePeriod{ - End: to.Ptr("2020-03-15"), - Start: to.Ptr("2020-03-01"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.GenerateDetailedCostReportOperationResult = armcostmanagement.GenerateDetailedCostReportOperationResult{ - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.Consumption/operationResult"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/operationResults/00000000-0000-0000-0000-000000000000"), - // Properties: &armcostmanagement.DownloadURL{ - // DownloadURL: to.Ptr("https://ccmreportstorageeastus.blob.core.windows.net/armreports/20201207/00000000-0000-0000-0000-000000000000?sv=2020-05-31&sr=b&sig=abcd"), - // ValidTill: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-08T05:55:59.439Z"); return t}()), - // }, - // } -} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationresults_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationresults_client.go index 6c7891e656d1..91d8bf9bc295 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationresults_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationresults_client.go @@ -44,7 +44,7 @@ func NewGenerateDetailedCostReportOperationResultsClient(credential azcore.Token // of the initial request. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - operationID - The target operation Id. // - scope - The ARM Resource ID for subscription, resource group, billing account, or other billing scopes. For details, see // https://aka.ms/costmgmt/scopes. @@ -71,7 +71,7 @@ func (client *GenerateDetailedCostReportOperationResultsClient) BeginGet(ctx con // initial request. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 func (client *GenerateDetailedCostReportOperationResultsClient) get(ctx context.Context, operationID string, scope string, options *GenerateDetailedCostReportOperationResultsClientBeginGetOptions) (*http.Response, error) { var err error const operationName = "GenerateDetailedCostReportOperationResultsClient.BeginGet" @@ -106,7 +106,7 @@ func (client *GenerateDetailedCostReportOperationResultsClient) getCreateRequest return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationresults_client_example_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationresults_client_example_test.go deleted file mode 100644 index 7083eefbee8e..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationresults_client_example_test.go +++ /dev/null @@ -1,51 +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 armcostmanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateDetailedCostReportOperationResultsBySubscriptionScope.json -func ExampleGenerateDetailedCostReportOperationResultsClient_BeginGet() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewGenerateDetailedCostReportOperationResultsClient().BeginGet(ctx, "00000000-0000-0000-0000-000000000000", "subscriptions/00000000-0000-0000-0000-000000000000", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.GenerateDetailedCostReportOperationResult = armcostmanagement.GenerateDetailedCostReportOperationResult{ - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.Consumption/operationResult"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/operationResults/00000000-0000-0000-0000-000000000000"), - // Properties: &armcostmanagement.DownloadURL{ - // DownloadURL: to.Ptr("https://ccmreportstorageeastus.blob.core.windows.net/armreports/20201207/00000000-0000-0000-0000-000000000000?sv=2020-05-31&sr=b&sig=abcd"), - // ValidTill: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-08T05:55:59.439Z"); return t}()), - // }, - // } -} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationstatus_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationstatus_client.go index 872a972c9870..7bbc8a519a5b 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationstatus_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationstatus_client.go @@ -44,7 +44,7 @@ func NewGenerateDetailedCostReportOperationStatusClient(credential azcore.TokenC // response header. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - operationID - The target operation Id. // - scope - The ARM Resource ID for subscription, resource group, billing account, or other billing scopes. For details, see // https://aka.ms/costmgmt/scopes. @@ -85,7 +85,7 @@ func (client *GenerateDetailedCostReportOperationStatusClient) getCreateRequest( return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationstatus_client_example_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationstatus_client_example_test.go deleted file mode 100644 index 3adaf3cdbfea..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationstatus_client_example_test.go +++ /dev/null @@ -1,52 +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 armcostmanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateDetailedCostReportOperationStatusBySubscriptionScope.json -func ExampleGenerateDetailedCostReportOperationStatusClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewGenerateDetailedCostReportOperationStatusClient().Get(ctx, "00000000-0000-0000-0000-000000000000", "subscriptions/00000000-0000-0000-0000-000000000000", 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.GenerateDetailedCostReportOperationStatuses = armcostmanagement.GenerateDetailedCostReportOperationStatuses{ - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.Consumption/operationStatus"), - // Error: &armcostmanagement.ErrorDetails{ - // Code: to.Ptr("0"), - // }, - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/operationStatus/00000000-0000-0000-0000-000000000000"), - // Properties: &armcostmanagement.DownloadURL{ - // DownloadURL: to.Ptr("https://ccmreportstorageeastus.blob.core.windows.net/armreports/20201207/00000000-0000-0000-0000-000000000000?sv=2020-05-31&sr=b&sig=abcd"), - // ValidTill: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-08T05:55:59.439Z"); return t}()), - // }, - // Status: &armcostmanagement.Status{ - // }, - // } -} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/generatereservationdetailsreport_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/generatereservationdetailsreport_client.go index e1f7194b1249..fa791d928a14 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/generatereservationdetailsreport_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/generatereservationdetailsreport_client.go @@ -45,7 +45,7 @@ func NewGenerateReservationDetailsReportClient(credential azcore.TokenCredential // on the roles see, https://docs.microsoft.com/en-us/azure/cost-management-billing/manage/understand-ea-roles#usage-and-costs-access-by-role // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - billingAccountID - Enrollment ID (Legacy BillingAccount ID) // - startDate - Start Date // - endDate - End Date @@ -74,7 +74,7 @@ func (client *GenerateReservationDetailsReportClient) BeginByBillingAccountID(ct // on the roles see, https://docs.microsoft.com/en-us/azure/cost-management-billing/manage/understand-ea-roles#usage-and-costs-access-by-role // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 func (client *GenerateReservationDetailsReportClient) byBillingAccountID(ctx context.Context, billingAccountID string, startDate string, endDate string, options *GenerateReservationDetailsReportClientBeginByBillingAccountIDOptions) (*http.Response, error) { var err error const operationName = "GenerateReservationDetailsReportClient.BeginByBillingAccountID" @@ -108,9 +108,9 @@ func (client *GenerateReservationDetailsReportClient) byBillingAccountIDCreateRe return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("startDate", startDate) + reqQP.Set("api-version", "2023-11-01") reqQP.Set("endDate", endDate) - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("startDate", startDate) req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -121,7 +121,7 @@ func (client *GenerateReservationDetailsReportClient) byBillingAccountIDCreateRe // details on the roles see, https://docs.microsoft.com/en-us/azure/cost-management-billing/reservations/reservation-utilization#view-utilization-in-the-azure-portal-with-azure-rbac-access // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - billingAccountID - Billing account ID // - billingProfileID - Billing profile ID. // - startDate - Start Date @@ -151,7 +151,7 @@ func (client *GenerateReservationDetailsReportClient) BeginByBillingProfileID(ct // details on the roles see, https://docs.microsoft.com/en-us/azure/cost-management-billing/reservations/reservation-utilization#view-utilization-in-the-azure-portal-with-azure-rbac-access // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 func (client *GenerateReservationDetailsReportClient) byBillingProfileID(ctx context.Context, billingAccountID string, billingProfileID string, startDate string, endDate string, options *GenerateReservationDetailsReportClientBeginByBillingProfileIDOptions) (*http.Response, error) { var err error const operationName = "GenerateReservationDetailsReportClient.BeginByBillingProfileID" @@ -189,9 +189,9 @@ func (client *GenerateReservationDetailsReportClient) byBillingProfileIDCreateRe return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("startDate", startDate) + reqQP.Set("api-version", "2023-11-01") reqQP.Set("endDate", endDate) - reqQP.Set("api-version", "2022-10-01") + 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/costmanagement/armcostmanagement/generatereservationdetailsreport_client_example_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/generatereservationdetailsreport_client_example_test.go deleted file mode 100644 index 5d3fcc4c1d6d..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/generatereservationdetailsreport_client_example_test.go +++ /dev/null @@ -1,80 +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 armcostmanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateReservationDetailsReportByBillingAccount.json -func ExampleGenerateReservationDetailsReportClient_BeginByBillingAccountID() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewGenerateReservationDetailsReportClient().BeginByBillingAccountID(ctx, "9845612", "2020-01-01", "2020-01-30", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.OperationStatus = armcostmanagement.OperationStatus{ - // Properties: &armcostmanagement.ReportURL{ - // ReportURL: to.Ptr(armcostmanagement.ReservationReportSchema("https://storage.blob.core.windows.net/details/20200911/00000000-0000-0000-0000-000000000000?sv=2016-05-31&sr=b&sig=jep8HT2aphfUkyERRZa5LRfd9RPzjXbzB%2F9TNiQ")), - // ValidUntil: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-09-12T02:56:55.502Z"); return t}()), - // }, - // Status: to.Ptr(armcostmanagement.OperationStatusTypeCompleted), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateReservationDetailsReportByBillingProfile.json -func ExampleGenerateReservationDetailsReportClient_BeginByBillingProfileID() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewGenerateReservationDetailsReportClient().BeginByBillingProfileID(ctx, "00000000-0000-0000-0000-000000000000", "CZSFR-SDFXC-DSDF", "2020-01-01", "2020-01-30", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.OperationStatus = armcostmanagement.OperationStatus{ - // Properties: &armcostmanagement.ReportURL{ - // ReportURL: to.Ptr(armcostmanagement.ReservationReportSchema("https://storage.blob.core.windows.net/details/20200911/00000000-0000-0000-0000-000000000000?sv=2016-05-31&sr=b&sig=jep8HT2aphfUkyERRZa5LRfd9RPzjXbzB%2F9TNiQ")), - // ValidUntil: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-09-12T02:56:55.502Z"); return t}()), - // }, - // Status: to.Ptr(armcostmanagement.OperationStatusTypeCompleted), - // } -} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/go.mod b/sdk/resourcemanager/costmanagement/armcostmanagement/go.mod index fd20ef69e93a..4c2eee2e296f 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/go.mod +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/go.mod @@ -1,21 +1,11 @@ -module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v2 +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v3 go 1.18 -require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.11.1 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.5.2 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.11.1 require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.7.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect - github.com/golang-jwt/jwt/v5 v5.2.1 // 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.22.0 // indirect golang.org/x/net v0.24.0 // indirect - golang.org/x/sys v0.19.0 // indirect golang.org/x/text v0.14.0 // indirect ) diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/go.sum b/sdk/resourcemanager/costmanagement/armcostmanagement/go.sum index 453385ef9f88..ffdff03203f8 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/go.sum +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/go.sum @@ -1,29 +1,12 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.11.1 h1:E+OJmp2tPvt1W+amx48v1eqbjDYsgN+RzP4q16yV5eM= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.11.1/go.mod h1:a6xsAQUZg+VsS3TJ05SRp524Hs4pZ/AeFSr5ENf0Yjo= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.5.2 h1:FDif4R1+UUR+00q6wquyX90K7A8dN+R5E8GEadoP7sU= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.5.2/go.mod h1:aiYBYui4BJ/BJCAIKs92XiPyQfTaBWqvHujDwKb6CBU= github.com/Azure/azure-sdk-for-go/sdk/internal v1.7.0 h1:rTfKOCZGy5ViVrlA74ZPE99a+SgoEE2K/yg3RyW9dFA= github.com/Azure/azure-sdk-for-go/sdk/internal v1.7.0/go.mod h1:4OG6tQ9EOP/MT0NMjDlRzWoVFxfu9rN9B2X+tlSVktg= -github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 h1:XHOnouVk1mxXfQidrMEnLlPk9UMeRtyBTnEFtxkV0kU= -github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= -github.com/golang-jwt/jwt/v5 v5.2.1/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/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/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= -golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= -golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/interfaces.go b/sdk/resourcemanager/costmanagement/armcostmanagement/interfaces.go index e4a993d599b2..5b4d0247d521 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/interfaces.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/interfaces.go @@ -25,3 +25,12 @@ type BenefitUtilizationSummaryClassification interface { // GetBenefitUtilizationSummary returns the BenefitUtilizationSummary content of the underlying type. GetBenefitUtilizationSummary() *BenefitUtilizationSummary } + +// SettingClassification provides polymorphic access to related types. +// Call the interface's GetSetting() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *Setting, *TagInheritanceSetting +type SettingClassification interface { + // GetSetting returns the Setting content of the underlying type. + GetSetting() *Setting +} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/models.go b/sdk/resourcemanager/costmanagement/armcostmanagement/models.go index 6e45b683a075..ae121beb9a0e 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/models.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/models.go @@ -197,6 +197,19 @@ type AllSavingsList struct { Value []*AllSavingsBenefitDetails } +// AsyncOperationStatusProperties - Object representing the report url and valid until date of the async report generated. +type AsyncOperationStatusProperties struct { + // Sas url to the async benefit utilization summaries report. Will be empty if the report is in Running or Failed state. + ReportURL *BenefitUtilizationSummaryReportSchema + + // Sas url to async benefit utilization summaries report in secondary storage in case of primary outage. Will be empty if + // the report is in Running or Failed state. + SecondaryReportURL *BenefitUtilizationSummaryReportSchema + + // The date that the sas url provided in reportUrl expires. + ValidUntil *time.Time +} + // BenefitRecommendationModel - benefit plan recommendation details. type BenefitRecommendationModel struct { // Reservation or SavingsPlan. @@ -280,6 +293,52 @@ type BenefitUtilizationSummariesListResult struct { Value []BenefitUtilizationSummaryClassification } +// BenefitUtilizationSummariesOperationStatus - Status of a benefit utilization summaries report. Provides Async Benefit Utilization +// Summaries Request input, status, and report sas url. +type BenefitUtilizationSummariesOperationStatus struct { + // Input given to create the benefit utilization summaries report. + Input *BenefitUtilizationSummariesRequest + + // Contains sas url to the async benefit utilization summaries report and a date that the url is valid until. These values + // will be empty if the report is in a Running or Failed state + Properties *AsyncOperationStatusProperties + + // The status of the creation of the benefit utilization summaries report. + Status *OperationStatusType +} + +// BenefitUtilizationSummariesRequest - Properties of an async benefit utilization summaries request. +type BenefitUtilizationSummariesRequest struct { + // REQUIRED; The end date of the summaries data that will be served in the report. + EndDate *time.Time + + // REQUIRED; The grain the summaries data is served at in the report. Accepted values are 'Daily' or 'Monthly'. + Grain *Grain + + // REQUIRED; The start date of the summaries data that will be served in the report. + StartDate *time.Time + + // Benefit id the benefit utilization summaries report is for. Required for benefit id scope. Not supported for benefit order + // or any billing scopes. + BenefitID *string + + // Benefit order id the benefit utilization summaries report is for. Required for benefit order and benefit id scopes. Not + // supported for any billing scopes. + BenefitOrderID *string + + // Billing account the benefit utilization summaries report is for. Required for billing account and billing profile scopes. + // Not supported for any benefit scopes. + BillingAccountID *string + + // Billing profile id the benefit utilization summaries report is for. Required for billing profile scope. Not supported for + // billing account or any benefit scopes. + BillingProfileID *string + + // The type of benefit data requested. Required for billing account and billing profile scopes. Implied and not to be passed + // at benefit scopes. Supported values are Reservation and SavingsPlan + Kind *BenefitKind +} + // BenefitUtilizationSummary - Benefit utilization summary resource. type BenefitUtilizationSummary struct { // REQUIRED; Supported values: 'SavingsPlan'. @@ -309,6 +368,173 @@ type BlobInfo struct { ByteCount *int64 } +// Budget - A budget resource. +type Budget 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 budget. + Properties *BudgetProperties + + // READ-ONLY; Resource Id. + ID *string + + // READ-ONLY; Resource name. + Name *string + + // READ-ONLY; Resource type. + Type *string +} + +// BudgetComparisonExpression - The comparison expression to be used in the budgets. +type BudgetComparisonExpression struct { + // REQUIRED; The name of the column to use in comparison. + Name *string + + // REQUIRED; The operator to use for comparison. + Operator *BudgetOperatorType + + // REQUIRED; Array of values to use for comparison + Values []*string +} + +// BudgetFilter - May be used to filter budgets by user-specified dimensions and/or tags. +// Supported for CategoryType(s): Cost, ReservationUtilization. +type BudgetFilter struct { + // The logical "AND" expression. Must have at least 2 items. + // Supported for CategoryType(s): Cost. + And []*BudgetFilterProperties + + // Has comparison expression for a dimension. + // Supported for CategoryType(s): Cost, ReservationUtilization. + // Supported dimension names for CategoryType: ReservationUtilization + // * ReservationId + // * ReservedResourceType + Dimensions *BudgetComparisonExpression + + // Has comparison expression for a tag. + // Supported for CategoryType(s): Cost. + Tags *BudgetComparisonExpression +} + +// BudgetFilterProperties - The Dimensions or Tags to filter a budget by. +// Supported for CategoryType(s): Cost, ReservationUtilization. +type BudgetFilterProperties struct { + // Has comparison expression for a dimension. + // Supported for CategoryType(s): Cost, ReservationUtilization. + // Supported dimension names for CategoryType: ReservationUtilization + // * ReservationId + // * ReservedResourceType + Dimensions *BudgetComparisonExpression + + // Has comparison expression for a tag. + // Supported for CategoryType(s): Cost. + Tags *BudgetComparisonExpression +} + +// BudgetProperties - The properties of the budget. +type BudgetProperties struct { + // REQUIRED; The category of the budget. + // * 'Cost' defines a Budget. + // * 'ReservationUtilization' defines a Reservation Utilization Alert Rule. + Category *CategoryType + + // REQUIRED; The time covered by a budget. Tracking of the amount will be reset based on the time grain. + // Supported for CategoryType(s): Cost, ReservationUtilization. + // Supported timeGrainTypes for CategoryType: Cost + // * Monthly + // + // + // * Quarterly + // + // + // * Annually + // + // + // * BillingMonth* + // + // + // * BillingQuarter* + // + // + // * BillingAnnual* + // + // *only supported for Web Direct customers. + // + // Supported timeGrainTypes for CategoryType: ReservationUtilization + // + // + // * Last7Days + // + // + // * Last30Days + // + // Required for CategoryType(s): Cost, ReservationUtilization. + TimeGrain *TimeGrainType + + // REQUIRED; The time period that defines the active period of the budget. The budget will evaluate data on or after the startDate + // and will expire on the endDate. + // Supported for CategoryType(s): Cost, ReservationUtilization. + // Required for CategoryType(s): Cost, ReservationUtilization. + TimePeriod *BudgetTimePeriod + + // The total amount of cost to track with the budget. + // Supported for CategoryType(s): Cost. + // Required for CategoryType(s): Cost. + Amount *float32 + + // May be used to filter budgets by user-specified dimensions and/or tags. + // Supported for CategoryType(s): Cost, ReservationUtilization. + Filter *BudgetFilter + + // Dictionary of notifications associated with the budget. + // Supported for CategoryType(s): Cost, ReservationUtilization. + // * Constraints for CategoryType: Cost - Budget can have up to 5 notifications with thresholdType: Actual and 5 notifications + // with thresholdType: Forecasted. + // * Constraints for CategoryType: ReservationUtilization - Only one notification allowed. thresholdType is not applicable. + Notifications map[string]*Notification + + // READ-ONLY; The current amount of cost which is being tracked for a budget. + // Supported for CategoryType(s): Cost. + CurrentSpend *CurrentSpend + + // READ-ONLY; The forecasted cost which is being tracked for a budget. + // Supported for CategoryType(s): Cost. + ForecastSpend *ForecastSpend +} + +// BudgetTimePeriod - The time period that defines the active period of the budget. The budget will evaluate data on or after +// the startDate and will expire on the endDate. +// Supported for CategoryType(s): Cost, ReservationUtilization. +// Required for CategoryType(s): Cost, ReservationUtilization. +type BudgetTimePeriod struct { + // REQUIRED; The start date for the budget. + // * Constraints for CategoryType: Cost - Must be first of the month and should be less than the end date. Budget start date + // must be on or after June 1, 2017. Future start date should not be more than + // twelve months. Past start date should be selected within the timegrain period. + // + // + // * Constraints for CategoryType: ReservationUtilization - Must be on or after the current date and less than the end date. + StartDate *time.Time + + // The end date for the budget. + // * Constraints for CategoryType: Cost - No constraints. If not provided, we default this to 10 years from the start date. + // + // + // * Constraints for CategoryType: ReservationUtilization - End date cannot be more than 3 years after the start date. + EndDate *time.Time +} + +// BudgetsListResult - Result of listing budgets. It contains a list of available budgets in the scope provided. +type BudgetsListResult struct { + // READ-ONLY; The link (url) to the next page of results. It's null for now, added for future use. + NextLink *string + + // READ-ONLY; The list of budgets. + Value []*Budget +} + // CheckNameAvailabilityRequest - The check availability request body. type CheckNameAvailabilityRequest struct { // The name of the resource for which availability needs to be checked. @@ -353,6 +579,89 @@ type CommonExportProperties struct { NextRunTimeEstimate *time.Time } +// CostAllocationProportion - Target resources and allocation +type CostAllocationProportion struct { + // REQUIRED; Target resource for cost allocation + Name *string + + // REQUIRED; Percentage of source cost to allocate to this resource. This value can be specified to two decimal places and + // the total percentage of all resources in this rule must sum to 100.00. + Percentage *float32 +} + +// CostAllocationRuleCheckNameAvailabilityRequest - The cost allocation rule check name availability request +type CostAllocationRuleCheckNameAvailabilityRequest struct { + // Rule name + Name *string + + // Resource type. This is expected to be Microsoft.CostManagement/costAllocationRules + Type *string +} + +// CostAllocationRuleCheckNameAvailabilityResponse - The cost allocation rule check name availability response +type CostAllocationRuleCheckNameAvailabilityResponse struct { + // Error message if the name is not available + Message *string + + // Whether this rule name is available + NameAvailable *bool + + // The reason this name is not available + Reason *Reason +} + +// CostAllocationRuleDefinition - The cost allocation rule model definition +type CostAllocationRuleDefinition struct { + // Cost allocation rule properties + Properties *CostAllocationRuleProperties + + // READ-ONLY; Azure Resource Manager Id for the rule. This is a read ony value. + ID *string + + // READ-ONLY; Name of the rule. This is a read only value. + Name *string + + // READ-ONLY; Resource type of the rule. This is a read only value of Microsoft.CostManagement/CostAllocationRule. + Type *string +} + +// CostAllocationRuleDetails - Resource details of the cost allocation rule +type CostAllocationRuleDetails struct { + // Source resources for cost allocation. At this time, this list can contain no more than one element. + SourceResources []*SourceCostAllocationResource + + // Target resources for cost allocation. At this time, this list can contain no more than one element. + TargetResources []*TargetCostAllocationResource +} + +// CostAllocationRuleList - Result of listing cost allocation rules. It contains a list of available rules in the billing +// account or enterprise enrollment provided. +type CostAllocationRuleList struct { + // The list of cost allocation rules. + Value []*CostAllocationRuleDefinition + + // READ-ONLY; URL to get the next set of rule list results if there are any. + NextLink *string +} + +// CostAllocationRuleProperties - The properties of a cost allocation rule +type CostAllocationRuleProperties struct { + // REQUIRED; Resource information for the cost allocation rule + Details *CostAllocationRuleDetails + + // REQUIRED; Status of the rule + Status *RuleStatus + + // Description of a cost allocation rule. + Description *string + + // READ-ONLY; Time at which the rule was created. Rules that change cost for the same resource are applied in order of creation. + CreatedDate *time.Time + + // READ-ONLY; Time at which the rule was last updated. + UpdatedDate *time.Time +} + // CostDetailsOperationResults - The result of the long running operation for cost details Api. type CostDetailsOperationResults struct { // The details of the error. @@ -387,6 +696,16 @@ type CostDetailsTimePeriod struct { Start *string } +// CurrentSpend - The current amount of cost which is being tracked for a budget. +// Supported for CategoryType(s): Cost. +type CurrentSpend struct { + // READ-ONLY; The total amount of cost which is being tracked by the budget. + Amount *float32 + + // READ-ONLY; The unit of measure for the budget amount. + Unit *string +} + // Dimension - List of Dimension. type Dimension struct { // Dimension properties. @@ -468,6 +787,104 @@ type DownloadURL struct { ExpiryTime *time.Time } +// EAPriceSheetProperties - The properties of the EA price sheet. +type EAPriceSheetProperties struct { + // READ-ONLY; The unit price at the time the customer signs on or the unit price at the time of service meter GA launch if + // it is after sign-on. + // This is applicable for Enterprise Agreement users + BasePrice *string + + // READ-ONLY; Currency in which the Enterprise Agreement was signed + CurrencyCode *string + + // READ-ONLY; Effective end date of the Price Sheet billing period + EffectiveEndDate *time.Time + + // READ-ONLY; Effective start date of the Price Sheet billing period + EffectiveStartDate *time.Time + + // READ-ONLY; Unique identifier for the EA billing account. + EnrollmentNumber *string + + // READ-ONLY; Quantities of a specific service to which an EA customer is entitled to consume without incremental charges. + IncludedQuantity *string + + // READ-ONLY; The current list price for a given product or service. This price is without any negotiations and is based on + // your Microsoft Agreement type. + // For PriceType Consumption, market price is reflected as the pay-as-you-go price. + // For PriceType Savings Plan, market price reflects the Savings plan benefit on top of pay-as-you-go price for the corresponding + // commitment term. + // For PriceType ReservedInstance, market price reflects the total price of the 1 or 3-year commitment. + // Note: For EA customers with no negotiations, market price may appear rounded to a different decimal precision than unit + // price. + MarketPrice *string + + // READ-ONLY; Name of the classification category for the meter. For example, Cloud services, Networking, etc. + MeterCategory *string + + // READ-ONLY; Unique identifier of the meter + MeterID *string + + // READ-ONLY; Name of the meter. The meter represents the deployable resource of an Azure service. + MeterName *string + + // READ-ONLY; Name of the Azure region where the meter for the service is available. + MeterRegion *string + + // READ-ONLY; Name of the meter subclassification category. + MeterSubCategory *string + + // READ-ONLY; Name of the meter type + MeterType *string + + // READ-ONLY; Part number associated with the meter + PartNumber *string + + // READ-ONLY; Price type for a product. For example, an Azure resource with a pay-as-you-go rate with priceType as Consumption. + // Other price types include ReservedInstance and Savings Plan. + PriceType *string + + // READ-ONLY; Name of the product accruing the charges. + Product *string + + // READ-ONLY; Unique identifier for the product whose meter is consumed. + ProductID *string + + // READ-ONLY; Unique identifier of the SKU + SKUID *string + + // READ-ONLY; Type of Azure service. For example, Compute, Analytics, and Security. + ServiceFamily *float32 + + // READ-ONLY; Term length for Azure Savings Plan or Reservation term – one year or three years (P1Y or P3Y) + Term *string + + // READ-ONLY; How usage is measured for the service + UnitOfMeasure *string + + // READ-ONLY; The per-unit price at the time of billing for a given product or service, inclusive of any negotiated discounts + // on top of the market price. + // For PriceType ReservedInstance, unit price reflects the total cost of the 1 or 3-year commitment including discounts. + // Note: The unit price isn't the same as the effective price in usage details downloads when services have differential prices + // across tiers. + // If services have multi-tiered pricing, the effective price is a blended rate across the tiers and doesn't show a tier-specific + // unit price. The blended price or effective price is the net price for the + // consumed quantity spanning across the multiple tiers (where each tier has a specific unit price). + UnitPrice *string +} + +// EAPricesheetDownloadProperties - The properties of the price sheet download. +type EAPricesheetDownloadProperties struct { + // The properties in downloaded file + DownloadFileProperties *EAPriceSheetProperties + + // READ-ONLY; The link (url) to download the pricesheet. + DownloadURL *string + + // READ-ONLY; Download link validity. + ValidTill *time.Time +} + // ErrorDetails - The details of the error. type ErrorDetails struct { // READ-ONLY; Error code. @@ -483,6 +900,12 @@ type Export struct { // the latest version or not. ETag *string + // The managed identity associated with Export + Identity *SystemAssignedServiceIdentity + + // The location of the Export's managed identity. Only required when utilizing managed identity. + Location *string + // The properties of the export. Properties *ExportProperties @@ -826,6 +1249,17 @@ type ForecastResult struct { Type *string } +// ForecastSpend - The forecasted cost which is being tracked for a budget. +// Supported for CategoryType(s): Cost. +type ForecastSpend struct { + // READ-ONLY; The forecasted cost for the total time period which is being tracked by the budget. This value is only provided + // if the budget contains a forecast alert type. + Amount *float32 + + // READ-ONLY; The unit of measure for the budget amount. + Unit *string +} + // ForecastTimePeriod - Has time period for pulling data for the forecast. type ForecastTimePeriod struct { // REQUIRED; The start date to pull data from. @@ -995,6 +1429,157 @@ type KpiProperties struct { Type *KpiType } +// MCAPriceSheetProperties - The properties of the price sheet. +type MCAPriceSheetProperties struct { + // READ-ONLY; The unit price at the time the customer signs on or the unit price at the time of service meter GA launch if + // it is after sign-on. + // This is applicable for Enterprise Agreement users + BasePrice *string + + // READ-ONLY; Unique identifier for the billing account. + BillingAccountID *string + + // READ-ONLY; Name of the billing profile that is set up to receive invoices. The prices in the price sheet are associated + // with this billing profile. + BillingAccountName *string + + // READ-ONLY; Currency in which charges are posted. + BillingCurrency *string + + // READ-ONLY; Unique identifier for the billing profile. + BillingProfileID *string + + // READ-ONLY; Name of the billing profile that is set up to receive invoices. The prices in the price sheet are associated + // with this billing profile. + BillingProfileName *string + + // READ-ONLY; Currency in which all the prices are reflected. + Currency *string + + // READ-ONLY; Effective end date of the Price Sheet billing period + EffectiveEndDate *time.Time + + // READ-ONLY; Effective start date of the Price Sheet billing period + EffectiveStartDate *time.Time + + // READ-ONLY; The current list price for a given product or service. This price is without any negotiations and is based on + // your Microsoft Agreement type. + // For PriceType Consumption, market price is reflected as the pay-as-you-go price. + // For PriceType Savings Plan, market price reflects the Savings plan benefit on top of pay-as-you-go price for the corresponding + // commitment term. + // For PriceType ReservedInstance, market price reflects the total price of the 1 or 3-year commitment. + MarketPrice *string + + // READ-ONLY; Name of the classification category for the meter. For example, Cloud services, Networking, etc. + MeterCategory *string + + // READ-ONLY; Name of the meter. The meter represents the deployable resource of an Azure service. + MeterName *string + + // READ-ONLY; Name of the Azure region where the meter for the service is available. + MeterRegion *string + + // READ-ONLY; Name of the meter subclassification category. + MeterSubCategory *string + + // READ-ONLY; Name of the meter type + MeterType *string + + // READ-ONLY; Price type for a product. For example, an Azure resource with a pay-as-you-go rate with priceType as Consumption. + // Other price types include ReservedInstance and Savings Plan. + PriceType *string + + // READ-ONLY; Name of the product accruing the charges. + Product *string + + // READ-ONLY; Unique identifier for the product whose meter is consumed. + ProductID *string + + // READ-ONLY; Unique identifier of the SKU + SKUID *string + + // READ-ONLY; Type of Azure service. For example, Compute, Analytics, and Security. + ServiceFamily *float32 + + // READ-ONLY; Term length for Azure Savings Plan or Reservation term – one year or three years (P1Y or P3Y) + Term *string + + // READ-ONLY; Defines the lower bound of the tier range for which prices are defined. For example, if the range is 0 to 100, + // tierMinimumUnits would be 0. + TierMinimumUnits *string + + // READ-ONLY; How usage is measured for the service + UnitOfMeasure *string + + // READ-ONLY; The per-unit price at the time of billing for a given product or service, inclusive of any negotiated discounts + // on top of the market price. + // For PriceType ReservedInstance, unit price reflects the total cost of the 1 or 3-year commitment including discounts. + // Note: The unit price isn't the same as the effective price in usage details downloads when services have differential prices + // across tiers. + // If services have multi-tiered pricing, the effective price is a blended rate across the tiers and doesn't show a tier-specific + // unit price. The blended price or effective price is the net price for the + // consumed quantity spanning across the multiple tiers (where each tier has a specific unit price). + UnitPrice *string +} + +// Notification - The notification associated with a budget. +// Supported for CategoryType(s): Cost, ReservationUtilization. +type Notification struct { + // REQUIRED; Email addresses to send the notification to when the threshold is breached. Must have at least one contact email + // or contact group specified at the Subscription or Resource Group scopes. All other + // scopes must have at least one contact email specified. + // Supported for CategoryType(s): Cost, ReservationUtilization. + ContactEmails []*string + + // REQUIRED; The notification is enabled or not. + // Supported for CategoryType(s): Cost, ReservationUtilization. + Enabled *bool + + // REQUIRED; The comparison operator. + // Supported for CategoryType(s): Cost, ReservationUtilization. + // Supported operators for CategoryType: Cost + // * GreaterThan + // + // + // * GreaterThanOrEqualTo + // + // Supported operators for CategoryType: ReservationUtilization + // + // + // * LessThan + Operator *BudgetNotificationOperatorType + + // REQUIRED; Threshold value associated with a notification. It is always percent with a maximum of 2 decimal places. + // Supported for CategoryType(s): Cost, ReservationUtilization. + // CategoryType: Cost - Must be between 0 and 1000. Notification is sent when the cost exceeded the threshold. + // CategoryType: ReservationUtilization - Must be between 0 and 100. Notification is sent when a reservation has a utilization + // percentage below the threshold. + Threshold *float32 + + // Subscription or Resource Group scopes only. Action groups to send the notification to when the threshold is exceeded. Must + // be provided as a fully qualified Azure resource id. + // Supported for CategoryType(s): Cost. + ContactGroups []*string + + // Subscription or Resource Group scopes only. Contact roles to send the notification to when the threshold is breached. + // Supported for CategoryType(s): Cost. + ContactRoles []*string + + // Frequency of a notification. Represents how long the notification will be silent after triggering an alert for a threshold + // breach. If not specified, the frequency will be set by default based on the + // timeGrain (Weekly when timeGrain: Last7Days, Monthly when timeGrain: Last30Days). + // Supported for CategoryType(s): ReservationUtilization. + Frequency *Frequency + + // Language in which the recipient will receive the notification, + // Supported for CategoryType(s): Cost, ReservationUtilization. + Locale *CultureCode + + // The type of threshold. + // Supported for CategoryType(s): Cost. + ThresholdType *ThresholdType +} + // NotificationProperties - The properties of the scheduled action notification. type NotificationProperties struct { // REQUIRED; Subject of the email. Length is limited to 70 characters. @@ -1074,6 +1659,15 @@ type OperationStatus struct { Status *OperationStatusType } +// OperationStatusAutoGenerated - The status of the long running operation. +type OperationStatusAutoGenerated struct { + // The properties of the resource generated. + Properties *EAPricesheetDownloadProperties + + // The status of the long running operation. + Status *OperationStatusType +} + // PivotProperties - Each pivot must contain a 'type' and 'name'. type PivotProperties struct { // Data field to show in view. @@ -1083,6 +1677,18 @@ type PivotProperties struct { Type *PivotType } +// PricesheetDownloadProperties - The URL to download the generated report. +type PricesheetDownloadProperties struct { + // The properties in downloaded file + DownloadFileProperties *MCAPriceSheetProperties + + // The URL to download the generated report. + DownloadURL *string + + // READ-ONLY; The time at which report URL becomes invalid/expires in UTC e.g. 2020-12-08T05:55:59.4394737Z. + ExpiryTime *time.Time +} + // QueryAggregation - The aggregation expression to be used in the query. type QueryAggregation struct { // REQUIRED; The name of the aggregation function to use. @@ -1431,7 +2037,7 @@ type SavingsPlanUtilizationSummaryProperties struct { ArmSKUName *string // READ-ONLY; This is the average hourly utilization for each date range that corresponds to given grain (Daily, Monthly). - // Suppose the API call is for usageDate > 2022-10-01 and usageDate < 2022-10-31 at a daily + // Suppose the API call is for usageDate > 2023-11-01 and usageDate < 2022-10-31 at a daily // granularity. There will be one record per benefit id for each day. For a single day, the avgUtilizationPercentage value // will be equal to the average of the set of values where the set contains 24 // utilization percentage entries one for each hour in a specific day. @@ -1444,7 +2050,7 @@ type SavingsPlanUtilizationSummaryProperties struct { BenefitOrderID *string // READ-ONLY; This is the maximum hourly utilization for each date range that corresponds to given grain (Daily, Monthly). - // Suppose the API call is for usageDate > 2022-10-01 and usageDate < 2022-10-31 at a daily + // Suppose the API call is for usageDate > 2023-11-01 and usageDate < 2022-10-31 at a daily // granularity. There will be one record per benefit id for each day. For a single day, the maxUtilizationPercentage value // will be equal to the largest in the set of values where the set contains 24 // utilization percentage entries one for each hour in a specific day. If on the day 2022-10-18, the largest utilization percentage @@ -1453,7 +2059,7 @@ type SavingsPlanUtilizationSummaryProperties struct { MaxUtilizationPercentage *float64 // READ-ONLY; This is the minimum hourly utilization for each date range that corresponds to given grain (Daily, Monthly). - // Suppose the API call is for usageDate > 2022-10-01 and usageDate < 2022-10-31 at a daily + // Suppose the API call is for usageDate > 2023-11-01 and usageDate < 2022-10-31 at a daily // granularity. There will be one record per benefit id for each day. For a single day, the minUtilizationPercentage value // will be equal to the smallest in the set of values where the set contains 24 // utilization percentage entries one for each hour in a specific day. If on the day 2022-10-18, the lowest utilization percentage @@ -1551,11 +2157,13 @@ type ScheduledActionProperties struct { // Email address of the point of contact that should get the unsubscribe requests and notification emails. NotificationEmail *string - // Cost Management scope like 'subscriptions/{subscriptionId}' for subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' - // for resourceGroup scope, - // 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' - // for Department - // scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount + // For private scheduled action(Create or Update), scope will be empty. + // For shared scheduled action(Create or Update By Scope), Cost Management scope can be 'subscriptions/{subscriptionId}' for + // subscription scope, + // 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + // for Billing Account scope, + // 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope, + // 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount // scope, // 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for BillingProfile // scope, @@ -1567,6 +2175,30 @@ type ScheduledActionProperties struct { Scope *string } +// Setting definition. +type Setting struct { + // REQUIRED; Specifies the kind of settings. + Kind *SettingsKind + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// GetSetting implements the SettingClassification interface for type Setting. +func (s *Setting) GetSetting() *Setting { return s } + +// SettingsListResult - Setting list result. It contains a list of settings. +type SettingsListResult struct { + // READ-ONLY; The list of settings. + Value []SettingClassification +} + // SharedScopeBenefitRecommendationProperties - The properties of the benefit recommendation when scope is 'Shared'. type SharedScopeBenefitRecommendationProperties struct { // REQUIRED; Benefit scope. For example, Single or Shared. @@ -1697,12 +2329,38 @@ func (s *SingleScopeBenefitRecommendationProperties) GetBenefitRecommendationPro } } +// SourceCostAllocationResource - Source resources for cost allocation +type SourceCostAllocationResource struct { + // REQUIRED; If resource type is dimension, this must be either ResourceGroupName or SubscriptionId. If resource type is tag, + // this must be a valid Azure tag + Name *string + + // REQUIRED; Type of resources contained in this cost allocation rule + ResourceType *CostAllocationResourceType + + // REQUIRED; Source Resources for cost allocation. This list cannot contain more than 25 values. + Values []*string +} + // Status - The status of the long running operation. type Status struct { // The status of the long running operation. Status *ReportOperationStatusType } +// SystemAssignedServiceIdentity - Managed service identity (either system assigned, or none) +type SystemAssignedServiceIdentity struct { + // REQUIRED; Type of managed service identity (either system assigned, or none). + Type *SystemAssignedServiceIdentityType + + // READ-ONLY; The service principal ID of the system assigned identity. This property will only be provided for a system assigned + // identity. + PrincipalID *string + + // READ-ONLY; The tenant ID of the system assigned identity. This property will only be provided for a system assigned identity. + TenantID *string +} + // SystemData - Metadata pertaining to creation and last modification of the resource. type SystemData struct { // The timestamp of resource creation (UTC). @@ -1724,6 +2382,61 @@ type SystemData struct { LastModifiedByType *CreatedByType } +// TagInheritanceProperties - The properties of the tag inheritance setting. +type TagInheritanceProperties struct { + // REQUIRED; This property defines the behavior when an inherited tag being applied matches a lower scope tag (Eg. Subscription + // tag matches the resource tag). If set to true - when tags match, the highest scope + // tags will be applied. Billing profile is the highest scope, followed by invoice sections, subscriptions and resource groups + // (allows overriding of lower scope tag values). If set to false - when tags + // match, the lowest scope tags will be applied. So, if a resource has the same tag as a subscription tag, the resource tag + // will be applied (does not allow overriding of lower scope tag values). + PreferContainerTags *bool +} + +// TagInheritanceSetting - Tag Inheritance Setting definition. +type TagInheritanceSetting struct { + // REQUIRED; Specifies the kind of settings. + Kind *SettingsKind + + // The properties of the tag inheritance setting. + Properties *TagInheritanceProperties + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// GetSetting implements the SettingClassification interface for type TagInheritanceSetting. +func (t *TagInheritanceSetting) GetSetting() *Setting { + return &Setting{ + ID: t.ID, + Kind: t.Kind, + Name: t.Name, + Type: t.Type, + } +} + +// TargetCostAllocationResource - Target resources for cost allocation. +type TargetCostAllocationResource struct { + // REQUIRED; If resource type is dimension, this must be either ResourceGroupName or SubscriptionId. If resource type is tag, + // this must be a valid Azure tag + Name *string + + // REQUIRED; Method of cost allocation for the rule + PolicyType *CostAllocationPolicyType + + // REQUIRED; Type of resources contained in this cost allocation rule + ResourceType *CostAllocationResourceType + + // REQUIRED; Target resources for cost allocation. This list cannot contain more than 25 values. + Values []*CostAllocationProportion +} + // View - States and configurations of Cost Analysis. type View struct { // eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating @@ -1760,6 +2473,9 @@ type ViewProperties struct { // Chart type of the main view in Cost Analysis. Required. Chart *ChartType + // Date range of the current view. + DateRange *string + // User input name of the view. Required. DisplayName *string @@ -1769,6 +2485,9 @@ type ViewProperties struct { // Metric to use when displaying costs. Metric *MetricType + // Date when the user last modified this view. + ModifiedOn *time.Time + // Configuration of 3 sub-views in the Cost Analysis UI. Pivots []*PivotProperties @@ -1795,10 +2514,4 @@ type ViewProperties struct { // READ-ONLY; Currency of the current view. Currency *string - - // READ-ONLY; Date range of the current view. - DateRange *string - - // READ-ONLY; Date when the user last modified this view. - ModifiedOn *time.Time } diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/models_serde.go b/sdk/resourcemanager/costmanagement/armcostmanagement/models_serde.go index d32fca77eaca..433c52ce937d 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/models_serde.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/models_serde.go @@ -392,6 +392,41 @@ func (a *AllSavingsList) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type AsyncOperationStatusProperties. +func (a AsyncOperationStatusProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "reportUrl", a.ReportURL) + populate(objectMap, "secondaryReportUrl", a.SecondaryReportURL) + populateDateTimeRFC3339(objectMap, "validUntil", a.ValidUntil) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AsyncOperationStatusProperties. +func (a *AsyncOperationStatusProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "reportUrl": + err = unpopulate(val, "ReportURL", &a.ReportURL) + delete(rawMsg, key) + case "secondaryReportUrl": + err = unpopulate(val, "SecondaryReportURL", &a.SecondaryReportURL) + delete(rawMsg, key) + case "validUntil": + err = unpopulateDateTimeRFC3339(val, "ValidUntil", &a.ValidUntil) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type BenefitRecommendationModel. func (b BenefitRecommendationModel) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -572,6 +607,96 @@ func (b *BenefitUtilizationSummariesListResult) UnmarshalJSON(data []byte) error return nil } +// MarshalJSON implements the json.Marshaller interface for type BenefitUtilizationSummariesOperationStatus. +func (b BenefitUtilizationSummariesOperationStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "input", b.Input) + populate(objectMap, "properties", b.Properties) + populate(objectMap, "status", b.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BenefitUtilizationSummariesOperationStatus. +func (b *BenefitUtilizationSummariesOperationStatus) 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", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "input": + err = unpopulate(val, "Input", &b.Input) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &b.Properties) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &b.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BenefitUtilizationSummariesRequest. +func (b BenefitUtilizationSummariesRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "benefitId", b.BenefitID) + populate(objectMap, "benefitOrderId", b.BenefitOrderID) + populate(objectMap, "billingAccountId", b.BillingAccountID) + populate(objectMap, "billingProfileId", b.BillingProfileID) + populateDateTimeRFC3339(objectMap, "endDate", b.EndDate) + populate(objectMap, "grain", b.Grain) + populate(objectMap, "kind", b.Kind) + populateDateTimeRFC3339(objectMap, "startDate", b.StartDate) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BenefitUtilizationSummariesRequest. +func (b *BenefitUtilizationSummariesRequest) 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", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "benefitId": + err = unpopulate(val, "BenefitID", &b.BenefitID) + delete(rawMsg, key) + case "benefitOrderId": + err = unpopulate(val, "BenefitOrderID", &b.BenefitOrderID) + delete(rawMsg, key) + case "billingAccountId": + err = unpopulate(val, "BillingAccountID", &b.BillingAccountID) + delete(rawMsg, key) + case "billingProfileId": + err = unpopulate(val, "BillingProfileID", &b.BillingProfileID) + delete(rawMsg, key) + case "endDate": + err = unpopulateDateTimeRFC3339(val, "EndDate", &b.EndDate) + delete(rawMsg, key) + case "grain": + err = unpopulate(val, "Grain", &b.Grain) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &b.Kind) + delete(rawMsg, key) + case "startDate": + err = unpopulateDateTimeRFC3339(val, "StartDate", &b.StartDate) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type BenefitUtilizationSummary. func (b BenefitUtilizationSummary) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -631,27 +756,537 @@ func (b *BlobInfo) UnmarshalJSON(data []byte) error { case "blobLink": err = unpopulate(val, "BlobLink", &b.BlobLink) delete(rawMsg, key) - case "byteCount": - err = unpopulate(val, "ByteCount", &b.ByteCount) + case "byteCount": + err = unpopulate(val, "ByteCount", &b.ByteCount) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Budget. +func (b Budget) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "eTag", b.ETag) + populate(objectMap, "id", b.ID) + populate(objectMap, "name", b.Name) + populate(objectMap, "properties", b.Properties) + populate(objectMap, "type", b.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Budget. +func (b *Budget) 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", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "eTag": + err = unpopulate(val, "ETag", &b.ETag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &b.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &b.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &b.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &b.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BudgetComparisonExpression. +func (b BudgetComparisonExpression) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", b.Name) + populate(objectMap, "operator", b.Operator) + populate(objectMap, "values", b.Values) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BudgetComparisonExpression. +func (b *BudgetComparisonExpression) 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", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &b.Name) + delete(rawMsg, key) + case "operator": + err = unpopulate(val, "Operator", &b.Operator) + delete(rawMsg, key) + case "values": + err = unpopulate(val, "Values", &b.Values) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BudgetFilter. +func (b BudgetFilter) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "and", b.And) + populate(objectMap, "dimensions", b.Dimensions) + populate(objectMap, "tags", b.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BudgetFilter. +func (b *BudgetFilter) 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", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "and": + err = unpopulate(val, "And", &b.And) + delete(rawMsg, key) + case "dimensions": + err = unpopulate(val, "Dimensions", &b.Dimensions) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &b.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BudgetFilterProperties. +func (b BudgetFilterProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "dimensions", b.Dimensions) + populate(objectMap, "tags", b.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BudgetFilterProperties. +func (b *BudgetFilterProperties) 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", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "dimensions": + err = unpopulate(val, "Dimensions", &b.Dimensions) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &b.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BudgetProperties. +func (b BudgetProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "amount", b.Amount) + populate(objectMap, "category", b.Category) + populate(objectMap, "currentSpend", b.CurrentSpend) + populate(objectMap, "filter", b.Filter) + populate(objectMap, "forecastSpend", b.ForecastSpend) + populate(objectMap, "notifications", b.Notifications) + populate(objectMap, "timeGrain", b.TimeGrain) + populate(objectMap, "timePeriod", b.TimePeriod) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BudgetProperties. +func (b *BudgetProperties) 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", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "amount": + err = unpopulate(val, "Amount", &b.Amount) + delete(rawMsg, key) + case "category": + err = unpopulate(val, "Category", &b.Category) + delete(rawMsg, key) + case "currentSpend": + err = unpopulate(val, "CurrentSpend", &b.CurrentSpend) + delete(rawMsg, key) + case "filter": + err = unpopulate(val, "Filter", &b.Filter) + delete(rawMsg, key) + case "forecastSpend": + err = unpopulate(val, "ForecastSpend", &b.ForecastSpend) + delete(rawMsg, key) + case "notifications": + err = unpopulate(val, "Notifications", &b.Notifications) + delete(rawMsg, key) + case "timeGrain": + err = unpopulate(val, "TimeGrain", &b.TimeGrain) + delete(rawMsg, key) + case "timePeriod": + err = unpopulate(val, "TimePeriod", &b.TimePeriod) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BudgetTimePeriod. +func (b BudgetTimePeriod) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "endDate", b.EndDate) + populateDateTimeRFC3339(objectMap, "startDate", b.StartDate) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BudgetTimePeriod. +func (b *BudgetTimePeriod) 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", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "endDate": + err = unpopulateDateTimeRFC3339(val, "EndDate", &b.EndDate) + delete(rawMsg, key) + case "startDate": + err = unpopulateDateTimeRFC3339(val, "StartDate", &b.StartDate) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BudgetsListResult. +func (b BudgetsListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", b.NextLink) + populate(objectMap, "value", b.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BudgetsListResult. +func (b *BudgetsListResult) 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", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &b.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &b.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CheckNameAvailabilityRequest. +func (c CheckNameAvailabilityRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", c.Name) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CheckNameAvailabilityRequest. +func (c *CheckNameAvailabilityRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CheckNameAvailabilityResponse. +func (c CheckNameAvailabilityResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "message", c.Message) + populate(objectMap, "nameAvailable", c.NameAvailable) + populate(objectMap, "reason", c.Reason) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CheckNameAvailabilityResponse. +func (c *CheckNameAvailabilityResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "message": + err = unpopulate(val, "Message", &c.Message) + delete(rawMsg, key) + case "nameAvailable": + err = unpopulate(val, "NameAvailable", &c.NameAvailable) + delete(rawMsg, key) + case "reason": + err = unpopulate(val, "Reason", &c.Reason) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CommonExportProperties. +func (c CommonExportProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "definition", c.Definition) + populate(objectMap, "deliveryInfo", c.DeliveryInfo) + populate(objectMap, "format", c.Format) + populateDateTimeRFC3339(objectMap, "nextRunTimeEstimate", c.NextRunTimeEstimate) + populate(objectMap, "partitionData", c.PartitionData) + populate(objectMap, "runHistory", c.RunHistory) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CommonExportProperties. +func (c *CommonExportProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "definition": + err = unpopulate(val, "Definition", &c.Definition) + delete(rawMsg, key) + case "deliveryInfo": + err = unpopulate(val, "DeliveryInfo", &c.DeliveryInfo) + delete(rawMsg, key) + case "format": + err = unpopulate(val, "Format", &c.Format) + delete(rawMsg, key) + case "nextRunTimeEstimate": + err = unpopulateDateTimeRFC3339(val, "NextRunTimeEstimate", &c.NextRunTimeEstimate) + delete(rawMsg, key) + case "partitionData": + err = unpopulate(val, "PartitionData", &c.PartitionData) + delete(rawMsg, key) + case "runHistory": + err = unpopulate(val, "RunHistory", &c.RunHistory) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CostAllocationProportion. +func (c CostAllocationProportion) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", c.Name) + populate(objectMap, "percentage", c.Percentage) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CostAllocationProportion. +func (c *CostAllocationProportion) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "percentage": + err = unpopulate(val, "Percentage", &c.Percentage) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CostAllocationRuleCheckNameAvailabilityRequest. +func (c CostAllocationRuleCheckNameAvailabilityRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", c.Name) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CostAllocationRuleCheckNameAvailabilityRequest. +func (c *CostAllocationRuleCheckNameAvailabilityRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CostAllocationRuleCheckNameAvailabilityResponse. +func (c CostAllocationRuleCheckNameAvailabilityResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "message", c.Message) + populate(objectMap, "nameAvailable", c.NameAvailable) + populate(objectMap, "reason", c.Reason) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CostAllocationRuleCheckNameAvailabilityResponse. +func (c *CostAllocationRuleCheckNameAvailabilityResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "message": + err = unpopulate(val, "Message", &c.Message) + delete(rawMsg, key) + case "nameAvailable": + err = unpopulate(val, "NameAvailable", &c.NameAvailable) + delete(rawMsg, key) + case "reason": + err = unpopulate(val, "Reason", &c.Reason) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CostAllocationRuleDefinition. +func (c CostAllocationRuleDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", c.ID) + populate(objectMap, "name", c.Name) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CostAllocationRuleDefinition. +func (c *CostAllocationRuleDefinition) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &c.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &c.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", b, err) + return fmt.Errorf("unmarshalling type %T: %v", c, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type CheckNameAvailabilityRequest. -func (c CheckNameAvailabilityRequest) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type CostAllocationRuleDetails. +func (c CostAllocationRuleDetails) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "name", c.Name) - populate(objectMap, "type", c.Type) + populate(objectMap, "sourceResources", c.SourceResources) + populate(objectMap, "targetResources", c.TargetResources) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type CheckNameAvailabilityRequest. -func (c *CheckNameAvailabilityRequest) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type CostAllocationRuleDetails. +func (c *CostAllocationRuleDetails) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", c, err) @@ -659,11 +1294,11 @@ func (c *CheckNameAvailabilityRequest) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "name": - err = unpopulate(val, "Name", &c.Name) + case "sourceResources": + err = unpopulate(val, "SourceResources", &c.SourceResources) delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &c.Type) + case "targetResources": + err = unpopulate(val, "TargetResources", &c.TargetResources) delete(rawMsg, key) } if err != nil { @@ -673,17 +1308,16 @@ func (c *CheckNameAvailabilityRequest) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type CheckNameAvailabilityResponse. -func (c CheckNameAvailabilityResponse) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type CostAllocationRuleList. +func (c CostAllocationRuleList) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "message", c.Message) - populate(objectMap, "nameAvailable", c.NameAvailable) - populate(objectMap, "reason", c.Reason) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type CheckNameAvailabilityResponse. -func (c *CheckNameAvailabilityResponse) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type CostAllocationRuleList. +func (c *CostAllocationRuleList) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", c, err) @@ -691,14 +1325,11 @@ func (c *CheckNameAvailabilityResponse) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "message": - err = unpopulate(val, "Message", &c.Message) - delete(rawMsg, key) - case "nameAvailable": - err = unpopulate(val, "NameAvailable", &c.NameAvailable) + case "nextLink": + err = unpopulate(val, "NextLink", &c.NextLink) delete(rawMsg, key) - case "reason": - err = unpopulate(val, "Reason", &c.Reason) + case "value": + err = unpopulate(val, "Value", &c.Value) delete(rawMsg, key) } if err != nil { @@ -708,20 +1339,19 @@ func (c *CheckNameAvailabilityResponse) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type CommonExportProperties. -func (c CommonExportProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type CostAllocationRuleProperties. +func (c CostAllocationRuleProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "definition", c.Definition) - populate(objectMap, "deliveryInfo", c.DeliveryInfo) - populate(objectMap, "format", c.Format) - populateDateTimeRFC3339(objectMap, "nextRunTimeEstimate", c.NextRunTimeEstimate) - populate(objectMap, "partitionData", c.PartitionData) - populate(objectMap, "runHistory", c.RunHistory) + populateDateTimeRFC3339(objectMap, "createdDate", c.CreatedDate) + populate(objectMap, "description", c.Description) + populate(objectMap, "details", c.Details) + populate(objectMap, "status", c.Status) + populateDateTimeRFC3339(objectMap, "updatedDate", c.UpdatedDate) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type CommonExportProperties. -func (c *CommonExportProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type CostAllocationRuleProperties. +func (c *CostAllocationRuleProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", c, err) @@ -729,23 +1359,20 @@ func (c *CommonExportProperties) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "definition": - err = unpopulate(val, "Definition", &c.Definition) - delete(rawMsg, key) - case "deliveryInfo": - err = unpopulate(val, "DeliveryInfo", &c.DeliveryInfo) + case "createdDate": + err = unpopulateDateTimeRFC3339(val, "CreatedDate", &c.CreatedDate) delete(rawMsg, key) - case "format": - err = unpopulate(val, "Format", &c.Format) + case "description": + err = unpopulate(val, "Description", &c.Description) delete(rawMsg, key) - case "nextRunTimeEstimate": - err = unpopulateDateTimeRFC3339(val, "NextRunTimeEstimate", &c.NextRunTimeEstimate) + case "details": + err = unpopulate(val, "Details", &c.Details) delete(rawMsg, key) - case "partitionData": - err = unpopulate(val, "PartitionData", &c.PartitionData) + case "status": + err = unpopulate(val, "Status", &c.Status) delete(rawMsg, key) - case "runHistory": - err = unpopulate(val, "RunHistory", &c.RunHistory) + case "updatedDate": + err = unpopulateDateTimeRFC3339(val, "UpdatedDate", &c.UpdatedDate) delete(rawMsg, key) } if err != nil { @@ -837,6 +1464,37 @@ func (c *CostDetailsTimePeriod) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type CurrentSpend. +func (c CurrentSpend) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "amount", c.Amount) + populate(objectMap, "unit", c.Unit) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CurrentSpend. +func (c *CurrentSpend) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "amount": + err = unpopulate(val, "Amount", &c.Amount) + delete(rawMsg, key) + case "unit": + err = unpopulate(val, "Unit", &c.Unit) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type Dimension. func (d Dimension) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1040,6 +1698,152 @@ func (d *DownloadURL) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type EAPriceSheetProperties. +func (e EAPriceSheetProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "basePrice", e.BasePrice) + populate(objectMap, "currencyCode", e.CurrencyCode) + populateDateTimeRFC3339(objectMap, "effectiveEndDate", e.EffectiveEndDate) + populateDateTimeRFC3339(objectMap, "effectiveStartDate", e.EffectiveStartDate) + populate(objectMap, "enrollmentNumber", e.EnrollmentNumber) + populate(objectMap, "includedQuantity", e.IncludedQuantity) + populate(objectMap, "marketPrice", e.MarketPrice) + populate(objectMap, "meterCategory", e.MeterCategory) + populate(objectMap, "meterId", e.MeterID) + populate(objectMap, "meterName", e.MeterName) + populate(objectMap, "meterRegion", e.MeterRegion) + populate(objectMap, "meterSubCategory", e.MeterSubCategory) + populate(objectMap, "meterType", e.MeterType) + populate(objectMap, "partNumber", e.PartNumber) + populate(objectMap, "priceType", e.PriceType) + populate(objectMap, "product", e.Product) + populate(objectMap, "productId", e.ProductID) + populate(objectMap, "skuId", e.SKUID) + populate(objectMap, "serviceFamily", e.ServiceFamily) + populate(objectMap, "term", e.Term) + populate(objectMap, "unitOfMeasure", e.UnitOfMeasure) + populate(objectMap, "unitPrice", e.UnitPrice) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EAPriceSheetProperties. +func (e *EAPriceSheetProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "basePrice": + err = unpopulate(val, "BasePrice", &e.BasePrice) + delete(rawMsg, key) + case "currencyCode": + err = unpopulate(val, "CurrencyCode", &e.CurrencyCode) + delete(rawMsg, key) + case "effectiveEndDate": + err = unpopulateDateTimeRFC3339(val, "EffectiveEndDate", &e.EffectiveEndDate) + delete(rawMsg, key) + case "effectiveStartDate": + err = unpopulateDateTimeRFC3339(val, "EffectiveStartDate", &e.EffectiveStartDate) + delete(rawMsg, key) + case "enrollmentNumber": + err = unpopulate(val, "EnrollmentNumber", &e.EnrollmentNumber) + delete(rawMsg, key) + case "includedQuantity": + err = unpopulate(val, "IncludedQuantity", &e.IncludedQuantity) + delete(rawMsg, key) + case "marketPrice": + err = unpopulate(val, "MarketPrice", &e.MarketPrice) + delete(rawMsg, key) + case "meterCategory": + err = unpopulate(val, "MeterCategory", &e.MeterCategory) + delete(rawMsg, key) + case "meterId": + err = unpopulate(val, "MeterID", &e.MeterID) + delete(rawMsg, key) + case "meterName": + err = unpopulate(val, "MeterName", &e.MeterName) + delete(rawMsg, key) + case "meterRegion": + err = unpopulate(val, "MeterRegion", &e.MeterRegion) + delete(rawMsg, key) + case "meterSubCategory": + err = unpopulate(val, "MeterSubCategory", &e.MeterSubCategory) + delete(rawMsg, key) + case "meterType": + err = unpopulate(val, "MeterType", &e.MeterType) + delete(rawMsg, key) + case "partNumber": + err = unpopulate(val, "PartNumber", &e.PartNumber) + delete(rawMsg, key) + case "priceType": + err = unpopulate(val, "PriceType", &e.PriceType) + delete(rawMsg, key) + case "product": + err = unpopulate(val, "Product", &e.Product) + delete(rawMsg, key) + case "productId": + err = unpopulate(val, "ProductID", &e.ProductID) + delete(rawMsg, key) + case "skuId": + err = unpopulate(val, "SKUID", &e.SKUID) + delete(rawMsg, key) + case "serviceFamily": + err = unpopulate(val, "ServiceFamily", &e.ServiceFamily) + delete(rawMsg, key) + case "term": + err = unpopulate(val, "Term", &e.Term) + delete(rawMsg, key) + case "unitOfMeasure": + err = unpopulate(val, "UnitOfMeasure", &e.UnitOfMeasure) + delete(rawMsg, key) + case "unitPrice": + err = unpopulate(val, "UnitPrice", &e.UnitPrice) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type EAPricesheetDownloadProperties. +func (e EAPricesheetDownloadProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "downloadFileProperties", e.DownloadFileProperties) + populate(objectMap, "downloadUrl", e.DownloadURL) + populateDateTimeRFC3339(objectMap, "validTill", e.ValidTill) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EAPricesheetDownloadProperties. +func (e *EAPricesheetDownloadProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "downloadFileProperties": + err = unpopulate(val, "DownloadFileProperties", &e.DownloadFileProperties) + delete(rawMsg, key) + case "downloadUrl": + err = unpopulate(val, "DownloadURL", &e.DownloadURL) + delete(rawMsg, key) + case "validTill": + err = unpopulateDateTimeRFC3339(val, "ValidTill", &e.ValidTill) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type ErrorDetails. func (e ErrorDetails) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1076,6 +1880,8 @@ func (e Export) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "eTag", e.ETag) populate(objectMap, "id", e.ID) + populate(objectMap, "identity", e.Identity) + populate(objectMap, "location", e.Location) populate(objectMap, "name", e.Name) populate(objectMap, "properties", e.Properties) populate(objectMap, "type", e.Type) @@ -1097,6 +1903,12 @@ func (e *Export) UnmarshalJSON(data []byte) error { case "id": err = unpopulate(val, "ID", &e.ID) delete(rawMsg, key) + case "identity": + err = unpopulate(val, "Identity", &e.Identity) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &e.Location) + delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &e.Name) delete(rawMsg, key) @@ -1951,6 +2763,37 @@ func (f *ForecastResult) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type ForecastSpend. +func (f ForecastSpend) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "amount", f.Amount) + populate(objectMap, "unit", f.Unit) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ForecastSpend. +func (f *ForecastSpend) 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", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "amount": + err = unpopulate(val, "Amount", &f.Amount) + delete(rawMsg, key) + case "unit": + err = unpopulate(val, "Unit", &f.Unit) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type ForecastTimePeriod. func (f ForecastTimePeriod) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -2273,42 +3116,220 @@ func (i *IncludedQuantityUtilizationSummaryProperties) UnmarshalJSON(data []byte delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", i, err) + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type KpiProperties. +func (k KpiProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "enabled", k.Enabled) + populate(objectMap, "id", k.ID) + populate(objectMap, "type", k.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type KpiProperties. +func (k *KpiProperties) 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", k, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "enabled": + err = unpopulate(val, "Enabled", &k.Enabled) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &k.ID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &k.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type MCAPriceSheetProperties. +func (m MCAPriceSheetProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "basePrice", m.BasePrice) + populate(objectMap, "billingAccountID", m.BillingAccountID) + populate(objectMap, "billingAccountName", m.BillingAccountName) + populate(objectMap, "billingCurrency", m.BillingCurrency) + populate(objectMap, "billingProfileId", m.BillingProfileID) + populate(objectMap, "billingProfileName", m.BillingProfileName) + populate(objectMap, "currency", m.Currency) + populateDateTimeRFC3339(objectMap, "effectiveEndDate", m.EffectiveEndDate) + populateDateTimeRFC3339(objectMap, "effectiveStartDate", m.EffectiveStartDate) + populate(objectMap, "marketPrice", m.MarketPrice) + populate(objectMap, "meterCategory", m.MeterCategory) + populate(objectMap, "meterName", m.MeterName) + populate(objectMap, "meterRegion", m.MeterRegion) + populate(objectMap, "meterSubCategory", m.MeterSubCategory) + populate(objectMap, "meterType", m.MeterType) + populate(objectMap, "priceType", m.PriceType) + populate(objectMap, "product", m.Product) + populate(objectMap, "productId", m.ProductID) + populate(objectMap, "skuId", m.SKUID) + populate(objectMap, "serviceFamily", m.ServiceFamily) + populate(objectMap, "term", m.Term) + populate(objectMap, "tierMinimumUnits", m.TierMinimumUnits) + populate(objectMap, "unitOfMeasure", m.UnitOfMeasure) + populate(objectMap, "unitPrice", m.UnitPrice) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MCAPriceSheetProperties. +func (m *MCAPriceSheetProperties) 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 "basePrice": + err = unpopulate(val, "BasePrice", &m.BasePrice) + delete(rawMsg, key) + case "billingAccountID": + err = unpopulate(val, "BillingAccountID", &m.BillingAccountID) + delete(rawMsg, key) + case "billingAccountName": + err = unpopulate(val, "BillingAccountName", &m.BillingAccountName) + delete(rawMsg, key) + case "billingCurrency": + err = unpopulate(val, "BillingCurrency", &m.BillingCurrency) + delete(rawMsg, key) + case "billingProfileId": + err = unpopulate(val, "BillingProfileID", &m.BillingProfileID) + delete(rawMsg, key) + case "billingProfileName": + err = unpopulate(val, "BillingProfileName", &m.BillingProfileName) + delete(rawMsg, key) + case "currency": + err = unpopulate(val, "Currency", &m.Currency) + delete(rawMsg, key) + case "effectiveEndDate": + err = unpopulateDateTimeRFC3339(val, "EffectiveEndDate", &m.EffectiveEndDate) + delete(rawMsg, key) + case "effectiveStartDate": + err = unpopulateDateTimeRFC3339(val, "EffectiveStartDate", &m.EffectiveStartDate) + delete(rawMsg, key) + case "marketPrice": + err = unpopulate(val, "MarketPrice", &m.MarketPrice) + delete(rawMsg, key) + case "meterCategory": + err = unpopulate(val, "MeterCategory", &m.MeterCategory) + delete(rawMsg, key) + case "meterName": + err = unpopulate(val, "MeterName", &m.MeterName) + delete(rawMsg, key) + case "meterRegion": + err = unpopulate(val, "MeterRegion", &m.MeterRegion) + delete(rawMsg, key) + case "meterSubCategory": + err = unpopulate(val, "MeterSubCategory", &m.MeterSubCategory) + delete(rawMsg, key) + case "meterType": + err = unpopulate(val, "MeterType", &m.MeterType) + delete(rawMsg, key) + case "priceType": + err = unpopulate(val, "PriceType", &m.PriceType) + delete(rawMsg, key) + case "product": + err = unpopulate(val, "Product", &m.Product) + delete(rawMsg, key) + case "productId": + err = unpopulate(val, "ProductID", &m.ProductID) + delete(rawMsg, key) + case "skuId": + err = unpopulate(val, "SKUID", &m.SKUID) + delete(rawMsg, key) + case "serviceFamily": + err = unpopulate(val, "ServiceFamily", &m.ServiceFamily) + delete(rawMsg, key) + case "term": + err = unpopulate(val, "Term", &m.Term) + delete(rawMsg, key) + case "tierMinimumUnits": + err = unpopulate(val, "TierMinimumUnits", &m.TierMinimumUnits) + delete(rawMsg, key) + case "unitOfMeasure": + err = unpopulate(val, "UnitOfMeasure", &m.UnitOfMeasure) + delete(rawMsg, key) + case "unitPrice": + err = unpopulate(val, "UnitPrice", &m.UnitPrice) + 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 KpiProperties. -func (k KpiProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type Notification. +func (n Notification) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "enabled", k.Enabled) - populate(objectMap, "id", k.ID) - populate(objectMap, "type", k.Type) + populate(objectMap, "contactEmails", n.ContactEmails) + populate(objectMap, "contactGroups", n.ContactGroups) + populate(objectMap, "contactRoles", n.ContactRoles) + populate(objectMap, "enabled", n.Enabled) + populate(objectMap, "frequency", n.Frequency) + populate(objectMap, "locale", n.Locale) + populate(objectMap, "operator", n.Operator) + populate(objectMap, "threshold", n.Threshold) + populate(objectMap, "thresholdType", n.ThresholdType) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type KpiProperties. -func (k *KpiProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type Notification. +func (n *Notification) 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", k, err) + return fmt.Errorf("unmarshalling type %T: %v", n, err) } for key, val := range rawMsg { var err error switch key { + case "contactEmails": + err = unpopulate(val, "ContactEmails", &n.ContactEmails) + delete(rawMsg, key) + case "contactGroups": + err = unpopulate(val, "ContactGroups", &n.ContactGroups) + delete(rawMsg, key) + case "contactRoles": + err = unpopulate(val, "ContactRoles", &n.ContactRoles) + delete(rawMsg, key) case "enabled": - err = unpopulate(val, "Enabled", &k.Enabled) + err = unpopulate(val, "Enabled", &n.Enabled) delete(rawMsg, key) - case "id": - err = unpopulate(val, "ID", &k.ID) + case "frequency": + err = unpopulate(val, "Frequency", &n.Frequency) delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &k.Type) + case "locale": + err = unpopulate(val, "Locale", &n.Locale) + delete(rawMsg, key) + case "operator": + err = unpopulate(val, "Operator", &n.Operator) + delete(rawMsg, key) + case "threshold": + err = unpopulate(val, "Threshold", &n.Threshold) + delete(rawMsg, key) + case "thresholdType": + err = unpopulate(val, "ThresholdType", &n.ThresholdType) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", k, err) + return fmt.Errorf("unmarshalling type %T: %v", n, err) } } return nil @@ -2505,6 +3526,37 @@ func (o *OperationStatus) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type OperationStatusAutoGenerated. +func (o OperationStatusAutoGenerated) 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 OperationStatusAutoGenerated. +func (o *OperationStatusAutoGenerated) 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 PivotProperties. func (p PivotProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -2536,6 +3588,41 @@ func (p *PivotProperties) 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, "downloadFileProperties", p.DownloadFileProperties) + populate(objectMap, "downloadUrl", p.DownloadURL) + populateDateTimeRFC3339(objectMap, "expiryTime", p.ExpiryTime) + 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 "downloadFileProperties": + err = unpopulate(val, "DownloadFileProperties", &p.DownloadFileProperties) + delete(rawMsg, key) + case "downloadUrl": + err = unpopulate(val, "DownloadURL", &p.DownloadURL) + delete(rawMsg, key) + case "expiryTime": + err = unpopulateDateTimeRFC3339(val, "ExpiryTime", &p.ExpiryTime) + 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 QueryAggregation. func (q QueryAggregation) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -3678,6 +4765,72 @@ func (s *ScheduledActionProperties) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type Setting. +func (s Setting) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", s.ID) + objectMap["kind"] = s.Kind + populate(objectMap, "name", s.Name) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Setting. +func (s *Setting) 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 "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &s.Kind) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &s.Type) + 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 SettingsListResult. +func (s SettingsListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SettingsListResult. +func (s *SettingsListResult) 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 "value": + s.Value, err = unmarshalSettingClassificationArray(val) + 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 SharedScopeBenefitRecommendationProperties. func (s SharedScopeBenefitRecommendationProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -3836,6 +4989,41 @@ func (s *SingleScopeBenefitRecommendationProperties) UnmarshalJSON(data []byte) return nil } +// MarshalJSON implements the json.Marshaller interface for type SourceCostAllocationResource. +func (s SourceCostAllocationResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", s.Name) + populate(objectMap, "resourceType", s.ResourceType) + populate(objectMap, "values", s.Values) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SourceCostAllocationResource. +func (s *SourceCostAllocationResource) 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 "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "resourceType": + err = unpopulate(val, "ResourceType", &s.ResourceType) + delete(rawMsg, key) + case "values": + err = unpopulate(val, "Values", &s.Values) + 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 Status. func (s Status) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -3863,6 +5051,41 @@ func (s *Status) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type SystemAssignedServiceIdentity. +func (s SystemAssignedServiceIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "principalId", s.PrincipalID) + populate(objectMap, "tenantId", s.TenantID) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemAssignedServiceIdentity. +func (s *SystemAssignedServiceIdentity) 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 "principalId": + err = unpopulate(val, "PrincipalID", &s.PrincipalID) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &s.TenantID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &s.Type) + 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 SystemData. func (s SystemData) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -3910,6 +5133,115 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type TagInheritanceProperties. +func (t TagInheritanceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "preferContainerTags", t.PreferContainerTags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TagInheritanceProperties. +func (t *TagInheritanceProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "preferContainerTags": + err = unpopulate(val, "PreferContainerTags", &t.PreferContainerTags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TagInheritanceSetting. +func (t TagInheritanceSetting) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", t.ID) + objectMap["kind"] = SettingsKindTaginheritance + populate(objectMap, "name", t.Name) + populate(objectMap, "properties", t.Properties) + populate(objectMap, "type", t.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TagInheritanceSetting. +func (t *TagInheritanceSetting) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &t.ID) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &t.Kind) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &t.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &t.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &t.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TargetCostAllocationResource. +func (t TargetCostAllocationResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", t.Name) + populate(objectMap, "policyType", t.PolicyType) + populate(objectMap, "resourceType", t.ResourceType) + populate(objectMap, "values", t.Values) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TargetCostAllocationResource. +func (t *TargetCostAllocationResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &t.Name) + delete(rawMsg, key) + case "policyType": + err = unpopulate(val, "PolicyType", &t.PolicyType) + delete(rawMsg, key) + case "resourceType": + err = unpopulate(val, "ResourceType", &t.ResourceType) + delete(rawMsg, key) + case "values": + err = unpopulate(val, "Values", &t.Values) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type View. func (v View) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -4076,7 +5408,7 @@ func populateAny(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/costmanagement/armcostmanagement/operations_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/operations_client.go index aa78c15cd30e..c4ee357859ff 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/operations_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/operations_client.go @@ -39,7 +39,7 @@ func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientO // NewListPager - Lists all of the available cost management REST API operations. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-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]{ @@ -72,7 +72,7 @@ func (client *OperationsClient) listCreateRequest(ctx context.Context, options * return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/operations_client_example_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/operations_client_example_test.go deleted file mode 100644 index 3d8646009998..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/operations_client_example_test.go +++ /dev/null @@ -1,146 +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 armcostmanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-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 := armcostmanagement.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 = armcostmanagement.OperationListResult{ - // Value: []*armcostmanagement.OperationForCostManagement{ - // { - // Name: to.Ptr("Microsoft.CostManagement/budgets/read"), - // Display: &armcostmanagement.OperationDisplay{ - // Description: to.Ptr("List the budgets by a subscription or a management group."), - // Operation: to.Ptr("List budgets"), - // Provider: to.Ptr("Microsoft.CostManagement"), - // Resource: to.Ptr("Budgets"), - // }, - // ID: to.Ptr("Microsoft.CostManagement/budgets/read"), - // }, - // { - // Name: to.Ptr("Microsoft.CostManagement/query/action"), - // Display: &armcostmanagement.OperationDisplay{ - // Description: to.Ptr("Query usage data by a scope."), - // Operation: to.Ptr("Query usage data"), - // Provider: to.Ptr("Microsoft.CostManagement"), - // Resource: to.Ptr("Query"), - // }, - // ID: to.Ptr("Microsoft.CostManagement/query/action"), - // }, - // { - // Name: to.Ptr("Microsoft.CostManagement/exports/read"), - // Display: &armcostmanagement.OperationDisplay{ - // Description: to.Ptr("List the exports by scope."), - // Operation: to.Ptr("List exports"), - // Provider: to.Ptr("Microsoft.CostManagement"), - // Resource: to.Ptr("Exports"), - // }, - // ID: to.Ptr("Microsoft.CostManagement/exports/read"), - // }, - // { - // Name: to.Ptr("Microsoft.CostManagement/exports/write"), - // Display: &armcostmanagement.OperationDisplay{ - // Description: to.Ptr("Create or update the specified export."), - // Operation: to.Ptr("Create and update export"), - // Provider: to.Ptr("Microsoft.CostManagement"), - // Resource: to.Ptr("Exports"), - // }, - // ID: to.Ptr("Microsoft.CostManagement/exports/write"), - // }, - // { - // Name: to.Ptr("Microsoft.CostManagement/exports/action"), - // Display: &armcostmanagement.OperationDisplay{ - // Description: to.Ptr("Run the specified export."), - // Operation: to.Ptr("Run export"), - // Provider: to.Ptr("Microsoft.CostManagement"), - // Resource: to.Ptr("Exports"), - // }, - // ID: to.Ptr("Microsoft.CostManagement/exports/action"), - // }, - // { - // Name: to.Ptr("Microsoft.CostManagement/exports/run/action"), - // Display: &armcostmanagement.OperationDisplay{ - // Description: to.Ptr("Run exports."), - // Operation: to.Ptr("Run exports"), - // Provider: to.Ptr("Microsoft.CostManagement"), - // Resource: to.Ptr("exports/run"), - // }, - // ID: to.Ptr("Microsoft.CostManagement/exports/run/action"), - // }, - // { - // Name: to.Ptr("Microsoft.CostManagement/alerts/read"), - // Display: &armcostmanagement.OperationDisplay{ - // Description: to.Ptr("List alerts."), - // Operation: to.Ptr("List Alerts"), - // Provider: to.Ptr("Microsoft.CostManagement"), - // Resource: to.Ptr("Alerts"), - // }, - // ID: to.Ptr("Microsoft.CostManagement/alerts/read"), - // }, - // { - // Name: to.Ptr("Microsoft.CostManagement/operations/read"), - // Display: &armcostmanagement.OperationDisplay{ - // Description: to.Ptr("List all supported operations by Microsoft.CostManagement resource provider."), - // Operation: to.Ptr("List supported operations"), - // Provider: to.Ptr("Microsoft.CostManagement"), - // Resource: to.Ptr("Operations"), - // }, - // ID: to.Ptr("Microsoft.CostManagement/operations/read"), - // }, - // { - // Name: to.Ptr("Microsoft.CostManagement/views/action"), - // Display: &armcostmanagement.OperationDisplay{ - // Description: to.Ptr("Create view."), - // Operation: to.Ptr("Create views"), - // Provider: to.Ptr("Microsoft.CostManagement"), - // Resource: to.Ptr("Views"), - // }, - // ID: to.Ptr("Microsoft.CostManagement/views/action"), - // }, - // { - // Name: to.Ptr("Microsoft.CostManagement/views/write"), - // Display: &armcostmanagement.OperationDisplay{ - // Description: to.Ptr("Update view."), - // Operation: to.Ptr("Update views"), - // Provider: to.Ptr("Microsoft.CostManagement"), - // Resource: to.Ptr("Views"), - // }, - // ID: to.Ptr("Microsoft.CostManagement/views/write"), - // }}, - // } - } -} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/options.go b/sdk/resourcemanager/costmanagement/armcostmanagement/options.go index e0fee6a2634a..ec3217390745 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/options.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/options.go @@ -85,6 +85,54 @@ type BenefitUtilizationSummariesClientListBySavingsPlanOrderOptions struct { GrainParameter *GrainParameter } +// BudgetsClientCreateOrUpdateOptions contains the optional parameters for the BudgetsClient.CreateOrUpdate method. +type BudgetsClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// BudgetsClientDeleteOptions contains the optional parameters for the BudgetsClient.Delete method. +type BudgetsClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// BudgetsClientGetOptions contains the optional parameters for the BudgetsClient.Get method. +type BudgetsClientGetOptions struct { + // placeholder for future optional parameters +} + +// BudgetsClientListOptions contains the optional parameters for the BudgetsClient.NewListPager method. +type BudgetsClientListOptions struct { + // OData filter option. May be used to filter budgets by properties/category. The filter supports 'eq' only. + Filter *string +} + +// CostAllocationRulesClientCheckNameAvailabilityOptions contains the optional parameters for the CostAllocationRulesClient.CheckNameAvailability +// method. +type CostAllocationRulesClientCheckNameAvailabilityOptions struct { + // placeholder for future optional parameters +} + +// CostAllocationRulesClientCreateOrUpdateOptions contains the optional parameters for the CostAllocationRulesClient.CreateOrUpdate +// method. +type CostAllocationRulesClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// CostAllocationRulesClientDeleteOptions contains the optional parameters for the CostAllocationRulesClient.Delete method. +type CostAllocationRulesClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// CostAllocationRulesClientGetOptions contains the optional parameters for the CostAllocationRulesClient.Get method. +type CostAllocationRulesClientGetOptions struct { + // placeholder for future optional parameters +} + +// CostAllocationRulesClientListOptions contains the optional parameters for the CostAllocationRulesClient.NewListPager method. +type CostAllocationRulesClientListOptions struct { + // placeholder for future optional parameters +} + // DimensionsClientByExternalCloudProviderTypeOptions contains the optional parameters for the DimensionsClient.NewByExternalCloudProviderTypePager // method. type DimensionsClientByExternalCloudProviderTypeOptions struct { @@ -173,6 +221,48 @@ type ForecastClientUsageOptions struct { Filter *string } +// GenerateBenefitUtilizationSummariesReportClientBeginGenerateByBillingAccountOptions contains the optional parameters for +// the GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByBillingAccount method. +type GenerateBenefitUtilizationSummariesReportClientBeginGenerateByBillingAccountOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// GenerateBenefitUtilizationSummariesReportClientBeginGenerateByBillingProfileOptions contains the optional parameters for +// the GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByBillingProfile method. +type GenerateBenefitUtilizationSummariesReportClientBeginGenerateByBillingProfileOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// GenerateBenefitUtilizationSummariesReportClientBeginGenerateByReservationIDOptions contains the optional parameters for +// the GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByReservationID method. +type GenerateBenefitUtilizationSummariesReportClientBeginGenerateByReservationIDOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// GenerateBenefitUtilizationSummariesReportClientBeginGenerateByReservationOrderIDOptions contains the optional parameters +// for the GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByReservationOrderID method. +type GenerateBenefitUtilizationSummariesReportClientBeginGenerateByReservationOrderIDOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// GenerateBenefitUtilizationSummariesReportClientBeginGenerateBySavingsPlanIDOptions contains the optional parameters for +// the GenerateBenefitUtilizationSummariesReportClient.BeginGenerateBySavingsPlanID method. +type GenerateBenefitUtilizationSummariesReportClientBeginGenerateBySavingsPlanIDOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// GenerateBenefitUtilizationSummariesReportClientBeginGenerateBySavingsPlanOrderIDOptions contains the optional parameters +// for the GenerateBenefitUtilizationSummariesReportClient.BeginGenerateBySavingsPlanOrderID method. +type GenerateBenefitUtilizationSummariesReportClientBeginGenerateBySavingsPlanOrderIDOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + // GenerateCostDetailsReportClientBeginCreateOperationOptions contains the optional parameters for the GenerateCostDetailsReportClient.BeginCreateOperation // method. type GenerateCostDetailsReportClientBeginCreateOperationOptions struct { @@ -226,6 +316,13 @@ type OperationsClientListOptions struct { // placeholder for future optional parameters } +// PriceSheetClientBeginDownloadByBillingAccountOptions contains the optional parameters for the PriceSheetClient.BeginDownloadByBillingAccount +// method. +type PriceSheetClientBeginDownloadByBillingAccountOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + // PriceSheetClientBeginDownloadByBillingProfileOptions contains the optional parameters for the PriceSheetClient.BeginDownloadByBillingProfile // method. type PriceSheetClientBeginDownloadByBillingProfileOptions struct { @@ -233,8 +330,9 @@ type PriceSheetClientBeginDownloadByBillingProfileOptions struct { ResumeToken string } -// PriceSheetClientBeginDownloadOptions contains the optional parameters for the PriceSheetClient.BeginDownload method. -type PriceSheetClientBeginDownloadOptions struct { +// PriceSheetClientBeginDownloadByInvoiceOptions contains the optional parameters for the PriceSheetClient.BeginDownloadByInvoice +// method. +type PriceSheetClientBeginDownloadByInvoiceOptions struct { // Resumes the LRO from the provided token. ResumeToken string } @@ -322,6 +420,27 @@ type ScheduledActionsClientRunOptions struct { // placeholder for future optional parameters } +// SettingsClientCreateOrUpdateByScopeOptions contains the optional parameters for the SettingsClient.CreateOrUpdateByScope +// method. +type SettingsClientCreateOrUpdateByScopeOptions struct { + // placeholder for future optional parameters +} + +// SettingsClientDeleteByScopeOptions contains the optional parameters for the SettingsClient.DeleteByScope method. +type SettingsClientDeleteByScopeOptions struct { + // placeholder for future optional parameters +} + +// SettingsClientGetByScopeOptions contains the optional parameters for the SettingsClient.GetByScope method. +type SettingsClientGetByScopeOptions struct { + // placeholder for future optional parameters +} + +// SettingsClientListOptions contains the optional parameters for the SettingsClient.List method. +type SettingsClientListOptions struct { + // placeholder for future optional parameters +} + // ViewsClientCreateOrUpdateByScopeOptions contains the optional parameters for the ViewsClient.CreateOrUpdateByScope method. type ViewsClientCreateOrUpdateByScopeOptions struct { // placeholder for future optional parameters diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/polymorphic_helpers.go b/sdk/resourcemanager/costmanagement/armcostmanagement/polymorphic_helpers.go index d6147d4c8f9c..76439717b658 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/polymorphic_helpers.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/polymorphic_helpers.go @@ -11,7 +11,7 @@ package armcostmanagement import "encoding/json" func unmarshalBenefitRecommendationPropertiesClassification(rawMsg json.RawMessage) (BenefitRecommendationPropertiesClassification, error) { - if rawMsg == nil { + if rawMsg == nil || string(rawMsg) == "null" { return nil, nil } var m map[string]any @@ -34,7 +34,7 @@ func unmarshalBenefitRecommendationPropertiesClassification(rawMsg json.RawMessa } func unmarshalBenefitUtilizationSummaryClassification(rawMsg json.RawMessage) (BenefitUtilizationSummaryClassification, error) { - if rawMsg == nil { + if rawMsg == nil || string(rawMsg) == "null" { return nil, nil } var m map[string]any @@ -57,7 +57,7 @@ func unmarshalBenefitUtilizationSummaryClassification(rawMsg json.RawMessage) (B } func unmarshalBenefitUtilizationSummaryClassificationArray(rawMsg json.RawMessage) ([]BenefitUtilizationSummaryClassification, error) { - if rawMsg == nil { + if rawMsg == nil || string(rawMsg) == "null" { return nil, nil } var rawMessages []json.RawMessage @@ -74,3 +74,43 @@ func unmarshalBenefitUtilizationSummaryClassificationArray(rawMsg json.RawMessag } return fArray, nil } + +func unmarshalSettingClassification(rawMsg json.RawMessage) (SettingClassification, 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 SettingClassification + switch m["kind"] { + case string(SettingsKindTaginheritance): + b = &TagInheritanceSetting{} + default: + b = &Setting{} + } + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil +} + +func unmarshalSettingClassificationArray(rawMsg json.RawMessage) ([]SettingClassification, error) { + if rawMsg == nil || string(rawMsg) == "null" { + return nil, nil + } + var rawMessages []json.RawMessage + if err := json.Unmarshal(rawMsg, &rawMessages); err != nil { + return nil, err + } + fArray := make([]SettingClassification, len(rawMessages)) + for index, rawMessage := range rawMessages { + f, err := unmarshalSettingClassification(rawMessage) + if err != nil { + return nil, err + } + fArray[index] = f + } + return fArray, nil +} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/pricesheet_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/pricesheet_client.go index 5e99cebe9829..3c9913e12251 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/pricesheet_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/pricesheet_client.go @@ -40,46 +40,61 @@ func NewPriceSheetClient(credential azcore.TokenCredential, options *arm.ClientO return client, nil } -// BeginDownload - Gets a URL to download the pricesheet for an invoice. The operation is supported for billing accounts with -// agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. +// BeginDownloadByBillingAccount - Generates the pricesheet for the provided billing period asynchronously based on the Enrollment +// ID. This is for Enterprise Agreement customers. You can use the new 2023-09-01 API version at +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingPeriods/{billingPeriodName}/providers/Microsoft.CostManagement/pricesheets/default/download' +// for billing periods January 2023 +// onwards. With a new schema detailed below, the new price sheet provides more information and includes prices for Azure +// Reserved Instances (RI) for the current billing period. +// We recommend downloading an Azure Price Sheet for when entering a new billing period if you would maintain a record of +// past Azure Reserved Instance (RI) pricing. Due to Azure product growth, the Azure +// price sheet download experience in this preview version will be updated from a single .csv file to a zip file containing +// multiple csv files, each with max size of 75MB. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 -// - billingAccountName - The ID that uniquely identifies a billing account. -// - billingProfileName - The ID that uniquely identifies a billing profile. -// - invoiceName - The ID that uniquely identifies an invoice. -// - options - PriceSheetClientBeginDownloadOptions contains the optional parameters for the PriceSheetClient.BeginDownload +// Generated from API version 2023-11-01 +// - billingAccountID - BillingAccount ID +// - billingPeriodName - Billing Period Name. +// - options - PriceSheetClientBeginDownloadByBillingAccountOptions contains the optional parameters for the PriceSheetClient.BeginDownloadByBillingAccount // method. -func (client *PriceSheetClient) BeginDownload(ctx context.Context, billingAccountName string, billingProfileName string, invoiceName string, options *PriceSheetClientBeginDownloadOptions) (*runtime.Poller[PriceSheetClientDownloadResponse], error) { +func (client *PriceSheetClient) BeginDownloadByBillingAccount(ctx context.Context, billingAccountID string, billingPeriodName string, options *PriceSheetClientBeginDownloadByBillingAccountOptions) (*runtime.Poller[PriceSheetClientDownloadByBillingAccountResponse], error) { if options == nil || options.ResumeToken == "" { - resp, err := client.download(ctx, billingAccountName, billingProfileName, invoiceName, options) + resp, err := client.downloadByBillingAccount(ctx, billingAccountID, billingPeriodName, options) if err != nil { return nil, err } - poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PriceSheetClientDownloadResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PriceSheetClientDownloadByBillingAccountResponse]{ FinalStateVia: runtime.FinalStateViaLocation, Tracer: client.internal.Tracer(), }) return poller, err } else { - return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[PriceSheetClientDownloadResponse]{ + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[PriceSheetClientDownloadByBillingAccountResponse]{ Tracer: client.internal.Tracer(), }) } } -// Download - Gets a URL to download the pricesheet for an invoice. The operation is supported for billing accounts with agreement -// type Microsoft Partner Agreement or Microsoft Customer Agreement. +// DownloadByBillingAccount - Generates the pricesheet for the provided billing period asynchronously based on the Enrollment +// ID. This is for Enterprise Agreement customers. You can use the new 2023-09-01 API version at +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingPeriods/{billingPeriodName}/providers/Microsoft.CostManagement/pricesheets/default/download' +// for billing periods January 2023 +// onwards. With a new schema detailed below, the new price sheet provides more information and includes prices for Azure +// Reserved Instances (RI) for the current billing period. +// We recommend downloading an Azure Price Sheet for when entering a new billing period if you would maintain a record of +// past Azure Reserved Instance (RI) pricing. Due to Azure product growth, the Azure +// price sheet download experience in this preview version will be updated from a single .csv file to a zip file containing +// multiple csv files, each with max size of 75MB. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 -func (client *PriceSheetClient) download(ctx context.Context, billingAccountName string, billingProfileName string, invoiceName string, options *PriceSheetClientBeginDownloadOptions) (*http.Response, error) { +// Generated from API version 2023-11-01 +func (client *PriceSheetClient) downloadByBillingAccount(ctx context.Context, billingAccountID string, billingPeriodName string, options *PriceSheetClientBeginDownloadByBillingAccountOptions) (*http.Response, error) { var err error - const operationName = "PriceSheetClient.BeginDownload" + const operationName = "PriceSheetClient.BeginDownloadByBillingAccount" ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) defer func() { endSpan(err) }() - req, err := client.downloadCreateRequest(ctx, billingAccountName, billingProfileName, invoiceName, options) + req, err := client.downloadByBillingAccountCreateRequest(ctx, billingAccountID, billingPeriodName, options) if err != nil { return nil, err } @@ -94,27 +109,23 @@ func (client *PriceSheetClient) download(ctx context.Context, billingAccountName return httpResp, nil } -// downloadCreateRequest creates the Download request. -func (client *PriceSheetClient) downloadCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, invoiceName string, options *PriceSheetClientBeginDownloadOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoices/{invoiceName}/providers/Microsoft.CostManagement/pricesheets/default/download" - if billingAccountName == "" { - return nil, errors.New("parameter billingAccountName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) - if billingProfileName == "" { - return nil, errors.New("parameter billingProfileName cannot be empty") +// downloadByBillingAccountCreateRequest creates the DownloadByBillingAccount request. +func (client *PriceSheetClient) downloadByBillingAccountCreateRequest(ctx context.Context, billingAccountID string, billingPeriodName string, options *PriceSheetClientBeginDownloadByBillingAccountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingPeriods/{billingPeriodName}/providers/Microsoft.CostManagement/pricesheets/default/download" + if billingAccountID == "" { + return nil, errors.New("parameter billingAccountID cannot be empty") } - urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) - if invoiceName == "" { - return nil, errors.New("parameter invoiceName 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, "{invoiceName}", url.PathEscape(invoiceName)) + 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", "2022-10-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -122,12 +133,15 @@ func (client *PriceSheetClient) downloadCreateRequest(ctx context.Context, billi // BeginDownloadByBillingProfile - Gets a URL to download the current month's pricesheet for a billing profile. The operation // is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer -// Agreement.Due to Azure product growth, the Azure price sheet download experience in this preview version will be updated -// from a single csv file to a Zip file containing multiple csv files, each with -// max 200k records. +// Agreement. +// You can use the new 2023-09-01 API version for billing periods January 2023 onwards. Azure Reserved Instance (RI) pricing +// is only available through the new version of the API. +// Due to Azure product growth, the Azure price sheet download experience in this preview version will be updated from a single +// csv/json file to a Zip file containing multiple csv/json files, each with +// max size of 75MB. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - billingAccountName - The ID that uniquely identifies a billing account. // - billingProfileName - The ID that uniquely identifies a billing profile. // - options - PriceSheetClientBeginDownloadByBillingProfileOptions contains the optional parameters for the PriceSheetClient.BeginDownloadByBillingProfile @@ -152,12 +166,15 @@ func (client *PriceSheetClient) BeginDownloadByBillingProfile(ctx context.Contex // DownloadByBillingProfile - Gets a URL to download the current month's pricesheet for a billing profile. The operation is // supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer -// Agreement.Due to Azure product growth, the Azure price sheet download experience in this preview version will be updated -// from a single csv file to a Zip file containing multiple csv files, each with -// max 200k records. +// Agreement. +// You can use the new 2023-09-01 API version for billing periods January 2023 onwards. Azure Reserved Instance (RI) pricing +// is only available through the new version of the API. +// Due to Azure product growth, the Azure price sheet download experience in this preview version will be updated from a single +// csv/json file to a Zip file containing multiple csv/json files, each with +// max size of 75MB. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 func (client *PriceSheetClient) downloadByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string, options *PriceSheetClientBeginDownloadByBillingProfileOptions) (*http.Response, error) { var err error const operationName = "PriceSheetClient.BeginDownloadByBillingProfile" @@ -195,7 +212,87 @@ func (client *PriceSheetClient) downloadByBillingProfileCreateRequest(ctx contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// BeginDownloadByInvoice - Gets a URL to download the pricesheet for an invoice. The operation is supported for billing accounts +// with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +// - billingAccountName - The ID that uniquely identifies a billing account. +// - billingProfileName - The ID that uniquely identifies a billing profile. +// - invoiceName - The ID that uniquely identifies an invoice. +// - options - PriceSheetClientBeginDownloadByInvoiceOptions contains the optional parameters for the PriceSheetClient.BeginDownloadByInvoice +// method. +func (client *PriceSheetClient) BeginDownloadByInvoice(ctx context.Context, billingAccountName string, billingProfileName string, invoiceName string, options *PriceSheetClientBeginDownloadByInvoiceOptions) (*runtime.Poller[PriceSheetClientDownloadByInvoiceResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.downloadByInvoice(ctx, billingAccountName, billingProfileName, invoiceName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PriceSheetClientDownloadByInvoiceResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[PriceSheetClientDownloadByInvoiceResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// DownloadByInvoice - Gets a URL to download the pricesheet for an invoice. The operation is supported for billing accounts +// with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +func (client *PriceSheetClient) downloadByInvoice(ctx context.Context, billingAccountName string, billingProfileName string, invoiceName string, options *PriceSheetClientBeginDownloadByInvoiceOptions) (*http.Response, error) { + var err error + const operationName = "PriceSheetClient.BeginDownloadByInvoice" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.downloadByInvoiceCreateRequest(ctx, billingAccountName, billingProfileName, invoiceName, 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 +} + +// downloadByInvoiceCreateRequest creates the DownloadByInvoice request. +func (client *PriceSheetClient) downloadByInvoiceCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, invoiceName string, options *PriceSheetClientBeginDownloadByInvoiceOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoices/{invoiceName}/providers/Microsoft.CostManagement/pricesheets/default/download" + if billingAccountName == "" { + return nil, errors.New("parameter billingAccountName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountName}", url.PathEscape(billingAccountName)) + if billingProfileName == "" { + return nil, errors.New("parameter billingProfileName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileName}", url.PathEscape(billingProfileName)) + if invoiceName == "" { + return nil, errors.New("parameter invoiceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{invoiceName}", url.PathEscape(invoiceName)) + 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", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/pricesheet_client_example_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/pricesheet_client_example_test.go deleted file mode 100644 index 6c3984eb49b1..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/pricesheet_client_example_test.go +++ /dev/null @@ -1,74 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armcostmanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/PricesheetDownload.json -func ExamplePriceSheetClient_BeginDownload() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewPriceSheetClient().BeginDownload(ctx, "7c05a543-80ff-571e-9f98-1063b3b53cf2:99ad03ad-2d1b-4889-a452-090ad407d25f_2019-05-31", "2USN-TPCD-BG7-TGB", "T000940677", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.DownloadURL = armcostmanagement.DownloadURL{ - // DownloadURL: to.Ptr("https://myaccount.blob.core.windows.net/?restype=service&comp=properties&sv=2015-04-05&ss=bf&srt=s&st=2015-04-29T22%3A18%3A26Z&se=2015-04-30T02%3A23%3A26Z&sr=b&sp=rw&spr=https&sig=G%2TEST%4B"), - // ExpiryTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-09-30T17:32:28.000Z"); return t}()), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/PricesheetDownloadByBillingProfile.json -func ExamplePriceSheetClient_BeginDownloadByBillingProfile() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewPriceSheetClient().BeginDownloadByBillingProfile(ctx, "7c05a543-80ff-571e-9f98-1063b3b53cf2:99ad03ad-2d1b-4889-a452-090ad407d25f_2019-05-31", "2USN-TPCD-BG7-TGB", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.DownloadURL = armcostmanagement.DownloadURL{ - // DownloadURL: to.Ptr("https://myaccount.blob.core.windows.net/?restype=service&comp=properties&sv=2015-04-05&ss=bf&srt=s&st=2015-04-29T22%3A18%3A26Z&se=2015-04-30T02%3A23%3A26Z&sr=b&sp=rw&spr=https&sig=G%2TEST%4B"), - // ExpiryTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-07-21T17:32:28.000Z"); return t}()), - // } -} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/query_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/query_client.go index 0edd2048acc0..67d6b0ba82da 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/query_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/query_client.go @@ -43,7 +43,7 @@ func NewQueryClient(credential azcore.TokenCredential, options *arm.ClientOption // Usage - Query the usage data for scope defined. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - scope - The scope associated with query and export operations. This includes '/subscriptions/{subscriptionId}/' for subscription // scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for // resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and @@ -87,7 +87,7 @@ func (client *QueryClient) usageCreateRequest(ctx context.Context, scope string, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -108,7 +108,7 @@ func (client *QueryClient) usageHandleResponse(resp *http.Response) (QueryClient // UsageByExternalCloudProviderType - Query the usage data for external cloud provider type defined. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - externalCloudProviderType - The external cloud provider type associated with dimension/query operations. This includes // 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account. // - externalCloudProviderID - This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' for @@ -154,7 +154,7 @@ func (client *QueryClient) usageByExternalCloudProviderTypeCreateRequest(ctx con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/query_client_example_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/query_client_example_test.go deleted file mode 100644 index 6d938b0233ce..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/query_client_example_test.go +++ /dev/null @@ -1,1934 +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 armcostmanagement_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/costmanagement/armcostmanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BillingAccountQuery.json -func ExampleQueryClient_Usage_billingAccountQueryLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQueryClient().Usage(ctx, "providers/Microsoft.Billing/billingAccounts/70664866", armcostmanagement.QueryDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeUsage), - Dataset: &armcostmanagement.QueryDataset{ - Filter: &armcostmanagement.QueryFilter{ - And: []*armcostmanagement.QueryFilter{ - { - Or: []*armcostmanagement.QueryFilter{ - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("East US"), - to.Ptr("West Europe")}, - }, - }, - { - Tags: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("UAT"), - to.Ptr("Prod")}, - }, - }}, - }, - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("API")}, - }, - }}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - }, 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.QueryResult = armcostmanagement.QueryResult{ - // Name: to.Ptr("ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Type: to.Ptr("microsoft.costmanagement/Query"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/70664866/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Properties: &armcostmanagement.QueryProperties{ - // Columns: []*armcostmanagement.QueryColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("ResourceGroup"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("UsageDate"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // float64(20180331), - // "USD"}, - // []any{ - // float64(173.41979241290323), - // "RVIIOT-TRIAL", - // float64(20180331), - // "USD"}, - // []any{ - // float64(20.35941656262545), - // "VSTSHOL-1595322048000", - // float64(20180331), - // "USD"}, - // []any{ - // float64(0.16677720329728665), - // "gs-stms-dev", - // float64(20180331), - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCABillingAccountQuery.json -func ExampleQueryClient_Usage_billingAccountQueryMca() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQueryClient().Usage(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789", armcostmanagement.QueryDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeUsage), - Dataset: &armcostmanagement.QueryDataset{ - Filter: &armcostmanagement.QueryFilter{ - And: []*armcostmanagement.QueryFilter{ - { - Or: []*armcostmanagement.QueryFilter{ - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("East US"), - to.Ptr("West Europe")}, - }, - }, - { - Tags: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("UAT"), - to.Ptr("Prod")}, - }, - }}, - }, - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("API")}, - }, - }}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - }, 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.QueryResult = armcostmanagement.QueryResult{ - // Name: to.Ptr("ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Type: to.Ptr("microsoft.costmanagement/Query"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Properties: &armcostmanagement.QueryProperties{ - // Columns: []*armcostmanagement.QueryColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("ResourceGroup"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("UsageDate"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // float64(20180331), - // "USD"}, - // []any{ - // float64(173.41979241290323), - // "RVIIOT-TRIAL", - // float64(20180331), - // "USD"}, - // []any{ - // float64(20.35941656262545), - // "VSTSHOL-1595322048000", - // float64(20180331), - // "USD"}, - // []any{ - // float64(0.16677720329728665), - // "gs-stms-dev", - // float64(20180331), - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BillingAccountQueryGrouping.json -func ExampleQueryClient_Usage_billingAccountQueryGroupingLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQueryClient().Usage(ctx, "providers/Microsoft.Billing/billingAccounts/70664866", armcostmanagement.QueryDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeUsage), - Dataset: &armcostmanagement.QueryDataset{ - Aggregation: map[string]*armcostmanagement.QueryAggregation{ - "totalCost": { - Name: to.Ptr("PreTaxCost"), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), - }, - }, - Granularity: to.Ptr(armcostmanagement.GranularityType("None")), - Grouping: []*armcostmanagement.QueryGrouping{ - { - Name: to.Ptr("ResourceGroup"), - Type: to.Ptr(armcostmanagement.QueryColumnTypeDimension), - }}, - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheLastMonth), - }, 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.QueryResult = armcostmanagement.QueryResult{ - // Name: to.Ptr("ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Type: to.Ptr("microsoft.costmanagement/Query"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/70664866/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Properties: &armcostmanagement.QueryProperties{ - // Columns: []*armcostmanagement.QueryColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("ResourceGroup"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // "USD"}, - // []any{ - // float64(173.41979241290323), - // "RVIIOT-TRIAL", - // "USD"}, - // []any{ - // float64(20.35941656262545), - // "VSTSHOL-1595322048000", - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCABillingAccountQueryGrouping.json -func ExampleQueryClient_Usage_billingAccountQueryGroupingMca() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQueryClient().Usage(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789", armcostmanagement.QueryDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeUsage), - Dataset: &armcostmanagement.QueryDataset{ - Aggregation: map[string]*armcostmanagement.QueryAggregation{ - "totalCost": { - Name: to.Ptr("PreTaxCost"), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), - }, - }, - Granularity: to.Ptr(armcostmanagement.GranularityType("None")), - Grouping: []*armcostmanagement.QueryGrouping{ - { - Name: to.Ptr("ResourceGroup"), - Type: to.Ptr(armcostmanagement.QueryColumnTypeDimension), - }}, - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheLastMonth), - }, 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.QueryResult = armcostmanagement.QueryResult{ - // Name: to.Ptr("ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Type: to.Ptr("microsoft.costmanagement/Query"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Properties: &armcostmanagement.QueryProperties{ - // Columns: []*armcostmanagement.QueryColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("ResourceGroup"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // "USD"}, - // []any{ - // float64(173.41979241290323), - // "RVIIOT-TRIAL", - // "USD"}, - // []any{ - // float64(20.35941656262545), - // "VSTSHOL-1595322048000", - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCABillingProfileQuery.json -func ExampleQueryClient_Usage_billingProfileQueryMca() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQueryClient().Usage(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579", armcostmanagement.QueryDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeUsage), - Dataset: &armcostmanagement.QueryDataset{ - Filter: &armcostmanagement.QueryFilter{ - And: []*armcostmanagement.QueryFilter{ - { - Or: []*armcostmanagement.QueryFilter{ - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("East US"), - to.Ptr("West Europe")}, - }, - }, - { - Tags: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("UAT"), - to.Ptr("Prod")}, - }, - }}, - }, - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("API")}, - }, - }}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - }, 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.QueryResult = armcostmanagement.QueryResult{ - // Name: to.Ptr("ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Type: to.Ptr("microsoft.costmanagement/Query"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Properties: &armcostmanagement.QueryProperties{ - // Columns: []*armcostmanagement.QueryColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("ResourceGroup"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("UsageDate"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // float64(20180331), - // "USD"}, - // []any{ - // float64(173.41979241290323), - // "RVIIOT-TRIAL", - // float64(20180331), - // "USD"}, - // []any{ - // float64(20.35941656262545), - // "VSTSHOL-1595322048000", - // float64(20180331), - // "USD"}, - // []any{ - // float64(0.16677720329728665), - // "gs-stms-dev", - // float64(20180331), - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCABillingProfileQueryGrouping.json -func ExampleQueryClient_Usage_billingProfileQueryGroupingMca() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQueryClient().Usage(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579", armcostmanagement.QueryDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeUsage), - Dataset: &armcostmanagement.QueryDataset{ - Aggregation: map[string]*armcostmanagement.QueryAggregation{ - "totalCost": { - Name: to.Ptr("PreTaxCost"), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), - }, - }, - Granularity: to.Ptr(armcostmanagement.GranularityType("None")), - Grouping: []*armcostmanagement.QueryGrouping{ - { - Name: to.Ptr("ResourceGroup"), - Type: to.Ptr(armcostmanagement.QueryColumnTypeDimension), - }}, - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheLastMonth), - }, 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.QueryResult = armcostmanagement.QueryResult{ - // Name: to.Ptr("ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Type: to.Ptr("microsoft.costmanagement/Query"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Properties: &armcostmanagement.QueryProperties{ - // Columns: []*armcostmanagement.QueryColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("ResourceGroup"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // "USD"}, - // []any{ - // float64(173.41979241290323), - // "RVIIOT-TRIAL", - // "USD"}, - // []any{ - // float64(20.35941656262545), - // "VSTSHOL-1595322048000", - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCACustomerQuery.json -func ExampleQueryClient_Usage_customerQueryMca() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQueryClient().Usage(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678", armcostmanagement.QueryDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeUsage), - Dataset: &armcostmanagement.QueryDataset{ - Filter: &armcostmanagement.QueryFilter{ - And: []*armcostmanagement.QueryFilter{ - { - Or: []*armcostmanagement.QueryFilter{ - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("East US"), - to.Ptr("West Europe")}, - }, - }, - { - Tags: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("UAT"), - to.Ptr("Prod")}, - }, - }}, - }, - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("API")}, - }, - }}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - }, 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.QueryResult = armcostmanagement.QueryResult{ - // Name: to.Ptr("ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Type: to.Ptr("microsoft.costmanagement/Query"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Properties: &armcostmanagement.QueryProperties{ - // Columns: []*armcostmanagement.QueryColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("ResourceGroup"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("UsageDate"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // float64(20180331), - // "USD"}, - // []any{ - // float64(173.41979241290323), - // "RVIIOT-TRIAL", - // float64(20180331), - // "USD"}, - // []any{ - // float64(20.35941656262545), - // "VSTSHOL-1595322048000", - // float64(20180331), - // "USD"}, - // []any{ - // float64(0.16677720329728665), - // "gs-stms-dev", - // float64(20180331), - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCACustomerQueryGrouping.json -func ExampleQueryClient_Usage_customerQueryGroupingMca() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQueryClient().Usage(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678", armcostmanagement.QueryDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeUsage), - Dataset: &armcostmanagement.QueryDataset{ - Aggregation: map[string]*armcostmanagement.QueryAggregation{ - "totalCost": { - Name: to.Ptr("PreTaxCost"), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), - }, - }, - Granularity: to.Ptr(armcostmanagement.GranularityType("None")), - Grouping: []*armcostmanagement.QueryGrouping{ - { - Name: to.Ptr("ResourceGroup"), - Type: to.Ptr(armcostmanagement.QueryColumnTypeDimension), - }}, - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheLastMonth), - }, 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.QueryResult = armcostmanagement.QueryResult{ - // Name: to.Ptr("ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Type: to.Ptr("microsoft.costmanagement/Query"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Properties: &armcostmanagement.QueryProperties{ - // Columns: []*armcostmanagement.QueryColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("ResourceGroup"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // "USD"}, - // []any{ - // float64(173.41979241290323), - // "RVIIOT-TRIAL", - // "USD"}, - // []any{ - // float64(20.35941656262545), - // "VSTSHOL-1595322048000", - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/DepartmentQuery.json -func ExampleQueryClient_Usage_departmentQueryLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQueryClient().Usage(ctx, "providers/Microsoft.Billing/billingAccounts/100/departments/123", armcostmanagement.QueryDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeUsage), - Dataset: &armcostmanagement.QueryDataset{ - Filter: &armcostmanagement.QueryFilter{ - And: []*armcostmanagement.QueryFilter{ - { - Or: []*armcostmanagement.QueryFilter{ - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("East US"), - to.Ptr("West Europe")}, - }, - }, - { - Tags: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("UAT"), - to.Ptr("Prod")}, - }, - }}, - }, - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("API")}, - }, - }}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - }, 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.QueryResult = armcostmanagement.QueryResult{ - // Name: to.Ptr("ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Type: to.Ptr("microsoft.costmanagement/Query"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/70664866/departments/123/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Properties: &armcostmanagement.QueryProperties{ - // Columns: []*armcostmanagement.QueryColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("ResourceGroup"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("UsageDate"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // float64(20180331), - // "USD"}, - // []any{ - // float64(173.41979241290323), - // "RVIIOT-TRIAL", - // float64(20180331), - // "USD"}, - // []any{ - // float64(20.35941656262545), - // "VSTSHOL-1595322048000", - // float64(20180331), - // "USD"}, - // []any{ - // float64(0.16677720329728665), - // "gs-stms-dev", - // float64(20180331), - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/DepartmentQueryGrouping.json -func ExampleQueryClient_Usage_departmentQueryGroupingLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQueryClient().Usage(ctx, "providers/Microsoft.Billing/billingAccounts/100/departments/123", armcostmanagement.QueryDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeUsage), - Dataset: &armcostmanagement.QueryDataset{ - Aggregation: map[string]*armcostmanagement.QueryAggregation{ - "totalCost": { - Name: to.Ptr("PreTaxCost"), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), - }, - }, - Granularity: to.Ptr(armcostmanagement.GranularityType("None")), - Grouping: []*armcostmanagement.QueryGrouping{ - { - Name: to.Ptr("ResourceGroup"), - Type: to.Ptr(armcostmanagement.QueryColumnTypeDimension), - }}, - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheLastMonth), - }, 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.QueryResult = armcostmanagement.QueryResult{ - // Name: to.Ptr("ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Type: to.Ptr("microsoft.costmanagement/Query"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/70664866/departments/123/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Properties: &armcostmanagement.QueryProperties{ - // Columns: []*armcostmanagement.QueryColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("ResourceGroup"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // "USD"}, - // []any{ - // float64(173.41979241290323), - // "RVIIOT-TRIAL", - // "USD"}, - // []any{ - // float64(20.35941656262545), - // "VSTSHOL-1595322048000", - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/EnrollmentAccountQuery.json -func ExampleQueryClient_Usage_enrollmentAccountQueryLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQueryClient().Usage(ctx, "providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456", armcostmanagement.QueryDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeUsage), - Dataset: &armcostmanagement.QueryDataset{ - Filter: &armcostmanagement.QueryFilter{ - And: []*armcostmanagement.QueryFilter{ - { - Or: []*armcostmanagement.QueryFilter{ - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("East US"), - to.Ptr("West Europe")}, - }, - }, - { - Tags: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("UAT"), - to.Ptr("Prod")}, - }, - }}, - }, - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("API")}, - }, - }}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - }, 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.QueryResult = armcostmanagement.QueryResult{ - // Name: to.Ptr("ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Type: to.Ptr("microsoft.costmanagement/Query"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/70664866/enrollmentAccounts/456/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Properties: &armcostmanagement.QueryProperties{ - // Columns: []*armcostmanagement.QueryColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("ResourceGroup"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("UsageDate"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // float64(20180331), - // "USD"}, - // []any{ - // float64(173.41979241290323), - // "RVIIOT-TRIAL", - // float64(20180331), - // "USD"}, - // []any{ - // float64(20.35941656262545), - // "VSTSHOL-1595322048000", - // float64(20180331), - // "USD"}, - // []any{ - // float64(0.16677720329728665), - // "gs-stms-dev", - // float64(20180331), - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/EnrollmentAccountQueryGrouping.json -func ExampleQueryClient_Usage_enrollmentAccountQueryGroupingLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQueryClient().Usage(ctx, "providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456", armcostmanagement.QueryDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeUsage), - Dataset: &armcostmanagement.QueryDataset{ - Aggregation: map[string]*armcostmanagement.QueryAggregation{ - "totalCost": { - Name: to.Ptr("PreTaxCost"), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), - }, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - Grouping: []*armcostmanagement.QueryGrouping{ - { - Name: to.Ptr("ResourceGroup"), - Type: to.Ptr(armcostmanagement.QueryColumnTypeDimension), - }}, - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheLastMonth), - }, 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.QueryResult = armcostmanagement.QueryResult{ - // Name: to.Ptr("ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Type: to.Ptr("microsoft.costmanagement/Query"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/70664866/enrollmentAccounts/456/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Properties: &armcostmanagement.QueryProperties{ - // Columns: []*armcostmanagement.QueryColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("ResourceGroup"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("UsageDate"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // float64(20180331), - // "USD"}, - // []any{ - // float64(173.41979241290323), - // "RVIIOT-TRIAL", - // float64(20180331), - // "USD"}, - // []any{ - // float64(20.35941656262545), - // "VSTSHOL-1595322048000", - // float64(20180331), - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCAInvoiceSectionQuery.json -func ExampleQueryClient_Usage_invoiceSectionQueryMca() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQueryClient().Usage(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876", armcostmanagement.QueryDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeUsage), - Dataset: &armcostmanagement.QueryDataset{ - Filter: &armcostmanagement.QueryFilter{ - And: []*armcostmanagement.QueryFilter{ - { - Or: []*armcostmanagement.QueryFilter{ - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("East US"), - to.Ptr("West Europe")}, - }, - }, - { - Tags: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("UAT"), - to.Ptr("Prod")}, - }, - }}, - }, - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("API")}, - }, - }}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - }, 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.QueryResult = armcostmanagement.QueryResult{ - // Name: to.Ptr("ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Type: to.Ptr("microsoft.costmanagement/Query"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Properties: &armcostmanagement.QueryProperties{ - // Columns: []*armcostmanagement.QueryColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("ResourceGroup"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("UsageDate"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // float64(20180331), - // "USD"}, - // []any{ - // float64(173.41979241290323), - // "RVIIOT-TRIAL", - // float64(20180331), - // "USD"}, - // []any{ - // float64(20.35941656262545), - // "VSTSHOL-1595322048000", - // float64(20180331), - // "USD"}, - // []any{ - // float64(0.16677720329728665), - // "gs-stms-dev", - // float64(20180331), - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCAInvoiceSectionQueryGrouping.json -func ExampleQueryClient_Usage_invoiceSectionQueryGroupingMca() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQueryClient().Usage(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876", armcostmanagement.QueryDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeUsage), - Dataset: &armcostmanagement.QueryDataset{ - Aggregation: map[string]*armcostmanagement.QueryAggregation{ - "totalCost": { - Name: to.Ptr("PreTaxCost"), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), - }, - }, - Granularity: to.Ptr(armcostmanagement.GranularityType("None")), - Grouping: []*armcostmanagement.QueryGrouping{ - { - Name: to.Ptr("ResourceGroup"), - Type: to.Ptr(armcostmanagement.QueryColumnTypeDimension), - }}, - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheLastMonth), - }, 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.QueryResult = armcostmanagement.QueryResult{ - // Name: to.Ptr("ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Type: to.Ptr("microsoft.costmanagement/Query"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Properties: &armcostmanagement.QueryProperties{ - // Columns: []*armcostmanagement.QueryColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("ResourceGroup"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // "USD"}, - // []any{ - // float64(173.41979241290323), - // "RVIIOT-TRIAL", - // "USD"}, - // []any{ - // float64(20.35941656262545), - // "VSTSHOL-1595322048000", - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ManagementGroupQuery.json -func ExampleQueryClient_Usage_managementGroupQueryLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQueryClient().Usage(ctx, "providers/Microsoft.Management/managementGroups/MyMgId", armcostmanagement.QueryDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeUsage), - Dataset: &armcostmanagement.QueryDataset{ - Filter: &armcostmanagement.QueryFilter{ - And: []*armcostmanagement.QueryFilter{ - { - Or: []*armcostmanagement.QueryFilter{ - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("East US"), - to.Ptr("West Europe")}, - }, - }, - { - Tags: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("UAT"), - to.Ptr("Prod")}, - }, - }}, - }, - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("API")}, - }, - }}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - }, 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.QueryResult = armcostmanagement.QueryResult{ - // Name: to.Ptr("ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Type: to.Ptr("microsoft.costmanagement/Query"), - // ID: to.Ptr("providers/Microsoft.Management/managementGroups/MyMgId/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Properties: &armcostmanagement.QueryProperties{ - // Columns: []*armcostmanagement.QueryColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("ResourceGroup"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("UsageDate"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // float64(20180331), - // "USD"}, - // []any{ - // float64(173.41979241290323), - // "RVIIOT-TRIAL", - // float64(20180331), - // "USD"}, - // []any{ - // float64(20.35941656262545), - // "VSTSHOL-1595322048000", - // float64(20180331), - // "USD"}, - // []any{ - // float64(0.16677720329728665), - // "gs-stms-dev", - // float64(20180331), - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ManagementGroupQueryGrouping.json -func ExampleQueryClient_Usage_managementGroupQueryGroupingLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQueryClient().Usage(ctx, "providers/Microsoft.Management/managementGroups/MyMgId", armcostmanagement.QueryDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeUsage), - Dataset: &armcostmanagement.QueryDataset{ - Aggregation: map[string]*armcostmanagement.QueryAggregation{ - "totalCost": { - Name: to.Ptr("PreTaxCost"), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), - }, - }, - Granularity: to.Ptr(armcostmanagement.GranularityType("None")), - Grouping: []*armcostmanagement.QueryGrouping{ - { - Name: to.Ptr("ResourceGroup"), - Type: to.Ptr(armcostmanagement.QueryColumnTypeDimension), - }}, - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheLastMonth), - }, 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.QueryResult = armcostmanagement.QueryResult{ - // Name: to.Ptr("ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Type: to.Ptr("microsoft.costmanagement/Query"), - // ID: to.Ptr("providers/Microsoft.Management/managementGroups/MyMgId/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Properties: &armcostmanagement.QueryProperties{ - // Columns: []*armcostmanagement.QueryColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("ResourceGroup"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("UsageDate"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(20.35941656262545), - // "VSTSHOL-1595322048000", - // float64(20180331), - // "USD"}, - // []any{ - // float64(173.41979241290323), - // "RVIIOT-TRIAL", - // float64(20180331), - // "USD"}, - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // float64(20180331), - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ResourceGroupQuery.json -func ExampleQueryClient_Usage_resourceGroupQueryLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQueryClient().Usage(ctx, "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ScreenSharingTest-peer", armcostmanagement.QueryDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeUsage), - Dataset: &armcostmanagement.QueryDataset{ - Filter: &armcostmanagement.QueryFilter{ - And: []*armcostmanagement.QueryFilter{ - { - Or: []*armcostmanagement.QueryFilter{ - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("East US"), - to.Ptr("West Europe")}, - }, - }, - { - Tags: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("UAT"), - to.Ptr("Prod")}, - }, - }}, - }, - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("API")}, - }, - }}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - }, 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.QueryResult = armcostmanagement.QueryResult{ - // Name: to.Ptr("9af9459d-441d-4055-9ed0-83d4c4a363fb"), - // Type: to.Ptr("microsoft.costmanagement/Query"), - // ID: to.Ptr("subscriptions/55312978-ba1b-415c-9304-c4b9c43c0481/resourcegroups/ScreenSharingTest-peer/providers/Microsoft.CostManagement/Query/9af9459d-441d-4055-9ed0-83d4c4a363fb"), - // Properties: &armcostmanagement.QueryProperties{ - // Columns: []*armcostmanagement.QueryColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("ResourceGroup"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("UsageDate"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(2.10333307059661), - // "ScreenSharingTest-peer", - // float64(20180417), - // "USD"}, - // []any{ - // float64(20.10333307059661), - // "ScreenSharingTest-peer", - // float64(20180418), - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ResourceGroupQueryGrouping.json -func ExampleQueryClient_Usage_resourceGroupQueryGroupingLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQueryClient().Usage(ctx, "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ScreenSharingTest-peer", armcostmanagement.QueryDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeUsage), - Dataset: &armcostmanagement.QueryDataset{ - Aggregation: map[string]*armcostmanagement.QueryAggregation{ - "totalCost": { - Name: to.Ptr("PreTaxCost"), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), - }, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - Grouping: []*armcostmanagement.QueryGrouping{ - { - Name: to.Ptr("ResourceType"), - Type: to.Ptr(armcostmanagement.QueryColumnTypeDimension), - }}, - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheLastMonth), - }, 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.QueryResult = armcostmanagement.QueryResult{ - // Name: to.Ptr("9af9459d-441d-4055-9ed0-83d4c4a363fb"), - // Type: to.Ptr("microsoft.costmanagement/Query"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/ScreenSharingTest-peer/providers/Microsoft.CostManagement/Query/9af9459d-441d-4055-9ed0-83d4c4a363fb"), - // Properties: &armcostmanagement.QueryProperties{ - // Columns: []*armcostmanagement.QueryColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("ResourceType"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("UsageDate"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(2.10333307059661), - // "Microsoft.SqlServer", - // float64(20180417), - // "USD"}, - // []any{ - // float64(20.10333307059661), - // "Microsoft.Compute", - // float64(20180418), - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/SubscriptionQuery.json -func ExampleQueryClient_Usage_subscriptionQueryLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQueryClient().Usage(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", armcostmanagement.QueryDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeUsage), - Dataset: &armcostmanagement.QueryDataset{ - Filter: &armcostmanagement.QueryFilter{ - And: []*armcostmanagement.QueryFilter{ - { - Or: []*armcostmanagement.QueryFilter{ - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("East US"), - to.Ptr("West Europe")}, - }, - }, - { - Tags: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("UAT"), - to.Ptr("Prod")}, - }, - }}, - }, - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("API")}, - }, - }}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - }, 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.QueryResult = armcostmanagement.QueryResult{ - // Name: to.Ptr("55312978-ba1b-415c-9304-cfd9c43c0481"), - // Type: to.Ptr("microsoft.costmanagement/Query"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/Query/00000000-0000-0000-0000-000000000000"), - // Properties: &armcostmanagement.QueryProperties{ - // Columns: []*armcostmanagement.QueryColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("ResourceGroup"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("UsageDate"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(2.10333307059661), - // "ScreenSharingTest-peer", - // float64(20180331), - // "USD"}, - // []any{ - // float64(218.68795741935486), - // "Ict_StratAndPlan_GoldSprova_Prod", - // float64(20180331), - // "USD"}, - // []any{ - // float64(0.14384913581657052), - // "ssbciotelement01", - // float64(20180401), - // "USD"}, - // []any{ - // float64(0.009865586851323632), - // "ict_stratandplan_goldsprova_prod", - // float64(20180429), - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/SubscriptionQueryGrouping.json -func ExampleQueryClient_Usage_subscriptionQueryGroupingLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQueryClient().Usage(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", armcostmanagement.QueryDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeUsage), - Dataset: &armcostmanagement.QueryDataset{ - Aggregation: map[string]*armcostmanagement.QueryAggregation{ - "totalCost": { - Name: to.Ptr("PreTaxCost"), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), - }, - }, - Granularity: to.Ptr(armcostmanagement.GranularityType("None")), - Grouping: []*armcostmanagement.QueryGrouping{ - { - Name: to.Ptr("ResourceGroup"), - Type: to.Ptr(armcostmanagement.QueryColumnTypeDimension), - }}, - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheLastMonth), - }, 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.QueryResult = armcostmanagement.QueryResult{ - // Name: to.Ptr("55312978-ba1b-415c-9304-cfd9c43c0481"), - // Type: to.Ptr("microsoft.costmanagement/Query"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/Query/00000000-0000-0000-0000-000000000000"), - // Properties: &armcostmanagement.QueryProperties{ - // Columns: []*armcostmanagement.QueryColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("ResourceGroup"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(0.009865586851323632), - // "Ict_StratAndPlan_GoldSprova_Prod_0", - // "USD"}, - // []any{ - // float64(218.68795741935486), - // "Ict_StratAndPlan_GoldSprova_Prod_1", - // "USD"}, - // []any{ - // float64(2.10333307059661), - // "ScreenSharingTest-peer1", - // "USD"}, - // []any{ - // float64(0.14384913581657052), - // "Ssbciotelement01", - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExternalBillingAccountsQuery.json -func ExampleQueryClient_UsageByExternalCloudProviderType_externalBillingAccountQueryList() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQueryClient().UsageByExternalCloudProviderType(ctx, armcostmanagement.ExternalCloudProviderTypeExternalBillingAccounts, "100", armcostmanagement.QueryDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeUsage), - Dataset: &armcostmanagement.QueryDataset{ - Filter: &armcostmanagement.QueryFilter{ - And: []*armcostmanagement.QueryFilter{ - { - Or: []*armcostmanagement.QueryFilter{ - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("East US"), - to.Ptr("West Europe")}, - }, - }, - { - Tags: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("UAT"), - to.Ptr("Prod")}, - }, - }}, - }, - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("API")}, - }, - }}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - }, 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.QueryResult = armcostmanagement.QueryResult{ - // Name: to.Ptr("6dc7b06a-d90a-4df5-b655-ce6cf1c0814d"), - // Type: to.Ptr("Microsoft.CostManagement/query"), - // ID: to.Ptr("providers/Microsoft.CostManagement/externalBillingAccounts/100/query/6dc7b06a-d90a-4df5-b655-ce6cf1c0814d"), - // Properties: &armcostmanagement.QueryProperties{ - // Columns: []*armcostmanagement.QueryColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("ServiceName"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(0), - // "abc db", - // "USD"}, - // []any{ - // float64(30.2572751438), - // "abc compute cloud", - // "USD"}, - // []any{ - // float64(0.07675760200000002), - // "abc file system", - // "USD"}, - // []any{ - // float64(50.43096419040001), - // "abc elasticache", - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExternalSubscriptionsQuery.json -func ExampleQueryClient_UsageByExternalCloudProviderType_externalSubscriptionsQuery() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQueryClient().UsageByExternalCloudProviderType(ctx, armcostmanagement.ExternalCloudProviderTypeExternalSubscriptions, "100", armcostmanagement.QueryDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeUsage), - Dataset: &armcostmanagement.QueryDataset{ - Filter: &armcostmanagement.QueryFilter{ - And: []*armcostmanagement.QueryFilter{ - { - Or: []*armcostmanagement.QueryFilter{ - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("East US"), - to.Ptr("West Europe")}, - }, - }, - { - Tags: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("UAT"), - to.Ptr("Prod")}, - }, - }}, - }, - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("API")}, - }, - }}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - }, 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.QueryResult = armcostmanagement.QueryResult{ - // Name: to.Ptr("d99477af-7510-40ee-aca2-e59bdca0d10d"), - // Type: to.Ptr("Microsoft.CostManagement/query"), - // ID: to.Ptr("providers/Microsoft.CostManagement/externalSubscriptions/100/query/d99477af-7510-40ee-aca2-e59bdca0d10d"), - // Properties: &armcostmanagement.QueryProperties{ - // Columns: []*armcostmanagement.QueryColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("UsageDate"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // }, - // }, - // } -} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/response_types.go b/sdk/resourcemanager/costmanagement/armcostmanagement/responses.go similarity index 64% rename from sdk/resourcemanager/costmanagement/armcostmanagement/response_types.go rename to sdk/resourcemanager/costmanagement/armcostmanagement/responses.go index 009ad137fe76..18b1f388fac5 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/response_types.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/responses.go @@ -62,6 +62,59 @@ type BenefitUtilizationSummariesClientListBySavingsPlanOrderResponse struct { BenefitUtilizationSummariesListResult } +// BudgetsClientCreateOrUpdateResponse contains the response from method BudgetsClient.CreateOrUpdate. +type BudgetsClientCreateOrUpdateResponse struct { + // A budget resource. + Budget +} + +// BudgetsClientDeleteResponse contains the response from method BudgetsClient.Delete. +type BudgetsClientDeleteResponse struct { + // placeholder for future response values +} + +// BudgetsClientGetResponse contains the response from method BudgetsClient.Get. +type BudgetsClientGetResponse struct { + // A budget resource. + Budget +} + +// BudgetsClientListResponse contains the response from method BudgetsClient.NewListPager. +type BudgetsClientListResponse struct { + // Result of listing budgets. It contains a list of available budgets in the scope provided. + BudgetsListResult +} + +// CostAllocationRulesClientCheckNameAvailabilityResponse contains the response from method CostAllocationRulesClient.CheckNameAvailability. +type CostAllocationRulesClientCheckNameAvailabilityResponse struct { + // The cost allocation rule check name availability response + CostAllocationRuleCheckNameAvailabilityResponse +} + +// CostAllocationRulesClientCreateOrUpdateResponse contains the response from method CostAllocationRulesClient.CreateOrUpdate. +type CostAllocationRulesClientCreateOrUpdateResponse struct { + // The cost allocation rule model definition + CostAllocationRuleDefinition +} + +// CostAllocationRulesClientDeleteResponse contains the response from method CostAllocationRulesClient.Delete. +type CostAllocationRulesClientDeleteResponse struct { + // placeholder for future response values +} + +// CostAllocationRulesClientGetResponse contains the response from method CostAllocationRulesClient.Get. +type CostAllocationRulesClientGetResponse struct { + // The cost allocation rule model definition + CostAllocationRuleDefinition +} + +// CostAllocationRulesClientListResponse contains the response from method CostAllocationRulesClient.NewListPager. +type CostAllocationRulesClientListResponse struct { + // Result of listing cost allocation rules. It contains a list of available rules in the billing account or enterprise enrollment + // provided. + CostAllocationRuleList +} + // DimensionsClientByExternalCloudProviderTypeResponse contains the response from method DimensionsClient.NewByExternalCloudProviderTypePager. type DimensionsClientByExternalCloudProviderTypeResponse struct { // Result of listing dimensions. It contains a list of available dimensions. @@ -120,6 +173,48 @@ type ForecastClientUsageResponse struct { ForecastResult } +// GenerateBenefitUtilizationSummariesReportClientGenerateByBillingAccountResponse contains the response from method GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByBillingAccount. +type GenerateBenefitUtilizationSummariesReportClientGenerateByBillingAccountResponse struct { + // Status of a benefit utilization summaries report. Provides Async Benefit Utilization Summaries Request input, status, and + // report sas url. + BenefitUtilizationSummariesOperationStatus +} + +// GenerateBenefitUtilizationSummariesReportClientGenerateByBillingProfileResponse contains the response from method GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByBillingProfile. +type GenerateBenefitUtilizationSummariesReportClientGenerateByBillingProfileResponse struct { + // Status of a benefit utilization summaries report. Provides Async Benefit Utilization Summaries Request input, status, and + // report sas url. + BenefitUtilizationSummariesOperationStatus +} + +// GenerateBenefitUtilizationSummariesReportClientGenerateByReservationIDResponse contains the response from method GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByReservationID. +type GenerateBenefitUtilizationSummariesReportClientGenerateByReservationIDResponse struct { + // Status of a benefit utilization summaries report. Provides Async Benefit Utilization Summaries Request input, status, and + // report sas url. + BenefitUtilizationSummariesOperationStatus +} + +// GenerateBenefitUtilizationSummariesReportClientGenerateByReservationOrderIDResponse contains the response from method GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByReservationOrderID. +type GenerateBenefitUtilizationSummariesReportClientGenerateByReservationOrderIDResponse struct { + // Status of a benefit utilization summaries report. Provides Async Benefit Utilization Summaries Request input, status, and + // report sas url. + BenefitUtilizationSummariesOperationStatus +} + +// GenerateBenefitUtilizationSummariesReportClientGenerateBySavingsPlanIDResponse contains the response from method GenerateBenefitUtilizationSummariesReportClient.BeginGenerateBySavingsPlanID. +type GenerateBenefitUtilizationSummariesReportClientGenerateBySavingsPlanIDResponse struct { + // Status of a benefit utilization summaries report. Provides Async Benefit Utilization Summaries Request input, status, and + // report sas url. + BenefitUtilizationSummariesOperationStatus +} + +// GenerateBenefitUtilizationSummariesReportClientGenerateBySavingsPlanOrderIDResponse contains the response from method GenerateBenefitUtilizationSummariesReportClient.BeginGenerateBySavingsPlanOrderID. +type GenerateBenefitUtilizationSummariesReportClientGenerateBySavingsPlanOrderIDResponse struct { + // Status of a benefit utilization summaries report. Provides Async Benefit Utilization Summaries Request input, status, and + // report sas url. + BenefitUtilizationSummariesOperationStatus +} + // GenerateCostDetailsReportClientCreateOperationResponse contains the response from method GenerateCostDetailsReportClient.BeginCreateOperation. type GenerateCostDetailsReportClientCreateOperationResponse struct { // The result of the long running operation for cost details Api. @@ -168,14 +263,20 @@ type OperationsClientListResponse struct { OperationListResult } +// PriceSheetClientDownloadByBillingAccountResponse contains the response from method PriceSheetClient.BeginDownloadByBillingAccount. +type PriceSheetClientDownloadByBillingAccountResponse struct { + // The status of the long running operation. + OperationStatusAutoGenerated +} + // PriceSheetClientDownloadByBillingProfileResponse contains the response from method PriceSheetClient.BeginDownloadByBillingProfile. type PriceSheetClientDownloadByBillingProfileResponse struct { // The URL to download the generated report. - DownloadURL + PricesheetDownloadProperties } -// PriceSheetClientDownloadResponse contains the response from method PriceSheetClient.BeginDownload. -type PriceSheetClientDownloadResponse struct { +// PriceSheetClientDownloadByInvoiceResponse contains the response from method PriceSheetClient.BeginDownloadByInvoice. +type PriceSheetClientDownloadByInvoiceResponse struct { // The URL to download the generated report. DownloadURL } @@ -260,6 +361,49 @@ type ScheduledActionsClientRunResponse struct { // placeholder for future response values } +// SettingsClientCreateOrUpdateByScopeResponse contains the response from method SettingsClient.CreateOrUpdateByScope. +type SettingsClientCreateOrUpdateByScopeResponse struct { + // Setting definition. + SettingClassification +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SettingsClientCreateOrUpdateByScopeResponse. +func (s *SettingsClientCreateOrUpdateByScopeResponse) UnmarshalJSON(data []byte) error { + res, err := unmarshalSettingClassification(data) + if err != nil { + return err + } + s.SettingClassification = res + return nil +} + +// SettingsClientDeleteByScopeResponse contains the response from method SettingsClient.DeleteByScope. +type SettingsClientDeleteByScopeResponse struct { + // placeholder for future response values +} + +// SettingsClientGetByScopeResponse contains the response from method SettingsClient.GetByScope. +type SettingsClientGetByScopeResponse struct { + // Setting definition. + SettingClassification +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SettingsClientGetByScopeResponse. +func (s *SettingsClientGetByScopeResponse) UnmarshalJSON(data []byte) error { + res, err := unmarshalSettingClassification(data) + if err != nil { + return err + } + s.SettingClassification = res + return nil +} + +// SettingsClientListResponse contains the response from method SettingsClient.List. +type SettingsClientListResponse struct { + // Setting list result. It contains a list of settings. + SettingsListResult +} + // ViewsClientCreateOrUpdateByScopeResponse contains the response from method ViewsClient.CreateOrUpdateByScope. type ViewsClientCreateOrUpdateByScopeResponse struct { // States and configurations of Cost Analysis. diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/scheduledactions_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/scheduledactions_client.go index a0ae7cfc3ce5..1445ef1dd820 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/scheduledactions_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/scheduledactions_client.go @@ -43,7 +43,7 @@ func NewScheduledActionsClient(credential azcore.TokenCredential, options *arm.C // CheckNameAvailability - Checks availability and correctness of the name for a scheduled action. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - checkNameAvailabilityRequest - Scheduled action to be created or updated. // - options - ScheduledActionsClientCheckNameAvailabilityOptions contains the optional parameters for the ScheduledActionsClient.CheckNameAvailability // method. @@ -77,7 +77,7 @@ func (client *ScheduledActionsClient) checkNameAvailabilityCreateRequest(ctx con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, checkNameAvailabilityRequest); err != nil { @@ -99,7 +99,7 @@ func (client *ScheduledActionsClient) checkNameAvailabilityHandleResponse(resp * // scope. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - scope - The scope associated with scheduled action operations. This includes 'subscriptions/{subscriptionId}' for subscription // scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for // resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, @@ -151,7 +151,7 @@ func (client *ScheduledActionsClient) checkNameAvailabilityByScopeCreateRequest( return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, checkNameAvailabilityRequest); err != nil { @@ -172,7 +172,7 @@ func (client *ScheduledActionsClient) checkNameAvailabilityByScopeHandleResponse // CreateOrUpdate - Create or update a private scheduled action. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - name - Scheduled action name. // - scheduledAction - Scheduled action to be created or updated. // - options - ScheduledActionsClientCreateOrUpdateOptions contains the optional parameters for the ScheduledActionsClient.CreateOrUpdate @@ -211,12 +211,12 @@ func (client *ScheduledActionsClient) createOrUpdateCreateRequest(ctx context.Co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, scheduledAction); err != nil { return nil, err } @@ -235,7 +235,7 @@ func (client *ScheduledActionsClient) createOrUpdateHandleResponse(resp *http.Re // CreateOrUpdateByScope - Create or update a shared scheduled action within the given scope. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - scope - The scope associated with scheduled action operations. This includes 'subscriptions/{subscriptionId}' for subscription // scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for // resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, @@ -292,12 +292,12 @@ func (client *ScheduledActionsClient) createOrUpdateByScopeCreateRequest(ctx con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } - req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, scheduledAction); err != nil { return nil, err } @@ -316,7 +316,7 @@ func (client *ScheduledActionsClient) createOrUpdateByScopeHandleResponse(resp * // Delete - Delete a private scheduled action. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - name - Scheduled action name. // - options - ScheduledActionsClientDeleteOptions contains the optional parameters for the ScheduledActionsClient.Delete method. func (client *ScheduledActionsClient) Delete(ctx context.Context, name string, options *ScheduledActionsClientDeleteOptions) (ScheduledActionsClientDeleteResponse, error) { @@ -352,7 +352,7 @@ func (client *ScheduledActionsClient) deleteCreateRequest(ctx context.Context, n return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -361,7 +361,7 @@ func (client *ScheduledActionsClient) deleteCreateRequest(ctx context.Context, n // DeleteByScope - Delete a scheduled action within the given scope. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - scope - The scope associated with scheduled action operations. This includes 'subscriptions/{subscriptionId}' for subscription // scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for // resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, @@ -416,7 +416,7 @@ func (client *ScheduledActionsClient) deleteByScopeCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -425,7 +425,7 @@ func (client *ScheduledActionsClient) deleteByScopeCreateRequest(ctx context.Con // Get - Get the private scheduled action by name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - name - Scheduled action name. // - options - ScheduledActionsClientGetOptions contains the optional parameters for the ScheduledActionsClient.Get method. func (client *ScheduledActionsClient) Get(ctx context.Context, name string, options *ScheduledActionsClientGetOptions) (ScheduledActionsClientGetResponse, error) { @@ -462,7 +462,7 @@ func (client *ScheduledActionsClient) getCreateRequest(ctx context.Context, name return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -480,7 +480,7 @@ func (client *ScheduledActionsClient) getHandleResponse(resp *http.Response) (Sc // GetByScope - Get the shared scheduled action from the given scope by name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - scope - The scope associated with scheduled action operations. This includes 'subscriptions/{subscriptionId}' for subscription // scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for // resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, @@ -536,7 +536,7 @@ func (client *ScheduledActionsClient) getByScopeCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -553,7 +553,7 @@ func (client *ScheduledActionsClient) getByScopeHandleResponse(resp *http.Respon // NewListPager - List all private scheduled actions. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - options - ScheduledActionsClientListOptions contains the optional parameters for the ScheduledActionsClient.NewListPager // method. func (client *ScheduledActionsClient) NewListPager(options *ScheduledActionsClientListOptions) *runtime.Pager[ScheduledActionsClientListResponse] { @@ -587,10 +587,10 @@ func (client *ScheduledActionsClient) listCreateRequest(ctx context.Context, opt return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -607,7 +607,7 @@ func (client *ScheduledActionsClient) listHandleResponse(resp *http.Response) (S // NewListByScopePager - List all shared scheduled actions within the given scope. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - scope - The scope associated with scheduled action operations. This includes 'subscriptions/{subscriptionId}' for subscription // scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for // resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, @@ -659,10 +659,10 @@ func (client *ScheduledActionsClient) listByScopeCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -680,7 +680,7 @@ func (client *ScheduledActionsClient) listByScopeHandleResponse(resp *http.Respo // Run - Processes a private scheduled action. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - name - Scheduled action name. // - options - ScheduledActionsClientRunOptions contains the optional parameters for the ScheduledActionsClient.Run method. func (client *ScheduledActionsClient) Run(ctx context.Context, name string, options *ScheduledActionsClientRunOptions) (ScheduledActionsClientRunResponse, error) { @@ -716,7 +716,7 @@ func (client *ScheduledActionsClient) runCreateRequest(ctx context.Context, name return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -725,7 +725,7 @@ func (client *ScheduledActionsClient) runCreateRequest(ctx context.Context, name // RunByScope - Runs a shared scheduled action within the given scope. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - scope - The scope associated with scheduled action operations. This includes 'subscriptions/{subscriptionId}' for subscription // scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for // resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, @@ -780,7 +780,7 @@ func (client *ScheduledActionsClient) runByScopeCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/scheduledactions_client_example_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/scheduledactions_client_example_test.go deleted file mode 100644 index 18a8a499ea74..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/scheduledactions_client_example_test.go +++ /dev/null @@ -1,899 +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 armcostmanagement_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/costmanagement/armcostmanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledActions-list-private.json -func ExampleScheduledActionsClient_NewListPager_privateScheduledActionsList() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewScheduledActionsClient().NewListPager(&armcostmanagement.ScheduledActionsClientListOptions{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.ScheduledActionListResult = armcostmanagement.ScheduledActionListResult{ - // Value: []*armcostmanagement.ScheduledAction{ - // { - // Name: to.Ptr("monthlyCostByResource"), - // Type: to.Ptr("Microsoft.CostManagement/ScheduledActions"), - // ID: to.Ptr("providers/Microsoft.CostManagement/scheduledActions/monthlyCostByResource"), - // ETag: to.Ptr("\"1d4ff9fe66f1d10\""), - // Kind: to.Ptr(armcostmanagement.ScheduledActionKindEmail), - // SystemData: &armcostmanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.128Z"); return t}()), - // CreatedBy: to.Ptr("testuser"), - // CreatedByType: to.Ptr(armcostmanagement.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.128Z"); return t}()), - // LastModifiedBy: to.Ptr("testuser"), - // LastModifiedByType: to.Ptr(armcostmanagement.CreatedByTypeUser), - // }, - // Properties: &armcostmanagement.ScheduledActionProperties{ - // DisplayName: to.Ptr("Monthly Cost By Resource"), - // Notification: &armcostmanagement.NotificationProperties{ - // Subject: to.Ptr("Cost by resource this month"), - // To: []*string{ - // to.Ptr("user@gmail.com"), - // to.Ptr("team@gmail.com")}, - // }, - // Schedule: &armcostmanagement.ScheduleProperties{ - // DaysOfWeek: []*armcostmanagement.DaysOfWeek{ - // to.Ptr(armcostmanagement.DaysOfWeekMonday)}, - // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-19T22:21:51.128Z"); return t}()), - // Frequency: to.Ptr(armcostmanagement.ScheduleFrequencyMonthly), - // HourOfDay: to.Ptr[int32](10), - // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-19T22:21:51.128Z"); return t}()), - // WeeksOfMonth: []*armcostmanagement.WeeksOfMonth{ - // to.Ptr(armcostmanagement.WeeksOfMonthFirst), - // to.Ptr(armcostmanagement.WeeksOfMonthThird)}, - // }, - // Scope: to.Ptr(""), - // Status: to.Ptr(armcostmanagement.ScheduledActionStatusEnabled), - // ViewID: to.Ptr("/providers/Microsoft.CostManagement/views/swaggerExample"), - // }, - // }, - // { - // Name: to.Ptr("dailyCostByResource"), - // Type: to.Ptr("Microsoft.CostManagement/ScheduledActions"), - // ID: to.Ptr("providers/Microsoft.CostManagement/scheduledActions/dailyCostByResource"), - // ETag: to.Ptr("\"1d4ff9fe66f1d15\""), - // Kind: to.Ptr(armcostmanagement.ScheduledActionKindEmail), - // SystemData: &armcostmanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.128Z"); return t}()), - // CreatedBy: to.Ptr("testuser"), - // CreatedByType: to.Ptr(armcostmanagement.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.128Z"); return t}()), - // LastModifiedBy: to.Ptr("testuser"), - // LastModifiedByType: to.Ptr(armcostmanagement.CreatedByTypeUser), - // }, - // Properties: &armcostmanagement.ScheduledActionProperties{ - // DisplayName: to.Ptr("Daily Cost By Resource"), - // Notification: &armcostmanagement.NotificationProperties{ - // Subject: to.Ptr("Daily Cost By Resource"), - // To: []*string{ - // to.Ptr("user@gmail.com"), - // to.Ptr("team@gmail.com")}, - // }, - // Schedule: &armcostmanagement.ScheduleProperties{ - // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-19T22:21:51.128Z"); return t}()), - // Frequency: to.Ptr(armcostmanagement.ScheduleFrequencyDaily), - // HourOfDay: to.Ptr[int32](12), - // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-19T22:21:51.128Z"); return t}()), - // }, - // Scope: to.Ptr(""), - // Status: to.Ptr(armcostmanagement.ScheduledActionStatusDisabled), - // ViewID: to.Ptr("/providers/Microsoft.CostManagement/views/swaggerExample"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledActions-listWithFilter-private.json -func ExampleScheduledActionsClient_NewListPager_privateScheduledActionsListFilterByViewId() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewScheduledActionsClient().NewListPager(&armcostmanagement.ScheduledActionsClientListOptions{Filter: to.Ptr("properties/viewId eq '/providers/Microsoft.CostManagement/views/swaggerExample'")}) - 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.ScheduledActionListResult = armcostmanagement.ScheduledActionListResult{ - // Value: []*armcostmanagement.ScheduledAction{ - // { - // Name: to.Ptr("monthlyCostByResource"), - // Type: to.Ptr("Microsoft.CostManagement/ScheduledActions"), - // ID: to.Ptr("providers/Microsoft.CostManagement/scheduledActions/monthlyCostByResource"), - // ETag: to.Ptr("\"1d4ff9fe66f1d10\""), - // Kind: to.Ptr(armcostmanagement.ScheduledActionKindEmail), - // SystemData: &armcostmanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.128Z"); return t}()), - // CreatedBy: to.Ptr("testuser"), - // CreatedByType: to.Ptr(armcostmanagement.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.128Z"); return t}()), - // LastModifiedBy: to.Ptr("testuser"), - // LastModifiedByType: to.Ptr(armcostmanagement.CreatedByTypeUser), - // }, - // Properties: &armcostmanagement.ScheduledActionProperties{ - // DisplayName: to.Ptr("Monthly Cost By Resource"), - // Notification: &armcostmanagement.NotificationProperties{ - // Subject: to.Ptr("Cost by resource this month"), - // To: []*string{ - // to.Ptr("user@gmail.com"), - // to.Ptr("team@gmail.com")}, - // }, - // Schedule: &armcostmanagement.ScheduleProperties{ - // DaysOfWeek: []*armcostmanagement.DaysOfWeek{ - // to.Ptr(armcostmanagement.DaysOfWeekMonday)}, - // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-19T22:21:51.128Z"); return t}()), - // Frequency: to.Ptr(armcostmanagement.ScheduleFrequencyMonthly), - // HourOfDay: to.Ptr[int32](10), - // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-19T22:21:51.128Z"); return t}()), - // WeeksOfMonth: []*armcostmanagement.WeeksOfMonth{ - // to.Ptr(armcostmanagement.WeeksOfMonthFirst), - // to.Ptr(armcostmanagement.WeeksOfMonthThird)}, - // }, - // Scope: to.Ptr(""), - // Status: to.Ptr(armcostmanagement.ScheduledActionStatusEnabled), - // ViewID: to.Ptr("/providers/Microsoft.CostManagement/views/swaggerExample"), - // }, - // }, - // { - // Name: to.Ptr("dailyCostByResource"), - // Type: to.Ptr("Microsoft.CostManagement/ScheduledActions"), - // ID: to.Ptr("providers/Microsoft.CostManagement/scheduledActions/dailyCostByResource"), - // ETag: to.Ptr("\"1d4ff9fe66f1d15\""), - // Kind: to.Ptr(armcostmanagement.ScheduledActionKindEmail), - // SystemData: &armcostmanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.128Z"); return t}()), - // CreatedBy: to.Ptr("testuser"), - // CreatedByType: to.Ptr(armcostmanagement.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.128Z"); return t}()), - // LastModifiedBy: to.Ptr("testuser"), - // LastModifiedByType: to.Ptr(armcostmanagement.CreatedByTypeUser), - // }, - // Properties: &armcostmanagement.ScheduledActionProperties{ - // DisplayName: to.Ptr("Daily Cost By Resource"), - // Notification: &armcostmanagement.NotificationProperties{ - // Subject: to.Ptr("Daily Cost By Resource"), - // To: []*string{ - // to.Ptr("user@gmail.com"), - // to.Ptr("team@gmail.com")}, - // }, - // Schedule: &armcostmanagement.ScheduleProperties{ - // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-19T22:21:51.128Z"); return t}()), - // Frequency: to.Ptr(armcostmanagement.ScheduleFrequencyDaily), - // HourOfDay: to.Ptr[int32](12), - // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-19T22:21:51.128Z"); return t}()), - // }, - // Scope: to.Ptr(""), - // Status: to.Ptr(armcostmanagement.ScheduledActionStatusDisabled), - // ViewID: to.Ptr("/providers/Microsoft.CostManagement/views/swaggerExample"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledActions-list-shared.json -func ExampleScheduledActionsClient_NewListByScopePager_scheduledActionsListByScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewScheduledActionsClient().NewListByScopePager("subscriptions/00000000-0000-0000-0000-000000000000", &armcostmanagement.ScheduledActionsClientListByScopeOptions{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.ScheduledActionListResult = armcostmanagement.ScheduledActionListResult{ - // Value: []*armcostmanagement.ScheduledAction{ - // { - // Name: to.Ptr("monthlyCostByResource"), - // Type: to.Ptr("Microsoft.CostManagement/ScheduledActions"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/scheduledActions/monthlyCostByResource"), - // ETag: to.Ptr("\"1d4ff9fe66f1d10\""), - // Kind: to.Ptr(armcostmanagement.ScheduledActionKindEmail), - // SystemData: &armcostmanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.128Z"); return t}()), - // CreatedBy: to.Ptr("testuser"), - // CreatedByType: to.Ptr(armcostmanagement.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.128Z"); return t}()), - // LastModifiedBy: to.Ptr("testuser"), - // LastModifiedByType: to.Ptr(armcostmanagement.CreatedByTypeUser), - // }, - // Properties: &armcostmanagement.ScheduledActionProperties{ - // DisplayName: to.Ptr("Monthly Cost By Resource"), - // Notification: &armcostmanagement.NotificationProperties{ - // Subject: to.Ptr("Cost by resource this month"), - // To: []*string{ - // to.Ptr("user@gmail.com"), - // to.Ptr("team@gmail.com")}, - // }, - // Schedule: &armcostmanagement.ScheduleProperties{ - // DaysOfWeek: []*armcostmanagement.DaysOfWeek{ - // to.Ptr(armcostmanagement.DaysOfWeekMonday)}, - // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-19T22:21:51.128Z"); return t}()), - // Frequency: to.Ptr(armcostmanagement.ScheduleFrequencyMonthly), - // HourOfDay: to.Ptr[int32](10), - // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-19T22:21:51.128Z"); return t}()), - // WeeksOfMonth: []*armcostmanagement.WeeksOfMonth{ - // to.Ptr(armcostmanagement.WeeksOfMonthFirst), - // to.Ptr(armcostmanagement.WeeksOfMonthThird)}, - // }, - // Scope: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000"), - // Status: to.Ptr(armcostmanagement.ScheduledActionStatusEnabled), - // ViewID: to.Ptr("/providers/Microsoft.CostManagement/views/swaggerExample"), - // }, - // }, - // { - // Name: to.Ptr("dailyCostByResource"), - // Type: to.Ptr("Microsoft.CostManagement/ScheduledActions"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/scheduledActions/dailyCostByResource"), - // ETag: to.Ptr("\"1d4ff9fe66f1d15\""), - // Kind: to.Ptr(armcostmanagement.ScheduledActionKindEmail), - // SystemData: &armcostmanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.128Z"); return t}()), - // CreatedBy: to.Ptr("testuser"), - // CreatedByType: to.Ptr(armcostmanagement.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.128Z"); return t}()), - // LastModifiedBy: to.Ptr("testuser"), - // LastModifiedByType: to.Ptr(armcostmanagement.CreatedByTypeUser), - // }, - // Properties: &armcostmanagement.ScheduledActionProperties{ - // DisplayName: to.Ptr("Daily Cost By Resource"), - // Notification: &armcostmanagement.NotificationProperties{ - // Subject: to.Ptr("Daily Cost By Resource"), - // To: []*string{ - // to.Ptr("user@gmail.com"), - // to.Ptr("team@gmail.com")}, - // }, - // Schedule: &armcostmanagement.ScheduleProperties{ - // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-19T22:21:51.128Z"); return t}()), - // Frequency: to.Ptr(armcostmanagement.ScheduleFrequencyDaily), - // HourOfDay: to.Ptr[int32](12), - // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-19T22:21:51.128Z"); return t}()), - // }, - // Scope: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000"), - // Status: to.Ptr(armcostmanagement.ScheduledActionStatusDisabled), - // ViewID: to.Ptr("/providers/Microsoft.CostManagement/views/swaggerExample"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledActions-listWithFilter-shared.json -func ExampleScheduledActionsClient_NewListByScopePager_scheduledActionsListByScopeFilterByViewId() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewScheduledActionsClient().NewListByScopePager("subscriptions/00000000-0000-0000-0000-000000000000", &armcostmanagement.ScheduledActionsClientListByScopeOptions{Filter: to.Ptr("properties/viewId eq '/providers/Microsoft.CostManagement/views/swaggerExample'")}) - 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.ScheduledActionListResult = armcostmanagement.ScheduledActionListResult{ - // Value: []*armcostmanagement.ScheduledAction{ - // { - // Name: to.Ptr("monthlyCostByResource"), - // Type: to.Ptr("Microsoft.CostManagement/ScheduledActions"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/scheduledActions/monthlyCostByResource"), - // ETag: to.Ptr("\"1d4ff9fe66f1d10\""), - // Kind: to.Ptr(armcostmanagement.ScheduledActionKindEmail), - // SystemData: &armcostmanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.128Z"); return t}()), - // CreatedBy: to.Ptr("testuser"), - // CreatedByType: to.Ptr(armcostmanagement.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.128Z"); return t}()), - // LastModifiedBy: to.Ptr("testuser"), - // LastModifiedByType: to.Ptr(armcostmanagement.CreatedByTypeUser), - // }, - // Properties: &armcostmanagement.ScheduledActionProperties{ - // DisplayName: to.Ptr("Monthly Cost By Resource"), - // Notification: &armcostmanagement.NotificationProperties{ - // Subject: to.Ptr("Cost by resource this month"), - // To: []*string{ - // to.Ptr("user@gmail.com"), - // to.Ptr("team@gmail.com")}, - // }, - // Schedule: &armcostmanagement.ScheduleProperties{ - // DaysOfWeek: []*armcostmanagement.DaysOfWeek{ - // to.Ptr(armcostmanagement.DaysOfWeekMonday)}, - // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-19T22:21:51.128Z"); return t}()), - // Frequency: to.Ptr(armcostmanagement.ScheduleFrequencyMonthly), - // HourOfDay: to.Ptr[int32](10), - // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-19T22:21:51.128Z"); return t}()), - // WeeksOfMonth: []*armcostmanagement.WeeksOfMonth{ - // to.Ptr(armcostmanagement.WeeksOfMonthFirst), - // to.Ptr(armcostmanagement.WeeksOfMonthThird)}, - // }, - // Scope: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000"), - // Status: to.Ptr(armcostmanagement.ScheduledActionStatusEnabled), - // ViewID: to.Ptr("/providers/Microsoft.CostManagement/views/swaggerExample"), - // }, - // }, - // { - // Name: to.Ptr("dailyCostByResource"), - // Type: to.Ptr("Microsoft.CostManagement/ScheduledActions"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/scheduledActions/dailyCostByResource"), - // ETag: to.Ptr("\"1d4ff9fe66f1d15\""), - // Kind: to.Ptr(armcostmanagement.ScheduledActionKindEmail), - // SystemData: &armcostmanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.128Z"); return t}()), - // CreatedBy: to.Ptr("testuser"), - // CreatedByType: to.Ptr(armcostmanagement.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.128Z"); return t}()), - // LastModifiedBy: to.Ptr("testuser"), - // LastModifiedByType: to.Ptr(armcostmanagement.CreatedByTypeUser), - // }, - // Properties: &armcostmanagement.ScheduledActionProperties{ - // DisplayName: to.Ptr("Daily Cost By Resource"), - // Notification: &armcostmanagement.NotificationProperties{ - // Subject: to.Ptr("Daily Cost By Resource"), - // To: []*string{ - // to.Ptr("user@gmail.com"), - // to.Ptr("team@gmail.com")}, - // }, - // Schedule: &armcostmanagement.ScheduleProperties{ - // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-19T22:21:51.128Z"); return t}()), - // Frequency: to.Ptr(armcostmanagement.ScheduleFrequencyDaily), - // HourOfDay: to.Ptr[int32](12), - // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-19T22:21:51.128Z"); return t}()), - // }, - // Scope: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000"), - // Status: to.Ptr(armcostmanagement.ScheduledActionStatusDisabled), - // ViewID: to.Ptr("/providers/Microsoft.CostManagement/views/swaggerExample"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledAction-createOrUpdate-private.json -func ExampleScheduledActionsClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewScheduledActionsClient().CreateOrUpdate(ctx, "monthlyCostByResource", armcostmanagement.ScheduledAction{ - Kind: to.Ptr(armcostmanagement.ScheduledActionKindEmail), - Properties: &armcostmanagement.ScheduledActionProperties{ - DisplayName: to.Ptr("Monthly Cost By Resource"), - Notification: &armcostmanagement.NotificationProperties{ - Subject: to.Ptr("Cost by resource this month"), - To: []*string{ - to.Ptr("user@gmail.com"), - to.Ptr("team@gmail.com")}, - }, - Schedule: &armcostmanagement.ScheduleProperties{ - DaysOfWeek: []*armcostmanagement.DaysOfWeek{ - to.Ptr(armcostmanagement.DaysOfWeekMonday)}, - EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-19T22:21:51.128Z"); return t }()), - Frequency: to.Ptr(armcostmanagement.ScheduleFrequencyMonthly), - HourOfDay: to.Ptr[int32](10), - StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-19T22:21:51.128Z"); return t }()), - WeeksOfMonth: []*armcostmanagement.WeeksOfMonth{ - to.Ptr(armcostmanagement.WeeksOfMonthFirst), - to.Ptr(armcostmanagement.WeeksOfMonthThird)}, - }, - Status: to.Ptr(armcostmanagement.ScheduledActionStatusEnabled), - ViewID: to.Ptr("/providers/Microsoft.CostManagement/views/swaggerExample"), - }, - }, &armcostmanagement.ScheduledActionsClientCreateOrUpdateOptions{IfMatch: to.Ptr("")}) - 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.ScheduledAction = armcostmanagement.ScheduledAction{ - // Name: to.Ptr("monthlyCostByResource"), - // Type: to.Ptr("Microsoft.CostManagement/ScheduledActions"), - // ID: to.Ptr("providers/Microsoft.CostManagement/scheduledActions/monthlyCostByResource"), - // ETag: to.Ptr("\"1d4ff9fe66f1d10\""), - // Kind: to.Ptr(armcostmanagement.ScheduledActionKindEmail), - // SystemData: &armcostmanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.128Z"); return t}()), - // CreatedBy: to.Ptr("testuser"), - // CreatedByType: to.Ptr(armcostmanagement.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-19T22:21:51.128Z"); return t}()), - // LastModifiedBy: to.Ptr("testuser"), - // LastModifiedByType: to.Ptr(armcostmanagement.CreatedByTypeUser), - // }, - // Properties: &armcostmanagement.ScheduledActionProperties{ - // DisplayName: to.Ptr("Monthly Cost By Resource"), - // Notification: &armcostmanagement.NotificationProperties{ - // RegionalFormat: to.Ptr("fr"), - // Subject: to.Ptr("Cost by resource this month"), - // To: []*string{ - // to.Ptr("user@gmail.com"), - // to.Ptr("team@gmail.com")}, - // Language: to.Ptr("fr"), - // }, - // Schedule: &armcostmanagement.ScheduleProperties{ - // DaysOfWeek: []*armcostmanagement.DaysOfWeek{ - // to.Ptr(armcostmanagement.DaysOfWeekMonday)}, - // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-19T22:21:51.128Z"); return t}()), - // Frequency: to.Ptr(armcostmanagement.ScheduleFrequencyMonthly), - // HourOfDay: to.Ptr[int32](10), - // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-19T22:21:51.128Z"); return t}()), - // WeeksOfMonth: []*armcostmanagement.WeeksOfMonth{ - // to.Ptr(armcostmanagement.WeeksOfMonthFirst), - // to.Ptr(armcostmanagement.WeeksOfMonthThird)}, - // }, - // Scope: to.Ptr(""), - // Status: to.Ptr(armcostmanagement.ScheduledActionStatusEnabled), - // ViewID: to.Ptr("/providers/Microsoft.CostManagement/views/swaggerExample"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledAction-get-private.json -func ExampleScheduledActionsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewScheduledActionsClient().Get(ctx, "monthlyCostByResource", 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.ScheduledAction = armcostmanagement.ScheduledAction{ - // Name: to.Ptr("monthlyCostByResource"), - // Type: to.Ptr("Microsoft.CostManagement/ScheduledActions"), - // ID: to.Ptr("providers/Microsoft.CostManagement/scheduledActions/monthlyCostByResource"), - // ETag: to.Ptr("\"1d4ff9fe66f1d10\""), - // Kind: to.Ptr(armcostmanagement.ScheduledActionKindEmail), - // SystemData: &armcostmanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.128Z"); return t}()), - // CreatedBy: to.Ptr("testuser"), - // CreatedByType: to.Ptr(armcostmanagement.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.128Z"); return t}()), - // LastModifiedBy: to.Ptr("testuser"), - // LastModifiedByType: to.Ptr(armcostmanagement.CreatedByTypeUser), - // }, - // Properties: &armcostmanagement.ScheduledActionProperties{ - // DisplayName: to.Ptr("Monthly Cost By Resource"), - // Notification: &armcostmanagement.NotificationProperties{ - // Subject: to.Ptr("Cost by resource this month"), - // To: []*string{ - // to.Ptr("user@gmail.com"), - // to.Ptr("team@gmail.com")}, - // }, - // Schedule: &armcostmanagement.ScheduleProperties{ - // DaysOfWeek: []*armcostmanagement.DaysOfWeek{ - // to.Ptr(armcostmanagement.DaysOfWeekMonday)}, - // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-19T22:21:51.128Z"); return t}()), - // Frequency: to.Ptr(armcostmanagement.ScheduleFrequencyMonthly), - // HourOfDay: to.Ptr[int32](10), - // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-19T22:21:51.128Z"); return t}()), - // WeeksOfMonth: []*armcostmanagement.WeeksOfMonth{ - // to.Ptr(armcostmanagement.WeeksOfMonthFirst), - // to.Ptr(armcostmanagement.WeeksOfMonthThird)}, - // }, - // Scope: to.Ptr(""), - // Status: to.Ptr(armcostmanagement.ScheduledActionStatusEnabled), - // ViewID: to.Ptr("/providers/Microsoft.CostManagement/views/swaggerExample"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledAction-delete-private.json -func ExampleScheduledActionsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewScheduledActionsClient().Delete(ctx, "monthlyCostByResource", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledAction-insightAlert-createOrUpdate-shared.json -func ExampleScheduledActionsClient_CreateOrUpdateByScope_createOrUpdateInsightAlertScheduledActionByScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewScheduledActionsClient().CreateOrUpdateByScope(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", "dailyAnomalyByResource", armcostmanagement.ScheduledAction{ - Kind: to.Ptr(armcostmanagement.ScheduledActionKindInsightAlert), - Properties: &armcostmanagement.ScheduledActionProperties{ - DisplayName: to.Ptr("Daily anomaly by resource"), - Notification: &armcostmanagement.NotificationProperties{ - Subject: to.Ptr("Cost anomaly detected in the resource"), - To: []*string{ - to.Ptr("user@gmail.com"), - to.Ptr("team@gmail.com")}, - }, - Schedule: &armcostmanagement.ScheduleProperties{ - EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-19T22:21:51.128Z"); return t }()), - Frequency: to.Ptr(armcostmanagement.ScheduleFrequencyDaily), - StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-19T22:21:51.128Z"); return t }()), - }, - Status: to.Ptr(armcostmanagement.ScheduledActionStatusEnabled), - ViewID: to.Ptr("/providers/Microsoft.CostManagement/views/swaggerExample"), - }, - }, &armcostmanagement.ScheduledActionsClientCreateOrUpdateByScopeOptions{IfMatch: to.Ptr("")}) - 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.ScheduledAction = armcostmanagement.ScheduledAction{ - // Name: to.Ptr("dailyAnomalyByResource"), - // Type: to.Ptr("Microsoft.CostManagement/ScheduledActions"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/scheduledActions/dailyAnomalyByResource"), - // ETag: to.Ptr("\"1d4ff9fe66f1d10\""), - // Kind: to.Ptr(armcostmanagement.ScheduledActionKindInsightAlert), - // SystemData: &armcostmanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.128Z"); return t}()), - // CreatedBy: to.Ptr("testuser"), - // CreatedByType: to.Ptr(armcostmanagement.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-19T22:21:51.128Z"); return t}()), - // LastModifiedBy: to.Ptr("testuser"), - // LastModifiedByType: to.Ptr(armcostmanagement.CreatedByTypeUser), - // }, - // Properties: &armcostmanagement.ScheduledActionProperties{ - // DisplayName: to.Ptr("Daily anomaly by resource"), - // FileDestination: &armcostmanagement.FileDestination{ - // FileFormats: []*armcostmanagement.FileFormat{ - // }, - // }, - // Notification: &armcostmanagement.NotificationProperties{ - // Subject: to.Ptr("Cost anomaly detected in the resource"), - // To: []*string{ - // to.Ptr("user@gmail.com"), - // to.Ptr("team@gmail.com")}, - // }, - // Schedule: &armcostmanagement.ScheduleProperties{ - // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-19T22:21:51.128Z"); return t}()), - // Frequency: to.Ptr(armcostmanagement.ScheduleFrequencyDaily), - // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-19T22:21:51.128Z"); return t}()), - // }, - // Scope: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000"), - // Status: to.Ptr(armcostmanagement.ScheduledActionStatusEnabled), - // ViewID: to.Ptr("/providers/Microsoft.CostManagement/views/swaggerExample"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledAction-createOrUpdate-shared.json -func ExampleScheduledActionsClient_CreateOrUpdateByScope_createOrUpdateScheduledActionByScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewScheduledActionsClient().CreateOrUpdateByScope(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", "monthlyCostByResource", armcostmanagement.ScheduledAction{ - Kind: to.Ptr(armcostmanagement.ScheduledActionKindEmail), - Properties: &armcostmanagement.ScheduledActionProperties{ - DisplayName: to.Ptr("Monthly Cost By Resource"), - FileDestination: &armcostmanagement.FileDestination{ - FileFormats: []*armcostmanagement.FileFormat{ - to.Ptr(armcostmanagement.FileFormatCSV)}, - }, - Notification: &armcostmanagement.NotificationProperties{ - Subject: to.Ptr("Cost by resource this month"), - To: []*string{ - to.Ptr("user@gmail.com"), - to.Ptr("team@gmail.com")}, - }, - Schedule: &armcostmanagement.ScheduleProperties{ - DaysOfWeek: []*armcostmanagement.DaysOfWeek{ - to.Ptr(armcostmanagement.DaysOfWeekMonday)}, - EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-19T22:21:51.128Z"); return t }()), - Frequency: to.Ptr(armcostmanagement.ScheduleFrequencyMonthly), - HourOfDay: to.Ptr[int32](10), - StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-19T22:21:51.128Z"); return t }()), - WeeksOfMonth: []*armcostmanagement.WeeksOfMonth{ - to.Ptr(armcostmanagement.WeeksOfMonthFirst), - to.Ptr(armcostmanagement.WeeksOfMonthThird)}, - }, - Status: to.Ptr(armcostmanagement.ScheduledActionStatusEnabled), - ViewID: to.Ptr("/providers/Microsoft.CostManagement/views/swaggerExample"), - }, - }, &armcostmanagement.ScheduledActionsClientCreateOrUpdateByScopeOptions{IfMatch: to.Ptr("")}) - 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.ScheduledAction = armcostmanagement.ScheduledAction{ - // Name: to.Ptr("monthlyCostByResource"), - // Type: to.Ptr("Microsoft.CostManagement/ScheduledActions"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/scheduledActions/monthlyCostByResource"), - // ETag: to.Ptr("\"1d4ff9fe66f1d10\""), - // Kind: to.Ptr(armcostmanagement.ScheduledActionKindEmail), - // SystemData: &armcostmanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.128Z"); return t}()), - // CreatedBy: to.Ptr("testuser"), - // CreatedByType: to.Ptr(armcostmanagement.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-19T22:21:51.128Z"); return t}()), - // LastModifiedBy: to.Ptr("testuser"), - // LastModifiedByType: to.Ptr(armcostmanagement.CreatedByTypeUser), - // }, - // Properties: &armcostmanagement.ScheduledActionProperties{ - // DisplayName: to.Ptr("Monthly Cost By Resource"), - // Notification: &armcostmanagement.NotificationProperties{ - // Subject: to.Ptr("Cost by resource this month"), - // To: []*string{ - // to.Ptr("user@gmail.com"), - // to.Ptr("team@gmail.com")}, - // }, - // Schedule: &armcostmanagement.ScheduleProperties{ - // DaysOfWeek: []*armcostmanagement.DaysOfWeek{ - // to.Ptr(armcostmanagement.DaysOfWeekMonday)}, - // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-19T22:21:51.128Z"); return t}()), - // Frequency: to.Ptr(armcostmanagement.ScheduleFrequencyMonthly), - // HourOfDay: to.Ptr[int32](10), - // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-19T22:21:51.128Z"); return t}()), - // WeeksOfMonth: []*armcostmanagement.WeeksOfMonth{ - // to.Ptr(armcostmanagement.WeeksOfMonthFirst), - // to.Ptr(armcostmanagement.WeeksOfMonthThird)}, - // }, - // Scope: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000"), - // Status: to.Ptr(armcostmanagement.ScheduledActionStatusEnabled), - // ViewID: to.Ptr("/providers/Microsoft.CostManagement/views/swaggerExample"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledAction-get-shared.json -func ExampleScheduledActionsClient_GetByScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewScheduledActionsClient().GetByScope(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", "monthlyCostByResource", 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.ScheduledAction = armcostmanagement.ScheduledAction{ - // Name: to.Ptr("monthlyCostByResource"), - // Type: to.Ptr("Microsoft.CostManagement/ScheduledActions"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/scheduledActions/monthlyCostByResource"), - // ETag: to.Ptr("\"1d4ff9fe66f1d10\""), - // Kind: to.Ptr(armcostmanagement.ScheduledActionKindEmail), - // SystemData: &armcostmanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.128Z"); return t}()), - // CreatedBy: to.Ptr("testuser"), - // CreatedByType: to.Ptr(armcostmanagement.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.128Z"); return t}()), - // LastModifiedBy: to.Ptr("testuser"), - // LastModifiedByType: to.Ptr(armcostmanagement.CreatedByTypeUser), - // }, - // Properties: &armcostmanagement.ScheduledActionProperties{ - // DisplayName: to.Ptr("Monthly Cost By Resource"), - // Notification: &armcostmanagement.NotificationProperties{ - // Subject: to.Ptr("Cost by resource this month"), - // To: []*string{ - // to.Ptr("user@gmail.com"), - // to.Ptr("team@gmail.com")}, - // }, - // Schedule: &armcostmanagement.ScheduleProperties{ - // DaysOfWeek: []*armcostmanagement.DaysOfWeek{ - // to.Ptr(armcostmanagement.DaysOfWeekMonday)}, - // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-19T22:21:51.128Z"); return t}()), - // Frequency: to.Ptr(armcostmanagement.ScheduleFrequencyMonthly), - // HourOfDay: to.Ptr[int32](10), - // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-19T22:21:51.128Z"); return t}()), - // WeeksOfMonth: []*armcostmanagement.WeeksOfMonth{ - // to.Ptr(armcostmanagement.WeeksOfMonthFirst), - // to.Ptr(armcostmanagement.WeeksOfMonthThird)}, - // }, - // Scope: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000"), - // Status: to.Ptr(armcostmanagement.ScheduledActionStatusEnabled), - // ViewID: to.Ptr("/providers/Microsoft.CostManagement/views/swaggerExample"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledAction-delete-shared.json -func ExampleScheduledActionsClient_DeleteByScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewScheduledActionsClient().DeleteByScope(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", "monthlyCostByResource", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledAction-sendNow-private.json -func ExampleScheduledActionsClient_Run() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewScheduledActionsClient().Run(ctx, "monthlyCostByResource", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledAction-sendNow-shared.json -func ExampleScheduledActionsClient_RunByScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewScheduledActionsClient().RunByScope(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", "monthlyCostByResource", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/checkNameAvailability-private-scheduledAction.json -func ExampleScheduledActionsClient_CheckNameAvailability() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewScheduledActionsClient().CheckNameAvailability(ctx, armcostmanagement.CheckNameAvailabilityRequest{ - Name: to.Ptr("testName"), - Type: to.Ptr("Microsoft.CostManagement/ScheduledActions"), - }, 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.CheckNameAvailabilityResponse = armcostmanagement.CheckNameAvailabilityResponse{ - // Message: to.Ptr("A private scheduled action with name 'testName' is already present. Please specify a differnt name."), - // NameAvailable: to.Ptr(false), - // Reason: to.Ptr(armcostmanagement.CheckNameAvailabilityReasonAlreadyExists), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/checkNameAvailability-shared-scheduledAction.json -func ExampleScheduledActionsClient_CheckNameAvailabilityByScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewScheduledActionsClient().CheckNameAvailabilityByScope(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", armcostmanagement.CheckNameAvailabilityRequest{ - Name: to.Ptr("testName"), - Type: to.Ptr("Microsoft.CostManagement/ScheduledActions"), - }, 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.CheckNameAvailabilityResponse = armcostmanagement.CheckNameAvailabilityResponse{ - // NameAvailable: to.Ptr(true), - // } -} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/settings_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/settings_client.go new file mode 100644 index 000000000000..fdc7f47fb0be --- /dev/null +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/settings_client.go @@ -0,0 +1,283 @@ +//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 armcostmanagement + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// SettingsClient contains the methods for the Settings group. +// Don't use this type directly, use NewSettingsClient() instead. +type SettingsClient struct { + internal *arm.Client +} + +// NewSettingsClient creates a new instance of SettingsClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewSettingsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*SettingsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &SettingsClient{ + internal: cl, + } + return client, nil +} + +// CreateOrUpdateByScope - Create or update a setting within the given scope. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +// - scope - The scope associated with this setting. This includes 'subscriptions/{subscriptionId}' for subscription scope, +// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account +// scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billing +// profile scope. +// - typeParam - Setting type. +// - setting - Setting to be created or updated. +// - options - SettingsClientCreateOrUpdateByScopeOptions contains the optional parameters for the SettingsClient.CreateOrUpdateByScope +// method. +func (client *SettingsClient) CreateOrUpdateByScope(ctx context.Context, scope string, typeParam SettingType, setting SettingClassification, options *SettingsClientCreateOrUpdateByScopeOptions) (SettingsClientCreateOrUpdateByScopeResponse, error) { + var err error + const operationName = "SettingsClient.CreateOrUpdateByScope" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateByScopeCreateRequest(ctx, scope, typeParam, setting, options) + if err != nil { + return SettingsClientCreateOrUpdateByScopeResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SettingsClientCreateOrUpdateByScopeResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return SettingsClientCreateOrUpdateByScopeResponse{}, err + } + resp, err := client.createOrUpdateByScopeHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateByScopeCreateRequest creates the CreateOrUpdateByScope request. +func (client *SettingsClient) createOrUpdateByScopeCreateRequest(ctx context.Context, scope string, typeParam SettingType, setting SettingClassification, options *SettingsClientCreateOrUpdateByScopeOptions) (*policy.Request, error) { + urlPath := "/{scope}/providers/Microsoft.CostManagement/settings/{type}" + if scope == "" { + return nil, errors.New("parameter scope cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scope}", url.PathEscape(scope)) + if typeParam == "" { + return nil, errors.New("parameter typeParam cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{type}", url.PathEscape(string(typeParam))) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, setting); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateByScopeHandleResponse handles the CreateOrUpdateByScope response. +func (client *SettingsClient) createOrUpdateByScopeHandleResponse(resp *http.Response) (SettingsClientCreateOrUpdateByScopeResponse, error) { + result := SettingsClientCreateOrUpdateByScopeResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result); err != nil { + return SettingsClientCreateOrUpdateByScopeResponse{}, err + } + return result, nil +} + +// DeleteByScope - Delete a setting within the given scope. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +// - scope - The scope associated with this setting. This includes 'subscriptions/{subscriptionId}' for subscription scope, +// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account +// scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billing +// profile scope. +// - typeParam - Setting type. +// - options - SettingsClientDeleteByScopeOptions contains the optional parameters for the SettingsClient.DeleteByScope method. +func (client *SettingsClient) DeleteByScope(ctx context.Context, scope string, typeParam SettingType, options *SettingsClientDeleteByScopeOptions) (SettingsClientDeleteByScopeResponse, error) { + var err error + const operationName = "SettingsClient.DeleteByScope" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteByScopeCreateRequest(ctx, scope, typeParam, options) + if err != nil { + return SettingsClientDeleteByScopeResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SettingsClientDeleteByScopeResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return SettingsClientDeleteByScopeResponse{}, err + } + return SettingsClientDeleteByScopeResponse{}, nil +} + +// deleteByScopeCreateRequest creates the DeleteByScope request. +func (client *SettingsClient) deleteByScopeCreateRequest(ctx context.Context, scope string, typeParam SettingType, options *SettingsClientDeleteByScopeOptions) (*policy.Request, error) { + urlPath := "/{scope}/providers/Microsoft.CostManagement/settings/{type}" + if scope == "" { + return nil, errors.New("parameter scope cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scope}", url.PathEscape(scope)) + if typeParam == "" { + return nil, errors.New("parameter typeParam cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{type}", url.PathEscape(string(typeParam))) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// GetByScope - Get the setting from the given scope by name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +// - scope - The scope associated with this setting. This includes 'subscriptions/{subscriptionId}' for subscription scope, +// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account +// scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billing +// profile scope. +// - typeParam - Setting type. +// - options - SettingsClientGetByScopeOptions contains the optional parameters for the SettingsClient.GetByScope method. +func (client *SettingsClient) GetByScope(ctx context.Context, scope string, typeParam SettingType, options *SettingsClientGetByScopeOptions) (SettingsClientGetByScopeResponse, error) { + var err error + const operationName = "SettingsClient.GetByScope" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getByScopeCreateRequest(ctx, scope, typeParam, options) + if err != nil { + return SettingsClientGetByScopeResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SettingsClientGetByScopeResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SettingsClientGetByScopeResponse{}, err + } + resp, err := client.getByScopeHandleResponse(httpResp) + return resp, err +} + +// getByScopeCreateRequest creates the GetByScope request. +func (client *SettingsClient) getByScopeCreateRequest(ctx context.Context, scope string, typeParam SettingType, options *SettingsClientGetByScopeOptions) (*policy.Request, error) { + urlPath := "/{scope}/providers/Microsoft.CostManagement/settings/{type}" + if scope == "" { + return nil, errors.New("parameter scope cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scope}", url.PathEscape(scope)) + if typeParam == "" { + return nil, errors.New("parameter typeParam cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{type}", url.PathEscape(string(typeParam))) + 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", "2023-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getByScopeHandleResponse handles the GetByScope response. +func (client *SettingsClient) getByScopeHandleResponse(resp *http.Response) (SettingsClientGetByScopeResponse, error) { + result := SettingsClientGetByScopeResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result); err != nil { + return SettingsClientGetByScopeResponse{}, err + } + return result, nil +} + +// List - List all cost management settings in the requested scope. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-01 +// - scope - The scope associated with this setting. This includes 'subscriptions/{subscriptionId}' for subscription scope, +// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account +// scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billing +// profile scope. +// - options - SettingsClientListOptions contains the optional parameters for the SettingsClient.List method. +func (client *SettingsClient) List(ctx context.Context, scope string, options *SettingsClientListOptions) (SettingsClientListResponse, error) { + var err error + const operationName = "SettingsClient.List" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.listCreateRequest(ctx, scope, options) + if err != nil { + return SettingsClientListResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SettingsClientListResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SettingsClientListResponse{}, err + } + resp, err := client.listHandleResponse(httpResp) + return resp, err +} + +// listCreateRequest creates the List request. +func (client *SettingsClient) listCreateRequest(ctx context.Context, scope string, options *SettingsClientListOptions) (*policy.Request, error) { + urlPath := "/{scope}/providers/Microsoft.CostManagement/settings" + if scope == "" { + return nil, errors.New("parameter scope cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{scope}", url.PathEscape(scope)) + 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", "2023-11-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *SettingsClient) listHandleResponse(resp *http.Response) (SettingsClientListResponse, error) { + result := SettingsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SettingsListResult); err != nil { + return SettingsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/time_rfc3339.go b/sdk/resourcemanager/costmanagement/armcostmanagement/time_rfc3339.go index 5d1c47a6e3ff..38e06a93e808 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/time_rfc3339.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/time_rfc3339.go @@ -19,12 +19,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 +44,33 @@ 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) { + 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/costmanagement/armcostmanagement/views_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/views_client.go index 1e79aee49dd2..d475172e9e43 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/views_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/views_client.go @@ -45,7 +45,7 @@ func NewViewsClient(credential azcore.TokenCredential, options *arm.ClientOption // require eTag. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - viewName - View name // - parameters - Parameters supplied to the CreateOrUpdate View operation. // - options - ViewsClientCreateOrUpdateOptions contains the optional parameters for the ViewsClient.CreateOrUpdate method. @@ -83,7 +83,7 @@ func (client *ViewsClient) createOrUpdateCreateRequest(ctx context.Context, view return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -106,7 +106,7 @@ func (client *ViewsClient) createOrUpdateHandleResponse(resp *http.Response) (Vi // require eTag. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - scope - The scope associated with view operations. This includes 'subscriptions/{subscriptionId}' for subscription scope, // 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup // scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' @@ -162,7 +162,7 @@ func (client *ViewsClient) createOrUpdateByScopeCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { @@ -183,7 +183,7 @@ func (client *ViewsClient) createOrUpdateByScopeHandleResponse(resp *http.Respon // Delete - The operation to delete a view. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - viewName - View name // - options - ViewsClientDeleteOptions contains the optional parameters for the ViewsClient.Delete method. func (client *ViewsClient) Delete(ctx context.Context, viewName string, options *ViewsClientDeleteOptions) (ViewsClientDeleteResponse, error) { @@ -219,7 +219,7 @@ func (client *ViewsClient) deleteCreateRequest(ctx context.Context, viewName str return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -228,7 +228,7 @@ func (client *ViewsClient) deleteCreateRequest(ctx context.Context, viewName str // DeleteByScope - The operation to delete a view. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - scope - The scope associated with view operations. This includes 'subscriptions/{subscriptionId}' for subscription scope, // 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup // scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' @@ -281,7 +281,7 @@ func (client *ViewsClient) deleteByScopeCreateRequest(ctx context.Context, scope return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -290,7 +290,7 @@ func (client *ViewsClient) deleteByScopeCreateRequest(ctx context.Context, scope // Get - Gets the view by view name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - viewName - View name // - options - ViewsClientGetOptions contains the optional parameters for the ViewsClient.Get method. func (client *ViewsClient) Get(ctx context.Context, viewName string, options *ViewsClientGetOptions) (ViewsClientGetResponse, error) { @@ -327,7 +327,7 @@ func (client *ViewsClient) getCreateRequest(ctx context.Context, viewName string return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -345,7 +345,7 @@ func (client *ViewsClient) getHandleResponse(resp *http.Response) (ViewsClientGe // GetByScope - Gets the view for the defined scope by view name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - scope - The scope associated with view operations. This includes 'subscriptions/{subscriptionId}' for subscription scope, // 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup // scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' @@ -399,7 +399,7 @@ func (client *ViewsClient) getByScopeCreateRequest(ctx context.Context, scope st return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -416,7 +416,7 @@ func (client *ViewsClient) getByScopeHandleResponse(resp *http.Response) (ViewsC // NewListPager - Lists all views by tenant and object. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - options - ViewsClientListOptions contains the optional parameters for the ViewsClient.NewListPager method. func (client *ViewsClient) NewListPager(options *ViewsClientListOptions) *runtime.Pager[ViewsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ViewsClientListResponse]{ @@ -449,7 +449,7 @@ func (client *ViewsClient) listCreateRequest(ctx context.Context, options *Views return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -466,7 +466,7 @@ func (client *ViewsClient) listHandleResponse(resp *http.Response) (ViewsClientL // NewListByScopePager - Lists all views at the given scope. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-11-01 // - scope - The scope associated with view operations. This includes 'subscriptions/{subscriptionId}' for subscription scope, // 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup // scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' @@ -516,7 +516,7 @@ func (client *ViewsClient) listByScopeCreateRequest(ctx context.Context, scope s return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-11-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/views_client_example_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/views_client_example_test.go deleted file mode 100644 index 1ed213bfd73e..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/views_client_example_test.go +++ /dev/null @@ -1,737 +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 armcostmanagement_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/costmanagement/armcostmanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/PrivateViewList.json -func ExampleViewsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewViewsClient().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.ViewListResult = armcostmanagement.ViewListResult{ - // Value: []*armcostmanagement.View{ - // { - // Name: to.Ptr("swaggerExample"), - // Type: to.Ptr("Microsoft.CostManagement/Views"), - // ETag: to.Ptr("\"1d4ff9fe66f1d10\""), - // ID: to.Ptr("/providers/Microsoft.CostManagement/views/swaggerExample"), - // Properties: &armcostmanagement.ViewProperties{ - // Accumulated: to.Ptr(armcostmanagement.AccumulatedTypeTrue), - // Chart: to.Ptr(armcostmanagement.ChartTypeTable), - // DisplayName: to.Ptr("swagger Example"), - // Kpis: []*armcostmanagement.KpiProperties{ - // { - // Type: to.Ptr(armcostmanagement.KpiTypeForecast), - // Enabled: to.Ptr(true), - // }, - // { - // Type: to.Ptr(armcostmanagement.KpiTypeBudget), - // Enabled: to.Ptr(true), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Consumption/budgets/swaggerDemo"), - // }}, - // Metric: to.Ptr(armcostmanagement.MetricTypeActualCost), - // Pivots: []*armcostmanagement.PivotProperties{ - // { - // Name: to.Ptr("ServiceName"), - // Type: to.Ptr(armcostmanagement.PivotTypeDimension), - // }, - // { - // Name: to.Ptr("MeterCategory"), - // Type: to.Ptr(armcostmanagement.PivotTypeDimension), - // }, - // { - // Name: to.Ptr("swaggerTagKey"), - // Type: to.Ptr(armcostmanagement.PivotTypeTagKey), - // }}, - // Query: &armcostmanagement.ReportConfigDefinition{ - // Type: to.Ptr(armcostmanagement.ReportTypeUsage), - // DataSet: &armcostmanagement.ReportConfigDataset{ - // Aggregation: map[string]*armcostmanagement.ReportConfigAggregation{ - // "totalCost": &armcostmanagement.ReportConfigAggregation{ - // Name: to.Ptr("PreTaxCost"), - // Function: to.Ptr(armcostmanagement.FunctionTypeSum), - // }, - // }, - // Granularity: to.Ptr(armcostmanagement.ReportGranularityTypeDaily), - // Grouping: []*armcostmanagement.ReportConfigGrouping{ - // }, - // Sorting: []*armcostmanagement.ReportConfigSorting{ - // { - // Name: to.Ptr("UsageDate"), - // Direction: to.Ptr(armcostmanagement.ReportConfigSortingTypeAscending), - // }}, - // }, - // Timeframe: to.Ptr(armcostmanagement.ReportTimeframeTypeMonthToDate), - // }, - // Scope: to.Ptr(""), - // }, - // }, - // { - // Name: to.Ptr("swaggerExample2"), - // Type: to.Ptr("Microsoft.CostManagement/Views"), - // ETag: to.Ptr("\"1d4ffa5a9c2430c\""), - // ID: to.Ptr("/providers/Microsoft.CostManagement/views/swaggerExample2"), - // Properties: &armcostmanagement.ViewProperties{ - // Accumulated: to.Ptr(armcostmanagement.AccumulatedTypeTrue), - // Chart: to.Ptr(armcostmanagement.ChartTypeGroupedColumn), - // DisplayName: to.Ptr("swagger Example 2"), - // Kpis: []*armcostmanagement.KpiProperties{ - // { - // Type: to.Ptr(armcostmanagement.KpiTypeForecast), - // Enabled: to.Ptr(true), - // }, - // { - // Type: to.Ptr(armcostmanagement.KpiTypeBudget), - // Enabled: to.Ptr(true), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Consumption/budgets/swaggerDemo"), - // }}, - // Metric: to.Ptr(armcostmanagement.MetricTypeActualCost), - // Pivots: []*armcostmanagement.PivotProperties{ - // { - // Name: to.Ptr("ServiceName"), - // Type: to.Ptr(armcostmanagement.PivotTypeDimension), - // }, - // { - // Name: to.Ptr("MeterCategory"), - // Type: to.Ptr(armcostmanagement.PivotTypeDimension), - // }, - // { - // Name: to.Ptr("swaggerTagKey"), - // Type: to.Ptr(armcostmanagement.PivotTypeTagKey), - // }}, - // Query: &armcostmanagement.ReportConfigDefinition{ - // Type: to.Ptr(armcostmanagement.ReportTypeUsage), - // DataSet: &armcostmanagement.ReportConfigDataset{ - // Aggregation: map[string]*armcostmanagement.ReportConfigAggregation{ - // "totalCost": &armcostmanagement.ReportConfigAggregation{ - // Name: to.Ptr("PreTaxCost"), - // Function: to.Ptr(armcostmanagement.FunctionTypeSum), - // }, - // }, - // Granularity: to.Ptr(armcostmanagement.ReportGranularityTypeDaily), - // Grouping: []*armcostmanagement.ReportConfigGrouping{ - // }, - // Sorting: []*armcostmanagement.ReportConfigSorting{ - // { - // Name: to.Ptr("UsageDate"), - // Direction: to.Ptr(armcostmanagement.ReportConfigSortingTypeAscending), - // }}, - // }, - // Timeframe: to.Ptr(armcostmanagement.ReportTimeframeType("LastMonthToDate")), - // }, - // Scope: to.Ptr(""), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ViewListByResourceGroup.json -func ExampleViewsClient_NewListByScopePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewViewsClient().NewListByScopePager("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG", 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.ViewListResult = armcostmanagement.ViewListResult{ - // Value: []*armcostmanagement.View{ - // { - // Name: to.Ptr("swaggerExample"), - // Type: to.Ptr("Microsoft.CostManagement/Views"), - // ETag: to.Ptr("\"1d4ff9fe66f1d10\""), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.CostManagement/views/swaggerExample"), - // Properties: &armcostmanagement.ViewProperties{ - // Accumulated: to.Ptr(armcostmanagement.AccumulatedTypeTrue), - // Chart: to.Ptr(armcostmanagement.ChartTypeTable), - // DisplayName: to.Ptr("swagger Example"), - // Kpis: []*armcostmanagement.KpiProperties{ - // { - // Type: to.Ptr(armcostmanagement.KpiTypeForecast), - // Enabled: to.Ptr(true), - // }, - // { - // Type: to.Ptr(armcostmanagement.KpiTypeBudget), - // Enabled: to.Ptr(true), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Consumption/budgets/swaggerDemo"), - // }}, - // Metric: to.Ptr(armcostmanagement.MetricTypeActualCost), - // Pivots: []*armcostmanagement.PivotProperties{ - // { - // Name: to.Ptr("ServiceName"), - // Type: to.Ptr(armcostmanagement.PivotTypeDimension), - // }, - // { - // Name: to.Ptr("MeterCategory"), - // Type: to.Ptr(armcostmanagement.PivotTypeDimension), - // }, - // { - // Name: to.Ptr("swaggerTagKey"), - // Type: to.Ptr(armcostmanagement.PivotTypeTagKey), - // }}, - // Query: &armcostmanagement.ReportConfigDefinition{ - // Type: to.Ptr(armcostmanagement.ReportTypeUsage), - // DataSet: &armcostmanagement.ReportConfigDataset{ - // Aggregation: map[string]*armcostmanagement.ReportConfigAggregation{ - // "totalCost": &armcostmanagement.ReportConfigAggregation{ - // Name: to.Ptr("PreTaxCost"), - // Function: to.Ptr(armcostmanagement.FunctionTypeSum), - // }, - // }, - // Granularity: to.Ptr(armcostmanagement.ReportGranularityTypeDaily), - // Grouping: []*armcostmanagement.ReportConfigGrouping{ - // }, - // Sorting: []*armcostmanagement.ReportConfigSorting{ - // { - // Name: to.Ptr("UsageDate"), - // Direction: to.Ptr(armcostmanagement.ReportConfigSortingTypeAscending), - // }}, - // }, - // Timeframe: to.Ptr(armcostmanagement.ReportTimeframeTypeMonthToDate), - // }, - // Scope: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG"), - // }, - // }, - // { - // Name: to.Ptr("swaggerExample2"), - // Type: to.Ptr("Microsoft.CostManagement/Views"), - // ETag: to.Ptr("\"1d4ffa5a9c2430c\""), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.CostManagement/views/swaggerExample2"), - // Properties: &armcostmanagement.ViewProperties{ - // Accumulated: to.Ptr(armcostmanagement.AccumulatedTypeTrue), - // Chart: to.Ptr(armcostmanagement.ChartTypeGroupedColumn), - // DisplayName: to.Ptr("swagger Example 2"), - // Kpis: []*armcostmanagement.KpiProperties{ - // { - // Type: to.Ptr(armcostmanagement.KpiTypeForecast), - // Enabled: to.Ptr(true), - // }, - // { - // Type: to.Ptr(armcostmanagement.KpiTypeBudget), - // Enabled: to.Ptr(true), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Consumption/budgets/swaggerDemo"), - // }}, - // Metric: to.Ptr(armcostmanagement.MetricTypeActualCost), - // Pivots: []*armcostmanagement.PivotProperties{ - // { - // Name: to.Ptr("ServiceName"), - // Type: to.Ptr(armcostmanagement.PivotTypeDimension), - // }, - // { - // Name: to.Ptr("MeterCategory"), - // Type: to.Ptr(armcostmanagement.PivotTypeDimension), - // }, - // { - // Name: to.Ptr("swaggerTagKey"), - // Type: to.Ptr(armcostmanagement.PivotTypeTagKey), - // }}, - // Query: &armcostmanagement.ReportConfigDefinition{ - // Type: to.Ptr(armcostmanagement.ReportTypeUsage), - // DataSet: &armcostmanagement.ReportConfigDataset{ - // Aggregation: map[string]*armcostmanagement.ReportConfigAggregation{ - // "totalCost": &armcostmanagement.ReportConfigAggregation{ - // Name: to.Ptr("PreTaxCost"), - // Function: to.Ptr(armcostmanagement.FunctionTypeSum), - // }, - // }, - // Granularity: to.Ptr(armcostmanagement.ReportGranularityTypeDaily), - // Grouping: []*armcostmanagement.ReportConfigGrouping{ - // }, - // Sorting: []*armcostmanagement.ReportConfigSorting{ - // { - // Name: to.Ptr("UsageDate"), - // Direction: to.Ptr(armcostmanagement.ReportConfigSortingTypeAscending), - // }}, - // }, - // Timeframe: to.Ptr(armcostmanagement.ReportTimeframeType("LastMonthToDate")), - // }, - // Scope: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/PrivateView.json -func ExampleViewsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewViewsClient().Get(ctx, "swaggerExample", 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.View = armcostmanagement.View{ - // Name: to.Ptr("swaggerExample"), - // Type: to.Ptr("Microsoft.CostManagement/Views"), - // ETag: to.Ptr("\"1d4ff9fe66f1d10\""), - // ID: to.Ptr("/providers/Microsoft.CostManagement/views/swaggerExample"), - // Properties: &armcostmanagement.ViewProperties{ - // Accumulated: to.Ptr(armcostmanagement.AccumulatedTypeTrue), - // Chart: to.Ptr(armcostmanagement.ChartTypeTable), - // DisplayName: to.Ptr("swagger Example"), - // Kpis: []*armcostmanagement.KpiProperties{ - // { - // Type: to.Ptr(armcostmanagement.KpiTypeForecast), - // Enabled: to.Ptr(true), - // }, - // { - // Type: to.Ptr(armcostmanagement.KpiTypeBudget), - // Enabled: to.Ptr(true), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Consumption/budgets/swaggerDemo"), - // }}, - // Metric: to.Ptr(armcostmanagement.MetricTypeActualCost), - // Pivots: []*armcostmanagement.PivotProperties{ - // { - // Name: to.Ptr("ServiceName"), - // Type: to.Ptr(armcostmanagement.PivotTypeDimension), - // }, - // { - // Name: to.Ptr("MeterCategory"), - // Type: to.Ptr(armcostmanagement.PivotTypeDimension), - // }, - // { - // Name: to.Ptr("swaggerTagKey"), - // Type: to.Ptr(armcostmanagement.PivotTypeTagKey), - // }}, - // Query: &armcostmanagement.ReportConfigDefinition{ - // Type: to.Ptr(armcostmanagement.ReportTypeUsage), - // DataSet: &armcostmanagement.ReportConfigDataset{ - // Aggregation: map[string]*armcostmanagement.ReportConfigAggregation{ - // "totalCost": &armcostmanagement.ReportConfigAggregation{ - // Name: to.Ptr("PreTaxCost"), - // Function: to.Ptr(armcostmanagement.FunctionTypeSum), - // }, - // }, - // Granularity: to.Ptr(armcostmanagement.ReportGranularityTypeDaily), - // Grouping: []*armcostmanagement.ReportConfigGrouping{ - // }, - // Sorting: []*armcostmanagement.ReportConfigSorting{ - // { - // Name: to.Ptr("UsageDate"), - // Direction: to.Ptr(armcostmanagement.ReportConfigSortingTypeAscending), - // }}, - // }, - // Timeframe: to.Ptr(armcostmanagement.ReportTimeframeTypeMonthToDate), - // }, - // Scope: to.Ptr(""), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/PrivateViewCreateOrUpdate.json -func ExampleViewsClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewViewsClient().CreateOrUpdate(ctx, "swaggerExample", armcostmanagement.View{ - ETag: to.Ptr("\"1d4ff9fe66f1d10\""), - Properties: &armcostmanagement.ViewProperties{ - Accumulated: to.Ptr(armcostmanagement.AccumulatedTypeTrue), - Chart: to.Ptr(armcostmanagement.ChartTypeTable), - DisplayName: to.Ptr("swagger Example"), - Kpis: []*armcostmanagement.KpiProperties{ - { - Type: to.Ptr(armcostmanagement.KpiTypeForecast), - Enabled: to.Ptr(true), - }, - { - Type: to.Ptr(armcostmanagement.KpiTypeBudget), - Enabled: to.Ptr(true), - ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Consumption/budgets/swaggerDemo"), - }}, - Metric: to.Ptr(armcostmanagement.MetricTypeActualCost), - Pivots: []*armcostmanagement.PivotProperties{ - { - Name: to.Ptr("ServiceName"), - Type: to.Ptr(armcostmanagement.PivotTypeDimension), - }, - { - Name: to.Ptr("MeterCategory"), - Type: to.Ptr(armcostmanagement.PivotTypeDimension), - }, - { - Name: to.Ptr("swaggerTagKey"), - Type: to.Ptr(armcostmanagement.PivotTypeTagKey), - }}, - Query: &armcostmanagement.ReportConfigDefinition{ - Type: to.Ptr(armcostmanagement.ReportTypeUsage), - DataSet: &armcostmanagement.ReportConfigDataset{ - Aggregation: map[string]*armcostmanagement.ReportConfigAggregation{ - "totalCost": { - Name: to.Ptr("PreTaxCost"), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), - }, - }, - Granularity: to.Ptr(armcostmanagement.ReportGranularityTypeDaily), - Grouping: []*armcostmanagement.ReportConfigGrouping{}, - Sorting: []*armcostmanagement.ReportConfigSorting{ - { - Name: to.Ptr("UsageDate"), - Direction: to.Ptr(armcostmanagement.ReportConfigSortingTypeAscending), - }}, - }, - Timeframe: to.Ptr(armcostmanagement.ReportTimeframeTypeMonthToDate), - }, - }, - }, 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.View = armcostmanagement.View{ - // Name: to.Ptr("swaggerExample"), - // Type: to.Ptr("Microsoft.CostManagement/Views"), - // ETag: to.Ptr("\"1d4ffa5a9c2430c\""), - // ID: to.Ptr("/providers/Microsoft.CostManagement/views/swaggerExample"), - // Properties: &armcostmanagement.ViewProperties{ - // Accumulated: to.Ptr(armcostmanagement.AccumulatedTypeTrue), - // Chart: to.Ptr(armcostmanagement.ChartTypeTable), - // DisplayName: to.Ptr("swagger Example"), - // Kpis: []*armcostmanagement.KpiProperties{ - // { - // Type: to.Ptr(armcostmanagement.KpiTypeForecast), - // Enabled: to.Ptr(true), - // }, - // { - // Type: to.Ptr(armcostmanagement.KpiTypeBudget), - // Enabled: to.Ptr(true), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Consumption/budgets/swaggerDemo"), - // }}, - // Metric: to.Ptr(armcostmanagement.MetricTypeActualCost), - // Pivots: []*armcostmanagement.PivotProperties{ - // { - // Name: to.Ptr("ServiceName"), - // Type: to.Ptr(armcostmanagement.PivotTypeDimension), - // }, - // { - // Name: to.Ptr("MeterCategory"), - // Type: to.Ptr(armcostmanagement.PivotTypeDimension), - // }, - // { - // Name: to.Ptr("swaggerTagKey"), - // Type: to.Ptr(armcostmanagement.PivotTypeTagKey), - // }}, - // Query: &armcostmanagement.ReportConfigDefinition{ - // Type: to.Ptr(armcostmanagement.ReportTypeUsage), - // DataSet: &armcostmanagement.ReportConfigDataset{ - // Aggregation: map[string]*armcostmanagement.ReportConfigAggregation{ - // "totalCost": &armcostmanagement.ReportConfigAggregation{ - // Name: to.Ptr("PreTaxCost"), - // Function: to.Ptr(armcostmanagement.FunctionTypeSum), - // }, - // }, - // Granularity: to.Ptr(armcostmanagement.ReportGranularityTypeDaily), - // Grouping: []*armcostmanagement.ReportConfigGrouping{ - // }, - // Sorting: []*armcostmanagement.ReportConfigSorting{ - // { - // Name: to.Ptr("UsageDate"), - // Direction: to.Ptr(armcostmanagement.ReportConfigSortingTypeAscending), - // }}, - // }, - // Timeframe: to.Ptr(armcostmanagement.ReportTimeframeTypeMonthToDate), - // }, - // Scope: to.Ptr(""), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/PrivateViewDelete.json -func ExampleViewsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewViewsClient().Delete(ctx, "TestView", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ViewByResourceGroup.json -func ExampleViewsClient_GetByScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewViewsClient().GetByScope(ctx, "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG", "swaggerExample", 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.View = armcostmanagement.View{ - // Name: to.Ptr("swaggerExample"), - // Type: to.Ptr("Microsoft.CostManagement/Views"), - // ETag: to.Ptr("\"1d4ff9fe66f1d10\""), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.CostManagement/views/swaggerExample"), - // Properties: &armcostmanagement.ViewProperties{ - // Accumulated: to.Ptr(armcostmanagement.AccumulatedTypeTrue), - // Chart: to.Ptr(armcostmanagement.ChartTypeTable), - // DisplayName: to.Ptr("swagger Example"), - // Kpis: []*armcostmanagement.KpiProperties{ - // { - // Type: to.Ptr(armcostmanagement.KpiTypeForecast), - // Enabled: to.Ptr(true), - // }, - // { - // Type: to.Ptr(armcostmanagement.KpiTypeBudget), - // Enabled: to.Ptr(true), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Consumption/budgets/swaggerDemo"), - // }}, - // Metric: to.Ptr(armcostmanagement.MetricTypeActualCost), - // Pivots: []*armcostmanagement.PivotProperties{ - // { - // Name: to.Ptr("ServiceName"), - // Type: to.Ptr(armcostmanagement.PivotTypeDimension), - // }, - // { - // Name: to.Ptr("MeterCategory"), - // Type: to.Ptr(armcostmanagement.PivotTypeDimension), - // }, - // { - // Name: to.Ptr("swaggerTagKey"), - // Type: to.Ptr(armcostmanagement.PivotTypeTagKey), - // }}, - // Query: &armcostmanagement.ReportConfigDefinition{ - // Type: to.Ptr(armcostmanagement.ReportTypeUsage), - // DataSet: &armcostmanagement.ReportConfigDataset{ - // Aggregation: map[string]*armcostmanagement.ReportConfigAggregation{ - // "totalCost": &armcostmanagement.ReportConfigAggregation{ - // Name: to.Ptr("PreTaxCost"), - // Function: to.Ptr(armcostmanagement.FunctionTypeSum), - // }, - // }, - // Granularity: to.Ptr(armcostmanagement.ReportGranularityTypeDaily), - // Grouping: []*armcostmanagement.ReportConfigGrouping{ - // }, - // Sorting: []*armcostmanagement.ReportConfigSorting{ - // { - // Name: to.Ptr("UsageDate"), - // Direction: to.Ptr(armcostmanagement.ReportConfigSortingTypeAscending), - // }}, - // }, - // Timeframe: to.Ptr(armcostmanagement.ReportTimeframeTypeMonthToDate), - // }, - // Scope: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ViewCreateOrUpdateByResourceGroup.json -func ExampleViewsClient_CreateOrUpdateByScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewViewsClient().CreateOrUpdateByScope(ctx, "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG", "swaggerExample", armcostmanagement.View{ - ETag: to.Ptr("\"1d4ff9fe66f1d10\""), - Properties: &armcostmanagement.ViewProperties{ - Accumulated: to.Ptr(armcostmanagement.AccumulatedTypeTrue), - Chart: to.Ptr(armcostmanagement.ChartTypeTable), - DisplayName: to.Ptr("swagger Example"), - Kpis: []*armcostmanagement.KpiProperties{ - { - Type: to.Ptr(armcostmanagement.KpiTypeForecast), - Enabled: to.Ptr(true), - }, - { - Type: to.Ptr(armcostmanagement.KpiTypeBudget), - Enabled: to.Ptr(true), - ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Consumption/budgets/swaggerDemo"), - }}, - Metric: to.Ptr(armcostmanagement.MetricTypeActualCost), - Pivots: []*armcostmanagement.PivotProperties{ - { - Name: to.Ptr("ServiceName"), - Type: to.Ptr(armcostmanagement.PivotTypeDimension), - }, - { - Name: to.Ptr("MeterCategory"), - Type: to.Ptr(armcostmanagement.PivotTypeDimension), - }, - { - Name: to.Ptr("swaggerTagKey"), - Type: to.Ptr(armcostmanagement.PivotTypeTagKey), - }}, - Query: &armcostmanagement.ReportConfigDefinition{ - Type: to.Ptr(armcostmanagement.ReportTypeUsage), - DataSet: &armcostmanagement.ReportConfigDataset{ - Aggregation: map[string]*armcostmanagement.ReportConfigAggregation{ - "totalCost": { - Name: to.Ptr("PreTaxCost"), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), - }, - }, - Granularity: to.Ptr(armcostmanagement.ReportGranularityTypeDaily), - Grouping: []*armcostmanagement.ReportConfigGrouping{}, - Sorting: []*armcostmanagement.ReportConfigSorting{ - { - Name: to.Ptr("UsageDate"), - Direction: to.Ptr(armcostmanagement.ReportConfigSortingTypeAscending), - }}, - }, - Timeframe: to.Ptr(armcostmanagement.ReportTimeframeTypeMonthToDate), - }, - }, - }, 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.View = armcostmanagement.View{ - // Name: to.Ptr("swaggerExample"), - // Type: to.Ptr("Microsoft.CostManagement/Views"), - // ETag: to.Ptr("\"1d4ffa5a9c2430c\""), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.CostManagement/views/swaggerExample"), - // Properties: &armcostmanagement.ViewProperties{ - // Accumulated: to.Ptr(armcostmanagement.AccumulatedTypeTrue), - // Chart: to.Ptr(armcostmanagement.ChartTypeTable), - // DisplayName: to.Ptr("swagger Example"), - // Kpis: []*armcostmanagement.KpiProperties{ - // { - // Type: to.Ptr(armcostmanagement.KpiTypeForecast), - // Enabled: to.Ptr(true), - // }, - // { - // Type: to.Ptr(armcostmanagement.KpiTypeBudget), - // Enabled: to.Ptr(true), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Consumption/budgets/swaggerDemo"), - // }}, - // Metric: to.Ptr(armcostmanagement.MetricTypeActualCost), - // Pivots: []*armcostmanagement.PivotProperties{ - // { - // Name: to.Ptr("ServiceName"), - // Type: to.Ptr(armcostmanagement.PivotTypeDimension), - // }, - // { - // Name: to.Ptr("MeterCategory"), - // Type: to.Ptr(armcostmanagement.PivotTypeDimension), - // }, - // { - // Name: to.Ptr("swaggerTagKey"), - // Type: to.Ptr(armcostmanagement.PivotTypeTagKey), - // }}, - // Query: &armcostmanagement.ReportConfigDefinition{ - // Type: to.Ptr(armcostmanagement.ReportTypeUsage), - // DataSet: &armcostmanagement.ReportConfigDataset{ - // Aggregation: map[string]*armcostmanagement.ReportConfigAggregation{ - // "totalCost": &armcostmanagement.ReportConfigAggregation{ - // Name: to.Ptr("PreTaxCost"), - // Function: to.Ptr(armcostmanagement.FunctionTypeSum), - // }, - // }, - // Granularity: to.Ptr(armcostmanagement.ReportGranularityTypeDaily), - // Grouping: []*armcostmanagement.ReportConfigGrouping{ - // }, - // Sorting: []*armcostmanagement.ReportConfigSorting{ - // { - // Name: to.Ptr("UsageDate"), - // Direction: to.Ptr(armcostmanagement.ReportConfigSortingTypeAscending), - // }}, - // }, - // Timeframe: to.Ptr(armcostmanagement.ReportTimeframeTypeMonthToDate), - // }, - // Scope: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ViewDeleteByResourceGroup.json -func ExampleViewsClient_DeleteByScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewViewsClient().DeleteByScope(ctx, "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG", "TestView", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -}