From 48cf349f0d16fefd231d51834dd18fa2d64240ac Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Tue, 21 Jan 2025 23:30:57 +0000 Subject: [PATCH] CodeGen from PR 32261 in Azure/azure-rest-api-specs Merge b91de97a0ee567808489ca70cae7afc695145868 into 9bc885271d3ad4d4d5697d221e7d25a80d09779d --- .../armcostmanagement/CHANGELOG.md | 90 + .../armcostmanagement/README.md | 2 +- .../armcostmanagement/alerts_client.go | 16 +- .../alerts_client_example_test.go | 1282 --------- .../armcostmanagement/autorest.md | 7 +- .../benefitrecommendations_client.go | 10 +- ...efitrecommendations_client_example_test.go | 154 -- .../benefitutilizationsummaries_client.go | 28 +- ...tilizationsummaries_client_example_test.go | 235 -- .../armcostmanagement/budgets_client.go | 443 ++++ .../armcostmanagement/client_factory.go | 116 +- .../armcostmanagement/constants.go | 411 ++- .../costallocationrules_client.go | 337 +++ .../armcostmanagement/dimensions_client.go | 20 +- .../dimensions_client_example_test.go | 1822 ------------- .../armcostmanagement/exports_client.go | 24 +- .../exports_client_example_test.go | 2301 ----------------- .../armcostmanagement/fake/alerts_server.go | 2 +- .../fake/benefitrecommendations_server.go | 2 +- .../benefitutilizationsummaries_server.go | 2 +- .../armcostmanagement/fake/budgets_server.go | 242 ++ .../fake/costallocationrules_server.go | 269 ++ .../fake/dimensions_server.go | 2 +- .../armcostmanagement/fake/exports_server.go | 2 +- .../armcostmanagement/fake/forecast_server.go | 2 +- ...enefitutilizationsummariesreport_server.go | 387 +++ .../fake/generatecostdetailsreport_server.go | 2 +- .../fake/generatedetailedcostreport_server.go | 2 +- ...tailedcostreportoperationresults_server.go | 2 +- ...etailedcostreportoperationstatus_server.go | 2 +- ...generatereservationdetailsreport_server.go | 2 +- .../armcostmanagement/fake/internal.go | 13 + .../fake/operations_server.go | 2 +- .../fake/polymorphic_helpers.go | 35 + .../fake/pricesheet_server.go | 106 +- .../armcostmanagement/fake/query_server.go | 2 +- .../fake/scheduledactions_server.go | 2 +- .../armcostmanagement/fake/server_factory.go | 24 + .../armcostmanagement/fake/settings_server.go | 239 ++ .../armcostmanagement/fake/time_rfc3339.go | 42 +- .../armcostmanagement/fake/views_server.go | 2 +- .../armcostmanagement/forecast_client.go | 8 +- .../forecast_client_example_test.go | 1010 -------- ...enefitutilizationsummariesreport_client.go | 496 ++++ .../generatecostdetailsreport_client.go | 20 +- ...tecostdetailsreport_client_example_test.go | 459 ---- .../generatedetailedcostreport_client.go | 6 +- ...edetailedcostreport_client_example_test.go | 206 -- ...tailedcostreportoperationresults_client.go | 6 +- ...ortoperationresults_client_example_test.go | 51 - ...etailedcostreportoperationstatus_client.go | 4 +- ...portoperationstatus_client_example_test.go | 52 - ...generatereservationdetailsreport_client.go | 16 +- ...vationdetailsreport_client_example_test.go | 80 - .../costmanagement/armcostmanagement/go.mod | 14 +- .../costmanagement/armcostmanagement/go.sum | 23 - .../armcostmanagement/interfaces.go | 9 + .../armcostmanagement/models.go | 750 +++++- .../armcostmanagement/models_serde.go | 1468 ++++++++++- .../armcostmanagement/operations_client.go | 4 +- .../operations_client_example_test.go | 146 -- .../armcostmanagement/options.go | 123 +- .../armcostmanagement/polymorphic_helpers.go | 46 +- .../armcostmanagement/pricesheet_client.go | 191 +- .../pricesheet_client_example_test.go | 74 - .../armcostmanagement/query_client.go | 8 +- .../query_client_example_test.go | 1934 -------------- .../{response_types.go => responses.go} | 150 +- .../scheduledactions_client.go | 52 +- .../scheduledactions_client_example_test.go | 899 ------- .../armcostmanagement/settings_client.go | 283 ++ .../armcostmanagement/time_rfc3339.go | 42 +- .../armcostmanagement/views_client.go | 32 +- .../views_client_example_test.go | 737 ------ 74 files changed, 6247 insertions(+), 11837 deletions(-) delete mode 100644 sdk/resourcemanager/costmanagement/armcostmanagement/alerts_client_example_test.go delete mode 100644 sdk/resourcemanager/costmanagement/armcostmanagement/benefitrecommendations_client_example_test.go delete mode 100644 sdk/resourcemanager/costmanagement/armcostmanagement/benefitutilizationsummaries_client_example_test.go create mode 100644 sdk/resourcemanager/costmanagement/armcostmanagement/budgets_client.go create mode 100644 sdk/resourcemanager/costmanagement/armcostmanagement/costallocationrules_client.go delete mode 100644 sdk/resourcemanager/costmanagement/armcostmanagement/dimensions_client_example_test.go delete mode 100644 sdk/resourcemanager/costmanagement/armcostmanagement/exports_client_example_test.go create mode 100644 sdk/resourcemanager/costmanagement/armcostmanagement/fake/budgets_server.go create mode 100644 sdk/resourcemanager/costmanagement/armcostmanagement/fake/costallocationrules_server.go create mode 100644 sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatebenefitutilizationsummariesreport_server.go create mode 100644 sdk/resourcemanager/costmanagement/armcostmanagement/fake/polymorphic_helpers.go create mode 100644 sdk/resourcemanager/costmanagement/armcostmanagement/fake/settings_server.go delete mode 100644 sdk/resourcemanager/costmanagement/armcostmanagement/forecast_client_example_test.go create mode 100644 sdk/resourcemanager/costmanagement/armcostmanagement/generatebenefitutilizationsummariesreport_client.go delete mode 100644 sdk/resourcemanager/costmanagement/armcostmanagement/generatecostdetailsreport_client_example_test.go delete mode 100644 sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreport_client_example_test.go delete mode 100644 sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationresults_client_example_test.go delete mode 100644 sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationstatus_client_example_test.go delete mode 100644 sdk/resourcemanager/costmanagement/armcostmanagement/generatereservationdetailsreport_client_example_test.go delete mode 100644 sdk/resourcemanager/costmanagement/armcostmanagement/operations_client_example_test.go delete mode 100644 sdk/resourcemanager/costmanagement/armcostmanagement/pricesheet_client_example_test.go delete mode 100644 sdk/resourcemanager/costmanagement/armcostmanagement/query_client_example_test.go rename sdk/resourcemanager/costmanagement/armcostmanagement/{response_types.go => responses.go} (64%) delete mode 100644 sdk/resourcemanager/costmanagement/armcostmanagement/scheduledactions_client_example_test.go create mode 100644 sdk/resourcemanager/costmanagement/armcostmanagement/settings_client.go delete mode 100644 sdk/resourcemanager/costmanagement/armcostmanagement/views_client_example_test.go diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/CHANGELOG.md b/sdk/resourcemanager/costmanagement/armcostmanagement/CHANGELOG.md index 14bd641be201..e2e417fe473b 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/CHANGELOG.md +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/CHANGELOG.md @@ -1,5 +1,95 @@ # Release History +## 3.0.0 (2025-01-21) +### 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 a7e14480c97b..9c4a6dbbc9f7 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/README.md +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/README.md @@ -18,7 +18,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..dbbbe3a0c9df 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 2024-08-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", "2024-08-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 2024-08-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", "2024-08-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 2024-08-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", "2024-08-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 2024-08-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", "2024-08-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..08c00c71d0a1 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 2024-08-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", "2024-08-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..3a9c71b41097 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 2024-08-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", "2024-08-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 2024-08-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", "2024-08-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 2024-08-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", "2024-08-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 2024-08-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", "2024-08-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..34a79b4d5029 --- /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 2024-08-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", "2024-08-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 2024-08-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", "2024-08-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 2024-08-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", "2024-08-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 2024-08-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", "2024-08-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..8f44bb440a0d --- /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 2024-08-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", "2024-08-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 2024-08-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", "2024-08-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 2024-08-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", "2024-08-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 2024-08-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", "2024-08-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 2024-08-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", "2024-08-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..f01e4fccfa5f 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 2024-08-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", "2024-08-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 2024-08-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", "2024-08-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..4a31faf4c077 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 2024-08-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", "2024-08-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 2024-08-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", "2024-08-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 2024-08-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", "2024-08-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 2024-08-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", "2024-08-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 2024-08-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", "2024-08-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 2024-08-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", "2024-08-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..1c9f31a6b887 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 2024-08-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", "2024-08-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 2024-08-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", "2024-08-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..fad956f5e8ba --- /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 2024-08-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 2024-08-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", "2024-08-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 2024-08-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 2024-08-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", "2024-08-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 2024-08-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 2024-08-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", "2024-08-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 2024-08-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 2024-08-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", "2024-08-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 2024-08-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 2024-08-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", "2024-08-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 2024-08-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 2024-08-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", "2024-08-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..8b0b9763aa87 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 2024-08-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 2024-08-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", "2024-08-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 2024-08-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 2024-08-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", "2024-08-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..84f89c691e3e 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 2024-08-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 2024-08-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", "2024-08-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..058916a23d23 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 2024-08-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 2024-08-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", "2024-08-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..830b9357667f 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 2024-08-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", "2024-08-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..21d626decfea 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 2024-08-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 2024-08-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", "2024-08-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 2024-08-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 2024-08-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", "2024-08-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 fd6dfa2fd73a..e17254001f41 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.16.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.0 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.16.0 require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v1.3.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.31.0 // indirect golang.org/x/net v0.33.0 // indirect - golang.org/x/sys v0.28.0 // indirect golang.org/x/text v0.21.0 // indirect ) diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/go.sum b/sdk/resourcemanager/costmanagement/armcostmanagement/go.sum index 9620a8f197a3..823eafcd76d5 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/go.sum +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/go.sum @@ -1,35 +1,12 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.16.0 h1:JZg6HRh6W6U4OLl6lk7BZ7BLisIzM9dG1R50zUk9C/M= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.16.0/go.mod h1:YL1xnZ6QejvQHWJrX/AvhFl4WW4rqHVoKspWNVwFk0M= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.0 h1:B/dfvscEQtew9dVuoxqxrUKKv8Ih2f55PydknDamU+g= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.0/go.mod h1:fiPSssYvltE08HJchL04dOy+RD4hgrjph0cwGGMntdI= -github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.3.0 h1:+m0M/LFxN43KvULkDNfdXOgrjtg6UYJPFBJyuEcRCAw= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY= -github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1 h1:WJTmL004Abzc5wDB5VtZG2PJk5ndYDgVacGqfirKxjM= -github.com/AzureAD/microsoft-authentication-library-for-go v1.3.2 h1:kYRSnvJju5gYVyhkij+RTJ/VR6QIUaCfWeaFm2ycsjQ= -github.com/AzureAD/microsoft-authentication-library-for-go v1.3.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= -github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= -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/keybase/go-keychain v0.0.0-20231219164618-57a3676c3af6 h1:IsMZxCuZqKuao2vNdfD82fjjgPLfyHLpR41Z88viRWs= -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/redis/go-redis/v9 v9.6.1 h1:HHDteefn6ZkTtY5fGUE8tj8uy85AHk6zP7CpzIAM0y4= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= -golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= -golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= -golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= 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..2e8ff90c8760 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,108 @@ type DownloadURL struct { ExpiryTime *time.Time } +// EAPriceSheetProperties - The properties of the EA price sheet. Properties supported with version 2024-08-01 are as below +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; Determines the Azure offer associated with this meter. Learn more about Azure offers [https://azure.microsoft.com/en-us/support/legal/offer-details/] + OfferID *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. Note: The field “Unit” has been removed with version 2023-11-01 as a + // duplicate of “UnitofMeasure”, please use the field “UnitOfMeasure”. + 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 +904,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 +1253,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 +1433,162 @@ 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; Name of the purchased product plan. Indicates if this pricing is standard Azure Plan pricing, Dev/Test pricing + // etc. + // Currently unavailable for Azure 3rd party and ReservedInstance meters. + ProductOrderName *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 +1668,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 +1686,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 +2046,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 > 2024-08-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 +2059,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 > 2024-08-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 +2068,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 > 2024-08-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 +2166,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 +2184,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 +2338,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 +2391,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 +2482,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 +2494,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 +2523,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..bc3cc58cbe2a 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) @@ -636,22 +761,532 @@ func (b *BlobInfo) UnmarshalJSON(data []byte) error { delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", b, err) + 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", 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) + case "createdDate": + err = unpopulateDateTimeRFC3339(val, "CreatedDate", &c.CreatedDate) delete(rawMsg, key) - case "deliveryInfo": - err = unpopulate(val, "DeliveryInfo", &c.DeliveryInfo) - 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,156 @@ 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, "offerId", e.OfferID) + 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 "offerId": + err = unpopulate(val, "OfferID", &e.OfferID) + 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 +1884,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 +1907,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 +2767,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 +3120,224 @@ 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, "productOrderName", m.ProductOrderName) + 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 "productOrderName": + err = unpopulate(val, "ProductOrderName", &m.ProductOrderName) + 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 +3534,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 +3596,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 +4773,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 +4997,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 +5059,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 +5141,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 +5416,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..c62bd16bf824 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 2024-08-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", "2024-08-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..82e087db04dc 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/pricesheet_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/pricesheet_client.go @@ -40,46 +40,75 @@ 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. +// Migrate to version 2024-08-01 +// You can use the 2024-08-01 API version with the new URI: +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingPeriods/{billingPeriodName}/providers/Microsoft.CostManagement/pricesheets/default/download' +// With a new schema detailed below, the new version of the price sheet provides additional 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 an ongoing record of past +// Azure Reserved Instance (RI) pricing. +// The EA Azure price sheet is available for billing periods in the past 13 months. To request a price sheet for a billing +// period older than 13 months, please contact support. +// The Azure price sheet download experience has been updated from a single .csv file to a zip file containing multiple .csv +// files, each with max size of 75MB. The 2023-11-01 version has been upgraded to +// use http POST method; details can be found below. +// All versions of the Microsoft.Consumption Azure Price Sheet - Download by Billing Account (including 2022-06-01, 2021-10-01, +// 2020-01-01-preview, 2019-10-01, 2019-05-01) are scheduled to be retired on +// 01 June 2026 and will no longer be supported after this date. // 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 2024-08-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. +// Migrate to version 2024-08-01 +// You can use the 2024-08-01 API version with the new URI: +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingPeriods/{billingPeriodName}/providers/Microsoft.CostManagement/pricesheets/default/download' +// With a new schema detailed below, the new version of the price sheet provides additional 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 an ongoing record of past +// Azure Reserved Instance (RI) pricing. +// The EA Azure price sheet is available for billing periods in the past 13 months. To request a price sheet for a billing +// period older than 13 months, please contact support. +// The Azure price sheet download experience has been updated from a single .csv file to a zip file containing multiple .csv +// files, each with max size of 75MB. The 2023-11-01 version has been upgraded to +// use http POST method; details can be found below. +// All versions of the Microsoft.Consumption Azure Price Sheet - Download by Billing Account (including 2022-06-01, 2021-10-01, +// 2020-01-01-preview, 2019-10-01, 2019-05-01) are scheduled to be retired on +// 01 June 2026 and will no longer be supported after this date. // 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 2024-08-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 +123,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", "2024-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -122,12 +147,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 2024-08-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 +180,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 2024-08-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 +226,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", "2024-08-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 2024-08-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 2024-08-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", "2024-08-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..b59a2c3591bd 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 2024-08-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", "2024-08-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 2024-08-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", "2024-08-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..2c1700bd9eea 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 2024-08-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", "2024-08-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 2024-08-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", "2024-08-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 2024-08-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", "2024-08-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 2024-08-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", "2024-08-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 2024-08-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", "2024-08-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 2024-08-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", "2024-08-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 2024-08-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", "2024-08-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 2024-08-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", "2024-08-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 2024-08-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", "2024-08-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 2024-08-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", "2024-08-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 2024-08-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", "2024-08-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 2024-08-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", "2024-08-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..8fc5242132cf --- /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 2024-08-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", "2024-08-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 2024-08-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", "2024-08-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 2024-08-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", "2024-08-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 2024-08-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", "2024-08-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..366286e9b4ac 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 2024-08-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", "2024-08-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 2024-08-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", "2024-08-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 2024-08-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", "2024-08-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 2024-08-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", "2024-08-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 2024-08-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", "2024-08-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 2024-08-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", "2024-08-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 2024-08-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", "2024-08-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 2024-08-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", "2024-08-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) - } -}