From 8715c3091daafede1371068f61e48b97924a6ac5 Mon Sep 17 00:00:00 2001 From: Judy Liu Date: Wed, 3 Dec 2025 14:11:53 +0800 Subject: [PATCH] add code --- .../armcostmanagement/CHANGELOG.md | 129 + .../armcostmanagement/README.md | 6 +- .../armcostmanagement/alerts_client.go | 125 +- .../alerts_client_example_test.go | 2039 +++++----- .../armcostmanagement/autorest.md | 13 - .../benefitrecommendations_client.go | 27 +- ...efitrecommendations_client_example_test.go | 155 +- .../benefitutilizationsummaries_client.go | 47 +- ...tilizationsummaries_client_example_test.go | 229 +- .../armcostmanagement/budgets_client.go | 270 ++ .../budgets_client_example_test.go | 2922 +++++++++++++ .../costmanagement/armcostmanagement/build.go | 7 - .../armcostmanagement/client_factory.go | 119 +- .../armcostmanagement/constants.go | 571 ++- .../costallocationrules_client.go | 334 ++ ...costallocationrules_client_example_test.go | 463 +++ .../armcostmanagement/dimensions_client.go | 75 +- .../dimensions_client_example_test.go | 2009 ++++----- .../armcostmanagement/exports_client.go | 179 +- .../exports_client_example_test.go | 3622 +++++++++++------ .../armcostmanagement/fake/alerts_server.go | 135 +- .../fake/benefitrecommendations_server.go | 70 +- .../benefitutilizationsummaries_server.go | 126 +- .../armcostmanagement/fake/budgets_server.go | 263 ++ .../fake/costallocationrules_server.go | 290 ++ .../fake/dimensions_server.go | 101 +- .../armcostmanagement/fake/exports_server.go | 188 +- .../armcostmanagement/fake/forecast_server.go | 66 +- ...enefitutilizationsummariesreport_server.go | 408 ++ .../fake/generatecostdetailsreport_server.go | 78 +- .../fake/generatedetailedcostreport_server.go | 64 +- ...tailedcostreportoperationresults_server.go | 64 +- ...etailedcostreportoperationstatus_server.go | 56 +- ...generatereservationdetailsreport_server.go | 82 +- .../armcostmanagement/fake/internal.go | 21 +- .../fake/operations_server.go | 62 +- .../fake/polymorphic_helpers.go | 31 + .../fake/pricesheet_server.go | 172 +- .../armcostmanagement/fake/query_server.go | 66 +- .../fake/scheduledactions_server.go | 156 +- .../armcostmanagement/fake/server_factory.go | 96 +- .../armcostmanagement/fake/settings_server.go | 269 ++ .../armcostmanagement/fake/time_rfc3339.go | 83 - .../armcostmanagement/fake/views_server.go | 124 +- .../armcostmanagement/forecast_client.go | 37 +- .../forecast_client_example_test.go | 1222 +++--- ...enefitutilizationsummariesreport_client.go | 493 +++ ...tionsummariesreport_client_example_test.go | 289 ++ .../generatecostdetailsreport_client.go | 78 +- ...tecostdetailsreport_client_example_test.go | 441 +- .../generatedetailedcostreport_client.go | 35 +- ...edetailedcostreport_client_example_test.go | 125 +- ...tailedcostreportoperationresults_client.go | 22 +- ...ortoperationresults_client_example_test.go | 27 +- ...etailedcostreportoperationstatus_client.go | 20 +- ...portoperationstatus_client_example_test.go | 38 +- ...generatereservationdetailsreport_client.go | 55 +- ...vationdetailsreport_client_example_test.go | 37 +- .../costmanagement/armcostmanagement/go.mod | 2 +- .../armcostmanagement/interfaces.go | 12 +- .../armcostmanagement/models.go | 1017 ++++- .../armcostmanagement/models_serde.go | 1459 ++++++- .../armcostmanagement/operations_client.go | 13 +- .../operations_client_example_test.go | 198 +- .../armcostmanagement/options.go | 169 +- .../armcostmanagement/polymorphic_helpers.go | 53 +- .../armcostmanagement/pricesheet_client.go | 207 +- .../pricesheet_client_example_test.go | 66 +- .../armcostmanagement/query_client.go | 41 +- .../query_client_example_test.go | 2486 ++++++----- .../{response_types.go => responses.go} | 146 +- .../armcostmanagement/responses_serde.go | 25 + .../scheduledactions_client.go | 179 +- .../scheduledactions_client_example_test.go | 1382 ++++--- .../armcostmanagement/settings_client.go | 268 ++ .../settings_client_example_test.go | 142 + .../armcostmanagement/testdata/_metadata.json | 4 + .../armcostmanagement/time_rfc3339.go | 48 +- .../armcostmanagement/tsp-location.yaml | 4 + .../armcostmanagement/version.go | 10 + .../armcostmanagement/views_client.go | 119 +- .../views_client_example_test.go | 1198 +++--- 82 files changed, 20027 insertions(+), 8552 deletions(-) delete mode 100644 sdk/resourcemanager/costmanagement/armcostmanagement/autorest.md create mode 100644 sdk/resourcemanager/costmanagement/armcostmanagement/budgets_client.go create mode 100644 sdk/resourcemanager/costmanagement/armcostmanagement/budgets_client_example_test.go delete mode 100644 sdk/resourcemanager/costmanagement/armcostmanagement/build.go create mode 100644 sdk/resourcemanager/costmanagement/armcostmanagement/costallocationrules_client.go create mode 100644 sdk/resourcemanager/costmanagement/armcostmanagement/costallocationrules_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/fake/time_rfc3339.go create mode 100644 sdk/resourcemanager/costmanagement/armcostmanagement/generatebenefitutilizationsummariesreport_client.go create mode 100644 sdk/resourcemanager/costmanagement/armcostmanagement/generatebenefitutilizationsummariesreport_client_example_test.go rename sdk/resourcemanager/costmanagement/armcostmanagement/{response_types.go => responses.go} (65%) create mode 100644 sdk/resourcemanager/costmanagement/armcostmanagement/responses_serde.go create mode 100644 sdk/resourcemanager/costmanagement/armcostmanagement/settings_client.go create mode 100644 sdk/resourcemanager/costmanagement/armcostmanagement/settings_client_example_test.go create mode 100644 sdk/resourcemanager/costmanagement/armcostmanagement/testdata/_metadata.json create mode 100644 sdk/resourcemanager/costmanagement/armcostmanagement/tsp-location.yaml create mode 100644 sdk/resourcemanager/costmanagement/armcostmanagement/version.go diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/CHANGELOG.md b/sdk/resourcemanager/costmanagement/armcostmanagement/CHANGELOG.md index 14bd641be201..a437859a31a7 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/CHANGELOG.md +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/CHANGELOG.md @@ -1,5 +1,134 @@ # Release History +## 3.0.0 (2025-12-03) +### Breaking Changes + +- Type of `Alert.ETag` has been changed from `*string` to `*azcore.ETag` +- Type of `Export.ETag` has been changed from `*string` to `*azcore.ETag` +- Type of `KpiProperties.Type` has been changed from `*KpiType` to `*KpiTypeType` +- Type of `OperationListResult.Value` has been changed from `[]*OperationForCostManagement` to `[]*Operation` +- Type of `PivotProperties.Type` has been changed from `*PivotType` to `*PivotTypeType` +- Type of `ScheduledAction.ETag` has been changed from `*string` to `*azcore.ETag` +- Type of `View.ETag` has been changed from `*string` to `*azcore.ETag` +- Enum `KpiType` has been removed +- Enum `PivotType` has been removed +- Function `*PriceSheetClient.BeginDownload` has been removed +- Operation `*AlertsClient.List` has supported pagination, use `*AlertsClient.NewListPager` instead. +- Operation `*ExportsClient.List` has supported pagination, use `*ExportsClient.NewListPager` instead. +- Struct `OperationForCostManagement` has been removed +- Field `DownloadURL` of struct `PriceSheetClientDownloadByBillingProfileResponse` has been removed + +### Features Added + +- New value `ExportTypeFocusCost`, `ExportTypePriceSheet`, `ExportTypeReservationDetails`, `ExportTypeReservationRecommendations`, `ExportTypeReservationTransactions` added to enum type `ExportType` +- New value `FormatTypeParquet` added to enum type `FormatType` +- New value `GranularityTypeMonthly` added to enum type `GranularityType` +- New value `TimeframeTypeTheCurrentMonth` added to enum type `TimeframeType` +- 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 `CompressionModeType` with values `CompressionModeTypeGzip`, `CompressionModeTypeNone`, `CompressionModeTypeSnappy` +- 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 `DataOverwriteBehaviorType` with values `DataOverwriteBehaviorTypeCreateNewReport`, `DataOverwriteBehaviorTypeOverwritePreviousReport` +- New enum type `DestinationType` with values `DestinationTypeAzureBlob` +- New enum type `FilterItemNames` with values `FilterItemNamesLookBackPeriod`, `FilterItemNamesReservationScope`, `FilterItemNamesResourceType` +- New enum type `Frequency` with values `FrequencyDaily`, `FrequencyMonthly`, `FrequencyWeekly` +- New enum type `KpiTypeType` with values `KpiTypeTypeBudget`, `KpiTypeTypeForecast` +- New enum type `PivotTypeType` with values `PivotTypeTypeDimension`, `PivotTypeTypeTagKey` +- 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(credential azcore.TokenCredential, options *arm.ClientOptions) (*BudgetsClient, error)` +- New function `*BudgetsClient.CreateOrUpdate(ctx context.Context, scope string, budgetName string, parameters Budget, options *BudgetsClientCreateOrUpdateOptions) (BudgetsClientCreateOrUpdateResponse, error)` +- New function `*BudgetsClient.Delete(ctx context.Context, scope string, budgetName string, options *BudgetsClientDeleteOptions) (BudgetsClientDeleteResponse, error)` +- New function `*BudgetsClient.Get(ctx context.Context, scope string, budgetName string, options *BudgetsClientGetOptions) (BudgetsClientGetResponse, error)` +- New function `*BudgetsClient.NewListPager(scope string, options *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(credential azcore.TokenCredential, options *arm.ClientOptions) (*CostAllocationRulesClient, error)` +- New function `*CostAllocationRulesClient.CheckNameAvailability(ctx context.Context, billingAccountID string, costAllocationRuleCheckNameAvailabilityRequest CostAllocationRuleCheckNameAvailabilityRequest, options *CostAllocationRulesClientCheckNameAvailabilityOptions) (CostAllocationRulesClientCheckNameAvailabilityResponse, error)` +- New function `*CostAllocationRulesClient.CreateOrUpdate(ctx context.Context, billingAccountID string, ruleName string, costAllocationRule CostAllocationRuleDefinition, options *CostAllocationRulesClientCreateOrUpdateOptions) (CostAllocationRulesClientCreateOrUpdateResponse, error)` +- New function `*CostAllocationRulesClient.Delete(ctx context.Context, billingAccountID string, ruleName string, options *CostAllocationRulesClientDeleteOptions) (CostAllocationRulesClientDeleteResponse, error)` +- New function `*CostAllocationRulesClient.Get(ctx context.Context, billingAccountID string, ruleName string, options *CostAllocationRulesClientGetOptions) (CostAllocationRulesClientGetResponse, error)` +- New function `*CostAllocationRulesClient.NewListPager(billingAccountID string, options *CostAllocationRulesClientListOptions) *runtime.Pager[CostAllocationRulesClientListResponse]` +- New function `NewGenerateBenefitUtilizationSummariesReportClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*GenerateBenefitUtilizationSummariesReportClient, error)` +- New function `*GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByBillingAccount(ctx context.Context, billingAccountID string, benefitUtilizationSummariesRequest BenefitUtilizationSummariesRequest, options *GenerateBenefitUtilizationSummariesReportClientBeginGenerateByBillingAccountOptions) (*runtime.Poller[GenerateBenefitUtilizationSummariesReportClientGenerateByBillingAccountResponse], error)` +- New function `*GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByBillingProfile(ctx context.Context, billingAccountID string, billingProfileID string, benefitUtilizationSummariesRequest BenefitUtilizationSummariesRequest, options *GenerateBenefitUtilizationSummariesReportClientBeginGenerateByBillingProfileOptions) (*runtime.Poller[GenerateBenefitUtilizationSummariesReportClientGenerateByBillingProfileResponse], error)` +- New function `*GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByReservationID(ctx context.Context, reservationOrderID string, reservationID string, benefitUtilizationSummariesRequest BenefitUtilizationSummariesRequest, options *GenerateBenefitUtilizationSummariesReportClientBeginGenerateByReservationIDOptions) (*runtime.Poller[GenerateBenefitUtilizationSummariesReportClientGenerateByReservationIDResponse], error)` +- New function `*GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByReservationOrderID(ctx context.Context, reservationOrderID string, benefitUtilizationSummariesRequest BenefitUtilizationSummariesRequest, options *GenerateBenefitUtilizationSummariesReportClientBeginGenerateByReservationOrderIDOptions) (*runtime.Poller[GenerateBenefitUtilizationSummariesReportClientGenerateByReservationOrderIDResponse], error)` +- New function `*GenerateBenefitUtilizationSummariesReportClient.BeginGenerateBySavingsPlanID(ctx context.Context, savingsPlanOrderID string, savingsPlanID string, benefitUtilizationSummariesRequest BenefitUtilizationSummariesRequest, options *GenerateBenefitUtilizationSummariesReportClientBeginGenerateBySavingsPlanIDOptions) (*runtime.Poller[GenerateBenefitUtilizationSummariesReportClientGenerateBySavingsPlanIDResponse], error)` +- New function `*GenerateBenefitUtilizationSummariesReportClient.BeginGenerateBySavingsPlanOrderID(ctx context.Context, savingsPlanOrderID string, benefitUtilizationSummariesRequest BenefitUtilizationSummariesRequest, options *GenerateBenefitUtilizationSummariesReportClientBeginGenerateBySavingsPlanOrderIDOptions) (*runtime.Poller[GenerateBenefitUtilizationSummariesReportClientGenerateBySavingsPlanOrderIDResponse], error)` +- New function `*PriceSheetClient.BeginDownloadByBillingAccount(ctx context.Context, billingAccountID string, billingPeriodName string, options *PriceSheetClientBeginDownloadByBillingAccountOptions) (*runtime.Poller[PriceSheetClientDownloadByBillingAccountResponse], error)` +- New function `*PriceSheetClient.BeginDownloadByInvoice(ctx context.Context, billingAccountName string, billingProfileName string, invoiceName string, options *PriceSheetClientBeginDownloadByInvoiceOptions) (*runtime.Poller[PriceSheetClientDownloadByInvoiceResponse], error)` +- New function `*Setting.GetSetting() *Setting` +- New function `NewSettingsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*SettingsClient, error)` +- New function `*SettingsClient.CreateOrUpdateByScope(ctx context.Context, scope string, typeParam SettingType, setting SettingClassification, options *SettingsClientCreateOrUpdateByScopeOptions) (SettingsClientCreateOrUpdateByScopeResponse, error)` +- New function `*SettingsClient.DeleteByScope(ctx context.Context, scope string, typeParam SettingType, options *SettingsClientDeleteByScopeOptions) (SettingsClientDeleteByScopeResponse, error)` +- New function `*SettingsClient.GetByScope(ctx context.Context, scope string, typeParam SettingType, options *SettingsClientGetByScopeOptions) (SettingsClientGetByScopeResponse, error)` +- New function `*SettingsClient.NewListPager(scope string, options *SettingsClientListOptions) *runtime.Pager[SettingsClientListResponse]` +- 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 `ExportRunRequest` +- New struct `ExportSuspensionContext` +- New struct `FilterItems` +- New struct `ForecastSpend` +- New struct `MCAPriceSheetProperties` +- New struct `Notification` +- New struct `Operation` +- New struct `PricesheetDownloadProperties` +- New struct `SettingsListResult` +- New struct `SourceCostAllocationResource` +- New struct `SystemAssignedServiceIdentity` +- New struct `TagInheritanceProperties` +- New struct `TagInheritanceSetting` +- New struct `TargetCostAllocationResource` +- New field `SystemData` in struct `Alert` +- New field `SystemData` in struct `BenefitRecommendationModel` +- New field `SystemData` in struct `BenefitUtilizationSummary` +- New field `CompressionMode`, `DataOverwriteBehavior`, `ExportDescription`, `SystemSuspensionContext` in struct `CommonExportProperties` +- New field `NextLink` in struct `DimensionsListResult` +- New field `Identity`, `Location`, `SystemData` in struct `Export` +- New field `DataVersion`, `Filters` in struct `ExportDatasetConfiguration` +- New field `Type` in struct `ExportDeliveryDestination` +- New field `CompressionMode`, `DataOverwriteBehavior`, `ExportDescription`, `SystemSuspensionContext` in struct `ExportProperties` +- New field `EndDate`, `ManifestFile`, `StartDate` in struct `ExportRunProperties` +- New field `Parameters` in struct `ExportsClientExecuteOptions` +- New field `AzureConsumptionAsyncOperation` in struct `GenerateDetailedCostReportClientCreateOperationResponse` +- New field `SystemData` in struct `GenerateDetailedCostReportOperationResult` +- New field `SystemData` in struct `GenerateDetailedCostReportOperationStatuses` +- New field `SystemData` in struct `IncludedQuantityUtilizationSummary` +- New anonymous field `PricesheetDownloadProperties` in struct `PriceSheetClientDownloadByBillingProfileResponse` +- New field `ODataEntityID` in struct `PriceSheetClientDownloadByBillingProfileResponse` +- New field `SystemData` in struct `SavingsPlanUtilizationSummary` +- New field `SystemData` in struct `View` + + ## 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 535a807e2c59..b3485d57905f 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 @@ -36,7 +36,7 @@ For more information on authentication, please see the documentation for `aziden Azure Costmanagement module consists of one or more clients. We provide a client factory which could be used to create any client in this module. ```go -clientFactory, err := armcostmanagement.NewClientFactory(, cred, nil) +clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) ``` You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). @@ -47,7 +47,7 @@ options := arm.ClientOptions { Cloud: cloud.AzureChina, }, } -clientFactory, err := armcostmanagement.NewClientFactory(, cred, &options) +clientFactory, err := armcostmanagement.NewClientFactory(cred, &options) ``` ## Clients diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/alerts_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/alerts_client.go index aa3f84ad6c12..c6d17f35042e 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/alerts_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/alerts_client.go @@ -1,7 +1,6 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armcostmanagement @@ -25,7 +24,7 @@ type AlertsClient struct { // NewAlertsClient creates a new instance of AlertsClient with the specified values. // - credential - used to authorize requests. Usually a credential from azidentity. -// - options - pass nil to accept the default values. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewAlertsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*AlertsClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -40,17 +39,8 @@ 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 -// - 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 -// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope, -// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount -// scope, -// '/providers/Microsoft.Management/managementGroups/{managementGroupId} for Management Group scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' -// for billingProfile scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' -// for invoiceSection scope, and -// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for partners. +// Generated from API version 2025-03-01 +// - scope - The fully qualified Azure Resource manager identifier of the resource. // - alertID - Alert ID // - parameters - Parameters supplied to the Dismiss Alert operation. // - options - AlertsClientDismissOptions contains the optional parameters for the AlertsClient.Dismiss method. @@ -77,18 +67,25 @@ func (client *AlertsClient) Dismiss(ctx context.Context, scope string, alertID s } // dismissCreateRequest creates the Dismiss request. -func (client *AlertsClient) dismissCreateRequest(ctx context.Context, scope string, alertID string, parameters DismissAlertPayload, options *AlertsClientDismissOptions) (*policy.Request, error) { +func (client *AlertsClient) dismissCreateRequest(ctx context.Context, scope string, alertID string, parameters DismissAlertPayload, _ *AlertsClientDismissOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.CostManagement/alerts/{alertId}" + if scope == "" { + return nil, errors.New("parameter scope cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) + if alertID == "" { + return nil, errors.New("parameter alertID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{alertId}", alertID) req, err := runtime.NewRequest(ctx, http.MethodPatch, 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", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -107,17 +104,8 @@ 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 -// - 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 -// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope, -// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount -// scope, -// '/providers/Microsoft.Management/managementGroups/{managementGroupId} for Management Group scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' -// for billingProfile scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' -// for invoiceSection scope, and -// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for partners. +// Generated from API version 2025-03-01 +// - scope - The fully qualified Azure Resource manager identifier of the resource. // - alertID - Alert ID // - options - AlertsClientGetOptions contains the optional parameters for the AlertsClient.Get method. func (client *AlertsClient) Get(ctx context.Context, scope string, alertID string, options *AlertsClientGetOptions) (AlertsClientGetResponse, error) { @@ -143,16 +131,22 @@ func (client *AlertsClient) Get(ctx context.Context, scope string, alertID strin } // getCreateRequest creates the Get request. -func (client *AlertsClient) getCreateRequest(ctx context.Context, scope string, alertID string, options *AlertsClientGetOptions) (*policy.Request, error) { +func (client *AlertsClient) getCreateRequest(ctx context.Context, scope string, alertID string, _ *AlertsClientGetOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.CostManagement/alerts/{alertId}" + if scope == "" { + return nil, errors.New("parameter scope cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) + if alertID == "" { + return nil, errors.New("parameter alertID cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{alertId}", alertID) 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", "2022-10-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -167,53 +161,48 @@ func (client *AlertsClient) getHandleResponse(resp *http.Response) (AlertsClient return result, nil } -// List - Lists the alerts for scope defined. -// If the operation fails it returns an *azcore.ResponseError type. +// NewListPager - Lists the alerts for scope defined. // -// Generated from API version 2022-10-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 -// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope, -// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount -// scope, -// '/providers/Microsoft.Management/managementGroups/{managementGroupId} for Management Group scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' -// for billingProfile scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' -// for invoiceSection scope, and -// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for partners. -// - options - AlertsClientListOptions contains the optional parameters for the AlertsClient.List method. -func (client *AlertsClient) List(ctx context.Context, scope string, options *AlertsClientListOptions) (AlertsClientListResponse, error) { - var err error - const operationName = "AlertsClient.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 AlertsClientListResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return AlertsClientListResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return AlertsClientListResponse{}, err - } - resp, err := client.listHandleResponse(httpResp) - return resp, err +// Generated from API version 2025-03-01 +// - scope - The fully qualified Azure Resource manager identifier of the resource. +// - options - AlertsClientListOptions contains the optional parameters for the AlertsClient.NewListPager method. +func (client *AlertsClient) NewListPager(scope string, options *AlertsClientListOptions) *runtime.Pager[AlertsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[AlertsClientListResponse]{ + More: func(page AlertsClientListResponse) bool { + return false + }, + Fetcher: func(ctx context.Context, page *AlertsClientListResponse) (AlertsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "AlertsClient.NewListPager") + req, err := client.listCreateRequest(ctx, scope, options) + if err != nil { + return AlertsClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return AlertsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AlertsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) } // listCreateRequest creates the List request. -func (client *AlertsClient) listCreateRequest(ctx context.Context, scope string, options *AlertsClientListOptions) (*policy.Request, error) { +func (client *AlertsClient) listCreateRequest(ctx context.Context, scope string, _ *AlertsClientListOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.CostManagement/alerts" + if scope == "" { + return nil, errors.New("parameter scope cannot be empty") + } 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() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -231,7 +220,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 2025-03-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 @@ -260,7 +249,7 @@ func (client *AlertsClient) ListExternal(ctx context.Context, externalCloudProvi } // listExternalCreateRequest creates the ListExternal request. -func (client *AlertsClient) listExternalCreateRequest(ctx context.Context, externalCloudProviderType ExternalCloudProviderType, externalCloudProviderID string, options *AlertsClientListExternalOptions) (*policy.Request, error) { +func (client *AlertsClient) listExternalCreateRequest(ctx context.Context, externalCloudProviderType ExternalCloudProviderType, externalCloudProviderID string, _ *AlertsClientListExternalOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.CostManagement/{externalCloudProviderType}/{externalCloudProviderId}/alerts" if externalCloudProviderType == "" { return nil, errors.New("parameter externalCloudProviderType cannot be empty") @@ -275,7 +264,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", "2025-03-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 index 45485c5d4c66..ceabba4ee75e 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/alerts_client_example_test.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/alerts_client_example_test.go @@ -1,799 +1,19 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. 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"), - // }, - // }, - // }}, - // } -} + "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/v3" + "log" +) -// Generated from 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() { +// Generated from example definition: 2025-03-01/DismissResourceGroupAlerts.json +func ExampleAlertsClient_Dismiss_patchResourceGroupAlerts() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -803,40 +23,44 @@ func ExampleAlertsClient_Get_singleResourceGroupAlerts() { 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) + 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.AlertStatusActive), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, + // res = armcostmanagement.AlertsClientDismissResponse{ + // 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{ + // ContactEmails: []*string{ + // to.Ptr("1234@contoso.com"), + // }, // ContactGroups: []*string{ // }, // ContactRoles: []*string{ // }, - // CurrentSpend: to.Ptr[float64](161000.12), // MeterFilter: []any{ // }, // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), @@ -847,17 +71,17 @@ func ExampleAlertsClient_Get_singleResourceGroupAlerts() { // }, // 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() { +// Generated from example definition: 2025-03-01/DismissSubscriptionAlerts.json +func ExampleAlertsClient_Dismiss_patchSubscriptionAlerts() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -867,40 +91,44 @@ func ExampleAlertsClient_Get_singleSubscriptionAlerts() { 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) + 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.AlertStatusActive), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, + // res = armcostmanagement.AlertsClientDismissResponse{ + // 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{ + // ContactEmails: []*string{ + // to.Ptr("1234@contoso.com"), + // }, // ContactGroups: []*string{ // }, // ContactRoles: []*string{ // }, - // CurrentSpend: to.Ptr[float64](161000.12), // MeterFilter: []any{ // }, // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), @@ -911,17 +139,17 @@ func ExampleAlertsClient_Get_singleSubscriptionAlerts() { // }, // 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() { +// Generated from example definition: 2025-03-01/SingleResourceGroupAlert.json +func ExampleAlertsClient_Get_singleResourceGroupAlerts() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -931,44 +159,40 @@ func ExampleAlertsClient_Dismiss_patchResourceGroupAlerts() { 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) + 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.AlertStatusDismissed), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, + // res = armcostmanagement.AlertsClientGetResponse{ + // 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{ + // ContactEmails: []*string{ + // to.Ptr("1234@contoso.com"), + // }, // ContactGroups: []*string{ // }, // ContactRoles: []*string{ // }, - // CurrentSpend: to.Ptr[float64](161000.12), // MeterFilter: []any{ // }, // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), @@ -979,17 +203,17 @@ func ExampleAlertsClient_Dismiss_patchResourceGroupAlerts() { // }, // 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() { +// Generated from example definition: 2025-03-01/SingleSubscriptionAlert.json +func ExampleAlertsClient_Get_singleSubscriptionAlerts() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -999,44 +223,40 @@ func ExampleAlertsClient_Dismiss_patchSubscriptionAlerts() { 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) + 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.AlertStatusDismissed), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, + // res = armcostmanagement.AlertsClientGetResponse{ + // 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{ + // ContactEmails: []*string{ + // to.Ptr("1234@contoso.com"), + // }, // ContactGroups: []*string{ // }, // ContactRoles: []*string{ // }, - // CurrentSpend: to.Ptr[float64](161000.12), // MeterFilter: []any{ // }, // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), @@ -1047,16 +267,821 @@ func ExampleAlertsClient_Dismiss_patchSubscriptionAlerts() { // }, // 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: 2025-03-01/BillingAccountAlerts.json +func ExampleAlertsClient_NewListPager_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) + } + pager := clientFactory.NewAlertsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345-6789", 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 = armcostmanagement.AlertsClientListResponse{ + // 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{ + // ContactEmails: []*string{ + // to.Ptr("1234@contoso.com"), + // }, + // ContactGroups: []*string{ + // }, + // ContactRoles: []*string{ + // }, + // MeterFilter: []any{ + // }, + // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), + // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), + // ResourceFilter: []any{ + // }, + // ResourceGroupFilter: []any{ + // }, + // TagFilter: map[string]any{ + // }, + // 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{ + // ContactEmails: []*string{ + // to.Ptr("1234@contoso.com"), + // }, + // ContactGroups: []*string{ + // }, + // ContactRoles: []*string{ + // }, + // MeterFilter: []any{ + // }, + // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), + // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), + // ResourceFilter: []any{ + // }, + // ResourceGroupFilter: []any{ + // }, + // TagFilter: map[string]any{ + // }, + // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), + // TriggeredBy: to.Ptr("11111111-1111-1111-111111111111_1_01"), + // Unit: to.Ptr("USD"), + // }, + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2025-03-01/BillingProfileAlerts.json +func ExampleAlertsClient_NewListPager_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) + } + pager := clientFactory.NewAlertsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345-6789/billingProfiles/13579", 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 = armcostmanagement.AlertsClientListResponse{ + // 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{ + // ContactEmails: []*string{ + // to.Ptr("1234@contoso.com"), + // }, + // ContactGroups: []*string{ + // }, + // ContactRoles: []*string{ + // }, + // MeterFilter: []any{ + // }, + // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), + // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), + // ResourceFilter: []any{ + // }, + // ResourceGroupFilter: []any{ + // }, + // TagFilter: map[string]any{ + // }, + // 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{ + // ContactEmails: []*string{ + // to.Ptr("1234@contoso.com"), + // }, + // ContactGroups: []*string{ + // }, + // ContactRoles: []*string{ + // }, + // MeterFilter: []any{ + // }, + // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), + // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), + // ResourceFilter: []any{ + // }, + // ResourceGroupFilter: []any{ + // }, + // TagFilter: map[string]any{ + // }, + // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), + // TriggeredBy: to.Ptr("11111111-1111-1111-111111111111_1_01"), + // Unit: to.Ptr("USD"), + // }, + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2025-03-01/DepartmentAlerts.json +func ExampleAlertsClient_NewListPager_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) + } + pager := clientFactory.NewAlertsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345:6789/departments/123", 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 = armcostmanagement.AlertsClientListResponse{ + // 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{ + // ContactEmails: []*string{ + // to.Ptr("1234@contoso.com"), + // }, + // ContactGroups: []*string{ + // }, + // ContactRoles: []*string{ + // }, + // MeterFilter: []any{ + // }, + // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), + // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), + // ResourceFilter: []any{ + // }, + // ResourceGroupFilter: []any{ + // }, + // TagFilter: map[string]any{ + // }, + // 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{ + // ContactEmails: []*string{ + // to.Ptr("1234@contoso.com"), + // }, + // ContactGroups: []*string{ + // }, + // ContactRoles: []*string{ + // }, + // MeterFilter: []any{ + // }, + // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), + // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), + // ResourceFilter: []any{ + // }, + // ResourceGroupFilter: []any{ + // }, + // TagFilter: map[string]any{ + // }, + // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), + // TriggeredBy: to.Ptr("11111111-1111-1111-111111111111_1_01"), + // Unit: to.Ptr("USD"), + // }, + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2025-03-01/EnrollmentAccountAlerts.json +func ExampleAlertsClient_NewListPager_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) + } + pager := clientFactory.NewAlertsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345:6789/enrollmentAccounts/456", 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 = armcostmanagement.AlertsClientListResponse{ + // 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{ + // ContactEmails: []*string{ + // to.Ptr("1234@contoso.com"), + // }, + // ContactGroups: []*string{ + // }, + // ContactRoles: []*string{ + // }, + // MeterFilter: []any{ + // }, + // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), + // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), + // ResourceFilter: []any{ + // }, + // ResourceGroupFilter: []any{ + // }, + // TagFilter: map[string]any{ + // }, + // 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{ + // ContactEmails: []*string{ + // to.Ptr("1234@contoso.com"), + // }, + // ContactGroups: []*string{ + // }, + // ContactRoles: []*string{ + // }, + // MeterFilter: []any{ + // }, + // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), + // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), + // ResourceFilter: []any{ + // }, + // ResourceGroupFilter: []any{ + // }, + // TagFilter: map[string]any{ + // }, + // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), + // TriggeredBy: to.Ptr("11111111-1111-1111-111111111111_1_01"), + // Unit: to.Ptr("USD"), + // }, + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2025-03-01/InvoiceSectionAlerts.json +func ExampleAlertsClient_NewListPager_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) + } + pager := clientFactory.NewAlertsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876", 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 = armcostmanagement.AlertsClientListResponse{ + // 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{ + // ContactEmails: []*string{ + // to.Ptr("1234@contoso.com"), + // }, + // ContactGroups: []*string{ + // }, + // ContactRoles: []*string{ + // }, + // MeterFilter: []any{ + // }, + // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), + // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), + // ResourceFilter: []any{ + // }, + // ResourceGroupFilter: []any{ + // }, + // TagFilter: map[string]any{ + // }, + // 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{ + // ContactEmails: []*string{ + // to.Ptr("1234@contoso.com"), + // }, + // ContactGroups: []*string{ + // }, + // ContactRoles: []*string{ + // }, + // MeterFilter: []any{ + // }, + // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), + // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), + // ResourceFilter: []any{ + // }, + // ResourceGroupFilter: []any{ + // }, + // TagFilter: map[string]any{ + // }, + // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), + // TriggeredBy: to.Ptr("11111111-1111-1111-111111111111_1_01"), + // Unit: to.Ptr("USD"), + // }, + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2025-03-01/ResourceGroupAlerts.json +func ExampleAlertsClient_NewListPager_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) + } + pager := clientFactory.NewAlertsClient().NewListPager("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ScreenSharingTest-peer", 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 = armcostmanagement.AlertsClientListResponse{ + // 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{ + // ContactEmails: []*string{ + // to.Ptr("1234@contoso.com"), + // }, + // ContactGroups: []*string{ + // }, + // ContactRoles: []*string{ + // }, + // MeterFilter: []any{ + // }, + // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), + // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), + // ResourceFilter: []any{ + // }, + // ResourceGroupFilter: []any{ + // }, + // TagFilter: map[string]any{ + // }, + // 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{ + // ContactEmails: []*string{ + // to.Ptr("1234@contoso.com"), + // }, + // ContactGroups: []*string{ + // }, + // ContactRoles: []*string{ + // }, + // MeterFilter: []any{ + // }, + // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), + // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), + // ResourceFilter: []any{ + // }, + // ResourceGroupFilter: []any{ + // }, + // TagFilter: map[string]any{ + // }, + // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), + // TriggeredBy: to.Ptr("11111111-1111-1111-111111111111_1_01"), + // Unit: to.Ptr("USD"), + // }, + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2025-03-01/SubscriptionAlerts.json +func ExampleAlertsClient_NewListPager_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) + } + pager := clientFactory.NewAlertsClient().NewListPager("subscriptions/00000000-0000-0000-0000-000000000000", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armcostmanagement.AlertsClientListResponse{ + // 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{ + // ContactEmails: []*string{ + // to.Ptr("1234@contoso.com"), + // }, + // ContactGroups: []*string{ + // }, + // ContactRoles: []*string{ + // }, + // MeterFilter: []any{ + // }, + // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), + // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), + // ResourceFilter: []any{ + // }, + // ResourceGroupFilter: []any{ + // }, + // TagFilter: map[string]any{ + // }, + // 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{ + // ContactEmails: []*string{ + // to.Ptr("1234@contoso.com"), + // }, + // ContactGroups: []*string{ + // }, + // ContactRoles: []*string{ + // }, + // MeterFilter: []any{ + // }, + // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), + // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), + // ResourceFilter: []any{ + // }, + // ResourceGroupFilter: []any{ + // }, + // TagFilter: map[string]any{ + // }, + // 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/ExternalBillingAccountAlerts.json +// Generated from example definition: 2025-03-01/ExternalBillingAccountAlerts.json func ExampleAlertsClient_ListExternal_externalBillingAccountAlerts() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -1074,35 +1099,35 @@ func ExampleAlertsClient_ListExternal_externalBillingAccountAlerts() { // 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")}, + // res = armcostmanagement.AlertsClientListExternalResponse{ + // 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{ + // ContactEmails: []*string{ + // to.Ptr("1234@contoso.com"), + // }, // ContactGroups: []*string{ // }, // ContactRoles: []*string{ // }, - // CurrentSpend: to.Ptr[float64](161000.12), // MeterFilter: []any{ // }, // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), @@ -1113,7 +1138,6 @@ func ExampleAlertsClient_ListExternal_externalBillingAccountAlerts() { // }, // 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"), @@ -1123,7 +1147,7 @@ func ExampleAlertsClient_ListExternal_externalBillingAccountAlerts() { // { // 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"), + // 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"), @@ -1139,35 +1163,35 @@ func ExampleAlertsClient_ListExternal_externalBillingAccountAlerts() { // 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"), + // to.Ptr("1234@contoso.com"), + // }, + // ContactGroups: []*string{ + // }, + // ContactRoles: []*string{ + // }, + // MeterFilter: []any{ + // }, + // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), + // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), + // ResourceFilter: []any{ + // }, + // ResourceGroupFilter: []any{ // }, + // TagFilter: map[string]any{ + // }, + // 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 +// Generated from example definition: 2025-03-01/ExternalSubscriptionAlerts.json func ExampleAlertsClient_ListExternal_externalSubscriptionAlerts() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -1185,35 +1209,35 @@ func ExampleAlertsClient_ListExternal_externalSubscriptionAlerts() { // 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")}, + // res = armcostmanagement.AlertsClientListExternalResponse{ + // 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{ + // ContactEmails: []*string{ + // to.Ptr("1234@contoso.com"), + // }, // ContactGroups: []*string{ // }, // ContactRoles: []*string{ // }, - // CurrentSpend: to.Ptr[float64](161000.12), // MeterFilter: []any{ // }, // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), @@ -1224,7 +1248,6 @@ func ExampleAlertsClient_ListExternal_externalSubscriptionAlerts() { // }, // 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"), @@ -1234,7 +1257,7 @@ func ExampleAlertsClient_ListExternal_externalSubscriptionAlerts() { // { // 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"), + // 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"), @@ -1250,30 +1273,30 @@ func ExampleAlertsClient_ListExternal_externalSubscriptionAlerts() { // 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"), + // to.Ptr("1234@contoso.com"), + // }, + // ContactGroups: []*string{ + // }, + // ContactRoles: []*string{ + // }, + // MeterFilter: []any{ + // }, + // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), + // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), + // ResourceFilter: []any{ + // }, + // ResourceGroupFilter: []any{ + // }, + // TagFilter: map[string]any{ // }, + // 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 deleted file mode 100644 index 4feb493f501a..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/autorest.md +++ /dev/null @@ -1,13 +0,0 @@ -### AutoRest Configuration - -> see https://aka.ms/autorest - -``` 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 -license-header: MICROSOFT_MIT_NO_VERSION -module-version: 2.1.0 -tag: package-2022-10 -``` \ 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 587238858949..01dece5f2ec0 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/benefitrecommendations_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/benefitrecommendations_client.go @@ -1,12 +1,12 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. 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" @@ -23,7 +23,7 @@ type BenefitRecommendationsClient struct { // NewBenefitRecommendationsClient creates a new instance of BenefitRecommendationsClient with the specified values. // - credential - used to authorize requests. Usually a credential from azidentity. -// - options - pass nil to accept the default values. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewBenefitRecommendationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*BenefitRecommendationsClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -37,13 +37,11 @@ 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 2025-03-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}' -// for enterprise agreement scope, and -// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billing profile -// scope +// for subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resource group scope, +// /providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for enterprise agreement scope, and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' +// for billing profile scope // - options - BenefitRecommendationsClientListOptions contains the optional parameters for the BenefitRecommendationsClient.NewListPager // method. func (client *BenefitRecommendationsClient) NewListPager(billingScope string, options *BenefitRecommendationsClientListOptions) *runtime.Pager[BenefitRecommendationsClientListResponse] { @@ -72,22 +70,25 @@ func (client *BenefitRecommendationsClient) NewListPager(billingScope string, op // listCreateRequest creates the List request. func (client *BenefitRecommendationsClient) listCreateRequest(ctx context.Context, billingScope string, options *BenefitRecommendationsClientListOptions) (*policy.Request, error) { urlPath := "/{billingScope}/providers/Microsoft.CostManagement/benefitRecommendations" + if billingScope == "" { + return nil, errors.New("parameter billingScope cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{billingScope}", billingScope) 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.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", "2025-03-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 index 95935db7d8dd..203703e54fc1 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/benefitrecommendations_client_example_test.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/benefitrecommendations_client_example_test.go @@ -1,21 +1,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. +// Code generated by Microsoft (R) Go Code Generator. 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" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v3" + "log" ) -// Generated from 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 +// Generated from example definition: 2025-03-01/BenefitRecommendationsByBillingAccount.json func ExampleBenefitRecommendationsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -26,10 +23,9 @@ func ExampleBenefitRecommendationsClient_NewListPager() { 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"), - }) + pager := clientFactory.NewBenefitRecommendationsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/123456", &armcostmanagement.BenefitRecommendationsClientListOptions{ + Expand: to.Ptr("properties/usage,properties/allRecommendationDetails"), + Filter: to.Ptr("properties/lookBackPeriod eq 'Last7Days' AND properties/term eq 'P1Y'")}) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -40,112 +36,43 @@ func ExampleBenefitRecommendationsClient_NewListPager() { _ = 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), + // page = armcostmanagement.BenefitRecommendationsClientListResponse{ + // 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{ + // { + // }, + // { + // }, + // }, + // }, + // ArmSKUName: to.Ptr("Compute_Savings_Plan"), + // CommitmentGranularity: to.Ptr(armcostmanagement.GrainHourly), + // CurrencyCode: to.Ptr("USD"), + // FirstConsumptionDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-18T00:00:00Z"); return t}()), + // LastConsumptionDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-25T00:00:00Z"); return t}()), + // LookBackPeriod: to.Ptr(armcostmanagement.LookBackPeriodLast7Days), + // RecommendationDetails: &armcostmanagement.AllSavingsBenefitDetails{ + // }, + // Scope: to.Ptr(armcostmanagement.ScopeShared), + // Term: to.Ptr(armcostmanagement.TermP1Y), + // TotalHours: to.Ptr[int32](168), + // Usage: &armcostmanagement.RecommendationUsageDetails{ + // Charges: []*float64{ // }, - // { - // 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 d1d8a5b0caa9..4a9987808a37 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/benefitutilizationsummaries_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/benefitutilizationsummaries_client.go @@ -1,7 +1,6 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armcostmanagement @@ -25,7 +24,7 @@ type BenefitUtilizationSummariesClient struct { // NewBenefitUtilizationSummariesClient creates a new instance of BenefitUtilizationSummariesClient with the specified values. // - credential - used to authorize requests. Usually a credential from azidentity. -// - options - pass nil to accept the default values. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewBenefitUtilizationSummariesClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*BenefitUtilizationSummariesClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -40,8 +39,8 @@ 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 -// - billingAccountID - Billing account ID +// Generated from API version 2025-03-01 +// - billingAccountID - BillingAccount ID // - options - BenefitUtilizationSummariesClientListByBillingAccountIDOptions contains the optional parameters for the BenefitUtilizationSummariesClient.NewListByBillingAccountIDPager // method. func (client *BenefitUtilizationSummariesClient) NewListByBillingAccountIDPager(billingAccountID string, options *BenefitUtilizationSummariesClientListByBillingAccountIDOptions) *runtime.Pager[BenefitUtilizationSummariesClientListByBillingAccountIDResponse] { @@ -69,7 +68,7 @@ func (client *BenefitUtilizationSummariesClient) NewListByBillingAccountIDPager( // listByBillingAccountIDCreateRequest creates the ListByBillingAccountID request. func (client *BenefitUtilizationSummariesClient) listByBillingAccountIDCreateRequest(ctx context.Context, billingAccountID string, options *BenefitUtilizationSummariesClientListByBillingAccountIDOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.CostManagement/benefitUtilizationSummaries" + urlPath := "/providers/microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.CostManagement/benefitUtilizationSummaries" if billingAccountID == "" { return nil, errors.New("parameter billingAccountID cannot be empty") } @@ -79,13 +78,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", "2025-03-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 @@ -103,9 +102,9 @@ 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 -// - billingAccountID - Billing account ID -// - billingProfileID - Billing profile ID. +// Generated from API version 2025-03-01 +// - billingAccountID - BillingAccount ID +// - billingProfileID - Billing Profile ID. // - options - BenefitUtilizationSummariesClientListByBillingProfileIDOptions contains the optional parameters for the BenefitUtilizationSummariesClient.NewListByBillingProfileIDPager // method. func (client *BenefitUtilizationSummariesClient) NewListByBillingProfileIDPager(billingAccountID string, billingProfileID string, options *BenefitUtilizationSummariesClientListByBillingProfileIDOptions) *runtime.Pager[BenefitUtilizationSummariesClientListByBillingProfileIDResponse] { @@ -133,7 +132,7 @@ func (client *BenefitUtilizationSummariesClient) NewListByBillingProfileIDPager( // listByBillingProfileIDCreateRequest creates the ListByBillingProfileID request. func (client *BenefitUtilizationSummariesClient) listByBillingProfileIDCreateRequest(ctx context.Context, billingAccountID string, billingProfileID string, options *BenefitUtilizationSummariesClientListByBillingProfileIDOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.CostManagement/benefitUtilizationSummaries" + urlPath := "/providers/microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.CostManagement/benefitUtilizationSummaries" if billingAccountID == "" { return nil, errors.New("parameter billingAccountID cannot be empty") } @@ -147,13 +146,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", "2025-03-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 @@ -170,7 +169,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 2025-03-01 // - savingsPlanOrderID - Savings plan order ID. // - savingsPlanID - Savings plan ID. // - options - BenefitUtilizationSummariesClientListBySavingsPlanIDOptions contains the optional parameters for the BenefitUtilizationSummariesClient.NewListBySavingsPlanIDPager @@ -200,7 +199,7 @@ func (client *BenefitUtilizationSummariesClient) NewListBySavingsPlanIDPager(sav // listBySavingsPlanIDCreateRequest creates the ListBySavingsPlanID request. func (client *BenefitUtilizationSummariesClient) listBySavingsPlanIDCreateRequest(ctx context.Context, savingsPlanOrderID string, savingsPlanID string, options *BenefitUtilizationSummariesClientListBySavingsPlanIDOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.BillingBenefits/savingsPlanOrders/{savingsPlanOrderId}/savingsPlans/{savingsPlanId}/providers/Microsoft.CostManagement/benefitUtilizationSummaries" + urlPath := "/providers/microsoft.BillingBenefits/savingsPlanOrders/{savingsPlanOrderId}/savingsPlans/{savingsPlanId}/providers/Microsoft.CostManagement/benefitUtilizationSummaries" if savingsPlanOrderID == "" { return nil, errors.New("parameter savingsPlanOrderID cannot be empty") } @@ -214,10 +213,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", "2025-03-01") if options != nil && options.GrainParameter != nil { reqQP.Set("grainParameter", string(*options.GrainParameter)) } @@ -237,7 +236,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 2025-03-01 // - savingsPlanOrderID - Savings plan order ID. // - options - BenefitUtilizationSummariesClientListBySavingsPlanOrderOptions contains the optional parameters for the BenefitUtilizationSummariesClient.NewListBySavingsPlanOrderPager // method. @@ -266,7 +265,7 @@ func (client *BenefitUtilizationSummariesClient) NewListBySavingsPlanOrderPager( // listBySavingsPlanOrderCreateRequest creates the ListBySavingsPlanOrder request. func (client *BenefitUtilizationSummariesClient) listBySavingsPlanOrderCreateRequest(ctx context.Context, savingsPlanOrderID string, options *BenefitUtilizationSummariesClientListBySavingsPlanOrderOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.BillingBenefits/savingsPlanOrders/{savingsPlanOrderId}/providers/Microsoft.CostManagement/benefitUtilizationSummaries" + urlPath := "/providers/microsoft.BillingBenefits/savingsPlanOrders/{savingsPlanOrderId}/providers/Microsoft.CostManagement/benefitUtilizationSummaries" if savingsPlanOrderID == "" { return nil, errors.New("parameter savingsPlanOrderID cannot be empty") } @@ -276,10 +275,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", "2025-03-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 index 14b2e2c7b542..97d72d82943c 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/benefitutilizationsummaries_client_example_test.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/benefitutilizationsummaries_client_example_test.go @@ -1,21 +1,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. +// Code generated by Microsoft (R) Go Code Generator. 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" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v3" + "log" ) -// Generated from 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 +// Generated from example definition: 2025-03-01/BenefitUtilizationSummaries/SavingsPlan-BillingAccount.json func ExampleBenefitUtilizationSummariesClient_NewListByBillingAccountIDPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -26,9 +23,8 @@ func ExampleBenefitUtilizationSummariesClient_NewListByBillingAccountIDPager() { 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"), - }) + pager := clientFactory.NewBenefitUtilizationSummariesClient().NewListByBillingAccountIDPager("12345", &armcostmanagement.BenefitUtilizationSummariesClientListByBillingAccountIDOptions{ + 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 { @@ -39,45 +35,42 @@ func ExampleBenefitUtilizationSummariesClient_NewListByBillingAccountIDPager() { _ = 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), + // page = armcostmanagement.BenefitUtilizationSummariesClientListByBillingAccountIDResponse{ + // 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:00Z"); return t}()), + // }, // }, - // }, - // &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), + // &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:00Z"); 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/BenefitUtilizationSummaries/SavingsPlan-BillingProfile.json +// Generated from example definition: 2025-03-01/BenefitUtilizationSummaries/SavingsPlan-BillingProfile.json func ExampleBenefitUtilizationSummariesClient_NewListByBillingProfileIDPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -88,9 +81,8 @@ func ExampleBenefitUtilizationSummariesClient_NewListByBillingProfileIDPager() { 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"), - }) + pager := clientFactory.NewBenefitUtilizationSummariesClient().NewListByBillingProfileIDPager("c0a00000-0e04-5ee3-000e-f0c6e00000ec:c0a00000-0e04-5ee3-000e-f0c6e00000ec", "200e5e90-000e-4960-8dcd-8d00a02db000", &armcostmanagement.BenefitUtilizationSummariesClientListByBillingProfileIDOptions{ + 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 { @@ -101,30 +93,30 @@ func ExampleBenefitUtilizationSummariesClient_NewListByBillingProfileIDPager() { _ = 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), + // page = armcostmanagement.BenefitUtilizationSummariesClientListByBillingProfileIDResponse{ + // 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:00Z"); 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/BenefitUtilizationSummaries/SavingsPlan-SavingsPlanOrderId-Daily.json -func ExampleBenefitUtilizationSummariesClient_NewListBySavingsPlanOrderPager() { +// Generated from example definition: 2025-03-01/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) @@ -134,9 +126,7 @@ func ExampleBenefitUtilizationSummariesClient_NewListBySavingsPlanOrderPager() { 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, - }) + pager := clientFactory.NewBenefitUtilizationSummariesClient().NewListBySavingsPlanIDPager("66cccc66-6ccc-6c66-666c-66cc6c6c66c6", "222d22dd-d2d2-2dd2-222d-2dd2222ddddd", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -147,30 +137,43 @@ func ExampleBenefitUtilizationSummariesClient_NewListBySavingsPlanOrderPager() { _ = 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), + // page = armcostmanagement.BenefitUtilizationSummariesClientListBySavingsPlanIDResponse{ + // 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:00Z"); return t}()), + // }, + // }, + // &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:00Z"); 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/BenefitUtilizationSummaries/SavingsPlan-SavingsPlanId-Monthly.json -func ExampleBenefitUtilizationSummariesClient_NewListBySavingsPlanIDPager() { +// Generated from example definition: 2025-03-01/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) @@ -180,9 +183,7 @@ func ExampleBenefitUtilizationSummariesClient_NewListBySavingsPlanIDPager() { 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, - }) + pager := clientFactory.NewBenefitUtilizationSummariesClient().NewListBySavingsPlanOrderPager("66cccc66-6ccc-6c66-666c-66cc6c6c66c6", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -193,40 +194,24 @@ func ExampleBenefitUtilizationSummariesClient_NewListBySavingsPlanIDPager() { _ = 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), + // page = armcostmanagement.BenefitUtilizationSummariesClientListBySavingsPlanOrderResponse{ + // 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:00Z"); return t}()), + // }, // }, // }, - // &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..6176e06c64e6 --- /dev/null +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/budgets_client.go @@ -0,0 +1,270 @@ +// 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) Go Code Generator. DO NOT EDIT. + +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 - Contains optional client configuration. 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 2025-03-01 +// - scope - The fully qualified Azure Resource manager identifier of the resource. +// - 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, _ *BudgetsClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/{scope}/providers/Microsoft.CostManagement/budgets/{budgetName}" + if scope == "" { + return nil, errors.New("parameter scope cannot be empty") + } + 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", "2025-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []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 2025-03-01 +// - scope - The fully qualified Azure Resource manager identifier of the resource. +// - 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, _ *BudgetsClientDeleteOptions) (*policy.Request, error) { + urlPath := "/{scope}/providers/Microsoft.CostManagement/budgets/{budgetName}" + if scope == "" { + return nil, errors.New("parameter scope cannot be empty") + } + 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", "2025-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + 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 2025-03-01 +// - scope - The fully qualified Azure Resource manager identifier of the resource. +// - 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, _ *BudgetsClientGetOptions) (*policy.Request, error) { + urlPath := "/{scope}/providers/Microsoft.CostManagement/budgets/{budgetName}" + if scope == "" { + return nil, errors.New("parameter scope cannot be empty") + } + 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", "2025-03-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 2025-03-01 +// - scope - The fully qualified Azure Resource manager identifier of the resource. +// - 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" + if scope == "" { + return nil, errors.New("parameter scope cannot be empty") + } + 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", "2025-03-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/budgets_client_example_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/budgets_client_example_test.go new file mode 100644 index 000000000000..39ab1d723d0b --- /dev/null +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/budgets_client_example_test.go @@ -0,0 +1,2922 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armcostmanagement_test + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "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/v3" + "log" + "time" +) + +// Generated from example definition: 2025-03-01/Budgets/CreateOrUpdate/Cost/CreateOrUpdate-Cost-Subscription-Budget.json +func ExampleBudgetsClient_CreateOrUpdate_createOrUpdateCostSubscriptionBudget() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain 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.NewBudgetsClient().CreateOrUpdate(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", "TestBudget", armcostmanagement.Budget{ + ETag: to.Ptr(azcore.ETag("\"1d34d016a593709\"")), + Properties: &armcostmanagement.BudgetProperties{ + Amount: to.Ptr[float32](100.65), + Category: to.Ptr(armcostmanagement.CategoryTypeCost), + Filter: &armcostmanagement.BudgetFilter{ + And: []*armcostmanagement.BudgetFilterProperties{ + { + Dimensions: &armcostmanagement.BudgetComparisonExpression{ + Name: to.Ptr("ResourceId"), + Operator: to.Ptr(armcostmanagement.BudgetOperatorTypeIn), + Values: []*string{ + to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Compute/virtualMachines/MSVM2"), + to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Compute/virtualMachines/platformcloudplatformGeneric1"), + }, + }, + }, + { + Tags: &armcostmanagement.BudgetComparisonExpression{ + Name: to.Ptr("category"), + Operator: to.Ptr(armcostmanagement.BudgetOperatorTypeIn), + Values: []*string{ + to.Ptr("Dev"), + to.Ptr("Prod"), + }, + }, + }, + { + Tags: &armcostmanagement.BudgetComparisonExpression{ + Name: to.Ptr("department"), + Operator: to.Ptr(armcostmanagement.BudgetOperatorTypeIn), + Values: []*string{ + to.Ptr("engineering"), + to.Ptr("sales"), + }, + }, + }, + }, + }, + Notifications: map[string]*armcostmanagement.Notification{ + "Actual_GreaterThan_80_Percent": { + ContactEmails: []*string{ + to.Ptr("johndoe@contoso.com"), + to.Ptr("janesmith@contoso.com"), + }, + ContactGroups: []*string{ + to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/microsoft.insights/actionGroups/SampleActionGroup"), + }, + ContactRoles: []*string{ + to.Ptr("Contributor"), + to.Ptr("Reader"), + }, + Enabled: to.Ptr(true), + Locale: to.Ptr(armcostmanagement.CultureCodeEnUs), + Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeGreaterThan), + Threshold: to.Ptr[float32](80), + ThresholdType: to.Ptr(armcostmanagement.ThresholdTypeActual), + }, + }, + TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeMonthly), + TimePeriod: &armcostmanagement.BudgetTimePeriod{ + EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-31T00:00:00Z"); return t }()), + StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t }()), + }, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcostmanagement.BudgetsClientCreateOrUpdateResponse{ + // Budget: &armcostmanagement.Budget{ + // Name: to.Ptr("TestBudget"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157f\"")), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/budgets/TestBudget"), + // Properties: &armcostmanagement.BudgetProperties{ + // Amount: to.Ptr[float32](100.65), + // Category: to.Ptr(armcostmanagement.CategoryTypeCost), + // CurrentSpend: &armcostmanagement.CurrentSpend{ + // Amount: to.Ptr[float32](80.89), + // Unit: to.Ptr("USD"), + // }, + // Filter: &armcostmanagement.BudgetFilter{ + // And: []*armcostmanagement.BudgetFilterProperties{ + // { + // Dimensions: &armcostmanagement.BudgetComparisonExpression{ + // Name: to.Ptr("ResourceId"), + // Operator: to.Ptr(armcostmanagement.BudgetOperatorTypeIn), + // Values: []*string{ + // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Compute/virtualMachines/MSVM2"), + // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Compute/virtualMachines/platformcloudplatformGeneric1"), + // }, + // }, + // }, + // { + // Tags: &armcostmanagement.BudgetComparisonExpression{ + // Name: to.Ptr("category"), + // Operator: to.Ptr(armcostmanagement.BudgetOperatorTypeIn), + // Values: []*string{ + // to.Ptr("Dev"), + // to.Ptr("Prod"), + // }, + // }, + // }, + // { + // Tags: &armcostmanagement.BudgetComparisonExpression{ + // Name: to.Ptr("department"), + // Operator: to.Ptr(armcostmanagement.BudgetOperatorTypeIn), + // Values: []*string{ + // to.Ptr("engineering"), + // to.Ptr("sales"), + // }, + // }, + // }, + // }, + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_GreaterThan_80_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // ContactGroups: []*string{ + // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/microsoft.insights/actionGroups/SampleActionGroup"), + // }, + // ContactRoles: []*string{ + // to.Ptr("Contributor"), + // to.Ptr("Reader"), + // }, + // Enabled: to.Ptr(true), + // Locale: to.Ptr(armcostmanagement.CultureCodeEnUs), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeGreaterThan), + // Threshold: to.Ptr[float32](80), + // ThresholdType: to.Ptr(armcostmanagement.ThresholdTypeActual), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeMonthly), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-31T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01/Budgets/CreateOrUpdate/ReservationUtilization/EA/BillingAccountEA-AlertRule-ReservationIdFilter.json +func ExampleBudgetsClient_CreateOrUpdate_createOrUpdateReservationUtilizationBillingAccountEaAlertRuleReservationIdFilter() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain 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.NewBudgetsClient().CreateOrUpdate(ctx, "providers/Microsoft.Billing/billingAccounts/123456", "TestAlertRule", armcostmanagement.Budget{ + ETag: to.Ptr(azcore.ETag("\"1d34d016a593709\"")), + Properties: &armcostmanagement.BudgetProperties{ + Category: to.Ptr(armcostmanagement.CategoryTypeReservationUtilization), + Filter: &armcostmanagement.BudgetFilter{ + Dimensions: &armcostmanagement.BudgetComparisonExpression{ + Name: to.Ptr("ReservationId"), + Operator: to.Ptr(armcostmanagement.BudgetOperatorTypeIn), + Values: []*string{ + to.Ptr("00000000-0000-0000-0000-000000000000"), + to.Ptr("00000000-0000-0000-0000-000000000001"), + to.Ptr("00000000-0000-0000-0000-000000000002"), + }, + }, + }, + Notifications: map[string]*armcostmanagement.Notification{ + "Actual_LessThan_99_Percent": { + ContactEmails: []*string{ + to.Ptr("johndoe@contoso.com"), + to.Ptr("janesmith@contoso.com"), + }, + Enabled: to.Ptr(true), + Frequency: to.Ptr(armcostmanagement.FrequencyWeekly), + Locale: to.Ptr(armcostmanagement.CultureCodeEnUs), + Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeLessThan), + Threshold: to.Ptr[float32](99), + }, + }, + TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeLast7Days), + TimePeriod: &armcostmanagement.BudgetTimePeriod{ + EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-01T00:00:00Z"); return t }()), + StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t }()), + }, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcostmanagement.BudgetsClientCreateOrUpdateResponse{ + // Budget: &armcostmanagement.Budget{ + // Name: to.Ptr("TestAlertRule"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157f\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/budgets/TestAlertRule"), + // Properties: &armcostmanagement.BudgetProperties{ + // Category: to.Ptr(armcostmanagement.CategoryTypeReservationUtilization), + // Filter: &armcostmanagement.BudgetFilter{ + // Dimensions: &armcostmanagement.BudgetComparisonExpression{ + // Name: to.Ptr("ReservationId"), + // Operator: to.Ptr(armcostmanagement.BudgetOperatorTypeIn), + // Values: []*string{ + // to.Ptr("00000000-0000-0000-0000-000000000000"), + // to.Ptr("00000000-0000-0000-0000-000000000001"), + // to.Ptr("00000000-0000-0000-0000-000000000002"), + // }, + // }, + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_LessThan_99_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // Enabled: to.Ptr(true), + // Frequency: to.Ptr(armcostmanagement.FrequencyWeekly), + // Locale: to.Ptr(armcostmanagement.CultureCodeEnUs), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeLessThan), + // Threshold: to.Ptr[float32](99), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeLast7Days), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-01T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01/Budgets/CreateOrUpdate/ReservationUtilization/EA/BillingAccountEA-AlertRule-ReservedResourceTypeFilter.json +func ExampleBudgetsClient_CreateOrUpdate_createOrUpdateReservationUtilizationBillingAccountEaAlertRuleReservedResourceTypeFilter() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain 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.NewBudgetsClient().CreateOrUpdate(ctx, "providers/Microsoft.Billing/billingAccounts/123456", "TestAlertRule", armcostmanagement.Budget{ + ETag: to.Ptr(azcore.ETag("\"1d34d016a593709\"")), + Properties: &armcostmanagement.BudgetProperties{ + Category: to.Ptr(armcostmanagement.CategoryTypeReservationUtilization), + Filter: &armcostmanagement.BudgetFilter{ + Dimensions: &armcostmanagement.BudgetComparisonExpression{ + Name: to.Ptr("ReservedResourceType"), + Operator: to.Ptr(armcostmanagement.BudgetOperatorTypeIn), + Values: []*string{ + to.Ptr("VirtualMachines"), + to.Ptr("SqlDatabases"), + to.Ptr("CosmosDb"), + }, + }, + }, + Notifications: map[string]*armcostmanagement.Notification{ + "Actual_LessThan_99_Percent": { + ContactEmails: []*string{ + to.Ptr("johndoe@contoso.com"), + to.Ptr("janesmith@contoso.com"), + }, + Enabled: to.Ptr(true), + Frequency: to.Ptr(armcostmanagement.FrequencyWeekly), + Locale: to.Ptr(armcostmanagement.CultureCodeEnUs), + Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeLessThan), + Threshold: to.Ptr[float32](99), + }, + }, + TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeLast7Days), + TimePeriod: &armcostmanagement.BudgetTimePeriod{ + EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-01T00:00:00Z"); return t }()), + StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t }()), + }, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcostmanagement.BudgetsClientCreateOrUpdateResponse{ + // Budget: &armcostmanagement.Budget{ + // Name: to.Ptr("TestAlertRule"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157f\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/budgets/TestAlertRule"), + // Properties: &armcostmanagement.BudgetProperties{ + // Category: to.Ptr(armcostmanagement.CategoryTypeReservationUtilization), + // Filter: &armcostmanagement.BudgetFilter{ + // Dimensions: &armcostmanagement.BudgetComparisonExpression{ + // Name: to.Ptr("ReservedResourceType"), + // Operator: to.Ptr(armcostmanagement.BudgetOperatorTypeIn), + // Values: []*string{ + // to.Ptr("VirtualMachines"), + // to.Ptr("SqlDatabases"), + // to.Ptr("CosmosDb"), + // }, + // }, + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_LessThan_99_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // Enabled: to.Ptr(true), + // Frequency: to.Ptr(armcostmanagement.FrequencyWeekly), + // Locale: to.Ptr(armcostmanagement.CultureCodeEnUs), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeLessThan), + // Threshold: to.Ptr[float32](99), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeLast7Days), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-01T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01/Budgets/CreateOrUpdate/ReservationUtilization/EA/BillingAccountEA-AlertRule.json +func ExampleBudgetsClient_CreateOrUpdate_createOrUpdateReservationUtilizationBillingAccountEaAlertRule() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain 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.NewBudgetsClient().CreateOrUpdate(ctx, "providers/Microsoft.Billing/billingAccounts/123456", "TestAlertRule", armcostmanagement.Budget{ + ETag: to.Ptr(azcore.ETag("\"1d34d016a593709\"")), + Properties: &armcostmanagement.BudgetProperties{ + Category: to.Ptr(armcostmanagement.CategoryTypeReservationUtilization), + Filter: &armcostmanagement.BudgetFilter{}, + Notifications: map[string]*armcostmanagement.Notification{ + "Actual_LessThan_99_Percent": { + ContactEmails: []*string{ + to.Ptr("johndoe@contoso.com"), + to.Ptr("janesmith@contoso.com"), + }, + Enabled: to.Ptr(true), + Frequency: to.Ptr(armcostmanagement.FrequencyWeekly), + Locale: to.Ptr(armcostmanagement.CultureCodeEnUs), + Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeLessThan), + Threshold: to.Ptr[float32](99), + }, + }, + TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeLast7Days), + TimePeriod: &armcostmanagement.BudgetTimePeriod{ + EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-01T00:00:00Z"); return t }()), + StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t }()), + }, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcostmanagement.BudgetsClientCreateOrUpdateResponse{ + // Budget: &armcostmanagement.Budget{ + // Name: to.Ptr("TestAlertRule"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157f\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/budgets/TestAlertRule"), + // Properties: &armcostmanagement.BudgetProperties{ + // Category: to.Ptr(armcostmanagement.CategoryTypeReservationUtilization), + // Filter: &armcostmanagement.BudgetFilter{ + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_LessThan_99_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // Enabled: to.Ptr(true), + // Frequency: to.Ptr(armcostmanagement.FrequencyWeekly), + // Locale: to.Ptr(armcostmanagement.CultureCodeEnUs), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeLessThan), + // Threshold: to.Ptr[float32](99), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeLast7Days), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-01T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01/Budgets/CreateOrUpdate/ReservationUtilization/MCA/BillingProfile-AlertRule-ReservationIdFilter.json +func ExampleBudgetsClient_CreateOrUpdate_createOrUpdateReservationUtilizationBillingProfileMcaAlertRuleReservationIdFilter() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain 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.NewBudgetsClient().CreateOrUpdate(ctx, "providers/Microsoft.Billing/billingAccounts/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:ffffffff-gggg-hhhh-iiii-jjjjjjjjjjjj_2023-04-01/billingProfiles/KKKK-LLLL-MMM-NNN", "TestAlertRule", armcostmanagement.Budget{ + ETag: to.Ptr(azcore.ETag("\"1d34d016a593709\"")), + Properties: &armcostmanagement.BudgetProperties{ + Category: to.Ptr(armcostmanagement.CategoryTypeReservationUtilization), + Filter: &armcostmanagement.BudgetFilter{ + Dimensions: &armcostmanagement.BudgetComparisonExpression{ + Name: to.Ptr("ReservationId"), + Operator: to.Ptr(armcostmanagement.BudgetOperatorTypeIn), + Values: []*string{ + to.Ptr("00000000-0000-0000-0000-000000000000"), + to.Ptr("00000000-0000-0000-0000-000000000001"), + to.Ptr("00000000-0000-0000-0000-000000000002"), + }, + }, + }, + Notifications: map[string]*armcostmanagement.Notification{ + "Actual_LessThan_99_Percent": { + ContactEmails: []*string{ + to.Ptr("johndoe@contoso.com"), + to.Ptr("janesmith@contoso.com"), + }, + Enabled: to.Ptr(true), + Frequency: to.Ptr(armcostmanagement.FrequencyDaily), + Locale: to.Ptr(armcostmanagement.CultureCodeEnUs), + Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeLessThan), + Threshold: to.Ptr[float32](99), + }, + }, + TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeLast30Days), + TimePeriod: &armcostmanagement.BudgetTimePeriod{ + EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-01T00:00:00Z"); return t }()), + StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t }()), + }, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcostmanagement.BudgetsClientCreateOrUpdateResponse{ + // Budget: &armcostmanagement.Budget{ + // Name: to.Ptr("TestAlertRule"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157f\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:ffffffff-gggg-hhhh-iiii-jjjjjjjjjjjj_2023-04-01/billingProfiles/KKKK-LLLL-MMM-NNN/providers/Microsoft.CostManagement/budgets/TestAlertRule"), + // Properties: &armcostmanagement.BudgetProperties{ + // Category: to.Ptr(armcostmanagement.CategoryTypeReservationUtilization), + // Filter: &armcostmanagement.BudgetFilter{ + // Dimensions: &armcostmanagement.BudgetComparisonExpression{ + // Name: to.Ptr("ReservationId"), + // Operator: to.Ptr(armcostmanagement.BudgetOperatorTypeIn), + // Values: []*string{ + // to.Ptr("00000000-0000-0000-0000-000000000000"), + // to.Ptr("00000000-0000-0000-0000-000000000001"), + // to.Ptr("00000000-0000-0000-0000-000000000002"), + // }, + // }, + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_LessThan_99_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // Enabled: to.Ptr(true), + // Frequency: to.Ptr(armcostmanagement.FrequencyDaily), + // Locale: to.Ptr(armcostmanagement.CultureCodeEnUs), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeLessThan), + // Threshold: to.Ptr[float32](99), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeLast30Days), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-01T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01/Budgets/CreateOrUpdate/ReservationUtilization/MCA/BillingProfile-AlertRule-ReservedResourceTypeFilter.json +func ExampleBudgetsClient_CreateOrUpdate_createOrUpdateReservationUtilizationBillingProfileMcaAlertRuleReservedResourceTypeFilter() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain 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.NewBudgetsClient().CreateOrUpdate(ctx, "providers/Microsoft.Billing/billingAccounts/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:ffffffff-gggg-hhhh-iiii-jjjjjjjjjjjj_2023-04-01/billingProfiles/KKKK-LLLL-MMM-NNN", "TestAlertRule", armcostmanagement.Budget{ + ETag: to.Ptr(azcore.ETag("\"1d34d016a593709\"")), + Properties: &armcostmanagement.BudgetProperties{ + Category: to.Ptr(armcostmanagement.CategoryTypeReservationUtilization), + Filter: &armcostmanagement.BudgetFilter{ + Dimensions: &armcostmanagement.BudgetComparisonExpression{ + Name: to.Ptr("ReservedResourceType"), + Operator: to.Ptr(armcostmanagement.BudgetOperatorTypeIn), + Values: []*string{ + to.Ptr("VirtualMachines"), + to.Ptr("SqlDatabases"), + to.Ptr("CosmosDb"), + }, + }, + }, + Notifications: map[string]*armcostmanagement.Notification{ + "Actual_LessThan_99_Percent": { + ContactEmails: []*string{ + to.Ptr("johndoe@contoso.com"), + to.Ptr("janesmith@contoso.com"), + }, + Enabled: to.Ptr(true), + Frequency: to.Ptr(armcostmanagement.FrequencyDaily), + Locale: to.Ptr(armcostmanagement.CultureCodeEnUs), + Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeLessThan), + Threshold: to.Ptr[float32](99), + }, + }, + TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeLast30Days), + TimePeriod: &armcostmanagement.BudgetTimePeriod{ + EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-01T00:00:00Z"); return t }()), + StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t }()), + }, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcostmanagement.BudgetsClientCreateOrUpdateResponse{ + // Budget: &armcostmanagement.Budget{ + // Name: to.Ptr("TestAlertRule"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157f\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:ffffffff-gggg-hhhh-iiii-jjjjjjjjjjjj_2023-04-01/billingProfiles/KKKK-LLLL-MMM-NNN/providers/Microsoft.CostManagement/budgets/TestAlertRule"), + // Properties: &armcostmanagement.BudgetProperties{ + // Category: to.Ptr(armcostmanagement.CategoryTypeReservationUtilization), + // Filter: &armcostmanagement.BudgetFilter{ + // Dimensions: &armcostmanagement.BudgetComparisonExpression{ + // Name: to.Ptr("ReservedResourceType"), + // Operator: to.Ptr(armcostmanagement.BudgetOperatorTypeIn), + // Values: []*string{ + // to.Ptr("VirtualMachines"), + // to.Ptr("SqlDatabases"), + // to.Ptr("CosmosDb"), + // }, + // }, + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_LessThan_99_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // Enabled: to.Ptr(true), + // Frequency: to.Ptr(armcostmanagement.FrequencyDaily), + // Locale: to.Ptr(armcostmanagement.CultureCodeEnUs), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeLessThan), + // Threshold: to.Ptr[float32](99), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeLast30Days), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-01T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01/Budgets/CreateOrUpdate/ReservationUtilization/MCA/BillingProfile-AlertRule.json +func ExampleBudgetsClient_CreateOrUpdate_createOrUpdateReservationUtilizationBillingProfileMcaAlertRuleJson() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain 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.NewBudgetsClient().CreateOrUpdate(ctx, "providers/Microsoft.Billing/billingAccounts/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:ffffffff-gggg-hhhh-iiii-jjjjjjjjjjjj_2023-04-01/billingProfiles/KKKK-LLLL-MMM-NNN", "TestAlertRule", armcostmanagement.Budget{ + ETag: to.Ptr(azcore.ETag("\"1d34d016a593709\"")), + Properties: &armcostmanagement.BudgetProperties{ + Category: to.Ptr(armcostmanagement.CategoryTypeReservationUtilization), + Filter: &armcostmanagement.BudgetFilter{}, + Notifications: map[string]*armcostmanagement.Notification{ + "Actual_LessThan_99_Percent": { + ContactEmails: []*string{ + to.Ptr("johndoe@contoso.com"), + to.Ptr("janesmith@contoso.com"), + }, + Enabled: to.Ptr(true), + Frequency: to.Ptr(armcostmanagement.FrequencyDaily), + Locale: to.Ptr(armcostmanagement.CultureCodeEnUs), + Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeLessThan), + Threshold: to.Ptr[float32](99), + }, + }, + TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeLast30Days), + TimePeriod: &armcostmanagement.BudgetTimePeriod{ + EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-01T00:00:00Z"); return t }()), + StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t }()), + }, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcostmanagement.BudgetsClientCreateOrUpdateResponse{ + // Budget: &armcostmanagement.Budget{ + // Name: to.Ptr("TestAlertRule"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157f\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:ffffffff-gggg-hhhh-iiii-jjjjjjjjjjjj_2023-04-01/billingProfiles/KKKK-LLLL-MMM-NNN/providers/Microsoft.CostManagement/budgets/TestAlertRule"), + // Properties: &armcostmanagement.BudgetProperties{ + // Category: to.Ptr(armcostmanagement.CategoryTypeReservationUtilization), + // Filter: &armcostmanagement.BudgetFilter{ + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_LessThan_99_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // Enabled: to.Ptr(true), + // Frequency: to.Ptr(armcostmanagement.FrequencyDaily), + // Locale: to.Ptr(armcostmanagement.CultureCodeEnUs), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeLessThan), + // Threshold: to.Ptr[float32](99), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeLast30Days), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-01T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01/Budgets/CreateOrUpdate/ReservationUtilization/MCA/Customer-AlertRule-ReservationIdFilter.json +func ExampleBudgetsClient_CreateOrUpdate_createOrUpdateReservationUtilizationCustomerCspAlertRuleReservationIdFilter() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain 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.NewBudgetsClient().CreateOrUpdate(ctx, "providers/Microsoft.Billing/billingAccounts/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:ffffffff-gggg-hhhh-iiii-jjjjjjjjjjjj_2023-04-01/customers/000000-1111-2222-3333-444444444444", "TestAlertRule", armcostmanagement.Budget{ + ETag: to.Ptr(azcore.ETag("\"1d34d016a593709\"")), + Properties: &armcostmanagement.BudgetProperties{ + Category: to.Ptr(armcostmanagement.CategoryTypeReservationUtilization), + Filter: &armcostmanagement.BudgetFilter{ + Dimensions: &armcostmanagement.BudgetComparisonExpression{ + Name: to.Ptr("ReservationId"), + Operator: to.Ptr(armcostmanagement.BudgetOperatorTypeIn), + Values: []*string{ + to.Ptr("00000000-0000-0000-0000-000000000000"), + to.Ptr("00000000-0000-0000-0000-000000000001"), + to.Ptr("00000000-0000-0000-0000-000000000002"), + }, + }, + }, + Notifications: map[string]*armcostmanagement.Notification{ + "Actual_LessThan_99_Percent": { + ContactEmails: []*string{ + to.Ptr("johndoe@contoso.com"), + to.Ptr("janesmith@contoso.com"), + }, + Enabled: to.Ptr(true), + Frequency: to.Ptr(armcostmanagement.FrequencyDaily), + Locale: to.Ptr(armcostmanagement.CultureCodeEnUs), + Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeLessThan), + Threshold: to.Ptr[float32](99), + }, + }, + TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeLast30Days), + TimePeriod: &armcostmanagement.BudgetTimePeriod{ + EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-01T00:00:00Z"); return t }()), + StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t }()), + }, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcostmanagement.BudgetsClientCreateOrUpdateResponse{ + // Budget: &armcostmanagement.Budget{ + // Name: to.Ptr("TestAlertRule"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157f\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:ffffffff-gggg-hhhh-iiii-jjjjjjjjjjjj_2023-04-01/customers/000000-1111-2222-3333-444444444444/providers/Microsoft.CostManagement/budgets/TestAlertRule"), + // Properties: &armcostmanagement.BudgetProperties{ + // Category: to.Ptr(armcostmanagement.CategoryTypeReservationUtilization), + // Filter: &armcostmanagement.BudgetFilter{ + // Dimensions: &armcostmanagement.BudgetComparisonExpression{ + // Name: to.Ptr("ReservationId"), + // Operator: to.Ptr(armcostmanagement.BudgetOperatorTypeIn), + // Values: []*string{ + // to.Ptr("00000000-0000-0000-0000-000000000000"), + // to.Ptr("00000000-0000-0000-0000-000000000001"), + // to.Ptr("00000000-0000-0000-0000-000000000002"), + // }, + // }, + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_LessThan_99_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // Enabled: to.Ptr(true), + // Frequency: to.Ptr(armcostmanagement.FrequencyDaily), + // Locale: to.Ptr(armcostmanagement.CultureCodeEnUs), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeLessThan), + // Threshold: to.Ptr[float32](99), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeLast30Days), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-01T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01/Budgets/CreateOrUpdate/ReservationUtilization/MCA/Customer-AlertRule-ReservedResourceTypeFilter.json +func ExampleBudgetsClient_CreateOrUpdate_createOrUpdateReservationUtilizationCustomerCspAlertRuleReservedResourceTypeFilter() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain 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.NewBudgetsClient().CreateOrUpdate(ctx, "providers/Microsoft.Billing/billingAccounts/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:ffffffff-gggg-hhhh-iiii-jjjjjjjjjjjj_2023-04-01/customers/000000-1111-2222-3333-444444444444", "TestAlertRule", armcostmanagement.Budget{ + ETag: to.Ptr(azcore.ETag("\"1d34d016a593709\"")), + Properties: &armcostmanagement.BudgetProperties{ + Category: to.Ptr(armcostmanagement.CategoryTypeReservationUtilization), + Filter: &armcostmanagement.BudgetFilter{ + Dimensions: &armcostmanagement.BudgetComparisonExpression{ + Name: to.Ptr("ReservedResourceType"), + Operator: to.Ptr(armcostmanagement.BudgetOperatorTypeIn), + Values: []*string{ + to.Ptr("VirtualMachines"), + to.Ptr("SqlDatabases"), + to.Ptr("CosmosDb"), + }, + }, + }, + Notifications: map[string]*armcostmanagement.Notification{ + "Actual_LessThan_99_Percent": { + ContactEmails: []*string{ + to.Ptr("johndoe@contoso.com"), + to.Ptr("janesmith@contoso.com"), + }, + Enabled: to.Ptr(true), + Frequency: to.Ptr(armcostmanagement.FrequencyDaily), + Locale: to.Ptr(armcostmanagement.CultureCodeEnUs), + Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeLessThan), + Threshold: to.Ptr[float32](99), + }, + }, + TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeLast30Days), + TimePeriod: &armcostmanagement.BudgetTimePeriod{ + EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-01T00:00:00Z"); return t }()), + StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t }()), + }, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcostmanagement.BudgetsClientCreateOrUpdateResponse{ + // Budget: &armcostmanagement.Budget{ + // Name: to.Ptr("TestAlertRule"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157f\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:ffffffff-gggg-hhhh-iiii-jjjjjjjjjjjj_2023-04-01/customers/000000-1111-2222-3333-444444444444/providers/Microsoft.CostManagement/budgets/TestAlertRule"), + // Properties: &armcostmanagement.BudgetProperties{ + // Category: to.Ptr(armcostmanagement.CategoryTypeReservationUtilization), + // Filter: &armcostmanagement.BudgetFilter{ + // Dimensions: &armcostmanagement.BudgetComparisonExpression{ + // Name: to.Ptr("ReservedResourceType"), + // Operator: to.Ptr(armcostmanagement.BudgetOperatorTypeIn), + // Values: []*string{ + // to.Ptr("VirtualMachines"), + // to.Ptr("SqlDatabases"), + // to.Ptr("CosmosDb"), + // }, + // }, + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_LessThan_99_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // Enabled: to.Ptr(true), + // Frequency: to.Ptr(armcostmanagement.FrequencyDaily), + // Locale: to.Ptr(armcostmanagement.CultureCodeEnUs), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeLessThan), + // Threshold: to.Ptr[float32](99), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeLast30Days), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-01T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01/Budgets/CreateOrUpdate/ReservationUtilization/MCA/Customer-AlertRule.json +func ExampleBudgetsClient_CreateOrUpdate_createOrUpdateReservationUtilizationCustomerCspAlertRuleJson() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain 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.NewBudgetsClient().CreateOrUpdate(ctx, "providers/Microsoft.Billing/billingAccounts/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:ffffffff-gggg-hhhh-iiii-jjjjjjjjjjjj_2023-04-01/customers/000000-1111-2222-3333-444444444444", "TestAlertRule", armcostmanagement.Budget{ + ETag: to.Ptr(azcore.ETag("\"1d34d016a593709\"")), + Properties: &armcostmanagement.BudgetProperties{ + Category: to.Ptr(armcostmanagement.CategoryTypeReservationUtilization), + Filter: &armcostmanagement.BudgetFilter{}, + Notifications: map[string]*armcostmanagement.Notification{ + "Actual_LessThan_99_Percent": { + ContactEmails: []*string{ + to.Ptr("johndoe@contoso.com"), + to.Ptr("janesmith@contoso.com"), + }, + Enabled: to.Ptr(true), + Frequency: to.Ptr(armcostmanagement.FrequencyDaily), + Locale: to.Ptr(armcostmanagement.CultureCodeEnUs), + Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeLessThan), + Threshold: to.Ptr[float32](99), + }, + }, + TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeLast30Days), + TimePeriod: &armcostmanagement.BudgetTimePeriod{ + EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-01T00:00:00Z"); return t }()), + StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t }()), + }, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcostmanagement.BudgetsClientCreateOrUpdateResponse{ + // Budget: &armcostmanagement.Budget{ + // Name: to.Ptr("TestAlertRule"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157f\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:ffffffff-gggg-hhhh-iiii-jjjjjjjjjjjj_2023-04-01/customers/000000-1111-2222-3333-444444444444/providers/Microsoft.CostManagement/budgets/TestAlertRule"), + // Properties: &armcostmanagement.BudgetProperties{ + // Category: to.Ptr(armcostmanagement.CategoryTypeReservationUtilization), + // Filter: &armcostmanagement.BudgetFilter{ + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_LessThan_99_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // Enabled: to.Ptr(true), + // Frequency: to.Ptr(armcostmanagement.FrequencyDaily), + // Locale: to.Ptr(armcostmanagement.CultureCodeEnUs), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeLessThan), + // Threshold: to.Ptr[float32](99), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeLast30Days), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-01T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01/Budgets/Delete/DeleteBudget.json +func ExampleBudgetsClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewBudgetsClient().Delete(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", "TestBudget", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // 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 = armcostmanagement.BudgetsClientDeleteResponse{ + // } +} + +// Generated from example definition: 2025-03-01/Budgets/Get/Cost/Get-Cost-Budget.json +func ExampleBudgetsClient_Get_getCostBudget() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain 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.NewBudgetsClient().Get(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", "TestBudget", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armcostmanagement.BudgetsClientGetResponse{ + // Budget: &armcostmanagement.Budget{ + // Name: to.Ptr("TestBudget"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157f\"")), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.CostManagement/budgets/TestBudget"), + // Properties: &armcostmanagement.BudgetProperties{ + // Amount: to.Ptr[float32](100.65), + // Category: to.Ptr(armcostmanagement.CategoryTypeCost), + // CurrentSpend: &armcostmanagement.CurrentSpend{ + // Amount: to.Ptr[float32](80.89), + // Unit: to.Ptr("USD"), + // }, + // Filter: &armcostmanagement.BudgetFilter{ + // And: []*armcostmanagement.BudgetFilterProperties{ + // { + // Dimensions: &armcostmanagement.BudgetComparisonExpression{ + // Name: to.Ptr("ResourceId"), + // Operator: to.Ptr(armcostmanagement.BudgetOperatorTypeIn), + // Values: []*string{ + // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Compute/virtualMachines/MSVM2"), + // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Compute/virtualMachines/platformcloudplatformGeneric1"), + // }, + // }, + // }, + // { + // Tags: &armcostmanagement.BudgetComparisonExpression{ + // Name: to.Ptr("category"), + // Operator: to.Ptr(armcostmanagement.BudgetOperatorTypeIn), + // Values: []*string{ + // to.Ptr("Dev"), + // to.Ptr("Prod"), + // }, + // }, + // }, + // { + // Tags: &armcostmanagement.BudgetComparisonExpression{ + // Name: to.Ptr("department"), + // Operator: to.Ptr(armcostmanagement.BudgetOperatorTypeIn), + // Values: []*string{ + // to.Ptr("engineering"), + // to.Ptr("sales"), + // }, + // }, + // }, + // }, + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_GreaterThan_80_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // ContactGroups: []*string{ + // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/microsoft.insights/actionGroups/SampleActionGroup"), + // }, + // ContactRoles: []*string{ + // to.Ptr("Contributor"), + // to.Ptr("Reader"), + // }, + // Enabled: to.Ptr(true), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeGreaterThan), + // Threshold: to.Ptr[float32](80), + // ThresholdType: to.Ptr(armcostmanagement.ThresholdTypeActual), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeMonthly), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-31T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01/Budgets/Get/ReservationUtilization/Get-ReservationUtilization-AlertRule.json +func ExampleBudgetsClient_Get_getReservationUtilizationAlertRule() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain 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.NewBudgetsClient().Get(ctx, "providers/Microsoft.Billing/billingAccounts/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:ffffffff-gggg-hhhh-iiii-jjjjjjjjjjjj_2023-04-01/billingProfiles/KKKK-LLLL-MMM-NNN", "TestAlertRule", 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 = armcostmanagement.BudgetsClientGetResponse{ + // Budget: &armcostmanagement.Budget{ + // Name: to.Ptr("TestAlertRule"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157f\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:ffffffff-gggg-hhhh-iiii-jjjjjjjjjjjj_2023-04-01/billingProfiles/KKKK-LLLL-MMM-NNN/providers/Microsoft.CostManagement/budgets/TestAlertRule"), + // Properties: &armcostmanagement.BudgetProperties{ + // Category: to.Ptr(armcostmanagement.CategoryTypeReservationUtilization), + // Filter: &armcostmanagement.BudgetFilter{ + // Dimensions: &armcostmanagement.BudgetComparisonExpression{ + // Name: to.Ptr("ReservedResourceType"), + // Operator: to.Ptr(armcostmanagement.BudgetOperatorTypeIn), + // Values: []*string{ + // to.Ptr("VirtualMachines"), + // to.Ptr("SqlDatabases"), + // to.Ptr("CosmosDb"), + // }, + // }, + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_LessThan_99_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // Enabled: to.Ptr(true), + // Frequency: to.Ptr(armcostmanagement.FrequencyDaily), + // Locale: to.Ptr(armcostmanagement.CultureCodeEnUs), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeLessThan), + // Threshold: to.Ptr[float32](99), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeLast30Days), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-01T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01/Budgets/List/EA/BillingAccountBudgetsList-EA-CategoryTypeFilter.json +func ExampleBudgetsClient_NewListPager_billingAccountBudgetsListEaCategoryTypeFilter() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain 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.NewBudgetsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/123456", &armcostmanagement.BudgetsClientListOptions{ + Filter: to.Ptr("properties/category eq 'ReservationUtilization'")}) + 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 = armcostmanagement.BudgetsClientListResponse{ + // BudgetsListResult: armcostmanagement.BudgetsListResult{ + // Value: []*armcostmanagement.Budget{ + // { + // Name: to.Ptr("TestRUAlert"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157f\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/budgets/TestRUAlert"), + // Properties: &armcostmanagement.BudgetProperties{ + // Category: to.Ptr(armcostmanagement.CategoryTypeReservationUtilization), + // Filter: &armcostmanagement.BudgetFilter{ + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_LessThan_99_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // Enabled: to.Ptr(true), + // Frequency: to.Ptr(armcostmanagement.FrequencyWeekly), + // Locale: to.Ptr(armcostmanagement.CultureCodeEnUs), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeLessThan), + // Threshold: to.Ptr[float32](99), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeLast7Days), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-01T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2025-03-01/Budgets/List/EA/BillingAccountBudgetsList-EA.json +func ExampleBudgetsClient_NewListPager_billingAccountBudgetsListEa() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain 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.NewBudgetsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/123456", 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 = armcostmanagement.BudgetsClientListResponse{ + // BudgetsListResult: armcostmanagement.BudgetsListResult{ + // Value: []*armcostmanagement.Budget{ + // { + // Name: to.Ptr("TestBudget1"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157c\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/budgets/TestBudget1"), + // Properties: &armcostmanagement.BudgetProperties{ + // Amount: to.Ptr[float32](10000), + // Category: to.Ptr(armcostmanagement.CategoryTypeCost), + // CurrentSpend: &armcostmanagement.CurrentSpend{ + // Amount: to.Ptr[float32](8000), + // Unit: to.Ptr("USD"), + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_GreaterThanOrEqualTo_80_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // Enabled: to.Ptr(true), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeGreaterThanOrEqualTo), + // Threshold: to.Ptr[float32](80), + // ThresholdType: to.Ptr(armcostmanagement.ThresholdTypeActual), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeMonthly), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-31T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // { + // Name: to.Ptr("TestBudget2"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157d\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/budgets/TestBudget2"), + // Properties: &armcostmanagement.BudgetProperties{ + // Amount: to.Ptr[float32](15000), + // Category: to.Ptr(armcostmanagement.CategoryTypeCost), + // CurrentSpend: &armcostmanagement.CurrentSpend{ + // Amount: to.Ptr[float32](12000), + // Unit: to.Ptr("USD"), + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_GreaterThanOrEqualTo_70_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // Enabled: to.Ptr(true), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeGreaterThanOrEqualTo), + // Threshold: to.Ptr[float32](70), + // ThresholdType: to.Ptr(armcostmanagement.ThresholdTypeActual), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeMonthly), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-31T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // { + // Name: to.Ptr("TestRUAlert"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157f\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/budgets/TestRUAlert"), + // Properties: &armcostmanagement.BudgetProperties{ + // Category: to.Ptr(armcostmanagement.CategoryTypeReservationUtilization), + // Filter: &armcostmanagement.BudgetFilter{ + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_LessThan_99_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // Enabled: to.Ptr(true), + // Frequency: to.Ptr(armcostmanagement.FrequencyWeekly), + // Locale: to.Ptr(armcostmanagement.CultureCodeEnUs), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeLessThan), + // Threshold: to.Ptr[float32](99), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeLast7Days), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-01T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2025-03-01/Budgets/List/EA/DepartmentBudgetsList.json +func ExampleBudgetsClient_NewListPager_departmentBudgetsListEa() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain 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.NewBudgetsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/123456/departments/789101", 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 = armcostmanagement.BudgetsClientListResponse{ + // BudgetsListResult: armcostmanagement.BudgetsListResult{ + // Value: []*armcostmanagement.Budget{ + // { + // Name: to.Ptr("DepartmentBudget1"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157e\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/123456/departments/789101/providers/Microsoft.CostManagement/budgets/DepartmentBudget1"), + // Properties: &armcostmanagement.BudgetProperties{ + // Amount: to.Ptr[float32](5000), + // Category: to.Ptr(armcostmanagement.CategoryTypeCost), + // CurrentSpend: &armcostmanagement.CurrentSpend{ + // Amount: to.Ptr[float32](3000), + // Unit: to.Ptr("USD"), + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_GreaterThanOrEqualTo_60_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // Enabled: to.Ptr(true), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeGreaterThanOrEqualTo), + // Threshold: to.Ptr[float32](60), + // ThresholdType: to.Ptr(armcostmanagement.ThresholdTypeActual), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeMonthly), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-31T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // { + // Name: to.Ptr("DepartmentBudget2"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157f\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/123456/departments/789101/providers/Microsoft.CostManagement/budgets/DepartmentBudget2"), + // Properties: &armcostmanagement.BudgetProperties{ + // Amount: to.Ptr[float32](8000), + // Category: to.Ptr(armcostmanagement.CategoryTypeCost), + // CurrentSpend: &armcostmanagement.CurrentSpend{ + // Amount: to.Ptr[float32](6000), + // Unit: to.Ptr("USD"), + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_GreaterThanOrEqualTo_75_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // Enabled: to.Ptr(true), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeGreaterThanOrEqualTo), + // Threshold: to.Ptr[float32](75), + // ThresholdType: to.Ptr(armcostmanagement.ThresholdTypeActual), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeMonthly), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-31T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2025-03-01/Budgets/List/EA/EnrollmentAccountBudgetsList.json +func ExampleBudgetsClient_NewListPager_enrollmentAccountBudgetsListEa() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain 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.NewBudgetsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/123456/enrollmentAccounts/473845", 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 = armcostmanagement.BudgetsClientListResponse{ + // BudgetsListResult: armcostmanagement.BudgetsListResult{ + // Value: []*armcostmanagement.Budget{ + // { + // Name: to.Ptr("EnrollmentAccountBudget1"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157e\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/123456/enrollmentAccounts/473845/providers/Microsoft.CostManagement/budgets/EnrollmentAccountBudget1"), + // Properties: &armcostmanagement.BudgetProperties{ + // Amount: to.Ptr[float32](5000), + // Category: to.Ptr(armcostmanagement.CategoryTypeCost), + // CurrentSpend: &armcostmanagement.CurrentSpend{ + // Amount: to.Ptr[float32](3000), + // Unit: to.Ptr("USD"), + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_GreaterThanOrEqualTo_60_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // Enabled: to.Ptr(true), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeGreaterThanOrEqualTo), + // Threshold: to.Ptr[float32](60), + // ThresholdType: to.Ptr(armcostmanagement.ThresholdTypeActual), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeMonthly), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-31T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // { + // Name: to.Ptr("EnrollmentAccountBudget2"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157f\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/123456/enrollmentAccounts/473845/providers/Microsoft.CostManagement/budgets/EnrollmentAccountBudget2"), + // Properties: &armcostmanagement.BudgetProperties{ + // Amount: to.Ptr[float32](8000), + // Category: to.Ptr(armcostmanagement.CategoryTypeCost), + // CurrentSpend: &armcostmanagement.CurrentSpend{ + // Amount: to.Ptr[float32](6000), + // Unit: to.Ptr("USD"), + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_GreaterThanOrEqualTo_75_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // Enabled: to.Ptr(true), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeGreaterThanOrEqualTo), + // Threshold: to.Ptr[float32](75), + // ThresholdType: to.Ptr(armcostmanagement.ThresholdTypeActual), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeMonthly), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-31T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2025-03-01/Budgets/List/MCA/BillingAccountBudgetsList-MCA-CategoryTypeFilter.json +func ExampleBudgetsClient_NewListPager_billingAccountBudgetsListMcaCategoryTypeFilter() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain 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.NewBudgetsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:ffffffff-gggg-hhhh-iiii-jjjjjjjjjjjj_2023-04-01", &armcostmanagement.BudgetsClientListOptions{ + Filter: to.Ptr("properties/category eq 'ReservationUtilization'")}) + 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 = armcostmanagement.BudgetsClientListResponse{ + // BudgetsListResult: armcostmanagement.BudgetsListResult{ + // Value: []*armcostmanagement.Budget{ + // { + // Name: to.Ptr("TestRUAlert"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157f\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:ffffffff-gggg-hhhh-iiii-jjjjjjjjjjjj_2023-04-01/billingProfiles/KKKK-LLLL-MMM-NNN/providers/Microsoft.CostManagement/budgets/TestRUAlert"), + // Properties: &armcostmanagement.BudgetProperties{ + // Category: to.Ptr(armcostmanagement.CategoryTypeReservationUtilization), + // Filter: &armcostmanagement.BudgetFilter{ + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_LessThan_99_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // Enabled: to.Ptr(true), + // Frequency: to.Ptr(armcostmanagement.FrequencyDaily), + // Locale: to.Ptr(armcostmanagement.CultureCodeEnUs), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeLessThan), + // Threshold: to.Ptr[float32](99), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeLast30Days), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-01T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2025-03-01/Budgets/List/MCA/BillingAccountBudgetsList-MCA.json +func ExampleBudgetsClient_NewListPager_billingAccountBudgetsListMca() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain 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.NewBudgetsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:ffffffff-gggg-hhhh-iiii-jjjjjjjjjjjj_2023-04-01", 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 = armcostmanagement.BudgetsClientListResponse{ + // BudgetsListResult: armcostmanagement.BudgetsListResult{ + // Value: []*armcostmanagement.Budget{ + // { + // Name: to.Ptr("TestBudget1"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157c\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:ffffffff-gggg-hhhh-iiii-jjjjjjjjjjjj_2023-04-01/providers/Microsoft.CostManagement/budgets/TestBudget1"), + // Properties: &armcostmanagement.BudgetProperties{ + // Amount: to.Ptr[float32](10000), + // Category: to.Ptr(armcostmanagement.CategoryTypeCost), + // CurrentSpend: &armcostmanagement.CurrentSpend{ + // Amount: to.Ptr[float32](8000), + // Unit: to.Ptr("USD"), + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_GreaterThanOrEqualTo_80_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // Enabled: to.Ptr(true), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeGreaterThanOrEqualTo), + // Threshold: to.Ptr[float32](80), + // ThresholdType: to.Ptr(armcostmanagement.ThresholdTypeActual), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeMonthly), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-31T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // { + // Name: to.Ptr("TestBudget2"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157d\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:ffffffff-gggg-hhhh-iiii-jjjjjjjjjjjj_2023-04-01/providers/Microsoft.CostManagement/budgets/TestBudget2"), + // Properties: &armcostmanagement.BudgetProperties{ + // Amount: to.Ptr[float32](15000), + // Category: to.Ptr(armcostmanagement.CategoryTypeCost), + // CurrentSpend: &armcostmanagement.CurrentSpend{ + // Amount: to.Ptr[float32](12000), + // Unit: to.Ptr("USD"), + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_GreaterThanOrEqualTo_70_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // Enabled: to.Ptr(true), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeGreaterThanOrEqualTo), + // Threshold: to.Ptr[float32](70), + // ThresholdType: to.Ptr(armcostmanagement.ThresholdTypeActual), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeMonthly), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-31T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // { + // Name: to.Ptr("TestRUAlert"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157f\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:ffffffff-gggg-hhhh-iiii-jjjjjjjjjjjj_2023-04-01/billingProfiles/KKKK-LLLL-MMM-NNN/providers/Microsoft.CostManagement/budgets/TestRUAlert"), + // Properties: &armcostmanagement.BudgetProperties{ + // Category: to.Ptr(armcostmanagement.CategoryTypeReservationUtilization), + // Filter: &armcostmanagement.BudgetFilter{ + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_LessThan_99_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // Enabled: to.Ptr(true), + // Frequency: to.Ptr(armcostmanagement.FrequencyDaily), + // Locale: to.Ptr(armcostmanagement.CultureCodeEnUs), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeLessThan), + // Threshold: to.Ptr[float32](99), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeLast30Days), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-01T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2025-03-01/Budgets/List/MCA/BillingProfileBudgetsList-CategoryTypeFilter.json +func ExampleBudgetsClient_NewListPager_billingProfileBudgetsListMcaCategoryTypeFilter() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain 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.NewBudgetsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:ffffffff-gggg-hhhh-iiii-jjjjjjjjjjjj_2023-04-01/billingProfiles/MYDEVTESTBP", &armcostmanagement.BudgetsClientListOptions{ + Filter: to.Ptr("properties/category eq 'ReservationUtilization'")}) + 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 = armcostmanagement.BudgetsClientListResponse{ + // BudgetsListResult: armcostmanagement.BudgetsListResult{ + // Value: []*armcostmanagement.Budget{ + // { + // Name: to.Ptr("TestRUAlert1"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157f\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:ffffffff-gggg-hhhh-iiii-jjjjjjjjjjjj_2023-04-01/billingProfiles/MYDEVTESTBP/providers/Microsoft.CostManagement/budgets/TestRUAlert1"), + // Properties: &armcostmanagement.BudgetProperties{ + // Category: to.Ptr(armcostmanagement.CategoryTypeReservationUtilization), + // Filter: &armcostmanagement.BudgetFilter{ + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_LessThan_99_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // Enabled: to.Ptr(true), + // Frequency: to.Ptr(armcostmanagement.FrequencyDaily), + // Locale: to.Ptr(armcostmanagement.CultureCodeEnUs), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeLessThan), + // Threshold: to.Ptr[float32](99), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeLast30Days), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-01T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // { + // Name: to.Ptr("TestRUAlert2"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157f\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:ffffffff-gggg-hhhh-iiii-jjjjjjjjjjjj_2023-04-01/billingProfiles/MYDEVTESTBP/providers/Microsoft.CostManagement/budgets/TestRUAlert2"), + // Properties: &armcostmanagement.BudgetProperties{ + // Category: to.Ptr(armcostmanagement.CategoryTypeReservationUtilization), + // Filter: &armcostmanagement.BudgetFilter{ + // Dimensions: &armcostmanagement.BudgetComparisonExpression{ + // Name: to.Ptr("ReservationId"), + // Operator: to.Ptr(armcostmanagement.BudgetOperatorTypeIn), + // Values: []*string{ + // to.Ptr("00000000-0000-0000-0000-000000000000"), + // to.Ptr("00000000-0000-0000-0000-000000000001"), + // to.Ptr("00000000-0000-0000-0000-000000000002"), + // }, + // }, + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_LessThan_99_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // Enabled: to.Ptr(true), + // Frequency: to.Ptr(armcostmanagement.FrequencyDaily), + // Locale: to.Ptr(armcostmanagement.CultureCodeEnUs), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeLessThan), + // Threshold: to.Ptr[float32](80), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeLast7Days), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-01T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2025-03-01/Budgets/List/MCA/BillingProfileBudgetsList.json +func ExampleBudgetsClient_NewListPager_billingProfileBudgetsListMca() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain 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.NewBudgetsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:ffffffff-gggg-hhhh-iiii-jjjjjjjjjjjj_2023-04-01/billingProfiles/MYDEVTESTBP", 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 = armcostmanagement.BudgetsClientListResponse{ + // BudgetsListResult: armcostmanagement.BudgetsListResult{ + // Value: []*armcostmanagement.Budget{ + // { + // Name: to.Ptr("TestBudget1"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157c\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:ffffffff-gggg-hhhh-iiii-jjjjjjjjjjjj_2023-04-01/billingProfiles/MYDEVTESTBP/providers/Microsoft.CostManagement/budgets/TestBudget1"), + // Properties: &armcostmanagement.BudgetProperties{ + // Amount: to.Ptr[float32](200), + // Category: to.Ptr(armcostmanagement.CategoryTypeCost), + // CurrentSpend: &armcostmanagement.CurrentSpend{ + // Amount: to.Ptr[float32](30), + // Unit: to.Ptr("USD"), + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_GreaterThanOrEqualTo_80_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // Enabled: to.Ptr(true), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeGreaterThanOrEqualTo), + // Threshold: to.Ptr[float32](80), + // ThresholdType: to.Ptr(armcostmanagement.ThresholdTypeActual), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeMonthly), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-31T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // { + // Name: to.Ptr("TestBudget2"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157d\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:ffffffff-gggg-hhhh-iiii-jjjjjjjjjjjj_2023-04-01/billingProfiles/MYDEVTESTBP/providers/Microsoft.CostManagement/budgets/TestBudget2"), + // Properties: &armcostmanagement.BudgetProperties{ + // Amount: to.Ptr[float32](600), + // Category: to.Ptr(armcostmanagement.CategoryTypeCost), + // CurrentSpend: &armcostmanagement.CurrentSpend{ + // Amount: to.Ptr[float32](20), + // Unit: to.Ptr("USD"), + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_GreaterThanOrEqualTo_70_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // Enabled: to.Ptr(true), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeGreaterThanOrEqualTo), + // Threshold: to.Ptr[float32](70), + // ThresholdType: to.Ptr(armcostmanagement.ThresholdTypeActual), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeMonthly), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-31T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // { + // Name: to.Ptr("TestRUAlert1"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157f\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:ffffffff-gggg-hhhh-iiii-jjjjjjjjjjjj_2023-04-01/billingProfiles/MYDEVTESTBP/providers/Microsoft.CostManagement/budgets/TestRUAlert1"), + // Properties: &armcostmanagement.BudgetProperties{ + // Category: to.Ptr(armcostmanagement.CategoryTypeReservationUtilization), + // Filter: &armcostmanagement.BudgetFilter{ + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_LessThan_99_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // Enabled: to.Ptr(true), + // Frequency: to.Ptr(armcostmanagement.FrequencyDaily), + // Locale: to.Ptr(armcostmanagement.CultureCodeEnUs), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeLessThan), + // Threshold: to.Ptr[float32](99), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeLast30Days), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-01T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // { + // Name: to.Ptr("TestRUAlert2"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157f\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:ffffffff-gggg-hhhh-iiii-jjjjjjjjjjjj_2023-04-01/billingProfiles/MYDEVTESTBP/providers/Microsoft.CostManagement/budgets/TestRUAlert2"), + // Properties: &armcostmanagement.BudgetProperties{ + // Category: to.Ptr(armcostmanagement.CategoryTypeReservationUtilization), + // Filter: &armcostmanagement.BudgetFilter{ + // Dimensions: &armcostmanagement.BudgetComparisonExpression{ + // Name: to.Ptr("ReservationId"), + // Operator: to.Ptr(armcostmanagement.BudgetOperatorTypeIn), + // Values: []*string{ + // to.Ptr("00000000-0000-0000-0000-000000000000"), + // to.Ptr("00000000-0000-0000-0000-000000000001"), + // to.Ptr("00000000-0000-0000-0000-000000000002"), + // }, + // }, + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_LessThan_99_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // Enabled: to.Ptr(true), + // Frequency: to.Ptr(armcostmanagement.FrequencyDaily), + // Locale: to.Ptr(armcostmanagement.CultureCodeEnUs), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeLessThan), + // Threshold: to.Ptr[float32](80), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeLast7Days), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-01T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2025-03-01/Budgets/List/MCA/CustomerBudgetsList-CategoryTypeFilter.json +func ExampleBudgetsClient_NewListPager_customerBudgetsListMcaCspCategoryTypeFilter() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain 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.NewBudgetsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:ffffffff-gggg-hhhh-iiii-jjjjjjjjjjjj_2023-04-01/customers/000000-1111-2222-3333-444444444444", &armcostmanagement.BudgetsClientListOptions{ + Filter: to.Ptr("properties/category eq 'ReservationUtilization'")}) + 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 = armcostmanagement.BudgetsClientListResponse{ + // BudgetsListResult: armcostmanagement.BudgetsListResult{ + // Value: []*armcostmanagement.Budget{ + // { + // Name: to.Ptr("TestRUAlert1"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157f\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:ffffffff-gggg-hhhh-iiii-jjjjjjjjjjjj_2023-04-01/customers/000000-1111-2222-3333-444444444444/providers/Microsoft.CostManagement/budgets/TestRUAlert1"), + // Properties: &armcostmanagement.BudgetProperties{ + // Category: to.Ptr(armcostmanagement.CategoryTypeReservationUtilization), + // Filter: &armcostmanagement.BudgetFilter{ + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_LessThan_99_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // Enabled: to.Ptr(true), + // Frequency: to.Ptr(armcostmanagement.FrequencyDaily), + // Locale: to.Ptr(armcostmanagement.CultureCodeEnUs), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeLessThan), + // Threshold: to.Ptr[float32](99), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeLast30Days), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-01T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // { + // Name: to.Ptr("TestRUAlert2"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157f\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:ffffffff-gggg-hhhh-iiii-jjjjjjjjjjjj_2023-04-01/customers/000000-1111-2222-3333-444444444444/providers/Microsoft.CostManagement/budgets/TestRUAlert2"), + // Properties: &armcostmanagement.BudgetProperties{ + // Category: to.Ptr(armcostmanagement.CategoryTypeReservationUtilization), + // Filter: &armcostmanagement.BudgetFilter{ + // Dimensions: &armcostmanagement.BudgetComparisonExpression{ + // Name: to.Ptr("ReservationId"), + // Operator: to.Ptr(armcostmanagement.BudgetOperatorTypeIn), + // Values: []*string{ + // to.Ptr("00000000-0000-0000-0000-000000000000"), + // to.Ptr("00000000-0000-0000-0000-000000000001"), + // to.Ptr("00000000-0000-0000-0000-000000000002"), + // }, + // }, + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_LessThan_99_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // Enabled: to.Ptr(true), + // Frequency: to.Ptr(armcostmanagement.FrequencyDaily), + // Locale: to.Ptr(armcostmanagement.CultureCodeEnUs), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeLessThan), + // Threshold: to.Ptr[float32](80), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeLast7Days), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-01T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2025-03-01/Budgets/List/MCA/CustomerBudgetsList.json +func ExampleBudgetsClient_NewListPager_customerBudgetsListMcaCsp() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain 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.NewBudgetsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:ffffffff-gggg-hhhh-iiii-jjjjjjjjjjjj_2023-04-01/customers/000000-1111-2222-3333-444444444444", 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 = armcostmanagement.BudgetsClientListResponse{ + // BudgetsListResult: armcostmanagement.BudgetsListResult{ + // Value: []*armcostmanagement.Budget{ + // { + // Name: to.Ptr("TestBudget1"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157c\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:ffffffff-gggg-hhhh-iiii-jjjjjjjjjjjj_2023-04-01/customers/000000-1111-2222-3333-444444444444"), + // Properties: &armcostmanagement.BudgetProperties{ + // Amount: to.Ptr[float32](200), + // Category: to.Ptr(armcostmanagement.CategoryTypeCost), + // CurrentSpend: &armcostmanagement.CurrentSpend{ + // Amount: to.Ptr[float32](30), + // Unit: to.Ptr("USD"), + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_GreaterThanOrEqualTo_80_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // Enabled: to.Ptr(true), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeGreaterThanOrEqualTo), + // Threshold: to.Ptr[float32](80), + // ThresholdType: to.Ptr(armcostmanagement.ThresholdTypeActual), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeMonthly), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-31T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // { + // Name: to.Ptr("TestBudget2"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157d\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:ffffffff-gggg-hhhh-iiii-jjjjjjjjjjjj_2023-04-01/customers/000000-1111-2222-3333-444444444444/providers/Microsoft.CostManagement/budgets/TestBudget2"), + // Properties: &armcostmanagement.BudgetProperties{ + // Amount: to.Ptr[float32](600), + // Category: to.Ptr(armcostmanagement.CategoryTypeCost), + // CurrentSpend: &armcostmanagement.CurrentSpend{ + // Amount: to.Ptr[float32](20), + // Unit: to.Ptr("USD"), + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_GreaterThanOrEqualTo_70_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // Enabled: to.Ptr(true), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeGreaterThanOrEqualTo), + // Threshold: to.Ptr[float32](70), + // ThresholdType: to.Ptr(armcostmanagement.ThresholdTypeActual), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeMonthly), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-31T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // { + // Name: to.Ptr("TestRUAlert1"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157f\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:ffffffff-gggg-hhhh-iiii-jjjjjjjjjjjj_2023-04-01/customers/000000-1111-2222-3333-444444444444/providers/Microsoft.CostManagement/budgets/TestRUAlert1"), + // Properties: &armcostmanagement.BudgetProperties{ + // Category: to.Ptr(armcostmanagement.CategoryTypeReservationUtilization), + // Filter: &armcostmanagement.BudgetFilter{ + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_LessThan_99_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // Enabled: to.Ptr(true), + // Frequency: to.Ptr(armcostmanagement.FrequencyDaily), + // Locale: to.Ptr(armcostmanagement.CultureCodeEnUs), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeLessThan), + // Threshold: to.Ptr[float32](99), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeLast30Days), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-01T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // { + // Name: to.Ptr("TestRUAlert2"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157f\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:ffffffff-gggg-hhhh-iiii-jjjjjjjjjjjj_2023-04-01/customers/000000-1111-2222-3333-444444444444/providers/Microsoft.CostManagement/budgets/TestRUAlert2"), + // Properties: &armcostmanagement.BudgetProperties{ + // Category: to.Ptr(armcostmanagement.CategoryTypeReservationUtilization), + // Filter: &armcostmanagement.BudgetFilter{ + // Dimensions: &armcostmanagement.BudgetComparisonExpression{ + // Name: to.Ptr("ReservationId"), + // Operator: to.Ptr(armcostmanagement.BudgetOperatorTypeIn), + // Values: []*string{ + // to.Ptr("00000000-0000-0000-0000-000000000000"), + // to.Ptr("00000000-0000-0000-0000-000000000001"), + // to.Ptr("00000000-0000-0000-0000-000000000002"), + // }, + // }, + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_LessThan_99_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // Enabled: to.Ptr(true), + // Frequency: to.Ptr(armcostmanagement.FrequencyDaily), + // Locale: to.Ptr(armcostmanagement.CultureCodeEnUs), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeLessThan), + // Threshold: to.Ptr[float32](80), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeLast7Days), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-01T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2025-03-01/Budgets/List/MCA/InvoiceSectionBudgetsList.json +func ExampleBudgetsClient_NewListPager_invoiceSectionBudgetsListMca() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain 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.NewBudgetsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:ffffffff-gggg-hhhh-iiii-jjjjjjjjjjjj_2023-04-01/billingProfiles/MYDEVTESTBP/invoiceSections/AAAA-BBBB-CCC-DDD", 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 = armcostmanagement.BudgetsClientListResponse{ + // BudgetsListResult: armcostmanagement.BudgetsListResult{ + // Value: []*armcostmanagement.Budget{ + // { + // Name: to.Ptr("TestBudget1"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157c\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:ffffffff-gggg-hhhh-iiii-jjjjjjjjjjjj_2023-04-01/billingProfiles/MYDEVTESTBP/invoiceSections/AAAA-BBBB-CCC-DDD/providers/Microsoft.CostManagement/budgets/TestBudget1"), + // Properties: &armcostmanagement.BudgetProperties{ + // Amount: to.Ptr[float32](20), + // Category: to.Ptr(armcostmanagement.CategoryTypeCost), + // CurrentSpend: &armcostmanagement.CurrentSpend{ + // Amount: to.Ptr[float32](5), + // Unit: to.Ptr("USD"), + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_GreaterThanOrEqualTo_80_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // Enabled: to.Ptr(true), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeGreaterThanOrEqualTo), + // Threshold: to.Ptr[float32](80), + // ThresholdType: to.Ptr(armcostmanagement.ThresholdTypeActual), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeMonthly), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-31T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // { + // Name: to.Ptr("TestBudget2"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157d\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:ffffffff-gggg-hhhh-iiii-jjjjjjjjjjjj_2023-04-01/billingProfiles/MYDEVTESTBP/invoiceSections/AAAA-BBBB-CCC-DDD/providers/Microsoft.CostManagement/budgets/TestBudget2"), + // Properties: &armcostmanagement.BudgetProperties{ + // Amount: to.Ptr[float32](60), + // Category: to.Ptr(armcostmanagement.CategoryTypeCost), + // CurrentSpend: &armcostmanagement.CurrentSpend{ + // Amount: to.Ptr[float32](20), + // Unit: to.Ptr("USD"), + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_GreaterThanOrEqualTo_70_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // Enabled: to.Ptr(true), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeGreaterThanOrEqualTo), + // Threshold: to.Ptr[float32](70), + // ThresholdType: to.Ptr(armcostmanagement.ThresholdTypeActual), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeMonthly), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-31T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2025-03-01/Budgets/List/RBAC/ManagementGroupBudgetsList.json +func ExampleBudgetsClient_NewListPager_managementGroupBudgetsList() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain 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.NewBudgetsClient().NewListPager("Microsoft.Management/managementGroups/MYDEVTESTMG", 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 = armcostmanagement.BudgetsClientListResponse{ + // BudgetsListResult: armcostmanagement.BudgetsListResult{ + // Value: []*armcostmanagement.Budget{ + // { + // Name: to.Ptr("TestBudget"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157f\"")), + // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/MYDEVTESTMG/providers/Microsoft.CostManagement/budgets/TestBudget"), + // Properties: &armcostmanagement.BudgetProperties{ + // Amount: to.Ptr[float32](10000), + // Category: to.Ptr(armcostmanagement.CategoryTypeCost), + // CurrentSpend: &armcostmanagement.CurrentSpend{ + // Amount: to.Ptr[float32](8000.89), + // Unit: to.Ptr("USD"), + // }, + // Filter: &armcostmanagement.BudgetFilter{ + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_GreaterThanOrEqualTo_80_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("managers@contoso.com"), + // }, + // Enabled: to.Ptr(true), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeGreaterThan), + // Threshold: to.Ptr[float32](80), + // ThresholdType: to.Ptr(armcostmanagement.ThresholdTypeActual), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeMonthly), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-31T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // { + // Name: to.Ptr("TestBudget"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157f\"")), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/budgets/TestBudget"), + // Properties: &armcostmanagement.BudgetProperties{ + // Amount: to.Ptr[float32](600.65), + // Category: to.Ptr(armcostmanagement.CategoryTypeCost), + // CurrentSpend: &armcostmanagement.CurrentSpend{ + // Amount: to.Ptr[float32](120.89), + // Unit: to.Ptr("USD"), + // }, + // Filter: &armcostmanagement.BudgetFilter{ + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_GreaterThanOrEqualTo_60_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // ContactGroups: []*string{ + // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/microsoft.insights/actionGroups/SampleActionGroup"), + // }, + // ContactRoles: []*string{ + // to.Ptr("Contributor"), + // to.Ptr("Reader"), + // }, + // Enabled: to.Ptr(true), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeGreaterThanOrEqualTo), + // Threshold: to.Ptr[float32](60), + // ThresholdType: to.Ptr(armcostmanagement.ThresholdTypeActual), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeMonthly), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-31T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // { + // Name: to.Ptr("TestBudget"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157f\"")), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.CostManagement/budgets/TestBudget"), + // Properties: &armcostmanagement.BudgetProperties{ + // Amount: to.Ptr[float32](100.65), + // Category: to.Ptr(armcostmanagement.CategoryTypeCost), + // CurrentSpend: &armcostmanagement.CurrentSpend{ + // Amount: to.Ptr[float32](80.89), + // Unit: to.Ptr("USD"), + // }, + // Filter: &armcostmanagement.BudgetFilter{ + // And: []*armcostmanagement.BudgetFilterProperties{ + // { + // Dimensions: &armcostmanagement.BudgetComparisonExpression{ + // Name: to.Ptr("ResourceId"), + // Operator: to.Ptr(armcostmanagement.BudgetOperatorTypeIn), + // Values: []*string{ + // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Compute/virtualMachines/MSVM2"), + // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Compute/virtualMachines/platformcloudplatformGeneric1"), + // }, + // }, + // }, + // { + // Tags: &armcostmanagement.BudgetComparisonExpression{ + // Name: to.Ptr("category"), + // Operator: to.Ptr(armcostmanagement.BudgetOperatorTypeIn), + // Values: []*string{ + // to.Ptr("Dev"), + // to.Ptr("Prod"), + // }, + // }, + // }, + // { + // Tags: &armcostmanagement.BudgetComparisonExpression{ + // Name: to.Ptr("department"), + // Operator: to.Ptr(armcostmanagement.BudgetOperatorTypeIn), + // Values: []*string{ + // to.Ptr("engineering"), + // to.Ptr("sales"), + // }, + // }, + // }, + // }, + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_GreaterThanOrEqualTo_90_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // ContactGroups: []*string{ + // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/microsoft.insights/actionGroups/SampleActionGroup"), + // }, + // ContactRoles: []*string{ + // to.Ptr("Contributor"), + // to.Ptr("Reader"), + // }, + // Enabled: to.Ptr(true), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeGreaterThanOrEqualTo), + // Threshold: to.Ptr[float32](90), + // ThresholdType: to.Ptr(armcostmanagement.ThresholdTypeActual), + // }, + // "Actual_GreaterThan_80_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // ContactRoles: []*string{ + // to.Ptr("Contributor"), + // to.Ptr("Reader"), + // }, + // Enabled: to.Ptr(true), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeGreaterThan), + // Threshold: to.Ptr[float32](80), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeMonthly), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-31T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // { + // Name: to.Ptr("TestBudget1"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157f\"")), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.CostManagement/budgets/TestBudget1"), + // Properties: &armcostmanagement.BudgetProperties{ + // Amount: to.Ptr[float32](200.65), + // Category: to.Ptr(armcostmanagement.CategoryTypeCost), + // CurrentSpend: &armcostmanagement.CurrentSpend{ + // Amount: to.Ptr[float32](120.89), + // Unit: to.Ptr("USD"), + // }, + // Filter: &armcostmanagement.BudgetFilter{ + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_GreaterThanOrEqualTo_60_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // ContactGroups: []*string{ + // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/microsoft.insights/actionGroups/SampleActionGroup"), + // }, + // ContactRoles: []*string{ + // to.Ptr("Contributor"), + // to.Ptr("Reader"), + // }, + // Enabled: to.Ptr(true), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeGreaterThanOrEqualTo), + // Threshold: to.Ptr[float32](60), + // ThresholdType: to.Ptr(armcostmanagement.ThresholdTypeActual), + // }, + // "Actual_GreaterThan_40_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // ContactRoles: []*string{ + // to.Ptr("Contributor"), + // to.Ptr("Reader"), + // }, + // Enabled: to.Ptr(true), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeGreaterThan), + // Threshold: to.Ptr[float32](40), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeMonthly), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-31T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2025-03-01/Budgets/List/RBAC/ResourceGroupBudgetsList.json +func ExampleBudgetsClient_NewListPager_resourceGroupBudgetsList() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain 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.NewBudgetsClient().NewListPager("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 = armcostmanagement.BudgetsClientListResponse{ + // BudgetsListResult: armcostmanagement.BudgetsListResult{ + // Value: []*armcostmanagement.Budget{ + // { + // Name: to.Ptr("TestBudget0"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157f\"")), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.CostManagement/budgets/TestBudget0"), + // Properties: &armcostmanagement.BudgetProperties{ + // Amount: to.Ptr[float32](100.65), + // Category: to.Ptr(armcostmanagement.CategoryTypeCost), + // CurrentSpend: &armcostmanagement.CurrentSpend{ + // Amount: to.Ptr[float32](80.89), + // Unit: to.Ptr("USD"), + // }, + // Filter: &armcostmanagement.BudgetFilter{ + // And: []*armcostmanagement.BudgetFilterProperties{ + // { + // Dimensions: &armcostmanagement.BudgetComparisonExpression{ + // Name: to.Ptr("ResourceId"), + // Operator: to.Ptr(armcostmanagement.BudgetOperatorTypeIn), + // Values: []*string{ + // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Compute/virtualMachines/MSVM2"), + // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Compute/virtualMachines/platformcloudplatformGeneric1"), + // }, + // }, + // }, + // { + // Tags: &armcostmanagement.BudgetComparisonExpression{ + // Name: to.Ptr("category"), + // Operator: to.Ptr(armcostmanagement.BudgetOperatorTypeIn), + // Values: []*string{ + // to.Ptr("Dev"), + // to.Ptr("Prod"), + // }, + // }, + // }, + // { + // Tags: &armcostmanagement.BudgetComparisonExpression{ + // Name: to.Ptr("department"), + // Operator: to.Ptr(armcostmanagement.BudgetOperatorTypeIn), + // Values: []*string{ + // to.Ptr("engineering"), + // to.Ptr("sales"), + // }, + // }, + // }, + // }, + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_GreaterThanOrEqualTo_90_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // ContactGroups: []*string{ + // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/microsoft.insights/actionGroups/SampleActionGroup"), + // }, + // ContactRoles: []*string{ + // to.Ptr("Contributor"), + // to.Ptr("Reader"), + // }, + // Enabled: to.Ptr(true), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeGreaterThanOrEqualTo), + // Threshold: to.Ptr[float32](90), + // ThresholdType: to.Ptr(armcostmanagement.ThresholdTypeActual), + // }, + // "Actual_GreaterThan_80_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // ContactRoles: []*string{ + // to.Ptr("Contributor"), + // to.Ptr("Reader"), + // }, + // Enabled: to.Ptr(true), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeGreaterThan), + // Threshold: to.Ptr[float32](80), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeMonthly), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-31T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // { + // Name: to.Ptr("TestBudget1"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157f\"")), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.CostManagement/budgets/TestBudget1"), + // Properties: &armcostmanagement.BudgetProperties{ + // Amount: to.Ptr[float32](200.65), + // Category: to.Ptr(armcostmanagement.CategoryTypeCost), + // CurrentSpend: &armcostmanagement.CurrentSpend{ + // Amount: to.Ptr[float32](120.89), + // Unit: to.Ptr("USD"), + // }, + // Filter: &armcostmanagement.BudgetFilter{ + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_GreaterThanOrEqualTo_60_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // ContactGroups: []*string{ + // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/microsoft.insights/actionGroups/SampleActionGroup"), + // }, + // ContactRoles: []*string{ + // to.Ptr("Contributor"), + // to.Ptr("Reader"), + // }, + // Enabled: to.Ptr(true), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeGreaterThanOrEqualTo), + // Threshold: to.Ptr[float32](60), + // ThresholdType: to.Ptr(armcostmanagement.ThresholdTypeActual), + // }, + // "Actual_GreaterThan_40_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // ContactRoles: []*string{ + // to.Ptr("Contributor"), + // to.Ptr("Reader"), + // }, + // Enabled: to.Ptr(true), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeGreaterThan), + // Threshold: to.Ptr[float32](40), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeMonthly), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-31T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2025-03-01/Budgets/List/RBAC/SubscriptionBudgetsList.json +func ExampleBudgetsClient_NewListPager_subscriptionBudgetsList() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain 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.NewBudgetsClient().NewListPager("subscriptions/00000000-0000-0000-0000-000000000000", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armcostmanagement.BudgetsClientListResponse{ + // BudgetsListResult: armcostmanagement.BudgetsListResult{ + // Value: []*armcostmanagement.Budget{ + // { + // Name: to.Ptr("TestBudget"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157f\"")), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/budgets/TestBudget"), + // Properties: &armcostmanagement.BudgetProperties{ + // Amount: to.Ptr[float32](600.65), + // Category: to.Ptr(armcostmanagement.CategoryTypeCost), + // CurrentSpend: &armcostmanagement.CurrentSpend{ + // Amount: to.Ptr[float32](120.89), + // Unit: to.Ptr("USD"), + // }, + // Filter: &armcostmanagement.BudgetFilter{ + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_GreaterThanOrEqualTo_60_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // ContactGroups: []*string{ + // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/microsoft.insights/actionGroups/SampleActionGroup"), + // }, + // ContactRoles: []*string{ + // to.Ptr("Contributor"), + // to.Ptr("Reader"), + // }, + // Enabled: to.Ptr(true), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeGreaterThanOrEqualTo), + // Threshold: to.Ptr[float32](60), + // ThresholdType: to.Ptr(armcostmanagement.ThresholdTypeActual), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeMonthly), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-31T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // { + // Name: to.Ptr("TestBudget"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157f\"")), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.CostManagement/budgets/TestBudget"), + // Properties: &armcostmanagement.BudgetProperties{ + // Amount: to.Ptr[float32](100.65), + // Category: to.Ptr(armcostmanagement.CategoryTypeCost), + // CurrentSpend: &armcostmanagement.CurrentSpend{ + // Amount: to.Ptr[float32](80.89), + // Unit: to.Ptr("USD"), + // }, + // Filter: &armcostmanagement.BudgetFilter{ + // And: []*armcostmanagement.BudgetFilterProperties{ + // { + // Dimensions: &armcostmanagement.BudgetComparisonExpression{ + // Name: to.Ptr("ResourceId"), + // Operator: to.Ptr(armcostmanagement.BudgetOperatorTypeIn), + // Values: []*string{ + // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Compute/virtualMachines/MSVM2"), + // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Compute/virtualMachines/platformcloudplatformGeneric1"), + // }, + // }, + // }, + // { + // Tags: &armcostmanagement.BudgetComparisonExpression{ + // Name: to.Ptr("category"), + // Operator: to.Ptr(armcostmanagement.BudgetOperatorTypeIn), + // Values: []*string{ + // to.Ptr("Dev"), + // to.Ptr("Prod"), + // }, + // }, + // }, + // { + // Tags: &armcostmanagement.BudgetComparisonExpression{ + // Name: to.Ptr("department"), + // Operator: to.Ptr(armcostmanagement.BudgetOperatorTypeIn), + // Values: []*string{ + // to.Ptr("engineering"), + // to.Ptr("sales"), + // }, + // }, + // }, + // }, + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_GreaterThanOrEqualTo_90_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // ContactGroups: []*string{ + // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/microsoft.insights/actionGroups/SampleActionGroup"), + // }, + // ContactRoles: []*string{ + // to.Ptr("Contributor"), + // to.Ptr("Reader"), + // }, + // Enabled: to.Ptr(true), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeGreaterThanOrEqualTo), + // Threshold: to.Ptr[float32](90), + // ThresholdType: to.Ptr(armcostmanagement.ThresholdTypeActual), + // }, + // "Actual_GreaterThan_80_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // ContactRoles: []*string{ + // to.Ptr("Contributor"), + // to.Ptr("Reader"), + // }, + // Enabled: to.Ptr(true), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeGreaterThan), + // Threshold: to.Ptr[float32](80), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeMonthly), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-31T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // { + // Name: to.Ptr("TestBudget1"), + // Type: to.Ptr("Microsoft.CostManagement/budgets"), + // ETag: to.Ptr(azcore.ETag("\"1d34d012214157f\"")), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.CostManagement/budgets/TestBudget1"), + // Properties: &armcostmanagement.BudgetProperties{ + // Amount: to.Ptr[float32](200.65), + // Category: to.Ptr(armcostmanagement.CategoryTypeCost), + // CurrentSpend: &armcostmanagement.CurrentSpend{ + // Amount: to.Ptr[float32](120.89), + // Unit: to.Ptr("USD"), + // }, + // Filter: &armcostmanagement.BudgetFilter{ + // }, + // Notifications: map[string]*armcostmanagement.Notification{ + // "Actual_GreaterThanOrEqualTo_60_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // ContactGroups: []*string{ + // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/microsoft.insights/actionGroups/SampleActionGroup"), + // }, + // ContactRoles: []*string{ + // to.Ptr("Contributor"), + // to.Ptr("Reader"), + // }, + // Enabled: to.Ptr(true), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeGreaterThanOrEqualTo), + // Threshold: to.Ptr[float32](60), + // ThresholdType: to.Ptr(armcostmanagement.ThresholdTypeActual), + // }, + // "Actual_GreaterThan_40_Percent": &armcostmanagement.Notification{ + // ContactEmails: []*string{ + // to.Ptr("johndoe@contoso.com"), + // to.Ptr("janesmith@contoso.com"), + // }, + // ContactRoles: []*string{ + // to.Ptr("Contributor"), + // to.Ptr("Reader"), + // }, + // Enabled: to.Ptr(true), + // Operator: to.Ptr(armcostmanagement.BudgetNotificationOperatorTypeGreaterThan), + // Threshold: to.Ptr[float32](40), + // }, + // }, + // TimeGrain: to.Ptr(armcostmanagement.TimeGrainTypeMonthly), + // TimePeriod: &armcostmanagement.BudgetTimePeriod{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-10-31T00:00:00Z"); return t}()), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // }, + // }, + // } + } +} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/build.go b/sdk/resourcemanager/costmanagement/armcostmanagement/build.go deleted file mode 100644 index 8e3e767c4182..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/build.go +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. - -// This file enables 'go generate' to regenerate this specific SDK -//go:generate pwsh ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate -removeUnreferencedTypes resourcemanager/costmanagement/armcostmanagement - -package armcostmanagement diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/client_factory.go b/sdk/resourcemanager/costmanagement/armcostmanagement/client_factory.go index 0469f2c0fcd0..fb45cb2c2da0 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/client_factory.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/client_factory.go @@ -1,7 +1,6 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armcostmanagement @@ -13,8 +12,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. @@ -22,108 +20,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 e6241356126c..17cfdc216e55 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/constants.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/constants.go @@ -1,15 +1,9 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armcostmanagement -const ( - moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement" - moduleVersion = "v2.1.0" -) - // AccumulatedType - Show costs accumulated over time. type AccumulatedType string @@ -26,10 +20,11 @@ func PossibleAccumulatedTypeValues() []AccumulatedType { } } -// ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. +// ActionType - Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. type ActionType string const ( + // ActionTypeInternal - Actions are for internal-only APIs. ActionTypeInternal ActionType = "Internal" ) @@ -235,6 +230,113 @@ 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 @@ -257,12 +359,14 @@ func PossibleChartTypeValues() []ChartType { } } -// CheckNameAvailabilityReason - The reason why the given name is not available. +// CheckNameAvailabilityReason - Possible reasons for a name not being available. type CheckNameAvailabilityReason string const ( + // CheckNameAvailabilityReasonAlreadyExists - Name already exists. CheckNameAvailabilityReasonAlreadyExists CheckNameAvailabilityReason = "AlreadyExists" - CheckNameAvailabilityReasonInvalid CheckNameAvailabilityReason = "Invalid" + // CheckNameAvailabilityReasonInvalid - Name is invalid. + CheckNameAvailabilityReasonInvalid CheckNameAvailabilityReason = "Invalid" ) // PossibleCheckNameAvailabilityReasonValues returns the possible values for the CheckNameAvailabilityReason const type. @@ -273,6 +377,59 @@ func PossibleCheckNameAvailabilityReasonValues() []CheckNameAvailabilityReason { } } +// CompressionModeType - Allow customers to select compress data for exports. This setting will enable destination file compression +// scheme at runtime. By default set to None. Gzip is for csv and snappy for parquet. +type CompressionModeType string + +const ( + CompressionModeTypeGzip CompressionModeType = "gzip" + CompressionModeTypeNone CompressionModeType = "none" + CompressionModeTypeSnappy CompressionModeType = "snappy" +) + +// PossibleCompressionModeTypeValues returns the possible values for the CompressionModeType const type. +func PossibleCompressionModeTypeValues() []CompressionModeType { + return []CompressionModeType{ + CompressionModeTypeGzip, + CompressionModeTypeNone, + CompressionModeTypeSnappy, + } +} + +// 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 @@ -327,14 +484,18 @@ func PossibleCostDetailsStatusTypeValues() []CostDetailsStatusType { } } -// CreatedByType - The type of identity that created the resource. +// CreatedByType - The kind of entity that created the resource. type CreatedByType string const ( - CreatedByTypeApplication CreatedByType = "Application" - CreatedByTypeKey CreatedByType = "Key" + // CreatedByTypeApplication - The entity was created by an application. + CreatedByTypeApplication CreatedByType = "Application" + // CreatedByTypeKey - The entity was created by a key. + CreatedByTypeKey CreatedByType = "Key" + // CreatedByTypeManagedIdentity - The entity was created by a managed identity. CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" - CreatedByTypeUser CreatedByType = "User" + // CreatedByTypeUser - The entity was created by a user. + CreatedByTypeUser CreatedByType = "User" ) // PossibleCreatedByTypeValues returns the possible values for the CreatedByType const type. @@ -347,6 +508,78 @@ 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, + } +} + +// DataOverwriteBehaviorType - Allow customers to select overwrite data(OverwritePreviousReport) for exports. This setting +// will enable overwrite data for the same month in customer storage account. By default set to CreateNewReport. +type DataOverwriteBehaviorType string + +const ( + DataOverwriteBehaviorTypeCreateNewReport DataOverwriteBehaviorType = "CreateNewReport" + DataOverwriteBehaviorTypeOverwritePreviousReport DataOverwriteBehaviorType = "OverwritePreviousReport" +) + +// PossibleDataOverwriteBehaviorTypeValues returns the possible values for the DataOverwriteBehaviorType const type. +func PossibleDataOverwriteBehaviorTypeValues() []DataOverwriteBehaviorType { + return []DataOverwriteBehaviorType{ + DataOverwriteBehaviorTypeCreateNewReport, + DataOverwriteBehaviorTypeOverwritePreviousReport, + } +} + // DaysOfWeek - Days of Week. type DaysOfWeek string @@ -373,6 +606,20 @@ func PossibleDaysOfWeekValues() []DaysOfWeek { } } +// DestinationType - The export delivery destination type. Currently only 'AzureBlob' is supported. +type DestinationType string + +const ( + DestinationTypeAzureBlob DestinationType = "AzureBlob" +) + +// PossibleDestinationTypeValues returns the possible values for the DestinationType const type. +func PossibleDestinationTypeValues() []DestinationType { + return []DestinationType{ + DestinationTypeAzureBlob, + } +} + // ExecutionStatus - The last known status of the export run. type ExecutionStatus string @@ -415,13 +662,19 @@ 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 ( - ExportTypeActualCost ExportType = "ActualCost" - ExportTypeAmortizedCost ExportType = "AmortizedCost" - ExportTypeUsage ExportType = "Usage" + ExportTypeActualCost ExportType = "ActualCost" + ExportTypeAmortizedCost ExportType = "AmortizedCost" + ExportTypeFocusCost ExportType = "FocusCost" + ExportTypePriceSheet ExportType = "PriceSheet" + ExportTypeReservationDetails ExportType = "ReservationDetails" + ExportTypeReservationRecommendations ExportType = "ReservationRecommendations" + ExportTypeReservationTransactions ExportType = "ReservationTransactions" + ExportTypeUsage ExportType = "Usage" ) // PossibleExportTypeValues returns the possible values for the ExportType const type. @@ -429,6 +682,11 @@ func PossibleExportTypeValues() []ExportType { return []ExportType{ ExportTypeActualCost, ExportTypeAmortizedCost, + ExportTypeFocusCost, + ExportTypePriceSheet, + ExportTypeReservationDetails, + ExportTypeReservationRecommendations, + ExportTypeReservationTransactions, ExportTypeUsage, } } @@ -462,6 +720,25 @@ func PossibleFileFormatValues() []FileFormat { } } +// FilterItemNames - The name of the filter. This is currently only supported for Export Definition type of ReservationRecommendations. +// Supported names are ['ReservationScope', 'LookBackPeriod', 'ResourceType'] +type FilterItemNames string + +const ( + FilterItemNamesLookBackPeriod FilterItemNames = "LookBackPeriod" + FilterItemNamesReservationScope FilterItemNames = "ReservationScope" + FilterItemNamesResourceType FilterItemNames = "ResourceType" +) + +// PossibleFilterItemNamesValues returns the possible values for the FilterItemNames const type. +func PossibleFilterItemNamesValues() []FilterItemNames { + return []FilterItemNames{ + FilterItemNamesLookBackPeriod, + FilterItemNamesReservationScope, + FilterItemNamesResourceType, + } +} + // ForecastOperatorType - The operator to use for comparison. type ForecastOperatorType string @@ -508,17 +785,44 @@ func PossibleForecastTypeValues() []ForecastType { } } -// FormatType - The format of the export being delivered. Currently only 'Csv' is supported. +// FormatType - The format of the export being delivered. type FormatType string const ( - FormatTypeCSV FormatType = "Csv" + FormatTypeCSV FormatType = "Csv" + FormatTypeParquet FormatType = "Parquet" ) // PossibleFormatTypeValues returns the possible values for the FormatType const type. func PossibleFormatTypeValues() []FormatType { return []FormatType{ FormatTypeCSV, + FormatTypeParquet, + } +} + +// 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, } } @@ -613,33 +917,35 @@ func PossibleGrainParameterValues() []GrainParameter { } } -// GranularityType - The granularity of rows in the forecast. +// GranularityType - The granularity of rows in the export. Currently 'Daily' is supported for most cases. type GranularityType string const ( - GranularityTypeDaily GranularityType = "Daily" + GranularityTypeDaily GranularityType = "Daily" + GranularityTypeMonthly GranularityType = "Monthly" ) // PossibleGranularityTypeValues returns the possible values for the GranularityType const type. func PossibleGranularityTypeValues() []GranularityType { return []GranularityType{ GranularityTypeDaily, + GranularityTypeMonthly, } } -// KpiType - KPI type (Forecast, Budget). -type KpiType string +// KpiTypeType - KPI type (Forecast, Budget). +type KpiTypeType string const ( - KpiTypeBudget KpiType = "Budget" - KpiTypeForecast KpiType = "Forecast" + KpiTypeTypeBudget KpiTypeType = "Budget" + KpiTypeTypeForecast KpiTypeType = "Forecast" ) -// PossibleKpiTypeValues returns the possible values for the KpiType const type. -func PossibleKpiTypeValues() []KpiType { - return []KpiType{ - KpiTypeBudget, - KpiTypeForecast, +// PossibleKpiTypeTypeValues returns the possible values for the KpiTypeType const type. +func PossibleKpiTypeTypeValues() []KpiTypeType { + return []KpiTypeType{ + KpiTypeTypeBudget, + KpiTypeTypeForecast, } } @@ -682,7 +988,7 @@ func PossibleMetricTypeValues() []MetricType { } } -// OperationStatusType - The status of the long running operation. +// OperationStatusType - Enum representing the status of an async operation. type OperationStatusType string const ( @@ -721,8 +1027,11 @@ func PossibleOperatorTypeValues() []OperatorType { type Origin string const ( - OriginSystem Origin = "system" - OriginUser Origin = "user" + // OriginSystem - Indicates the operation is initiated by a system. + OriginSystem Origin = "system" + // OriginUser - Indicates the operation is initiated by a user. + OriginUser Origin = "user" + // OriginUserSystem - Indicates the operation is initiated by a user or system. OriginUserSystem Origin = "user,system" ) @@ -735,19 +1044,19 @@ func PossibleOriginValues() []Origin { } } -// PivotType - Data type to show in view. -type PivotType string +// PivotTypeType - Data type to show in view. +type PivotTypeType string const ( - PivotTypeDimension PivotType = "Dimension" - PivotTypeTagKey PivotType = "TagKey" + PivotTypeTypeDimension PivotTypeType = "Dimension" + PivotTypeTypeTagKey PivotTypeType = "TagKey" ) -// PossiblePivotTypeValues returns the possible values for the PivotType const type. -func PossiblePivotTypeValues() []PivotType { - return []PivotType{ - PivotTypeDimension, - PivotTypeTagKey, +// PossiblePivotTypeTypeValues returns the possible values for the PivotTypeType const type. +func PossiblePivotTypeTypeValues() []PivotTypeType { + return []PivotTypeType{ + PivotTypeTypeDimension, + PivotTypeTypeTagKey, } } @@ -783,6 +1092,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 @@ -882,8 +1209,7 @@ func PossibleReportTimeframeTypeValues() []ReportTimeframeType { } // ReportType - The type of the report. Usage represents actual usage, forecast represents forecasted data and UsageAndForecast -// represents both usage and forecasted data. Actual usage and forecasted data can be -// differentiated based on dates. +// represents both usage and forecasted data. Actual usage and forecasted data can be differentiated based on dates. type ReportType string const ( @@ -932,6 +1258,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 @@ -1011,7 +1359,37 @@ func PossibleScopeValues() []Scope { } } -// StatusType - The status of the export's schedule. If 'Inactive', the export's schedule is paused. +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. To enable export set +// the status to be Active and then make a PUT request. type StatusType string const ( @@ -1027,6 +1405,24 @@ func PossibleStatusTypeValues() []StatusType { } } +// SystemAssignedServiceIdentityType - Type of managed service identity (either system assigned, or none). +type SystemAssignedServiceIdentityType string + +const ( + // SystemAssignedServiceIdentityTypeNone - No managed system identity. + SystemAssignedServiceIdentityTypeNone SystemAssignedServiceIdentityType = "None" + // SystemAssignedServiceIdentityTypeSystemAssigned - System assigned managed system identity. + 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 @@ -1045,13 +1441,93 @@ 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 ( TimeframeTypeBillingMonthToDate TimeframeType = "BillingMonthToDate" TimeframeTypeCustom TimeframeType = "Custom" TimeframeTypeMonthToDate TimeframeType = "MonthToDate" + TimeframeTypeTheCurrentMonth TimeframeType = "TheCurrentMonth" TimeframeTypeTheLastBillingMonth TimeframeType = "TheLastBillingMonth" TimeframeTypeTheLastMonth TimeframeType = "TheLastMonth" TimeframeTypeWeekToDate TimeframeType = "WeekToDate" @@ -1063,6 +1539,7 @@ func PossibleTimeframeTypeValues() []TimeframeType { TimeframeTypeBillingMonthToDate, TimeframeTypeCustom, TimeframeTypeMonthToDate, + TimeframeTypeTheCurrentMonth, TimeframeTypeTheLastBillingMonth, TimeframeTypeTheLastMonth, TimeframeTypeWeekToDate, diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/costallocationrules_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/costallocationrules_client.go new file mode 100644 index 000000000000..55cb0a887315 --- /dev/null +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/costallocationrules_client.go @@ -0,0 +1,334 @@ +// 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) Go Code Generator. DO NOT EDIT. + +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 - Contains optional client configuration. 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 2025-03-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, _ *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", "2025-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []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 2025-03-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, _ *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", "2025-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []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 2025-03-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, _ *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", "2025-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + 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 2025-03-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, _ *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", "2025-03-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 2025-03-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, _ *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", "2025-03-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/costallocationrules_client_example_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/costallocationrules_client_example_test.go new file mode 100644 index 000000000000..d15d3d312b74 --- /dev/null +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/costallocationrules_client_example_test.go @@ -0,0 +1,463 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armcostmanagement_test + +import ( + "context" + "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/v3" + "log" +) + +// Generated from example definition: 2025-03-01/CostAllocationRuleCheckNameAvailability.json +func ExampleCostAllocationRulesClient_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.NewCostAllocationRulesClient().CheckNameAvailability(ctx, "100", armcostmanagement.CostAllocationRuleCheckNameAvailabilityRequest{ + Name: to.Ptr("testRule"), + Type: to.Ptr("Microsoft.CostManagement/costAllocationRules"), + }, 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 = armcostmanagement.CostAllocationRulesClientCheckNameAvailabilityResponse{ + // CostAllocationRuleCheckNameAvailabilityResponse: &armcostmanagement.CostAllocationRuleCheckNameAvailabilityResponse{ + // Message: to.Ptr("A cost allocation rule with name testRule is already present for the billing account 100. Please specify a differnt name."), + // NameAvailable: to.Ptr(false), + // Reason: to.Ptr(armcostmanagement.ReasonAlreadyExists), + // }, + // } +} + +// Generated from example definition: 2025-03-01/CostAllocationRuleCreate.json +func ExampleCostAllocationRulesClient_CreateOrUpdate_costAllocationRulesCreateResourceGroup() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain 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.NewCostAllocationRulesClient().CreateOrUpdate(ctx, "100", "testRule", armcostmanagement.CostAllocationRuleDefinition{ + Properties: &armcostmanagement.CostAllocationRuleProperties{ + Description: to.Ptr("This is a testRule"), + Status: to.Ptr(armcostmanagement.RuleStatusActive), + Details: &armcostmanagement.CostAllocationRuleDetails{ + SourceResources: []*armcostmanagement.SourceCostAllocationResource{ + { + Name: to.Ptr("ResourceGroupName"), + ResourceType: to.Ptr(armcostmanagement.CostAllocationResourceTypeDimension), + Values: []*string{ + to.Ptr("sampleRG"), + to.Ptr("secondRG"), + }, + }, + }, + TargetResources: []*armcostmanagement.TargetCostAllocationResource{ + { + Name: to.Ptr("ResourceGroupName"), + PolicyType: to.Ptr(armcostmanagement.CostAllocationPolicyTypeFixedProportion), + ResourceType: to.Ptr(armcostmanagement.CostAllocationResourceTypeDimension), + Values: []*armcostmanagement.CostAllocationProportion{ + { + Name: to.Ptr("destinationRG"), + Percentage: to.Ptr[float32](45), + }, + { + Name: to.Ptr("destinationRG2"), + Percentage: to.Ptr[float32](54), + }, + }, + }, + }, + }, + }, + }, 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 = armcostmanagement.CostAllocationRulesClientCreateOrUpdateResponse{ + // CostAllocationRuleDefinition: &armcostmanagement.CostAllocationRuleDefinition{ + // Name: to.Ptr("testRule"), + // Type: to.Ptr("Microsoft.CostManagement/costAllocationRules"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/100/providers/Microsoft.CostManagement/costAllocationRules/testRule"), + // Properties: &armcostmanagement.CostAllocationRuleProperties{ + // Description: to.Ptr("This is a testRule"), + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.1287144Z"); return t}()), + // Status: to.Ptr(armcostmanagement.RuleStatus("Creating")), + // UpdatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.1287144Z"); return t}()), + // Details: &armcostmanagement.CostAllocationRuleDetails{ + // SourceResources: []*armcostmanagement.SourceCostAllocationResource{ + // { + // Name: to.Ptr("ResourceGroupName"), + // ResourceType: to.Ptr(armcostmanagement.CostAllocationResourceTypeDimension), + // Values: []*string{ + // to.Ptr("sampleRG"), + // }, + // }, + // }, + // TargetResources: []*armcostmanagement.TargetCostAllocationResource{ + // { + // Name: to.Ptr("ResourceGroupName"), + // PolicyType: to.Ptr(armcostmanagement.CostAllocationPolicyTypeFixedProportion), + // ResourceType: to.Ptr(armcostmanagement.CostAllocationResourceTypeDimension), + // Values: []*armcostmanagement.CostAllocationProportion{ + // { + // Name: to.Ptr("destinationRG"), + // Percentage: to.Ptr[float32](50), + // }, + // { + // Name: to.Ptr("destinationRG2"), + // Percentage: to.Ptr[float32](50), + // }, + // }, + // }, + // }, + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01/CostAllocationRuleCreateTag.json +func ExampleCostAllocationRulesClient_CreateOrUpdate_costAllocationRulesCreateTag() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain 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.NewCostAllocationRulesClient().CreateOrUpdate(ctx, "100", "testRule", armcostmanagement.CostAllocationRuleDefinition{ + Properties: &armcostmanagement.CostAllocationRuleProperties{ + Description: to.Ptr("This is a testRule"), + Status: to.Ptr(armcostmanagement.RuleStatusActive), + Details: &armcostmanagement.CostAllocationRuleDetails{ + SourceResources: []*armcostmanagement.SourceCostAllocationResource{ + { + Name: to.Ptr("category"), + ResourceType: to.Ptr(armcostmanagement.CostAllocationResourceTypeTag), + Values: []*string{ + to.Ptr("devops"), + }, + }, + }, + TargetResources: []*armcostmanagement.TargetCostAllocationResource{ + { + Name: to.Ptr("ResourceGroupName"), + PolicyType: to.Ptr(armcostmanagement.CostAllocationPolicyTypeFixedProportion), + ResourceType: to.Ptr(armcostmanagement.CostAllocationResourceTypeDimension), + Values: []*armcostmanagement.CostAllocationProportion{ + { + Name: to.Ptr("destinationRG"), + Percentage: to.Ptr[float32](33.33), + }, + { + Name: to.Ptr("destinationRG2"), + Percentage: to.Ptr[float32](33.33), + }, + { + Name: to.Ptr("destinationRG3"), + Percentage: to.Ptr[float32](33.34), + }, + }, + }, + }, + }, + }, + }, 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 = armcostmanagement.CostAllocationRulesClientCreateOrUpdateResponse{ + // CostAllocationRuleDefinition: &armcostmanagement.CostAllocationRuleDefinition{ + // Name: to.Ptr("testRule"), + // Type: to.Ptr("Microsoft.CostManagement/costAllocationRules"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/100/providers/Microsoft.CostManagement/costAllocationRules/testRule"), + // Properties: &armcostmanagement.CostAllocationRuleProperties{ + // Description: to.Ptr("This is a testRule"), + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.1287144Z"); return t}()), + // Status: to.Ptr(armcostmanagement.RuleStatus("Creating")), + // UpdatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.1287144Z"); return t}()), + // Details: &armcostmanagement.CostAllocationRuleDetails{ + // SourceResources: []*armcostmanagement.SourceCostAllocationResource{ + // { + // Name: to.Ptr("ResourceGroupName"), + // ResourceType: to.Ptr(armcostmanagement.CostAllocationResourceTypeDimension), + // Values: []*string{ + // to.Ptr("sampleRG"), + // }, + // }, + // }, + // TargetResources: []*armcostmanagement.TargetCostAllocationResource{ + // { + // Name: to.Ptr("ResourceGroupName"), + // PolicyType: to.Ptr(armcostmanagement.CostAllocationPolicyTypeFixedProportion), + // ResourceType: to.Ptr(armcostmanagement.CostAllocationResourceTypeDimension), + // Values: []*armcostmanagement.CostAllocationProportion{ + // { + // Name: to.Ptr("destinationRG"), + // Percentage: to.Ptr[float32](50), + // }, + // { + // Name: to.Ptr("destinationRG2"), + // Percentage: to.Ptr[float32](50), + // }, + // }, + // }, + // }, + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01/CostAllocationRuleDelete.json +func ExampleCostAllocationRulesClient_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) + } + res, err := clientFactory.NewCostAllocationRulesClient().Delete(ctx, "100", "testRule", 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 = armcostmanagement.CostAllocationRulesClientDeleteResponse{ + // } +} + +// Generated from example definition: 2025-03-01/CostAllocationRuleGet.json +func ExampleCostAllocationRulesClient_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.NewCostAllocationRulesClient().Get(ctx, "100", "testRule", 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 = armcostmanagement.CostAllocationRulesClientGetResponse{ + // CostAllocationRuleDefinition: &armcostmanagement.CostAllocationRuleDefinition{ + // Name: to.Ptr("testRule"), + // Type: to.Ptr("Microsoft.CostManagement/costAllocationRules"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/100/providers/Microsoft.CostManagement/costAllocationRules/testRule"), + // Properties: &armcostmanagement.CostAllocationRuleProperties{ + // Description: to.Ptr("This is a testRule"), + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.1287144Z"); return t}()), + // Status: to.Ptr(armcostmanagement.RuleStatusNotActive), + // UpdatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.1287144Z"); return t}()), + // Details: &armcostmanagement.CostAllocationRuleDetails{ + // SourceResources: []*armcostmanagement.SourceCostAllocationResource{ + // { + // Name: to.Ptr("ResourceGroupName"), + // ResourceType: to.Ptr(armcostmanagement.CostAllocationResourceTypeDimension), + // Values: []*string{ + // to.Ptr("sampleRG"), + // }, + // }, + // }, + // TargetResources: []*armcostmanagement.TargetCostAllocationResource{ + // { + // Name: to.Ptr("ResourceGroupName"), + // PolicyType: to.Ptr(armcostmanagement.CostAllocationPolicyTypeFixedProportion), + // ResourceType: to.Ptr(armcostmanagement.CostAllocationResourceTypeDimension), + // Values: []*armcostmanagement.CostAllocationProportion{ + // { + // Name: to.Ptr("destinationRG"), + // Percentage: to.Ptr[float32](50), + // }, + // { + // Name: to.Ptr("destinationRG2"), + // Percentage: to.Ptr[float32](50), + // }, + // }, + // }, + // }, + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01/CostAllocationRulesList.json +func ExampleCostAllocationRulesClient_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.NewCostAllocationRulesClient().NewListPager("100", 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 = armcostmanagement.CostAllocationRulesClientListResponse{ + // CostAllocationRuleList: armcostmanagement.CostAllocationRuleList{ + // Value: []*armcostmanagement.CostAllocationRuleDefinition{ + // { + // Name: to.Ptr("testRule"), + // Type: to.Ptr("Microsoft.CostManagement/costAllocationRules"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/100/providers/Microsoft.CostManagement/costAllocationRules/testRule"), + // Properties: &armcostmanagement.CostAllocationRuleProperties{ + // Description: to.Ptr("This is a testRule"), + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.1287144Z"); return t}()), + // Status: to.Ptr(armcostmanagement.RuleStatusNotActive), + // UpdatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.1287144Z"); return t}()), + // Details: &armcostmanagement.CostAllocationRuleDetails{ + // SourceResources: []*armcostmanagement.SourceCostAllocationResource{ + // { + // Name: to.Ptr("ResourceGroupName"), + // ResourceType: to.Ptr(armcostmanagement.CostAllocationResourceTypeDimension), + // Values: []*string{ + // to.Ptr("sampleRG"), + // }, + // }, + // }, + // TargetResources: []*armcostmanagement.TargetCostAllocationResource{ + // { + // Name: to.Ptr("ResourceGroupName"), + // PolicyType: to.Ptr(armcostmanagement.CostAllocationPolicyTypeFixedProportion), + // ResourceType: to.Ptr(armcostmanagement.CostAllocationResourceTypeDimension), + // Values: []*armcostmanagement.CostAllocationProportion{ + // { + // Name: to.Ptr("destinationRG"), + // Percentage: to.Ptr[float32](50), + // }, + // { + // Name: to.Ptr("destinationRG2"), + // Percentage: to.Ptr[float32](50), + // }, + // }, + // }, + // }, + // }, + // }, + // }, + // { + // Name: to.Ptr("testRule2"), + // Type: to.Ptr("Microsoft.CostManagement/costAllocationRules"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/100/providers/Microsoft.CostManagement/costAllocationRules/testRule2"), + // Properties: &armcostmanagement.CostAllocationRuleProperties{ + // Description: to.Ptr("This is a second test Rule"), + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.1287144Z"); return t}()), + // Status: to.Ptr(armcostmanagement.RuleStatusActive), + // UpdatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.1287144Z"); return t}()), + // Details: &armcostmanagement.CostAllocationRuleDetails{ + // SourceResources: []*armcostmanagement.SourceCostAllocationResource{ + // { + // Name: to.Ptr("SubscriptionId"), + // ResourceType: to.Ptr(armcostmanagement.CostAllocationResourceTypeDimension), + // Values: []*string{ + // to.Ptr("2A002F2D-536F-4D7C-90DA-3D0BAE879B0E"), + // }, + // }, + // }, + // TargetResources: []*armcostmanagement.TargetCostAllocationResource{ + // { + // Name: to.Ptr("category"), + // PolicyType: to.Ptr(armcostmanagement.CostAllocationPolicyTypeFixedProportion), + // ResourceType: to.Ptr(armcostmanagement.CostAllocationResourceTypeTag), + // Values: []*armcostmanagement.CostAllocationProportion{ + // { + // Name: to.Ptr("devops"), + // Percentage: to.Ptr[float32](100), + // }, + // }, + // }, + // }, + // }, + // }, + // }, + // { + // Name: to.Ptr("testRule3"), + // Type: to.Ptr("Microsoft.CostManagement/costAllocationRules"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/100/providers/Microsoft.CostManagement/costAllocationRules/testRule3"), + // Properties: &armcostmanagement.CostAllocationRuleProperties{ + // Description: to.Ptr("This is a third test Rule"), + // CreatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.1287144Z"); return t}()), + // Status: to.Ptr(armcostmanagement.RuleStatusActive), + // UpdatedDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.1287144Z"); return t}()), + // Details: &armcostmanagement.CostAllocationRuleDetails{ + // SourceResources: []*armcostmanagement.SourceCostAllocationResource{ + // { + // Name: to.Ptr("category"), + // ResourceType: to.Ptr(armcostmanagement.CostAllocationResourceTypeTag), + // Values: []*string{ + // to.Ptr("devops"), + // }, + // }, + // }, + // TargetResources: []*armcostmanagement.TargetCostAllocationResource{ + // { + // Name: to.Ptr("ResourceGroupName"), + // PolicyType: to.Ptr(armcostmanagement.CostAllocationPolicyTypeFixedProportion), + // ResourceType: to.Ptr(armcostmanagement.CostAllocationResourceTypeDimension), + // Values: []*armcostmanagement.CostAllocationProportion{ + // { + // Name: to.Ptr("ResourceGroup"), + // Percentage: to.Ptr[float32](55.55), + // }, + // { + // Name: to.Ptr("ResourceGroupSecond"), + // Percentage: to.Ptr[float32](44.45), + // }, + // }, + // }, + // }, + // }, + // }, + // }, + // }, + // }, + // } + } +} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/dimensions_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/dimensions_client.go index 06c2c0e4a7da..120807cbca9f 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/dimensions_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/dimensions_client.go @@ -1,7 +1,6 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armcostmanagement @@ -26,7 +25,7 @@ type DimensionsClient struct { // NewDimensionsClient creates a new instance of DimensionsClient with the specified values. // - credential - used to authorize requests. Usually a credential from azidentity. -// - options - pass nil to accept the default values. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewDimensionsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*DimensionsClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -40,7 +39,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 2025-03-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 @@ -50,21 +49,20 @@ func NewDimensionsClient(credential azcore.TokenCredential, options *arm.ClientO func (client *DimensionsClient) NewByExternalCloudProviderTypePager(externalCloudProviderType ExternalCloudProviderType, externalCloudProviderID string, options *DimensionsClientByExternalCloudProviderTypeOptions) *runtime.Pager[DimensionsClientByExternalCloudProviderTypeResponse] { return runtime.NewPager(runtime.PagingHandler[DimensionsClientByExternalCloudProviderTypeResponse]{ More: func(page DimensionsClientByExternalCloudProviderTypeResponse) bool { - return false + return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *DimensionsClientByExternalCloudProviderTypeResponse) (DimensionsClientByExternalCloudProviderTypeResponse, error) { ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "DimensionsClient.NewByExternalCloudProviderTypePager") - req, err := client.byExternalCloudProviderTypeCreateRequest(ctx, externalCloudProviderType, externalCloudProviderID, options) - if err != nil { - return DimensionsClientByExternalCloudProviderTypeResponse{}, err + nextLink := "" + if page != nil { + nextLink = *page.NextLink } - resp, err := client.internal.Pipeline().Do(req) + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.byExternalCloudProviderTypeCreateRequest(ctx, externalCloudProviderType, externalCloudProviderID, options) + }, nil) if err != nil { return DimensionsClientByExternalCloudProviderTypeResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DimensionsClientByExternalCloudProviderTypeResponse{}, runtime.NewResponseError(resp) - } return client.byExternalCloudProviderTypeHandleResponse(resp) }, Tracer: client.internal.Tracer(), @@ -87,19 +85,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", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -116,36 +114,34 @@ func (client *DimensionsClient) byExternalCloudProviderTypeHandleResponse(resp * // NewListPager - Lists the dimensions by the defined scope. // -// Generated from API version 2022-10-01 +// Generated from API version 2025-03-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, -// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope, -// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount -// scope, -// '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' -// for billingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' -// for invoiceSection scope, and -// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for partners. +// 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.Management/managementGroups/{managementGroupId}' for Management Group +// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile +// scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' +// for invoiceSection scope, and 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific +// for partners. // - options - DimensionsClientListOptions contains the optional parameters for the DimensionsClient.NewListPager method. func (client *DimensionsClient) NewListPager(scope string, options *DimensionsClientListOptions) *runtime.Pager[DimensionsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[DimensionsClientListResponse]{ More: func(page DimensionsClientListResponse) bool { - return false + return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *DimensionsClientListResponse) (DimensionsClientListResponse, error) { ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "DimensionsClient.NewListPager") - req, err := client.listCreateRequest(ctx, scope, options) - if err != nil { - return DimensionsClientListResponse{}, err + nextLink := "" + if page != nil { + nextLink = *page.NextLink } - resp, err := client.internal.Pipeline().Do(req) + 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 DimensionsClientListResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DimensionsClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, Tracer: client.internal.Tracer(), @@ -155,25 +151,28 @@ func (client *DimensionsClient) NewListPager(scope string, options *DimensionsCl // listCreateRequest creates the List request. func (client *DimensionsClient) listCreateRequest(ctx context.Context, scope string, options *DimensionsClientListOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.CostManagement/dimensions" + if scope == "" { + return nil, errors.New("parameter scope cannot be empty") + } 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() - 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", "2025-03-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 index 4219b1bdbca3..dd7d6e518885 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/dimensions_client_example_test.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/dimensions_client_example_test.go @@ -1,22 +1,19 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. 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" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v3" + "log" ) -// Generated from 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() { +// Generated from example definition: 2025-03-01/ExternalBillingAccountsDimensions.json +func ExampleDimensionsClient_NewByExternalCloudProviderTypePager_externalBillingAccountDimensionList() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -26,11 +23,7 @@ func ExampleDimensionsClient_NewListPager_billingAccountDimensionsListLegacy() { 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, - }) + pager := clientFactory.NewDimensionsClient().NewByExternalCloudProviderTypePager(armcostmanagement.ExternalCloudProviderTypeExternalBillingAccounts, "100", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -41,32 +34,86 @@ func ExampleDimensionsClient_NewListPager_billingAccountDimensionsListLegacy() { _ = 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")}, + // page = armcostmanagement.DimensionsClientByExternalCloudProviderTypeResponse{ + // 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](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}()), + // Total: to.Ptr[int32](0), + // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-12-31T00:00:00Z"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-12-01T00:00:00Z"); 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"), + // 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:00Z"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-12-01T00:00:00Z"); return t}()), + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2025-03-01/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", 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 = armcostmanagement.DimensionsClientByExternalCloudProviderTypeResponse{ + // 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"), @@ -75,20 +122,44 @@ func ExampleDimensionsClient_NewListPager_billingAccountDimensionsListLegacy() { // 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}()), + // 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:00Z"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-12-01T00:00:00Z"); 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:00Z"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-12-01T00:00:00Z"); 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() { +// Generated from example definition: 2025-03-01/BillingAccountDimensionsList.json +func ExampleDimensionsClient_NewListPager_billingAccountDimensionsListLegacy() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -98,11 +169,7 @@ func ExampleDimensionsClient_NewListPager_billingAccountDimensionsListMca() { 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, - }) + pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/100", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -113,45 +180,58 @@ func ExampleDimensionsClient_NewListPager_billingAccountDimensionsListMca() { _ = 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{ + // page = armcostmanagement.DimensionsClientListResponse{ + // 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-31T00:00:00-07:00"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T00:00:00-07:00"); return t}()), // }, - // 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{ + // { + // 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-31T00:00:00-07:00"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T00:00:00-07:00"); return t}()), // }, - // 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 +// Generated from example definition: 2025-03-01/BillingAccountDimensionsListExpandAndTop.json func ExampleDimensionsClient_NewListPager_billingAccountDimensionsListExpandAndTopLegacy() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -162,11 +242,9 @@ func ExampleDimensionsClient_NewListPager_billingAccountDimensionsListExpandAndT 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), - }) + pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/100", &armcostmanagement.DimensionsClientListOptions{ + Expand: to.Ptr("properties/data"), + Top: to.Ptr[int32](5)}) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -177,32 +255,34 @@ func ExampleDimensionsClient_NewListPager_billingAccountDimensionsListExpandAndT _ = 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")}, + // page = armcostmanagement.DimensionsClientListResponse{ + // 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}()), + // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-31T00:00:00-07:00"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T00:00:00-07:00"); 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"), + // 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"), @@ -211,20 +291,79 @@ func ExampleDimensionsClient_NewListPager_billingAccountDimensionsListExpandAndT // 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}()), + // 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-31T00:00:00-07:00"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T00:00:00-07:00"); 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() { +// Generated from example definition: 2025-03-01/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{ + Expand: to.Ptr("properties/data"), + Filter: to.Ptr("properties/category eq 'resourceId'"), + 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 = armcostmanagement.DimensionsClientListResponse{ + // 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), + // NextLink: to.Ptr("http://management.azure.com/providers/Microsoft.Billing/billingAccounts/100/providers/Microsoft.CostManagement/Dimensions?$filter=properties/category eq 'resourceId'&$top=5&api-version=2019-10-01&$expand=properties/data&$skiptoken=AQAAAA%3D%3D"), + // Total: to.Ptr[int32](1409), + // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-31T00:00:00-07:00"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T00:00:00-07:00"); return t}()), + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2025-03-01/DepartmentDimensionsList.json +func ExampleDimensionsClient_NewListPager_departmentDimensionsListLegacy() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -234,11 +373,7 @@ func ExampleDimensionsClient_NewListPager_billingAccountDimensionsListExpandAndT 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), - }) + pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/100/departments/123", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -249,54 +384,59 @@ func ExampleDimensionsClient_NewListPager_billingAccountDimensionsListExpandAndT _ = 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")}, + // page = armcostmanagement.DimensionsClientListResponse{ + // 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, "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}()), + // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-31T00:00:00-07:00"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T00:00:00-07:00"); return t}()), // }, // }, // { - // Name: to.Ptr("dimensions_ResourceType_2019-10-01_2019-10-31"), + // Name: to.Ptr("dimensions_ResourceType_2018-05-01_2018-05-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"), + // 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("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}()), + // 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-31T00:00:00-07:00"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T00:00:00-07:00"); 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() { +// Generated from example definition: 2025-03-01/DepartmentDimensionsListExpandAndTop.json +func ExampleDimensionsClient_NewListPager_departmentDimensionsListExpandAndTopLegacy() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -306,11 +446,9 @@ func ExampleDimensionsClient_NewListPager_billingAccountDimensionsListWithFilter 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), - }) + pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/100/departments/123", &armcostmanagement.DimensionsClientListOptions{ + Expand: to.Ptr("properties/data"), + Top: to.Ptr[int32](5)}) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -321,34 +459,59 @@ func ExampleDimensionsClient_NewListPager_billingAccountDimensionsListWithFilter _ = 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")}, + // page = armcostmanagement.DimensionsClientListResponse{ + // 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](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}()), + // Total: to.Ptr[int32](377), + // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-31T00:00:00-07:00"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T00:00:00-07:00"); 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-31T00:00:00-07:00"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T00:00:00-07:00"); 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() { +// Generated from example definition: 2025-03-01/DepartmentDimensionsListWithFilter.json +func ExampleDimensionsClient_NewListPager_departmentDimensionsListWithFilterLegacy() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -358,11 +521,10 @@ func ExampleDimensionsClient_NewListPager_billingAccountDimensionsListWithFilter 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), - }) + pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/100/departments/123", &armcostmanagement.DimensionsClientListOptions{ + Expand: to.Ptr("properties/data"), + Filter: to.Ptr("properties/category eq 'resourceId'"), + Top: to.Ptr[int32](5)}) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -373,34 +535,39 @@ func ExampleDimensionsClient_NewListPager_billingAccountDimensionsListWithFilter _ = 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")}, + // page = armcostmanagement.DimensionsClientListResponse{ + // 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), + // NextLink: to.Ptr("https://management.azure.com/providers/Microsoft.Billing/billingAccounts/100/departments/123/providers/Microsoft.CostManagement/Dimensions?$filter=properties/category eq 'resourceId'&$top=5&api-version=2019-10-01&$expand=properties/data&$skiptoken=AQAAAA%3D%3D"), // 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}()), + // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-31T00:00:00-07:00"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T00:00:00-07:00"); 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() { +// Generated from example definition: 2025-03-01/EnrollmentAccountDimensionsList.json +func ExampleDimensionsClient_NewListPager_enrollmentAccountDimensionsListLegacy() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -410,11 +577,7 @@ func ExampleDimensionsClient_NewListPager_billingProfileDimensionsListMca() { 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, - }) + pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -425,46 +588,49 @@ func ExampleDimensionsClient_NewListPager_billingProfileDimensionsListMca() { _ = 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{ + // page = armcostmanagement.DimensionsClientListResponse{ + // 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-31T00:00:00-07:00"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T00:00:00-07:00"); return t}()), // }, - // 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{ + // { + // 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-31T00:00:00-07:00"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T00:00:00-07:00"); return t}()), // }, - // 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() { +// Generated from example definition: 2025-03-01/EnrollmentAccountDimensionsListExpandAndTop.json +func ExampleDimensionsClient_NewListPager_enrollmentAccountDimensionsListExpandAndTopLegacy() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -474,11 +640,9 @@ func ExampleDimensionsClient_NewListPager_billingProfileDimensionsListExpandAndT 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), - }) + pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456", &armcostmanagement.DimensionsClientListOptions{ + Expand: to.Ptr("properties/data"), + Top: to.Ptr[int32](5)}) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -489,32 +653,34 @@ func ExampleDimensionsClient_NewListPager_billingProfileDimensionsListExpandAndT _ = 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")}, + // page = armcostmanagement.DimensionsClientListResponse{ + // 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, "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}()), + // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-31T00:00:00-07:00"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T00:00:00-07:00"); return t}()), // }, // }, // { - // Name: to.Ptr("dimensions_ResourceType_2019-10-01_2019-10-31"), + // 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/12345:6789/billingProfiles/13579/providers/microsoft.CostManagement/dimensions_ResourceType_2019-10-01_2019-10-31"), + // 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"), @@ -523,20 +689,23 @@ func ExampleDimensionsClient_NewListPager_billingProfileDimensionsListExpandAndT // 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}()), + // 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-31T00:00:00-07:00"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T00:00:00-07:00"); 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() { +// Generated from example definition: 2025-03-01/EnrollmentAccountDimensionsListWithFilter.json +func ExampleDimensionsClient_NewListPager_enrollmentAccountDimensionsListWithFilterLegacy() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -546,11 +715,10 @@ func ExampleDimensionsClient_NewListPager_billingProfileDimensionsListWithFilter 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), - }) + pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456", &armcostmanagement.DimensionsClientListOptions{ + Expand: to.Ptr("properties/data"), + Filter: to.Ptr("properties/category eq 'resourceId'"), + Top: to.Ptr[int32](5)}) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -561,34 +729,39 @@ func ExampleDimensionsClient_NewListPager_billingProfileDimensionsListWithFilter _ = 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")}, + // page = armcostmanagement.DimensionsClientListResponse{ + // 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), + // NextLink: to.Ptr("https://management.azure.com/providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456/providers/Microsoft.CostManagement/Dimensions?$filter=properties/category eq 'resourceId'&$top=5&api-version=2019-10-01&$expand=properties/data&$skiptoken=AQAAAA%3D%3D"), // 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}()), + // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-31T00:00:00-07:00"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T00:00:00-07:00"); 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() { +// Generated from example definition: 2025-03-01/MCABillingAccountDimensionsList.json +func ExampleDimensionsClient_NewListPager_billingAccountDimensionsListMca() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -598,11 +771,7 @@ func ExampleDimensionsClient_NewListPager_customerDimensionsListMca() { 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, - }) + pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345:6789", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -613,46 +782,49 @@ func ExampleDimensionsClient_NewListPager_customerDimensionsListMca() { _ = 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{ + // page = armcostmanagement.DimensionsClientListResponse{ + // 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-31T00:00:00-07:00"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-01T00:00:00-07:00"); return t}()), // }, - // 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{ + // { + // 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-31T00:00:00-07:00"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-01T00:00:00-07:00"); return t}()), // }, - // 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() { +// Generated from example definition: 2025-03-01/MCABillingAccountDimensionsListExpandAndTop.json +func ExampleDimensionsClient_NewListPager_billingAccountDimensionsListExpandAndTopMca() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -662,11 +834,9 @@ func ExampleDimensionsClient_NewListPager_customerDimensionsListExpandAndTopMca( 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), - }) + pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345:6789", &armcostmanagement.DimensionsClientListOptions{ + Expand: to.Ptr("properties/data"), + Top: to.Ptr[int32](5)}) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -677,32 +847,34 @@ func ExampleDimensionsClient_NewListPager_customerDimensionsListExpandAndTopMca( _ = 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")}, + // page = armcostmanagement.DimensionsClientListResponse{ + // 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}()), + // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-31T00:00:00-07:00"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-01T00:00:00-07:00"); 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"), + // 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"), @@ -711,20 +883,23 @@ func ExampleDimensionsClient_NewListPager_customerDimensionsListExpandAndTopMca( // 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}()), + // 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-31T00:00:00-07:00"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-01T00:00:00-07:00"); 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() { +// Generated from example definition: 2025-03-01/MCABillingAccountDimensionsListWithFilter.json +func ExampleDimensionsClient_NewListPager_billingAccountDimensionsListWithFilterMca() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -734,11 +909,10 @@ func ExampleDimensionsClient_NewListPager_customerDimensionsListWithFilterMca() 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), - }) + pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345:6789", &armcostmanagement.DimensionsClientListOptions{ + Expand: to.Ptr("properties/data"), + Filter: to.Ptr("properties/category eq 'resourceId'"), + Top: to.Ptr[int32](5)}) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -749,34 +923,39 @@ func ExampleDimensionsClient_NewListPager_customerDimensionsListWithFilterMca() _ = 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")}, + // page = armcostmanagement.DimensionsClientListResponse{ + // 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), + // NextLink: to.Ptr("http://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/providers/Microsoft.CostManagement/Dimensions?$filter=properties/category eq 'resourceId'&$top=5&api-version=2019-10-01&$expand=properties/data&$skiptoken=AQAAAA%3D%3D"), // 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}()), + // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-31T00:00:00-07:00"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-01T00:00:00-07:00"); 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() { +// Generated from example definition: 2025-03-01/MCABillingProfileDimensionsList.json +func ExampleDimensionsClient_NewListPager_billingProfileDimensionsListMca() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -786,11 +965,7 @@ func ExampleDimensionsClient_NewListPager_departmentDimensionsListLegacy() { 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, - }) + pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -801,54 +976,49 @@ func ExampleDimensionsClient_NewListPager_departmentDimensionsListLegacy() { _ = 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")}, + // page = armcostmanagement.DimensionsClientListResponse{ + // 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, "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}()), + // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-31T00:00:00-07:00"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-01T00:00:00-07:00"); return t}()), // }, // }, // { - // Name: to.Ptr("dimensions_ResourceType_2018-05-01_2018-05-31"), + // Name: to.Ptr("dimensions_ResourceType_2019-10-01_2019-10-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"), + // 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("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}()), // }, - // }}, - // } + // 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-31T00:00:00-07:00"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-01T00:00:00-07:00"); 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() { +// Generated from example definition: 2025-03-01/MCABillingProfileDimensionsListExpandAndTop.json +func ExampleDimensionsClient_NewListPager_billingProfileDimensionsListExpandAndTopMca() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -858,11 +1028,9 @@ func ExampleDimensionsClient_NewListPager_departmentDimensionsListExpandAndTopLe 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), - }) + pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579", &armcostmanagement.DimensionsClientListOptions{ + Expand: to.Ptr("properties/data"), + Top: to.Ptr[int32](5)}) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -873,32 +1041,34 @@ func ExampleDimensionsClient_NewListPager_departmentDimensionsListExpandAndTopLe _ = 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")}, + // page = armcostmanagement.DimensionsClientListResponse{ + // 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, "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}()), + // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-31T00:00:00-07:00"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-01T00:00:00-07:00"); return t}()), // }, // }, // { - // Name: to.Ptr("dimensions_ResourceType_2018-05-01_2018-05-31_5"), + // Name: to.Ptr("dimensions_ResourceType_2019-10-01_2019-10-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_5"), + // 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"), @@ -907,20 +1077,23 @@ func ExampleDimensionsClient_NewListPager_departmentDimensionsListExpandAndTopLe // 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}()), + // 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-31T00:00:00-07:00"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-01T00:00:00-07:00"); 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() { +// Generated from example definition: 2025-03-01/MCABillingProfileDimensionsListWithFilter.json +func ExampleDimensionsClient_NewListPager_billingProfileDimensionsListWithFilterMca() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -930,11 +1103,10 @@ func ExampleDimensionsClient_NewListPager_departmentDimensionsListWithFilterLega 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), - }) + pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579", &armcostmanagement.DimensionsClientListOptions{ + Expand: to.Ptr("properties/data"), + Filter: to.Ptr("properties/category eq 'resourceId'"), + Top: to.Ptr[int32](5)}) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -945,34 +1117,39 @@ func ExampleDimensionsClient_NewListPager_departmentDimensionsListWithFilterLega _ = 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")}, + // page = armcostmanagement.DimensionsClientListResponse{ + // 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), + // NextLink: to.Ptr("http://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/providers/Microsoft.CostManagement/Dimensions?$filter=properties/category eq 'resourceId'&$top=5&api-version=2019-10-01&$expand=properties/data&$skiptoken=AQAAAA%3D%3D"), // 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}()), + // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-31T00:00:00-07:00"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-01T00:00:00-07:00"); 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() { +// Generated from example definition: 2025-03-01/MCACustomerDimensionsList.json +func ExampleDimensionsClient_NewListPager_customerDimensionsListMca() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -982,11 +1159,7 @@ func ExampleDimensionsClient_NewListPager_enrollmentAccountDimensionsListLegacy( 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, - }) + pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -997,46 +1170,49 @@ func ExampleDimensionsClient_NewListPager_enrollmentAccountDimensionsListLegacy( _ = 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{ + // page = armcostmanagement.DimensionsClientListResponse{ + // 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-31T00:00:00-07:00"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-01T00:00:00-07:00"); return t}()), // }, - // 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{ + // { + // 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-31T00:00:00-07:00"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-01T00:00:00-07:00"); return t}()), // }, - // 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() { +// Generated from example definition: 2025-03-01/MCACustomerDimensionsListExpandAndTop.json +func ExampleDimensionsClient_NewListPager_customerDimensionsListExpandAndTopMca() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -1046,11 +1222,9 @@ func ExampleDimensionsClient_NewListPager_enrollmentAccountDimensionsListExpandA 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), - }) + pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678", &armcostmanagement.DimensionsClientListOptions{ + Expand: to.Ptr("properties/data"), + Top: to.Ptr[int32](5)}) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -1061,32 +1235,34 @@ func ExampleDimensionsClient_NewListPager_enrollmentAccountDimensionsListExpandA _ = 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")}, + // page = armcostmanagement.DimensionsClientListResponse{ + // 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, "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}()), + // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-31T00:00:00-07:00"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-01T00:00:00-07:00"); return t}()), // }, // }, // { - // Name: to.Ptr("dimensions_ResourceType_2018-05-01_2018-05-31_5"), + // Name: to.Ptr("dimensions_ResourceType_2019-10-01_2019-10-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_5"), + // 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"), @@ -1095,20 +1271,23 @@ func ExampleDimensionsClient_NewListPager_enrollmentAccountDimensionsListExpandA // 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}()), + // 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-31T00:00:00-07:00"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-01T00:00:00-07:00"); 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() { +// Generated from example definition: 2025-03-01/MCACustomerDimensionsListWithFilter.json +func ExampleDimensionsClient_NewListPager_customerDimensionsListWithFilterMca() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -1118,11 +1297,10 @@ func ExampleDimensionsClient_NewListPager_enrollmentAccountDimensionsListWithFil 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), - }) + pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678", &armcostmanagement.DimensionsClientListOptions{ + Expand: to.Ptr("properties/data"), + Filter: to.Ptr("properties/category eq 'resourceId'"), + Top: to.Ptr[int32](5)}) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -1133,33 +1311,38 @@ func ExampleDimensionsClient_NewListPager_enrollmentAccountDimensionsListWithFil _ = 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")}, + // page = armcostmanagement.DimensionsClientListResponse{ + // 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), + // NextLink: to.Ptr("http://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678/providers/Microsoft.CostManagement/Dimensions?$filter=properties/category eq 'resourceId'&$top=5&api-version=2019-10-01&$expand=properties/data&$skiptoken=AQAAAA%3D%3D"), // 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}()), + // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-31T00:00:00-07:00"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-01T00:00:00-07:00"); 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 +// Generated from example definition: 2025-03-01/MCAInvoiceSectionDimensionsList.json func ExampleDimensionsClient_NewListPager_invoiceSectionDimensionsListMca() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -1170,11 +1353,7 @@ func ExampleDimensionsClient_NewListPager_invoiceSectionDimensionsListMca() { 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, - }) + pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -1185,45 +1364,48 @@ func ExampleDimensionsClient_NewListPager_invoiceSectionDimensionsListMca() { _ = 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{ + // page = armcostmanagement.DimensionsClientListResponse{ + // 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-31T00:00:00-07:00"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-01T00:00:00-07:00"); return t}()), // }, - // 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{ + // { + // 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-31T00:00:00-07:00"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-01T00:00:00-07:00"); return t}()), // }, - // 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 +// Generated from example definition: 2025-03-01/MCAInvoiceSectionDimensionsListExpandAndTop.json func ExampleDimensionsClient_NewListPager_invoiceSectionDimensionsListExpandAndTopMca() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -1234,11 +1416,9 @@ func ExampleDimensionsClient_NewListPager_invoiceSectionDimensionsListExpandAndT 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), - }) + pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876", &armcostmanagement.DimensionsClientListOptions{ + Expand: to.Ptr("properties/data"), + Top: to.Ptr[int32](5)}) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -1249,32 +1429,34 @@ func ExampleDimensionsClient_NewListPager_invoiceSectionDimensionsListExpandAndT _ = 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")}, + // page = armcostmanagement.DimensionsClientListResponse{ + // 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}()), + // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-31T00:00:00-07:00"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-01T00:00:00-07:00"); 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"), + // 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"), @@ -1283,19 +1465,22 @@ func ExampleDimensionsClient_NewListPager_invoiceSectionDimensionsListExpandAndT // 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}()), + // 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-31T00:00:00-07:00"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-01T00:00:00-07:00"); 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 +// Generated from example definition: 2025-03-01/MCAInvoiceSectionDimensionsListWithFilter.json func ExampleDimensionsClient_NewListPager_invoiceSectionDimensionsListWithFilterMca() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -1306,11 +1491,10 @@ func ExampleDimensionsClient_NewListPager_invoiceSectionDimensionsListWithFilter 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), - }) + pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876", &armcostmanagement.DimensionsClientListOptions{ + Expand: to.Ptr("properties/data"), + Filter: to.Ptr("properties/category eq 'resourceId'"), + Top: to.Ptr[int32](5)}) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -1321,33 +1505,38 @@ func ExampleDimensionsClient_NewListPager_invoiceSectionDimensionsListWithFilter _ = 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")}, + // page = armcostmanagement.DimensionsClientListResponse{ + // 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), + // NextLink: to.Ptr("http://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876/providers/Microsoft.CostManagement/Dimensions?$filter=properties/category eq 'resourceId'&$top=5&api-version=2019-10-01&$expand=properties/data&$skiptoken=AQAAAA%3D%3D"), // 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}()), + // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-31T00:00:00-07:00"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-01T00:00:00-07:00"); 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 +// Generated from example definition: 2025-03-01/ManagementGroupDimensionsList.json func ExampleDimensionsClient_NewListPager_managementGroupDimensionsListLegacy() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -1358,11 +1547,7 @@ func ExampleDimensionsClient_NewListPager_managementGroupDimensionsListLegacy() 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, - }) + pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Management/managementGroups/MyMgId", nil) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -1373,45 +1558,48 @@ func ExampleDimensionsClient_NewListPager_managementGroupDimensionsListLegacy() _ = 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{ + // page = armcostmanagement.DimensionsClientListResponse{ + // 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-31T00:00:00-07:00"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T00:00:00-07:00"); return t}()), // }, - // 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{ + // { + // 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-31T00:00:00-07:00"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T00:00:00-07:00"); return t}()), // }, - // 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 +// Generated from example definition: 2025-03-01/ManagementGroupDimensionsListExpandAndTop.json func ExampleDimensionsClient_NewListPager_managementGroupDimensionsListExpandAndTopLegacy() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -1422,11 +1610,9 @@ func ExampleDimensionsClient_NewListPager_managementGroupDimensionsListExpandAnd 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), - }) + pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Management/managementGroups/MyMgId", &armcostmanagement.DimensionsClientListOptions{ + Expand: to.Ptr("properties/data"), + Top: to.Ptr[int32](5)}) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -1437,32 +1623,34 @@ func ExampleDimensionsClient_NewListPager_managementGroupDimensionsListExpandAnd _ = 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")}, + // page = armcostmanagement.DimensionsClientListResponse{ + // 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}()), + // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-31T00:00:00-07:00"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T00:00:00-07:00"); 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"), + // 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"), @@ -1471,19 +1659,22 @@ func ExampleDimensionsClient_NewListPager_managementGroupDimensionsListExpandAnd // 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}()), + // 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-31T00:00:00-07:00"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T00:00:00-07:00"); 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 +// Generated from example definition: 2025-03-01/ManagementGroupDimensionsListWithFilter.json func ExampleDimensionsClient_NewListPager_managementGroupDimensionsListWithFilterLegacy() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -1494,11 +1685,10 @@ func ExampleDimensionsClient_NewListPager_managementGroupDimensionsListWithFilte 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), - }) + pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Management/managementGroups/MyMgId", &armcostmanagement.DimensionsClientListOptions{ + Expand: to.Ptr("properties/data"), + Filter: to.Ptr("properties/category eq 'resourceId'"), + Top: to.Ptr[int32](5)}) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -1509,33 +1699,38 @@ func ExampleDimensionsClient_NewListPager_managementGroupDimensionsListWithFilte _ = 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")}, + // page = armcostmanagement.DimensionsClientListResponse{ + // 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), + // NextLink: to.Ptr("http://management.azure.com/providers/Microsoft.Management/managementGroups/MyMgId/providers/Microsoft.CostManagement/Dimensions?$filter=properties/category eq 'resourceId'&$top=5&api-version=2019-10-01&$expand=properties/data&$skiptoken=AQAAAA%3D%3D"), // 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}()), + // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-31T00:00:00-07:00"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T00:00:00-07:00"); 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 +// Generated from example definition: 2025-03-01/ResourceGroupDimensionsList.json func ExampleDimensionsClient_NewListPager_resourceGroupDimensionsListLegacy() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -1546,11 +1741,9 @@ func ExampleDimensionsClient_NewListPager_resourceGroupDimensionsListLegacy() { 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), - }) + pager := clientFactory.NewDimensionsClient().NewListPager("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/system.orlando", &armcostmanagement.DimensionsClientListOptions{ + Expand: to.Ptr("properties/data"), + Top: to.Ptr[int32](5)}) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -1561,28 +1754,30 @@ func ExampleDimensionsClient_NewListPager_resourceGroupDimensionsListLegacy() { _ = 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")}, + // page = armcostmanagement.DimensionsClientListResponse{ + // 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}()), + // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-31T00:00:00-07:00"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T00:00:00-07:00"); 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"), + // 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"), @@ -1591,19 +1786,22 @@ func ExampleDimensionsClient_NewListPager_resourceGroupDimensionsListLegacy() { // 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}()), + // 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-31T00:00:00-07:00"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T00:00:00-07:00"); 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 +// Generated from example definition: 2025-03-01/SubscriptionDimensionsList.json func ExampleDimensionsClient_NewListPager_subscriptionDimensionsListLegacy() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -1614,11 +1812,9 @@ func ExampleDimensionsClient_NewListPager_subscriptionDimensionsListLegacy() { 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), - }) + pager := clientFactory.NewDimensionsClient().NewListPager("subscriptions/00000000-0000-0000-0000-000000000000", &armcostmanagement.DimensionsClientListOptions{ + Expand: to.Ptr("properties/data"), + Top: to.Ptr[int32](5)}) for pager.More() { page, err := pager.NextPage(ctx) if err != nil { @@ -1629,32 +1825,34 @@ func ExampleDimensionsClient_NewListPager_subscriptionDimensionsListLegacy() { _ = 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")}, + // page = armcostmanagement.DimensionsClientListResponse{ + // 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}()), + // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-31T00:00:00-07:00"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T00:00:00-07:00"); 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"), + // 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"), @@ -1662,158 +1860,17 @@ func ExampleDimensionsClient_NewListPager_subscriptionDimensionsListLegacy() { // 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}()), + // to.Ptr("microsoft.compute/virtualmachines"), // }, - // }}, - // } - } -} - -// Generated from 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}()), + // Total: to.Ptr[int32](4), + // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-31T00:00:00-07:00"); return t}()), + // UsageStart: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-01T00:00:00-07:00"); 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 b91cf6643e89..ef4e6cd92297 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/exports_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/exports_client.go @@ -1,7 +1,6 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armcostmanagement @@ -25,7 +24,7 @@ type ExportsClient struct { // NewExportsClient creates a new instance of ExportsClient with the specified values. // - credential - used to authorize requests. Usually a credential from azidentity. -// - options - pass nil to accept the default values. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewExportsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*ExportsClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -38,21 +37,11 @@ func NewExportsClient(credential azcore.TokenCredential, options *arm.ClientOpti } // CreateOrUpdate - The operation to create or update a export. Update operation requires latest eTag to be set in the request. -// You may obtain the latest eTag by performing a get operation. Create operation does not -// require eTag. +// You may obtain the latest eTag by performing a get operation. Create operation does not require eTag. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-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 -// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope, -// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount -// scope, -// '/providers/Microsoft.Management/managementGroups/{managementGroupId} for Management Group scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' -// for billingProfile scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' -// for invoiceSection scope, and -// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for partners. +// Generated from API version 2025-03-01 +// - scope - The fully qualified Azure Resource manager identifier of the resource. // - exportName - Export Name. // - parameters - Parameters supplied to the CreateOrUpdate Export operation. // - options - ExportsClientCreateOrUpdateOptions contains the optional parameters for the ExportsClient.CreateOrUpdate method. @@ -79,8 +68,11 @@ func (client *ExportsClient) CreateOrUpdate(ctx context.Context, scope string, e } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *ExportsClient) createOrUpdateCreateRequest(ctx context.Context, scope string, exportName string, parameters Export, options *ExportsClientCreateOrUpdateOptions) (*policy.Request, error) { +func (client *ExportsClient) createOrUpdateCreateRequest(ctx context.Context, scope string, exportName string, parameters Export, _ *ExportsClientCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.CostManagement/exports/{exportName}" + if scope == "" { + return nil, errors.New("parameter scope cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) if exportName == "" { return nil, errors.New("parameter exportName cannot be empty") @@ -91,9 +83,10 @@ 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", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -112,17 +105,8 @@ 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 -// - 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 -// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope, -// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount -// scope, -// '/providers/Microsoft.Management/managementGroups/{managementGroupId} for Management Group scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' -// for billingProfile scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' -// for invoiceSection scope, and -// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for partners. +// Generated from API version 2025-03-01 +// - scope - The fully qualified Azure Resource manager identifier of the resource. // - exportName - Export Name. // - options - ExportsClientDeleteOptions contains the optional parameters for the ExportsClient.Delete method. func (client *ExportsClient) Delete(ctx context.Context, scope string, exportName string, options *ExportsClientDeleteOptions) (ExportsClientDeleteResponse, error) { @@ -147,8 +131,11 @@ func (client *ExportsClient) Delete(ctx context.Context, scope string, exportNam } // deleteCreateRequest creates the Delete request. -func (client *ExportsClient) deleteCreateRequest(ctx context.Context, scope string, exportName string, options *ExportsClientDeleteOptions) (*policy.Request, error) { +func (client *ExportsClient) deleteCreateRequest(ctx context.Context, scope string, exportName string, _ *ExportsClientDeleteOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.CostManagement/exports/{exportName}" + if scope == "" { + return nil, errors.New("parameter scope cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) if exportName == "" { return nil, errors.New("parameter exportName cannot be empty") @@ -159,26 +146,16 @@ 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", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } // Execute - The operation to run an export. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-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 -// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope, -// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount -// scope, -// '/providers/Microsoft.Management/managementGroups/{managementGroupId} for Management Group scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' -// for billingProfile scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' -// for invoiceSection scope, and -// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for partners. +// Generated from API version 2025-03-01 +// - scope - The fully qualified Azure Resource manager identifier of the resource. // - exportName - Export Name. // - options - ExportsClientExecuteOptions contains the optional parameters for the ExportsClient.Execute method. func (client *ExportsClient) Execute(ctx context.Context, scope string, exportName string, options *ExportsClientExecuteOptions) (ExportsClientExecuteResponse, error) { @@ -205,6 +182,9 @@ func (client *ExportsClient) Execute(ctx context.Context, scope string, exportNa // executeCreateRequest creates the Execute request. func (client *ExportsClient) executeCreateRequest(ctx context.Context, scope string, exportName string, options *ExportsClientExecuteOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.CostManagement/exports/{exportName}/run" + if scope == "" { + return nil, errors.New("parameter scope cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) if exportName == "" { return nil, errors.New("parameter exportName cannot be empty") @@ -215,26 +195,23 @@ 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", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} + if options != nil && options.Parameters != nil { + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, *options.Parameters); err != nil { + return nil, err + } + return req, nil + } return req, nil } // 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 -// - 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 -// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope, -// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount -// scope, -// '/providers/Microsoft.Management/managementGroups/{managementGroupId} for Management Group scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' -// for billingProfile scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' -// for invoiceSection scope, and -// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for partners. +// Generated from API version 2025-03-01 +// - scope - The fully qualified Azure Resource manager identifier of the resource. // - exportName - Export Name. // - options - ExportsClientGetOptions contains the optional parameters for the ExportsClient.Get method. func (client *ExportsClient) Get(ctx context.Context, scope string, exportName string, options *ExportsClientGetOptions) (ExportsClientGetResponse, error) { @@ -262,6 +239,9 @@ func (client *ExportsClient) Get(ctx context.Context, scope string, exportName s // getCreateRequest creates the Get request. func (client *ExportsClient) getCreateRequest(ctx context.Context, scope string, exportName string, options *ExportsClientGetOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.CostManagement/exports/{exportName}" + if scope == "" { + return nil, errors.New("parameter scope cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) if exportName == "" { return nil, errors.New("parameter exportName cannot be empty") @@ -272,10 +252,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", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -293,17 +273,8 @@ 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 -// - 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 -// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope, -// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount -// scope, -// '/providers/Microsoft.Management/managementGroups/{managementGroupId} for Management Group scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' -// for billingProfile scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' -// for invoiceSection scope, and -// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for partners. +// Generated from API version 2025-03-01 +// - scope - The fully qualified Azure Resource manager identifier of the resource. // - exportName - Export Name. // - options - ExportsClientGetExecutionHistoryOptions contains the optional parameters for the ExportsClient.GetExecutionHistory // method. @@ -330,8 +301,11 @@ func (client *ExportsClient) GetExecutionHistory(ctx context.Context, scope stri } // getExecutionHistoryCreateRequest creates the GetExecutionHistory request. -func (client *ExportsClient) getExecutionHistoryCreateRequest(ctx context.Context, scope string, exportName string, options *ExportsClientGetExecutionHistoryOptions) (*policy.Request, error) { +func (client *ExportsClient) getExecutionHistoryCreateRequest(ctx context.Context, scope string, exportName string, _ *ExportsClientGetExecutionHistoryOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.CostManagement/exports/{exportName}/runHistory" + if scope == "" { + return nil, errors.New("parameter scope cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) if exportName == "" { return nil, errors.New("parameter exportName cannot be empty") @@ -342,7 +316,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", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -357,56 +331,51 @@ func (client *ExportsClient) getExecutionHistoryHandleResponse(resp *http.Respon return result, nil } -// List - The operation to list all exports at the given scope. -// If the operation fails it returns an *azcore.ResponseError type. +// NewListPager - The operation to list all exports at the given scope. // -// Generated from API version 2022-10-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 -// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope, -// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount -// scope, -// '/providers/Microsoft.Management/managementGroups/{managementGroupId} for Management Group scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' -// for billingProfile scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' -// for invoiceSection scope, and -// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for partners. -// - options - ExportsClientListOptions contains the optional parameters for the ExportsClient.List method. -func (client *ExportsClient) List(ctx context.Context, scope string, options *ExportsClientListOptions) (ExportsClientListResponse, error) { - var err error - const operationName = "ExportsClient.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 ExportsClientListResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return ExportsClientListResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return ExportsClientListResponse{}, err - } - resp, err := client.listHandleResponse(httpResp) - return resp, err +// Generated from API version 2025-03-01 +// - scope - The fully qualified Azure Resource manager identifier of the resource. +// - options - ExportsClientListOptions contains the optional parameters for the ExportsClient.NewListPager method. +func (client *ExportsClient) NewListPager(scope string, options *ExportsClientListOptions) *runtime.Pager[ExportsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[ExportsClientListResponse]{ + More: func(page ExportsClientListResponse) bool { + return false + }, + Fetcher: func(ctx context.Context, page *ExportsClientListResponse) (ExportsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ExportsClient.NewListPager") + req, err := client.listCreateRequest(ctx, scope, options) + if err != nil { + return ExportsClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ExportsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ExportsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) } // listCreateRequest creates the List request. func (client *ExportsClient) listCreateRequest(ctx context.Context, scope string, options *ExportsClientListOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.CostManagement/exports" + if scope == "" { + return nil, errors.New("parameter scope cannot be empty") + } 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() - reqQP.Set("api-version", "2022-10-01") if options != nil && options.Expand != nil { reqQP.Set("$expand", *options.Expand) } + reqQP.Set("api-version", "2025-03-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 index a3ec387a9570..26c3036a99a2 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/exports_client_example_test.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/exports_client_example_test.go @@ -1,594 +1,20 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. 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" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v3" + "log" + "time" ) -// Generated from 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() { +// Generated from example definition: 2025-03-01/ExportCreateOrUpdateByBillingAccount.json +func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateByBillingAccount() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -598,37 +24,76 @@ func ExampleExportsClient_Get_exportGetByBillingAccount() { 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}) + res, err := clientFactory.NewExportsClient().CreateOrUpdate(ctx, "providers/Microsoft.Billing/billingAccounts/123456", "TestExport", armcostmanagement.Export{ + Identity: &armcostmanagement.SystemAssignedServiceIdentity{ + Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned), + }, + Location: to.Ptr("centralus"), + Properties: &armcostmanagement.ExportProperties{ + Format: to.Ptr(armcostmanagement.FormatTypeCSV), + CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), + Definition: &armcostmanagement.ExportDefinition{ + Type: to.Ptr(armcostmanagement.ExportTypeActualCost), + DataSet: &armcostmanagement.ExportDataset{ + Configuration: &armcostmanagement.ExportDatasetConfiguration{ + DataVersion: to.Ptr("2023-05-01"), + }, + Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + }, + Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), + }, + DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ + Destination: &armcostmanagement.ExportDeliveryDestination{ + Type: to.Ptr(armcostmanagement.DestinationTypeAzureBlob), + 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"), + }, + }, + ExportDescription: to.Ptr("This is a test export."), + PartitionData: to.Ptr(true), + Schedule: &armcostmanagement.ExportSchedule{ + Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeDaily), + RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{ + From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t }()), + To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); 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/{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")}, + // res = armcostmanagement.ExportsClientCreateOrUpdateResponse{ + // Export: &armcostmanagement.Export{ + // Name: to.Ptr("TestExport"), + // Type: to.Ptr("Microsoft.CostManagement/exports"), + // ETag: to.Ptr(azcore.ETag("\"00000000-0000-0000-0000-000000000000\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/exports/TestExport"), + // Identity: &armcostmanagement.SystemAssignedServiceIdentity{ + // Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // Location: to.Ptr("centralus"), + // Properties: &armcostmanagement.ExportProperties{ + // Format: to.Ptr(armcostmanagement.FormatTypeCSV), + // CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + // DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), + // Definition: &armcostmanagement.ExportDefinition{ + // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), + // DataSet: &armcostmanagement.ExportDataset{ + // Configuration: &armcostmanagement.ExportDatasetConfiguration{ + // DataVersion: to.Ptr("2023-05-01"), // }, // 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), + // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), // }, // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ // Destination: &armcostmanagement.ExportDeliveryDestination{ @@ -637,12 +102,24 @@ func ExampleExportsClient_Get_exportGetByBillingAccount() { // RootFolderPath: to.Ptr("ad-hoc"), // }, // }, + // ExportDescription: to.Ptr("This is a test export."), + // NextRunTimeEstimate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T23:00:00Z"); return t}()), + // PartitionData: to.Ptr(true), + // Schedule: &armcostmanagement.ExportSchedule{ + // Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeDaily), + // RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{ + // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); 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/ExportGetByDepartment.json -func ExampleExportsClient_Get_exportGetByDepartment() { +// Generated from example definition: 2025-03-01/ExportCreateOrUpdateByBillingAccountCustom.json +func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateByBillingAccountCustom() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -652,35 +129,77 @@ func ExampleExportsClient_Get_exportGetByDepartment() { 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}) + res, err := clientFactory.NewExportsClient().CreateOrUpdate(ctx, "providers/Microsoft.Billing/billingAccounts/123456", "TestExport", armcostmanagement.Export{ + Identity: &armcostmanagement.SystemAssignedServiceIdentity{ + Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned), + }, + Location: to.Ptr("centralus"), + Properties: &armcostmanagement.ExportProperties{ + Format: to.Ptr(armcostmanagement.FormatTypeCSV), + CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), + Definition: &armcostmanagement.ExportDefinition{ + Type: to.Ptr(armcostmanagement.ExportTypeActualCost), + DataSet: &armcostmanagement.ExportDataset{ + Configuration: &armcostmanagement.ExportDatasetConfiguration{ + DataVersion: to.Ptr("2023-05-01"), + }, + Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + }, + TimePeriod: &armcostmanagement.ExportTimePeriod{ + From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-03T00:00:00.000Z"); return t }()), + To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-03T00:00:00.000Z"); return t }()), + }, + Timeframe: to.Ptr(armcostmanagement.TimeframeTypeCustom), + }, + DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ + Destination: &armcostmanagement.ExportDeliveryDestination{ + Type: to.Ptr(armcostmanagement.DestinationTypeAzureBlob), + 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"), + }, + }, + ExportDescription: to.Ptr("This is a test export."), + PartitionData: to.Ptr(true), + Schedule: &armcostmanagement.ExportSchedule{ + Status: to.Ptr(armcostmanagement.StatusTypeInactive), + }, + }, + }, 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")}, + // res = armcostmanagement.ExportsClientCreateOrUpdateResponse{ + // Export: &armcostmanagement.Export{ + // Name: to.Ptr("TestExport"), + // Type: to.Ptr("Microsoft.CostManagement/exports"), + // ETag: to.Ptr(azcore.ETag("\"00000000-0000-0000-0000-000000000000\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/exports/TestExport"), + // Identity: &armcostmanagement.SystemAssignedServiceIdentity{ + // Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // Location: to.Ptr("centralus"), + // Properties: &armcostmanagement.ExportProperties{ + // Format: to.Ptr(armcostmanagement.FormatTypeCSV), + // CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + // DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), + // Definition: &armcostmanagement.ExportDefinition{ + // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), + // DataSet: &armcostmanagement.ExportDataset{ + // Configuration: &armcostmanagement.ExportDatasetConfiguration{ + // DataVersion: to.Ptr("2023-05-01"), // }, // 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}()), + // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-03T00:00:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2025-04-03T00:00:00Z"); return t}()), // }, // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeCustom), // }, @@ -691,12 +210,19 @@ func ExampleExportsClient_Get_exportGetByDepartment() { // RootFolderPath: to.Ptr("ad-hoc"), // }, // }, + // ExportDescription: to.Ptr("This is a test export."), + // PartitionData: to.Ptr(true), + // Schedule: &armcostmanagement.ExportSchedule{ + // Recurrence: to.Ptr(armcostmanagement.RecurrenceType("None")), + // Status: to.Ptr(armcostmanagement.StatusTypeInactive), + // }, // }, - // } + // }, + // } } -// Generated from 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() { +// Generated from example definition: 2025-03-01/ExportCreateOrUpdateByBillingAccountMonthly.json +func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateByBillingAccountMonthly() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -706,37 +232,76 @@ func ExampleExportsClient_Get_exportGetByEnrollmentAccount() { 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}) + res, err := clientFactory.NewExportsClient().CreateOrUpdate(ctx, "providers/Microsoft.Billing/billingAccounts/123456", "TestExport", armcostmanagement.Export{ + Identity: &armcostmanagement.SystemAssignedServiceIdentity{ + Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned), + }, + Location: to.Ptr("centralus"), + Properties: &armcostmanagement.ExportProperties{ + Format: to.Ptr(armcostmanagement.FormatTypeCSV), + CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), + Definition: &armcostmanagement.ExportDefinition{ + Type: to.Ptr(armcostmanagement.ExportTypeActualCost), + DataSet: &armcostmanagement.ExportDataset{ + Configuration: &armcostmanagement.ExportDatasetConfiguration{ + DataVersion: to.Ptr("2023-05-01"), + }, + Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + }, + Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheLastMonth), + }, + DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ + Destination: &armcostmanagement.ExportDeliveryDestination{ + Type: to.Ptr(armcostmanagement.DestinationTypeAzureBlob), + 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"), + }, + }, + ExportDescription: to.Ptr("This is a test export."), + PartitionData: to.Ptr(true), + Schedule: &armcostmanagement.ExportSchedule{ + Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeMonthly), + RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{ + From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-05T00:00:00Z"); return t }()), + To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2030-06-30T00:00:00Z"); 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")}, + // res = armcostmanagement.ExportsClientCreateOrUpdateResponse{ + // Export: &armcostmanagement.Export{ + // Name: to.Ptr("TestExport"), + // Type: to.Ptr("Microsoft.CostManagement/exports"), + // ETag: to.Ptr(azcore.ETag("\"00000000-0000-0000-0000-000000000000\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/exports/TestExport"), + // Identity: &armcostmanagement.SystemAssignedServiceIdentity{ + // Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // Location: to.Ptr("centralus"), + // Properties: &armcostmanagement.ExportProperties{ + // Format: to.Ptr(armcostmanagement.FormatTypeCSV), + // CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + // DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), + // Definition: &armcostmanagement.ExportDefinition{ + // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), + // DataSet: &armcostmanagement.ExportDataset{ + // Configuration: &armcostmanagement.ExportDatasetConfiguration{ + // DataVersion: to.Ptr("2023-05-01"), // }, // 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), + // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheLastMonth), // }, // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ // Destination: &armcostmanagement.ExportDeliveryDestination{ @@ -745,12 +310,24 @@ func ExampleExportsClient_Get_exportGetByEnrollmentAccount() { // RootFolderPath: to.Ptr("ad-hoc"), // }, // }, + // ExportDescription: to.Ptr("This is a test export."), + // NextRunTimeEstimate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-05T23:00:00Z"); return t}()), + // PartitionData: to.Ptr(true), + // Schedule: &armcostmanagement.ExportSchedule{ + // Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeMonthly), + // RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{ + // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-05T00:00:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2030-06-30T00:00:00Z"); 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/ExportGetByManagementGroup.json -func ExampleExportsClient_Get_exportGetByManagementGroup() { +// Generated from example definition: 2025-03-01/ExportCreateOrUpdateByBillingAccountPricesheet.json +func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateByBillingAccountPricesheet() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -760,37 +337,76 @@ func ExampleExportsClient_Get_exportGetByManagementGroup() { 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}) + res, err := clientFactory.NewExportsClient().CreateOrUpdate(ctx, "providers/Microsoft.Billing/billingAccounts/123456", "TestExport", armcostmanagement.Export{ + Identity: &armcostmanagement.SystemAssignedServiceIdentity{ + Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned), + }, + Location: to.Ptr("centralus"), + Properties: &armcostmanagement.ExportProperties{ + Format: to.Ptr(armcostmanagement.FormatTypeCSV), + CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), + Definition: &armcostmanagement.ExportDefinition{ + Type: to.Ptr(armcostmanagement.ExportTypePriceSheet), + DataSet: &armcostmanagement.ExportDataset{ + Configuration: &armcostmanagement.ExportDatasetConfiguration{ + DataVersion: to.Ptr("2023-05-01"), + }, + Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + }, + Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheCurrentMonth), + }, + DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ + Destination: &armcostmanagement.ExportDeliveryDestination{ + Type: to.Ptr(armcostmanagement.DestinationTypeAzureBlob), + 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"), + }, + }, + ExportDescription: to.Ptr("This is a test export."), + PartitionData: to.Ptr(true), + Schedule: &armcostmanagement.ExportSchedule{ + Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeDaily), + RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{ + From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-01T00:00:00Z"); return t }()), + To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-30T00:00:00Z"); 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("UsageDate"), - // to.Ptr("MeterId"), - // to.Ptr("InstanceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("UsageQuantity")}, + // res = armcostmanagement.ExportsClientCreateOrUpdateResponse{ + // Export: &armcostmanagement.Export{ + // Name: to.Ptr("TestExport"), + // Type: to.Ptr("Microsoft.CostManagement/exports"), + // ETag: to.Ptr(azcore.ETag("\"00000000-0000-0000-0000-000000000000\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/exports/TestExport"), + // Identity: &armcostmanagement.SystemAssignedServiceIdentity{ + // Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // Location: to.Ptr("centralus"), + // Properties: &armcostmanagement.ExportProperties{ + // Format: to.Ptr(armcostmanagement.FormatTypeCSV), + // CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + // DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), + // Definition: &armcostmanagement.ExportDefinition{ + // Type: to.Ptr(armcostmanagement.ExportTypePriceSheet), + // DataSet: &armcostmanagement.ExportDataset{ + // Configuration: &armcostmanagement.ExportDatasetConfiguration{ + // DataVersion: to.Ptr("2023-05-01"), // }, // 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), + // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheCurrentMonth), // }, // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ // Destination: &armcostmanagement.ExportDeliveryDestination{ @@ -799,12 +415,24 @@ func ExampleExportsClient_Get_exportGetByManagementGroup() { // RootFolderPath: to.Ptr("ad-hoc"), // }, // }, + // ExportDescription: to.Ptr("This is a test export."), + // NextRunTimeEstimate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-01T23:00:00Z"); return t}()), + // PartitionData: to.Ptr(true), + // Schedule: &armcostmanagement.ExportSchedule{ + // Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeDaily), + // RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{ + // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-01T00:00:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-30T00:00:00Z"); 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/ExportGetByResourceGroup.json -func ExampleExportsClient_Get_exportGetByResourceGroup() { +// Generated from example definition: 2025-03-01/ExportCreateOrUpdateByBillingAccountReservationDetails.json +func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateByBillingAccountReservationDetails() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -814,37 +442,80 @@ func ExampleExportsClient_Get_exportGetByResourceGroup() { 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}) + res, err := clientFactory.NewExportsClient().CreateOrUpdate(ctx, "providers/Microsoft.Billing/billingAccounts/123456", "TestExport", armcostmanagement.Export{ + Identity: &armcostmanagement.SystemAssignedServiceIdentity{ + Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned), + }, + Location: to.Ptr("centralus"), + Properties: &armcostmanagement.ExportProperties{ + Format: to.Ptr(armcostmanagement.FormatTypeCSV), + CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), + Definition: &armcostmanagement.ExportDefinition{ + Type: to.Ptr(armcostmanagement.ExportTypeReservationDetails), + DataSet: &armcostmanagement.ExportDataset{ + Configuration: &armcostmanagement.ExportDatasetConfiguration{ + DataVersion: to.Ptr("2023-03-01"), + }, + Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + }, + Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), + }, + DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ + Destination: &armcostmanagement.ExportDeliveryDestination{ + Type: to.Ptr(armcostmanagement.DestinationTypeAzureBlob), + 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"), + }, + }, + ExportDescription: to.Ptr("This is a test export."), + PartitionData: to.Ptr(true), + Schedule: &armcostmanagement.ExportSchedule{ + Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeDaily), + RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{ + From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-01T00:00:00Z"); return t }()), + To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-30T00:00:00Z"); 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")}, + // res = armcostmanagement.ExportsClientCreateOrUpdateResponse{ + // Export: &armcostmanagement.Export{ + // Name: to.Ptr("TestExport"), + // Type: to.Ptr("Microsoft.CostManagement/exports"), + // ETag: to.Ptr(azcore.ETag("\"00000000-0000-0000-0000-000000000000\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/exports/TestExport"), + // Identity: &armcostmanagement.SystemAssignedServiceIdentity{ + // Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // Location: to.Ptr("centralus"), + // Properties: &armcostmanagement.ExportProperties{ + // Format: to.Ptr(armcostmanagement.FormatTypeCSV), + // CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + // DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), + // Definition: &armcostmanagement.ExportDefinition{ + // Type: to.Ptr(armcostmanagement.ExportTypeReservationDetails), + // DataSet: &armcostmanagement.ExportDataset{ + // Configuration: &armcostmanagement.ExportDatasetConfiguration{ + // Columns: []*string{ + // }, + // DataVersion: to.Ptr("2023-03-01"), + // Filters: []*armcostmanagement.FilterItems{ + // }, // }, // 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), + // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), // }, // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ // Destination: &armcostmanagement.ExportDeliveryDestination{ @@ -853,12 +524,24 @@ func ExampleExportsClient_Get_exportGetByResourceGroup() { // RootFolderPath: to.Ptr("ad-hoc"), // }, // }, + // ExportDescription: to.Ptr("This is a test export."), + // NextRunTimeEstimate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-01T23:00:00Z"); return t}()), + // PartitionData: to.Ptr(true), + // Schedule: &armcostmanagement.ExportSchedule{ + // Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeDaily), + // RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{ + // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-01T00:00:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-30T00:00:00Z"); 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/ExportGetBySubscription.json -func ExampleExportsClient_Get_exportGetBySubscription() { +// Generated from example definition: 2025-03-01/ExportCreateOrUpdateByBillingAccountReservationRecommendation.json +func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateByBillingAccountReservationRecommendation() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -868,37 +551,104 @@ func ExampleExportsClient_Get_exportGetBySubscription() { 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}) + res, err := clientFactory.NewExportsClient().CreateOrUpdate(ctx, "providers/Microsoft.Billing/billingAccounts/123456", "TestExport", armcostmanagement.Export{ + Identity: &armcostmanagement.SystemAssignedServiceIdentity{ + Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned), + }, + Location: to.Ptr("centralus"), + Properties: &armcostmanagement.ExportProperties{ + Format: to.Ptr(armcostmanagement.FormatTypeCSV), + CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), + Definition: &armcostmanagement.ExportDefinition{ + Type: to.Ptr(armcostmanagement.ExportTypeReservationRecommendations), + DataSet: &armcostmanagement.ExportDataset{ + Configuration: &armcostmanagement.ExportDatasetConfiguration{ + DataVersion: to.Ptr("2023-05-01"), + Filters: []*armcostmanagement.FilterItems{ + { + Name: to.Ptr(armcostmanagement.FilterItemNamesReservationScope), + Value: to.Ptr("Single"), + }, + { + Name: to.Ptr(armcostmanagement.FilterItemNamesResourceType), + Value: to.Ptr("VirtualMachines"), + }, + { + Name: to.Ptr(armcostmanagement.FilterItemNamesLookBackPeriod), + Value: to.Ptr("Last7Days"), + }, + }, + }, + }, + Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), + }, + DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ + Destination: &armcostmanagement.ExportDeliveryDestination{ + Type: to.Ptr(armcostmanagement.DestinationTypeAzureBlob), + 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"), + }, + }, + ExportDescription: to.Ptr("This is a test export."), + PartitionData: to.Ptr(true), + Schedule: &armcostmanagement.ExportSchedule{ + Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeDaily), + RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{ + From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-01T00:00:00Z"); return t }()), + To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-30T00:00:00Z"); 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")}, + // res = armcostmanagement.ExportsClientCreateOrUpdateResponse{ + // Export: &armcostmanagement.Export{ + // Name: to.Ptr("TestExport"), + // Type: to.Ptr("Microsoft.CostManagement/exports"), + // ETag: to.Ptr(azcore.ETag("\"00000000-0000-0000-0000-000000000000\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/exports/TestExport"), + // Identity: &armcostmanagement.SystemAssignedServiceIdentity{ + // Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // Location: to.Ptr("centralus"), + // Properties: &armcostmanagement.ExportProperties{ + // Format: to.Ptr(armcostmanagement.FormatTypeCSV), + // CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + // DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), + // Definition: &armcostmanagement.ExportDefinition{ + // Type: to.Ptr(armcostmanagement.ExportTypeReservationRecommendations), + // DataSet: &armcostmanagement.ExportDataset{ + // Configuration: &armcostmanagement.ExportDatasetConfiguration{ + // Columns: []*string{ + // }, + // DataVersion: to.Ptr("2023-05-01"), + // Filters: []*armcostmanagement.FilterItems{ + // { + // Name: to.Ptr(armcostmanagement.FilterItemNamesReservationScope), + // Value: to.Ptr("Single"), + // }, + // { + // Name: to.Ptr(armcostmanagement.FilterItemNamesResourceType), + // Value: to.Ptr("VirtualMachines"), + // }, + // { + // Name: to.Ptr(armcostmanagement.FilterItemNamesLookBackPeriod), + // Value: to.Ptr("Last7Days"), + // }, + // }, // }, - // 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), + // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), // }, // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ // Destination: &armcostmanagement.ExportDeliveryDestination{ @@ -907,12 +657,24 @@ func ExampleExportsClient_Get_exportGetBySubscription() { // RootFolderPath: to.Ptr("ad-hoc"), // }, // }, + // ExportDescription: to.Ptr("This is a test export."), + // NextRunTimeEstimate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-01T23:00:00Z"); return t}()), + // PartitionData: to.Ptr(true), + // Schedule: &armcostmanagement.ExportSchedule{ + // Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeDaily), + // RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{ + // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-01T00:00:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-30T00:00:00Z"); 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/ExportCreateOrUpdateByBillingAccount.json -func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateByBillingAccount() { +// Generated from example definition: 2025-03-01/ExportCreateOrUpdateByBillingAccountReservationTransactions.json +func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateExportCreateOrUpdateByBillingAccountReservationTransactionsByBillingAccount() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -923,37 +685,40 @@ func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateByBillingAccount() log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewExportsClient().CreateOrUpdate(ctx, "providers/Microsoft.Billing/billingAccounts/123456", "TestExport", armcostmanagement.Export{ + Identity: &armcostmanagement.SystemAssignedServiceIdentity{ + Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned), + }, + Location: to.Ptr("centralus"), Properties: &armcostmanagement.ExportProperties{ - Format: to.Ptr(armcostmanagement.FormatTypeCSV), + Format: to.Ptr(armcostmanagement.FormatTypeCSV), + CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), Definition: &armcostmanagement.ExportDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeActualCost), + Type: to.Ptr(armcostmanagement.ExportTypeReservationTransactions), DataSet: &armcostmanagement.ExportDataset{ Configuration: &armcostmanagement.ExportDatasetConfiguration{ - Columns: []*string{ - to.Ptr("Date"), - to.Ptr("MeterId"), - to.Ptr("ResourceId"), - to.Ptr("ResourceLocation"), - to.Ptr("Quantity")}, + DataVersion: to.Ptr("2023-05-01"), }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), + 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"), + Type: to.Ptr(armcostmanagement.DestinationTypeAzureBlob), + 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"), }, }, + ExportDescription: to.Ptr("This is a test export."), + PartitionData: to.Ptr(true), Schedule: &armcostmanagement.ExportSchedule{ - Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeWeekly), + Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeDaily), 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 }()), + From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-01T00:00:00Z"); return t }()), + To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-30T00:00:00Z"); return t }()), }, - Status: to.Ptr(armcostmanagement.StatusTypeActive), + Status: to.Ptr(armcostmanagement.StatusTypeActive), }, }, }, nil) @@ -963,24 +728,32 @@ func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateByBillingAccount() // 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")}, + // res = armcostmanagement.ExportsClientCreateOrUpdateResponse{ + // Export: &armcostmanagement.Export{ + // Name: to.Ptr("TestExport"), + // Type: to.Ptr("Microsoft.CostManagement/exports"), + // ETag: to.Ptr(azcore.ETag("\"00000000-0000-0000-0000-000000000000\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/exports/TestExport"), + // Identity: &armcostmanagement.SystemAssignedServiceIdentity{ + // Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // Location: to.Ptr("centralus"), + // Properties: &armcostmanagement.ExportProperties{ + // Format: to.Ptr(armcostmanagement.FormatTypeCSV), + // CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + // DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), + // Definition: &armcostmanagement.ExportDefinition{ + // Type: to.Ptr(armcostmanagement.ExportTypeReservationTransactions), + // DataSet: &armcostmanagement.ExportDataset{ + // Configuration: &armcostmanagement.ExportDatasetConfiguration{ + // Columns: []*string{ + // }, + // DataVersion: to.Ptr("2023-05-01"), + // Filters: []*armcostmanagement.FilterItems{ + // }, // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), // }, // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), // }, @@ -991,19 +764,23 @@ func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateByBillingAccount() // RootFolderPath: to.Ptr("ad-hoc"), // }, // }, + // ExportDescription: to.Ptr("This is a test export."), + // NextRunTimeEstimate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-01T23:00:00Z"); return t}()), + // PartitionData: to.Ptr(true), // Schedule: &armcostmanagement.ExportSchedule{ - // Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeWeekly), + // Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeDaily), // 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}()), + // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-01T00:00:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-06-30T00:00:00Z"); 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 +// Generated from example definition: 2025-03-01/ExportCreateOrUpdateByDepartment.json func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateByDepartment() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -1015,37 +792,41 @@ func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateByDepartment() { log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewExportsClient().CreateOrUpdate(ctx, "providers/Microsoft.Billing/billingAccounts/12/departments/1234", "TestExport", armcostmanagement.Export{ + Identity: &armcostmanagement.SystemAssignedServiceIdentity{ + Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned), + }, + Location: to.Ptr("centralus"), Properties: &armcostmanagement.ExportProperties{ - Format: to.Ptr(armcostmanagement.FormatTypeCSV), + Format: to.Ptr(armcostmanagement.FormatTypeParquet), + CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeSnappy), + DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), Definition: &armcostmanagement.ExportDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeActualCost), + 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")}, + DataVersion: to.Ptr("2023-05-01"), }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), + 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"), + Type: to.Ptr(armcostmanagement.DestinationTypeAzureBlob), + 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"), }, }, + ExportDescription: to.Ptr("This is a test export."), + PartitionData: to.Ptr(true), Schedule: &armcostmanagement.ExportSchedule{ - Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeWeekly), + Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeDaily), 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 }()), + From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t }()), + To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); return t }()), }, - Status: to.Ptr(armcostmanagement.StatusTypeActive), + Status: to.Ptr(armcostmanagement.StatusTypeActive), }, }, }, nil) @@ -1055,22 +836,27 @@ func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateByDepartment() { // 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")}, + // res = armcostmanagement.ExportsClientCreateOrUpdateResponse{ + // Export: &armcostmanagement.Export{ + // Name: to.Ptr("TestExport"), + // Type: to.Ptr("Microsoft.CostManagement/exports"), + // ETag: to.Ptr(azcore.ETag("\"00000000-0000-0000-0000-000000000000\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/12/departments/1234/providers/Microsoft.CostManagement/exports/TestExport"), + // Identity: &armcostmanagement.SystemAssignedServiceIdentity{ + // Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // Location: to.Ptr("centralus"), + // Properties: &armcostmanagement.ExportProperties{ + // Format: to.Ptr(armcostmanagement.FormatTypeParquet), + // CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeSnappy), + // DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), + // Definition: &armcostmanagement.ExportDefinition{ + // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), + // DataSet: &armcostmanagement.ExportDataset{ + // Configuration: &armcostmanagement.ExportDatasetConfiguration{ + // DataVersion: to.Ptr("2023-05-01"), // }, // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), // }, @@ -1083,19 +869,23 @@ func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateByDepartment() { // RootFolderPath: to.Ptr("ad-hoc"), // }, // }, + // ExportDescription: to.Ptr("This is a test export."), + // NextRunTimeEstimate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T23:00:00Z"); return t}()), + // PartitionData: to.Ptr(true), // Schedule: &armcostmanagement.ExportSchedule{ - // Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeWeekly), + // Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeDaily), // 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}()), + // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); 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 +// Generated from example definition: 2025-03-01/ExportCreateOrUpdateByEnrollmentAccount.json func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateByEnrollmentAccount() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -1107,37 +897,41 @@ func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateByEnrollmentAccount log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewExportsClient().CreateOrUpdate(ctx, "providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456", "TestExport", armcostmanagement.Export{ + Identity: &armcostmanagement.SystemAssignedServiceIdentity{ + Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned), + }, + Location: to.Ptr("centralus"), Properties: &armcostmanagement.ExportProperties{ - Format: to.Ptr(armcostmanagement.FormatTypeCSV), + Format: to.Ptr(armcostmanagement.FormatTypeCSV), + CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), Definition: &armcostmanagement.ExportDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeActualCost), + 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")}, + DataVersion: to.Ptr("2023-05-01"), }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), + 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"), + Type: to.Ptr(armcostmanagement.DestinationTypeAzureBlob), + 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"), }, }, + ExportDescription: to.Ptr("This is a test export."), + PartitionData: to.Ptr(true), Schedule: &armcostmanagement.ExportSchedule{ - Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeWeekly), + Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeDaily), 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 }()), + From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t }()), + To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); return t }()), }, - Status: to.Ptr(armcostmanagement.StatusTypeActive), + Status: to.Ptr(armcostmanagement.StatusTypeActive), }, }, }, nil) @@ -1147,22 +941,27 @@ func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateByEnrollmentAccount // 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")}, + // res = armcostmanagement.ExportsClientCreateOrUpdateResponse{ + // Export: &armcostmanagement.Export{ + // Name: to.Ptr("TestExport"), + // Type: to.Ptr("Microsoft.CostManagement/exports"), + // ETag: to.Ptr(azcore.ETag("\"00000000-0000-0000-0000-000000000000\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456/providers/Microsoft.CostManagement/exports/TestExport"), + // Identity: &armcostmanagement.SystemAssignedServiceIdentity{ + // Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // Location: to.Ptr("centralus"), + // Properties: &armcostmanagement.ExportProperties{ + // Format: to.Ptr(armcostmanagement.FormatTypeCSV), + // CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + // DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), + // Definition: &armcostmanagement.ExportDefinition{ + // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), + // DataSet: &armcostmanagement.ExportDataset{ + // Configuration: &armcostmanagement.ExportDatasetConfiguration{ + // DataVersion: to.Ptr("2023-05-01"), // }, // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), // }, @@ -1175,19 +974,23 @@ func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateByEnrollmentAccount // RootFolderPath: to.Ptr("ad-hoc"), // }, // }, + // ExportDescription: to.Ptr("This is a test export."), + // NextRunTimeEstimate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T23:00:00Z"); return t}()), + // PartitionData: to.Ptr(true), // Schedule: &armcostmanagement.ExportSchedule{ - // Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeWeekly), + // Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeDaily), // 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}()), + // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); 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 +// Generated from example definition: 2025-03-01/ExportCreateOrUpdateByManagementGroup.json func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateByManagementGroup() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -1199,37 +1002,41 @@ func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateByManagementGroup() log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewExportsClient().CreateOrUpdate(ctx, "providers/Microsoft.Management/managementGroups/TestMG", "TestExport", armcostmanagement.Export{ + Identity: &armcostmanagement.SystemAssignedServiceIdentity{ + Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned), + }, + Location: to.Ptr("centralus"), Properties: &armcostmanagement.ExportProperties{ - Format: to.Ptr(armcostmanagement.FormatTypeCSV), + Format: to.Ptr(armcostmanagement.FormatTypeCSV), + CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), Definition: &armcostmanagement.ExportDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeActualCost), + 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")}, + DataVersion: to.Ptr("2023-05-01"), }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), + 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"), + Type: to.Ptr(armcostmanagement.DestinationTypeAzureBlob), + 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"), }, }, + ExportDescription: to.Ptr("This is a test export."), + PartitionData: to.Ptr(true), Schedule: &armcostmanagement.ExportSchedule{ - Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeWeekly), + Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeDaily), 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 }()), + From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t }()), + To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); return t }()), }, - Status: to.Ptr(armcostmanagement.StatusTypeActive), + Status: to.Ptr(armcostmanagement.StatusTypeActive), }, }, }, nil) @@ -1239,22 +1046,27 @@ func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateByManagementGroup() // 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")}, + // res = armcostmanagement.ExportsClientCreateOrUpdateResponse{ + // Export: &armcostmanagement.Export{ + // Name: to.Ptr("TestExport"), + // Type: to.Ptr("Microsoft.CostManagement/exports"), + // ETag: to.Ptr(azcore.ETag("\"00000000-0000-0000-0000-000000000000\"")), + // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/TestMG/providers/Microsoft.CostManagement/exports/TestExport"), + // Identity: &armcostmanagement.SystemAssignedServiceIdentity{ + // Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // Location: to.Ptr("centralus"), + // Properties: &armcostmanagement.ExportProperties{ + // Format: to.Ptr(armcostmanagement.FormatTypeCSV), + // CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + // DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), + // Definition: &armcostmanagement.ExportDefinition{ + // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), + // DataSet: &armcostmanagement.ExportDataset{ + // Configuration: &armcostmanagement.ExportDatasetConfiguration{ + // DataVersion: to.Ptr("2023-05-01"), // }, // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), // }, @@ -1267,19 +1079,23 @@ func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateByManagementGroup() // RootFolderPath: to.Ptr("ad-hoc"), // }, // }, + // ExportDescription: to.Ptr("This is a test export."), + // NextRunTimeEstimate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T23:00:00Z"); return t}()), + // PartitionData: to.Ptr(true), // Schedule: &armcostmanagement.ExportSchedule{ - // Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeWeekly), + // Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeDaily), // 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}()), + // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); 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 +// Generated from example definition: 2025-03-01/ExportCreateOrUpdateByResourceGroup.json func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateByResourceGroup() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -1291,37 +1107,41 @@ func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateByResourceGroup() { 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{ + Identity: &armcostmanagement.SystemAssignedServiceIdentity{ + Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned), + }, + Location: to.Ptr("centralus"), Properties: &armcostmanagement.ExportProperties{ - Format: to.Ptr(armcostmanagement.FormatTypeCSV), + Format: to.Ptr(armcostmanagement.FormatTypeCSV), + CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), Definition: &armcostmanagement.ExportDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeActualCost), + 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")}, + DataVersion: to.Ptr("2023-05-01"), }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), + 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"), + Type: to.Ptr(armcostmanagement.DestinationTypeAzureBlob), + 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"), }, }, + ExportDescription: to.Ptr("This is a test export."), + PartitionData: to.Ptr(true), Schedule: &armcostmanagement.ExportSchedule{ - Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeWeekly), + Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeDaily), 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 }()), + From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t }()), + To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); return t }()), }, - Status: to.Ptr(armcostmanagement.StatusTypeActive), + Status: to.Ptr(armcostmanagement.StatusTypeActive), }, }, }, nil) @@ -1331,22 +1151,27 @@ func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateByResourceGroup() { // 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")}, + // res = armcostmanagement.ExportsClientCreateOrUpdateResponse{ + // Export: &armcostmanagement.Export{ + // Name: to.Ptr("TestExport"), + // Type: to.Ptr("Microsoft.CostManagement/exports"), + // ETag: to.Ptr(azcore.ETag("\"00000000-0000-0000-0000-000000000000\"")), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.CostManagement/exports/TestExport"), + // Identity: &armcostmanagement.SystemAssignedServiceIdentity{ + // Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // Location: to.Ptr("centralus"), + // Properties: &armcostmanagement.ExportProperties{ + // Format: to.Ptr(armcostmanagement.FormatTypeCSV), + // CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + // DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), + // Definition: &armcostmanagement.ExportDefinition{ + // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), + // DataSet: &armcostmanagement.ExportDataset{ + // Configuration: &armcostmanagement.ExportDatasetConfiguration{ + // DataVersion: to.Ptr("2023-05-01"), // }, // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), // }, @@ -1359,19 +1184,23 @@ func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateByResourceGroup() { // RootFolderPath: to.Ptr("ad-hoc"), // }, // }, + // ExportDescription: to.Ptr("This is a test export."), + // NextRunTimeEstimate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T23:00:00Z"); return t}()), + // PartitionData: to.Ptr(true), // Schedule: &armcostmanagement.ExportSchedule{ - // Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeWeekly), + // Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeDaily), // 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}()), + // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); 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 +// Generated from example definition: 2025-03-01/ExportCreateOrUpdateBySubscription.json func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateBySubscription() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -1383,37 +1212,41 @@ func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateBySubscription() { log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewExportsClient().CreateOrUpdate(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", "TestExport", armcostmanagement.Export{ + Identity: &armcostmanagement.SystemAssignedServiceIdentity{ + Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned), + }, + Location: to.Ptr("centralus"), Properties: &armcostmanagement.ExportProperties{ - Format: to.Ptr(armcostmanagement.FormatTypeCSV), + Format: to.Ptr(armcostmanagement.FormatTypeCSV), + CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), Definition: &armcostmanagement.ExportDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeActualCost), + 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")}, + DataVersion: to.Ptr("2023-05-01"), }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), + 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"), + Type: to.Ptr(armcostmanagement.DestinationTypeAzureBlob), + 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"), }, }, + ExportDescription: to.Ptr("This is a test export."), + PartitionData: to.Ptr(true), Schedule: &armcostmanagement.ExportSchedule{ - Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeWeekly), + Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeDaily), 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 }()), + From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t }()), + To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); return t }()), }, - Status: to.Ptr(armcostmanagement.StatusTypeActive), + Status: to.Ptr(armcostmanagement.StatusTypeActive), }, }, }, nil) @@ -1423,22 +1256,27 @@ func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateBySubscription() { // 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")}, + // res = armcostmanagement.ExportsClientCreateOrUpdateResponse{ + // Export: &armcostmanagement.Export{ + // Name: to.Ptr("TestExport"), + // Type: to.Ptr("Microsoft.CostManagement/exports"), + // ETag: to.Ptr(azcore.ETag("\"00000000-0000-0000-0000-000000000000\"")), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/exports/TestExport"), + // Identity: &armcostmanagement.SystemAssignedServiceIdentity{ + // Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // Location: to.Ptr("centralus"), + // Properties: &armcostmanagement.ExportProperties{ + // Format: to.Ptr(armcostmanagement.FormatTypeCSV), + // CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + // DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), + // Definition: &armcostmanagement.ExportDefinition{ + // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), + // DataSet: &armcostmanagement.ExportDataset{ + // Configuration: &armcostmanagement.ExportDatasetConfiguration{ + // DataVersion: to.Ptr("2023-05-01"), // }, // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), // }, @@ -1451,19 +1289,23 @@ func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateBySubscription() { // RootFolderPath: to.Ptr("ad-hoc"), // }, // }, + // ExportDescription: to.Ptr("This is a test export."), + // NextRunTimeEstimate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T23:00:00Z"); return t}()), + // PartitionData: to.Ptr(true), // Schedule: &armcostmanagement.ExportSchedule{ - // Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeWeekly), + // Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeDaily), // 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}()), + // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); 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 +// Generated from example definition: 2025-03-01/ExportDeleteByBillingAccount.json func ExampleExportsClient_Delete_exportDeleteByBillingAccount() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -1474,13 +1316,18 @@ func ExampleExportsClient_Delete_exportDeleteByBillingAccount() { if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = clientFactory.NewExportsClient().Delete(ctx, "providers/Microsoft.Billing/billingAccounts/123456", "TestExport", nil) + res, err := clientFactory.NewExportsClient().Delete(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 = armcostmanagement.ExportsClientDeleteResponse{ + // } } -// Generated from 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 +// Generated from example definition: 2025-03-01/ExportDeleteByDepartment.json func ExampleExportsClient_Delete_exportDeleteByDepartment() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -1491,13 +1338,18 @@ func ExampleExportsClient_Delete_exportDeleteByDepartment() { 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) + res, 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) } + // 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 = armcostmanagement.ExportsClientDeleteResponse{ + // } } -// Generated from 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 +// Generated from example definition: 2025-03-01/ExportDeleteByEnrollmentAccount.json func ExampleExportsClient_Delete_exportDeleteByEnrollmentAccount() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -1508,13 +1360,18 @@ func ExampleExportsClient_Delete_exportDeleteByEnrollmentAccount() { 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) + res, 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) } + // 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 = armcostmanagement.ExportsClientDeleteResponse{ + // } } -// Generated from 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 +// Generated from example definition: 2025-03-01/ExportDeleteByManagementGroup.json func ExampleExportsClient_Delete_exportDeleteByManagementGroup() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -1525,13 +1382,18 @@ func ExampleExportsClient_Delete_exportDeleteByManagementGroup() { if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = clientFactory.NewExportsClient().Delete(ctx, "providers/Microsoft.Management/managementGroups/TestMG", "TestExport", nil) + res, err := clientFactory.NewExportsClient().Delete(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 = armcostmanagement.ExportsClientDeleteResponse{ + // } } -// Generated from 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 +// Generated from example definition: 2025-03-01/ExportDeleteByResourceGroup.json func ExampleExportsClient_Delete_exportDeleteByResourceGroup() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -1542,13 +1404,18 @@ func ExampleExportsClient_Delete_exportDeleteByResourceGroup() { 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) + res, 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) } + // 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 = armcostmanagement.ExportsClientDeleteResponse{ + // } } -// Generated from 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 +// Generated from example definition: 2025-03-01/ExportDeleteBySubscription.json func ExampleExportsClient_Delete_exportDeleteBySubscription() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -1559,13 +1426,18 @@ func ExampleExportsClient_Delete_exportDeleteBySubscription() { if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = clientFactory.NewExportsClient().Delete(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", "TestExport", nil) + res, 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) } + // 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 = armcostmanagement.ExportsClientDeleteResponse{ + // } } -// Generated from 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 +// Generated from example definition: 2025-03-01/ExportRunByBillingAccount.json func ExampleExportsClient_Execute_exportRunByBillingAccount() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -1576,13 +1448,40 @@ func ExampleExportsClient_Execute_exportRunByBillingAccount() { if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = clientFactory.NewExportsClient().Execute(ctx, "providers/Microsoft.Billing/billingAccounts/123456", "TestExport", nil) + res, err := clientFactory.NewExportsClient().Execute(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 = armcostmanagement.ExportsClientExecuteResponse{ + // } +} + +// Generated from example definition: 2025-03-01/ExportRunByBillingAccountWithOptionalRequestBody.json +func ExampleExportsClient_Execute_exportRunByBillingAccountWithOptionalRequestBody() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain 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().Execute(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 = armcostmanagement.ExportsClientExecuteResponse{ + // } } -// Generated from 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 +// Generated from example definition: 2025-03-01/ExportRunByDepartment.json func ExampleExportsClient_Execute_exportRunByDepartment() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -1593,13 +1492,18 @@ func ExampleExportsClient_Execute_exportRunByDepartment() { 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) + res, 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) } + // 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 = armcostmanagement.ExportsClientExecuteResponse{ + // } } -// Generated from 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 +// Generated from example definition: 2025-03-01/ExportRunByEnrollmentAccount.json func ExampleExportsClient_Execute_exportRunByEnrollmentAccount() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -1610,13 +1514,18 @@ func ExampleExportsClient_Execute_exportRunByEnrollmentAccount() { 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) + res, 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) } + // 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 = armcostmanagement.ExportsClientExecuteResponse{ + // } } -// Generated from 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 +// Generated from example definition: 2025-03-01/ExportRunByManagementGroup.json func ExampleExportsClient_Execute_exportRunByManagementGroup() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -1627,13 +1536,18 @@ func ExampleExportsClient_Execute_exportRunByManagementGroup() { if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = clientFactory.NewExportsClient().Execute(ctx, "providers/Microsoft.Management/managementGroups/TestMG", "TestExport", nil) + res, err := clientFactory.NewExportsClient().Execute(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 = armcostmanagement.ExportsClientExecuteResponse{ + // } } -// Generated from 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 +// Generated from example definition: 2025-03-01/ExportRunByResourceGroup.json func ExampleExportsClient_Execute_exportRunByResourceGroup() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -1644,14 +1558,351 @@ func ExampleExportsClient_Execute_exportRunByResourceGroup() { 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) + res, 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) + } + // 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 = armcostmanagement.ExportsClientExecuteResponse{ + // } +} + +// Generated from example definition: 2025-03-01/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) + } + res, 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) + } + // 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 = armcostmanagement.ExportsClientExecuteResponse{ + // } +} + +// Generated from example definition: 2025-03-01/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", 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 = armcostmanagement.ExportsClientGetResponse{ + // Export: &armcostmanagement.Export{ + // Name: to.Ptr("TestExport"), + // Type: to.Ptr("Microsoft.CostManagement/exports"), + // ETag: to.Ptr(azcore.ETag("\"00000000-0000-0000-0000-000000000000\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccount-Id}/providers/Microsoft.CostManagement/exports/TestExport"), + // Identity: &armcostmanagement.SystemAssignedServiceIdentity{ + // Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // Location: to.Ptr("centralus"), + // Properties: &armcostmanagement.ExportProperties{ + // Format: to.Ptr(armcostmanagement.FormatTypeCSV), + // CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + // DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), + // Definition: &armcostmanagement.ExportDefinition{ + // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), + // DataSet: &armcostmanagement.ExportDataset{ + // Configuration: &armcostmanagement.ExportDatasetConfiguration{ + // DataVersion: to.Ptr("2023-05-01"), + // }, + // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + // }, + // TimePeriod: &armcostmanagement.ExportTimePeriod{ + // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T00:00:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-31T00:00:00Z"); 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"), + // }, + // }, + // ExportDescription: to.Ptr("This is a test export."), + // PartitionData: to.Ptr(true), + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01/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", 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 = armcostmanagement.ExportsClientGetResponse{ + // Export: &armcostmanagement.Export{ + // Name: to.Ptr("TestExport"), + // Type: to.Ptr("Microsoft.CostManagement/exports"), + // ETag: to.Ptr(azcore.ETag("\"00000000-0000-0000-0000-000000000000\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/12/departments/1234/providers/Microsoft.CostManagement/exports/TestExport"), + // Identity: &armcostmanagement.SystemAssignedServiceIdentity{ + // Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // Location: to.Ptr("centralus"), + // Properties: &armcostmanagement.ExportProperties{ + // Format: to.Ptr(armcostmanagement.FormatTypeCSV), + // CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + // DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), + // Definition: &armcostmanagement.ExportDefinition{ + // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), + // DataSet: &armcostmanagement.ExportDataset{ + // Configuration: &armcostmanagement.ExportDatasetConfiguration{ + // DataVersion: to.Ptr("2023-05-01"), + // }, + // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + // }, + // TimePeriod: &armcostmanagement.ExportTimePeriod{ + // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); 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"), + // }, + // }, + // ExportDescription: to.Ptr("This is a test export."), + // PartitionData: to.Ptr(true), + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01/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", 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 = armcostmanagement.ExportsClientGetResponse{ + // Export: &armcostmanagement.Export{ + // Name: to.Ptr("TestExport"), + // Type: to.Ptr("Microsoft.CostManagement/exports"), + // ETag: to.Ptr(azcore.ETag("\"00000000-0000-0000-0000-000000000000\"")), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456/providers/Microsoft.CostManagement/exports/TestExport"), + // Identity: &armcostmanagement.SystemAssignedServiceIdentity{ + // Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // Location: to.Ptr("centralus"), + // Properties: &armcostmanagement.ExportProperties{ + // Format: to.Ptr(armcostmanagement.FormatTypeCSV), + // CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + // DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), + // Definition: &armcostmanagement.ExportDefinition{ + // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), + // DataSet: &armcostmanagement.ExportDataset{ + // Configuration: &armcostmanagement.ExportDatasetConfiguration{ + // DataVersion: to.Ptr("2023-05-01"), + // }, + // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + // }, + // TimePeriod: &armcostmanagement.ExportTimePeriod{ + // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-01T00:00:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-30T00:00:00Z"); 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"), + // }, + // }, + // ExportDescription: to.Ptr("This is a test export."), + // PartitionData: to.Ptr(true), + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01/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", 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 = armcostmanagement.ExportsClientGetResponse{ + // Export: &armcostmanagement.Export{ + // Name: to.Ptr("TestExport"), + // Type: to.Ptr("Microsoft.CostManagement/exports"), + // ETag: to.Ptr(azcore.ETag("\"00000000-0000-0000-0000-000000000000\"")), + // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/TestMG/providers/Microsoft.CostManagement/exports/TestExport"), + // Identity: &armcostmanagement.SystemAssignedServiceIdentity{ + // Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // Location: to.Ptr("centralus"), + // Properties: &armcostmanagement.ExportProperties{ + // Format: to.Ptr(armcostmanagement.FormatTypeCSV), + // CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + // DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), + // Definition: &armcostmanagement.ExportDefinition{ + // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), + // DataSet: &armcostmanagement.ExportDataset{ + // Configuration: &armcostmanagement.ExportDatasetConfiguration{ + // DataVersion: to.Ptr("2023-05-01"), + // }, + // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + // }, + // TimePeriod: &armcostmanagement.ExportTimePeriod{ + // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-01T00:00:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-09-30T00:00:00Z"); 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"), + // }, + // }, + // ExportDescription: to.Ptr("This is a test export."), + // PartitionData: to.Ptr(true), + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01/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", 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 = armcostmanagement.ExportsClientGetResponse{ + // Export: &armcostmanagement.Export{ + // Name: to.Ptr("TestExport"), + // Type: to.Ptr("Microsoft.CostManagement/exports"), + // ETag: to.Ptr(azcore.ETag("\"00000000-0000-0000-0000-000000000000\"")), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.CostManagement/exports/TestExport"), + // Identity: &armcostmanagement.SystemAssignedServiceIdentity{ + // Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // Location: to.Ptr("centralus"), + // Properties: &armcostmanagement.ExportProperties{ + // Format: to.Ptr(armcostmanagement.FormatTypeCSV), + // CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + // DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), + // Definition: &armcostmanagement.ExportDefinition{ + // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), + // DataSet: &armcostmanagement.ExportDataset{ + // Configuration: &armcostmanagement.ExportDatasetConfiguration{ + // DataVersion: to.Ptr("2023-05-01"), + // }, + // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + // }, + // TimePeriod: &armcostmanagement.ExportTimePeriod{ + // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); 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"), + // }, + // }, + // ExportDescription: to.Ptr("This is a test export."), + // PartitionData: to.Ptr(true), + // }, + // }, + // } } -// Generated from 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() { +// Generated from example definition: 2025-03-01/ExportGetBySubscription.json +func ExampleExportsClient_Get_exportGetBySubscription() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -1661,13 +1912,58 @@ func ExampleExportsClient_Execute_exportRunBySubscription() { if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = clientFactory.NewExportsClient().Execute(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", "TestExport", nil) + res, err := clientFactory.NewExportsClient().Get(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 = armcostmanagement.ExportsClientGetResponse{ + // Export: &armcostmanagement.Export{ + // Name: to.Ptr("TestExport"), + // Type: to.Ptr("Microsoft.CostManagement/exports"), + // ETag: to.Ptr(azcore.ETag("\"00000000-0000-0000-0000-000000000000\"")), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/exports/TestExport"), + // Identity: &armcostmanagement.SystemAssignedServiceIdentity{ + // Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // Location: to.Ptr("centralus"), + // Properties: &armcostmanagement.ExportProperties{ + // Format: to.Ptr(armcostmanagement.FormatTypeCSV), + // CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + // DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), + // Definition: &armcostmanagement.ExportDefinition{ + // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), + // DataSet: &armcostmanagement.ExportDataset{ + // Configuration: &armcostmanagement.ExportDatasetConfiguration{ + // DataVersion: to.Ptr("2023-05-01"), + // }, + // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + // }, + // TimePeriod: &armcostmanagement.ExportTimePeriod{ + // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-06-01T00:00:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-06-30T00:00:00Z"); 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"), + // }, + // }, + // ExportDescription: to.Ptr("This is a test export."), + // PartitionData: to.Ptr(true), + // }, + // }, + // } } -// Generated from 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 +// Generated from example definition: 2025-03-01/ExportRunHistoryGetByBillingAccount.json func ExampleExportsClient_GetExecutionHistory_exportRunHistoryGetByBillingAccount() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -1685,33 +1981,33 @@ func ExampleExportsClient_GetExecutionHistory_exportRunHistoryGetByBillingAccoun // 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")}, + // res = armcostmanagement.ExportsClientGetExecutionHistoryResponse{ + // 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{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); return t}()), + // ExecutionType: to.Ptr(armcostmanagement.ExecutionTypeOnDemand), + // FileName: to.Ptr("ScheduledTestsForJohnDoe/JohnDoeSchedule/20180729-20180804/JohnDoeSchedule_1e25d58a-a3b0-4916-9542-6e04a89bc100.csv"), + // ManifestFile: to.Ptr("ScheduledTestsForJohnDoe/JohnDoeSchedule/20180729-20180804/manifestfile"), + // ProcessingEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:28.0373318Z"); return t}()), + // ProcessingStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:16.9123797Z"); return t}()), + // RunSettings: &armcostmanagement.CommonExportProperties{ + // Format: to.Ptr(armcostmanagement.FormatTypeCSV), + // CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + // DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), + // Definition: &armcostmanagement.ExportDefinition{ + // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), + // DataSet: &armcostmanagement.ExportDataset{ + // Configuration: &armcostmanagement.ExportDatasetConfiguration{ + // DataVersion: to.Ptr("2023-05-01"), // }, // 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}()), + // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); return t}()), // }, // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeCustom), // }, @@ -1722,57 +2018,64 @@ func ExampleExportsClient_GetExecutionHistory_exportRunHistoryGetByBillingAccoun // RootFolderPath: to.Ptr("ScheduledTestsForJohnDoe"), // }, // }, + // ExportDescription: to.Ptr("This is a test export."), + // PartitionData: to.Ptr(true), // }, + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), // 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}()), + // SubmittedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:15.6016681Z"); return t}()), // }, // }, // { - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/{billingAccount-id}/providers/Microsoft.CostManagement/exports/JohnDoeSchedule/Run/11ac6811-dca3-46ad-b326-4704cf0c58ef"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/{billingAccount-id}/providers/Microsoft.CostManagement/exports/JohnDoeSchedule/Run/11ac6811-dca3-46ad-b326-4704cf0c58ef"), // Properties: &armcostmanagement.ExportRunProperties{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); return t}()), // 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}()), + // ManifestFile: to.Ptr("ScheduledTestsForJohnDoe/JohnDoeSchedule/20180729-20180804/manifestfile"), + // ProcessingEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T09:04:19.7223808Z"); return t}()), + // ProcessingStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T09:03:58.5710244Z"); return t}()), // RunSettings: &armcostmanagement.CommonExportProperties{ // Format: to.Ptr(armcostmanagement.FormatTypeCSV), + // CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + // DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), // 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), + // DataVersion: to.Ptr("2023-05-01"), // }, - // 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), + // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), // }, - // 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"), - // }, + // TimePeriod: &armcostmanagement.ExportTimePeriod{ + // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); 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}()), + // ExportDescription: to.Ptr("This is a test export."), + // PartitionData: to.Ptr(true), // }, - // }}, - // } + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), + // 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.5710244Z"); 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 +// Generated from example definition: 2025-03-01/ExportRunHistoryGetByDepartment.json func ExampleExportsClient_GetExecutionHistory_exportRunHistoryGetByDepartment() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -1790,33 +2093,33 @@ func ExampleExportsClient_GetExecutionHistory_exportRunHistoryGetByDepartment() // 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")}, + // res = armcostmanagement.ExportsClientGetExecutionHistoryResponse{ + // 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{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); return t}()), + // ExecutionType: to.Ptr(armcostmanagement.ExecutionTypeOnDemand), + // FileName: to.Ptr("ScheduledTestsForJohnDoe/JohnDoeSchedule/20180729-20180804/JohnDoeSchedule_1e25d58a-a3b0-4916-9542-6e04a89bc100.csv"), + // ManifestFile: to.Ptr("ScheduledTestsForJohnDoe/JohnDoeSchedule/20180729-20180804/manifestfile"), + // ProcessingEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:28.0373318Z"); return t}()), + // ProcessingStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:16.9123797Z"); return t}()), + // RunSettings: &armcostmanagement.CommonExportProperties{ + // Format: to.Ptr(armcostmanagement.FormatTypeCSV), + // CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + // DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), + // Definition: &armcostmanagement.ExportDefinition{ + // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), + // DataSet: &armcostmanagement.ExportDataset{ + // Configuration: &armcostmanagement.ExportDatasetConfiguration{ + // DataVersion: to.Ptr("2023-05-01"), // }, // 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}()), + // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); return t}()), // }, // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeCustom), // }, @@ -1827,57 +2130,64 @@ func ExampleExportsClient_GetExecutionHistory_exportRunHistoryGetByDepartment() // RootFolderPath: to.Ptr("ScheduledTestsForJohnDoe"), // }, // }, + // ExportDescription: to.Ptr("This is a test export."), + // PartitionData: to.Ptr(true), // }, + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), // 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}()), + // SubmittedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:15.6016681Z"); return t}()), // }, // }, // { - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12/departments/1234/providers/Microsoft.CostManagement/exports/JohnDoeSchedule/Run/11ac6811-dca3-46ad-b326-4704cf0c58ef"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/12/departments/1234/providers/Microsoft.CostManagement/exports/JohnDoeSchedule/Run/11ac6811-dca3-46ad-b326-4704cf0c58ef"), // Properties: &armcostmanagement.ExportRunProperties{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); return t}()), // 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}()), + // ManifestFile: to.Ptr("ScheduledTestsForJohnDoe/JohnDoeSchedule/20180729-20180804/manifestfile"), + // ProcessingEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T09:04:19.7223808Z"); return t}()), + // ProcessingStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T09:03:58.5710244Z"); return t}()), // RunSettings: &armcostmanagement.CommonExportProperties{ // Format: to.Ptr(armcostmanagement.FormatTypeCSV), + // CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + // DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), // 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), + // DataVersion: to.Ptr("2023-05-01"), // }, - // 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), + // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), // }, - // 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"), - // }, + // TimePeriod: &armcostmanagement.ExportTimePeriod{ + // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); 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}()), + // ExportDescription: to.Ptr("This is a test export."), + // PartitionData: to.Ptr(true), // }, - // }}, - // } + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), + // 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.5710244Z"); 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 +// Generated from example definition: 2025-03-01/ExportRunHistoryGetByEnrollmentAccount.json func ExampleExportsClient_GetExecutionHistory_exportRunHistoryGetByEnrollmentAccount() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -1895,33 +2205,33 @@ func ExampleExportsClient_GetExecutionHistory_exportRunHistoryGetByEnrollmentAcc // 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")}, + // res = armcostmanagement.ExportsClientGetExecutionHistoryResponse{ + // 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{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); return t}()), + // ExecutionType: to.Ptr(armcostmanagement.ExecutionTypeOnDemand), + // FileName: to.Ptr("ScheduledTestsForJohnDoe/JohnDoeSchedule/20180729-20180804/JohnDoeSchedule_1e25d58a-a3b0-4916-9542-6e04a89bc100.csv"), + // ManifestFile: to.Ptr("ScheduledTestsForJohnDoe/JohnDoeSchedule/20180729-20180804/manifestfile"), + // ProcessingEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:28.0373318Z"); return t}()), + // ProcessingStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:16.9123797Z"); return t}()), + // RunSettings: &armcostmanagement.CommonExportProperties{ + // Format: to.Ptr(armcostmanagement.FormatTypeCSV), + // CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + // DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), + // Definition: &armcostmanagement.ExportDefinition{ + // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), + // DataSet: &armcostmanagement.ExportDataset{ + // Configuration: &armcostmanagement.ExportDatasetConfiguration{ + // DataVersion: to.Ptr("2023-05-01"), // }, // 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}()), + // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); return t}()), // }, // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeCustom), // }, @@ -1932,57 +2242,64 @@ func ExampleExportsClient_GetExecutionHistory_exportRunHistoryGetByEnrollmentAcc // RootFolderPath: to.Ptr("ScheduledTestsForJohnDoe"), // }, // }, + // ExportDescription: to.Ptr("This is a test export."), + // PartitionData: to.Ptr(true), // }, + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), // 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}()), + // SubmittedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:15.6016681Z"); return t}()), // }, // }, // { - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456/providers/Microsoft.CostManagement/exports/JohnDoeSchedule/Run/11ac6811-dca3-46ad-b326-4704cf0c58ef"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456/providers/Microsoft.CostManagement/exports/JohnDoeSchedule/Run/11ac6811-dca3-46ad-b326-4704cf0c58ef"), // Properties: &armcostmanagement.ExportRunProperties{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); return t}()), // 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}()), + // ManifestFile: to.Ptr("ScheduledTestsForJohnDoe/JohnDoeSchedule/20180729-20180804/manifestfile"), + // ProcessingEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T09:04:19.7223808Z"); return t}()), + // ProcessingStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T09:03:58.5710244Z"); return t}()), // RunSettings: &armcostmanagement.CommonExportProperties{ // Format: to.Ptr(armcostmanagement.FormatTypeCSV), + // CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + // DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), // 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), + // DataVersion: to.Ptr("2023-05-01"), // }, - // 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), + // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), // }, - // 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"), - // }, + // TimePeriod: &armcostmanagement.ExportTimePeriod{ + // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); 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}()), + // ExportDescription: to.Ptr("This is a test export."), + // PartitionData: to.Ptr(true), // }, - // }}, - // } + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), + // 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.5710244Z"); 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 +// Generated from example definition: 2025-03-01/ExportRunHistoryGetByManagementGroup.json func ExampleExportsClient_GetExecutionHistory_exportRunHistoryGetByManagementGroup() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -2000,33 +2317,33 @@ func ExampleExportsClient_GetExecutionHistory_exportRunHistoryGetByManagementGro // 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")}, + // res = armcostmanagement.ExportsClientGetExecutionHistoryResponse{ + // 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{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); return t}()), + // ExecutionType: to.Ptr(armcostmanagement.ExecutionTypeOnDemand), + // FileName: to.Ptr("ScheduledForTestExport/TestExportSchedule/20180729-20180804/TestExportSchedule_1e25d58a-a3b0-4916-9542-6e04a89bc100.csv"), + // ManifestFile: to.Ptr("ScheduledTestsForJohnDoe/JohnDoeSchedule/20180729-20180804/manifestfile"), + // ProcessingEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:28.0373318Z"); return t}()), + // ProcessingStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:16.9123797Z"); return t}()), + // RunSettings: &armcostmanagement.CommonExportProperties{ + // Format: to.Ptr(armcostmanagement.FormatTypeCSV), + // CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + // DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), + // Definition: &armcostmanagement.ExportDefinition{ + // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), + // DataSet: &armcostmanagement.ExportDataset{ + // Configuration: &armcostmanagement.ExportDatasetConfiguration{ + // DataVersion: to.Ptr("2023-05-01"), // }, // 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}()), + // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); return t}()), // }, // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeCustom), // }, @@ -2037,57 +2354,64 @@ func ExampleExportsClient_GetExecutionHistory_exportRunHistoryGetByManagementGro // RootFolderPath: to.Ptr("ScheduledTestsForJohnDoe"), // }, // }, + // ExportDescription: to.Ptr("This is a test export."), + // PartitionData: to.Ptr(true), // }, + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), // 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}()), + // SubmittedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:15.6016681Z"); return t}()), // }, // }, // { - // ID: to.Ptr("providers/Microsoft.Management/managementGroups/TestMG/providers/Microsoft.CostManagement/exports/TestExport/Run/11ac6811-dca3-46ad-b326-4704cf0c58ef"), + // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/TestMG/providers/Microsoft.CostManagement/exports/TestExport/Run/11ac6811-dca3-46ad-b326-4704cf0c58ef"), // Properties: &armcostmanagement.ExportRunProperties{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); return t}()), // 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}()), + // ManifestFile: to.Ptr("ScheduledTestsForJohnDoe/JohnDoeSchedule/20180729-20180804/manifestfile"), + // ProcessingEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T09:04:19.7223808Z"); return t}()), + // ProcessingStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T09:03:58.5710244Z"); return t}()), // RunSettings: &armcostmanagement.CommonExportProperties{ // Format: to.Ptr(armcostmanagement.FormatTypeCSV), + // CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + // DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), // 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), + // DataVersion: to.Ptr("2023-05-01"), // }, - // 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), + // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), // }, - // 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"), - // }, + // TimePeriod: &armcostmanagement.ExportTimePeriod{ + // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); 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}()), + // ExportDescription: to.Ptr("This is a test export."), + // PartitionData: to.Ptr(true), // }, - // }}, - // } + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), + // 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.5710244Z"); 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 +// Generated from example definition: 2025-03-01/ExportRunHistoryGetByResourceGroup.json func ExampleExportsClient_GetExecutionHistory_exportRunHistoryGetByResourceGroup() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -2105,33 +2429,33 @@ func ExampleExportsClient_GetExecutionHistory_exportRunHistoryGetByResourceGroup // 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")}, + // res = armcostmanagement.ExportsClientGetExecutionHistoryResponse{ + // 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{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); return t}()), + // ExecutionType: to.Ptr(armcostmanagement.ExecutionTypeOnDemand), + // FileName: to.Ptr("ScheduledTestsForJohnDoe/JohnDoeSchedule/20180729-20180804/JohnDoeSchedule_1e25d58a-a3b0-4916-9542-6e04a89bc100.csv"), + // ManifestFile: to.Ptr("ScheduledTestsForJohnDoe/JohnDoeSchedule/20180729-20180804/manifestfile"), + // ProcessingEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:28.0373318Z"); return t}()), + // ProcessingStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:16.9123797Z"); return t}()), + // RunSettings: &armcostmanagement.CommonExportProperties{ + // Format: to.Ptr(armcostmanagement.FormatTypeCSV), + // CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + // DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), + // Definition: &armcostmanagement.ExportDefinition{ + // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), + // DataSet: &armcostmanagement.ExportDataset{ + // Configuration: &armcostmanagement.ExportDatasetConfiguration{ + // DataVersion: to.Ptr("2023-05-01"), // }, // 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}()), + // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); return t}()), // }, // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeCustom), // }, @@ -2142,57 +2466,64 @@ func ExampleExportsClient_GetExecutionHistory_exportRunHistoryGetByResourceGroup // RootFolderPath: to.Ptr("ScheduledTestsForJohnDoe"), // }, // }, + // ExportDescription: to.Ptr("This is a test export."), + // PartitionData: to.Ptr(true), // }, + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), // 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}()), + // SubmittedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:15.6016681Z"); return t}()), // }, // }, // { - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.CostManagement/exports/JohnDoeSchedule/Run/11ac6811-dca3-46ad-b326-4704cf0c58ef"), + // 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{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); return t}()), // 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}()), + // ManifestFile: to.Ptr("ScheduledTestsForJohnDoe/JohnDoeSchedule/20180729-20180804/manifestfile"), + // ProcessingEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T09:04:19.7223808Z"); return t}()), + // ProcessingStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T09:03:58.5710244Z"); return t}()), // RunSettings: &armcostmanagement.CommonExportProperties{ // Format: to.Ptr(armcostmanagement.FormatTypeCSV), + // CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + // DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), // 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), + // DataVersion: to.Ptr("2023-05-01"), // }, - // 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), + // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), // }, - // 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"), - // }, + // TimePeriod: &armcostmanagement.ExportTimePeriod{ + // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); 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}()), + // ExportDescription: to.Ptr("This is a test export."), + // PartitionData: to.Ptr(true), // }, - // }}, - // } + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), + // 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.5710244Z"); 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 +// Generated from example definition: 2025-03-01/ExportRunHistoryGetBySubscription.json func ExampleExportsClient_GetExecutionHistory_exportRunHistoryGetBySubscription() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -2210,33 +2541,33 @@ func ExampleExportsClient_GetExecutionHistory_exportRunHistoryGetBySubscription( // 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")}, + // res = armcostmanagement.ExportsClientGetExecutionHistoryResponse{ + // 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{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); return t}()), + // ExecutionType: to.Ptr(armcostmanagement.ExecutionTypeOnDemand), + // FileName: to.Ptr("ScheduledTestsForJohnDoe/JohnDoeSchedule/20180729-20180804/JohnDoeSchedule_1e25d58a-a3b0-4916-9542-6e04a89bc100.csv"), + // ManifestFile: to.Ptr("ScheduledTestsForJohnDoe/JohnDoeSchedule/20180729-20180804/manifestfile"), + // ProcessingEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:28.0373318Z"); return t}()), + // ProcessingStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:16.9123797Z"); return t}()), + // RunSettings: &armcostmanagement.CommonExportProperties{ + // Format: to.Ptr(armcostmanagement.FormatTypeCSV), + // CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + // DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), + // Definition: &armcostmanagement.ExportDefinition{ + // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), + // DataSet: &armcostmanagement.ExportDataset{ + // Configuration: &armcostmanagement.ExportDatasetConfiguration{ + // DataVersion: to.Ptr("2023-05-01"), // }, // 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}()), + // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); return t}()), // }, // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeCustom), // }, @@ -2247,52 +2578,757 @@ func ExampleExportsClient_GetExecutionHistory_exportRunHistoryGetBySubscription( // RootFolderPath: to.Ptr("ScheduledTestsForJohnDoe"), // }, // }, + // ExportDescription: to.Ptr("This is a test export."), + // PartitionData: to.Ptr(true), // }, + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), // 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}()), + // SubmittedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:15.6016681Z"); return t}()), // }, // }, // { - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/exports/JohnDoeSchedule/Run/11ac6811-dca3-46ad-b326-4704cf0c58ef"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/exports/JohnDoeSchedule/Run/11ac6811-dca3-46ad-b326-4704cf0c58ef"), // Properties: &armcostmanagement.ExportRunProperties{ + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); return t}()), // 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}()), + // ManifestFile: to.Ptr("ScheduledTestsForJohnDoe/JohnDoeSchedule/20180729-20180804/manifestfile"), + // ProcessingEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T09:04:19.7223808Z"); return t}()), + // ProcessingStartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T09:03:58.5710244Z"); return t}()), // RunSettings: &armcostmanagement.CommonExportProperties{ // Format: to.Ptr(armcostmanagement.FormatTypeCSV), + // CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + // DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), // 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), + // DataVersion: to.Ptr("2023-05-01"), // }, - // 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), + // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), // }, - // 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"), - // }, + // TimePeriod: &armcostmanagement.ExportTimePeriod{ + // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); 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}()), + // ExportDescription: to.Ptr("This is a test export."), + // PartitionData: to.Ptr(true), // }, - // }}, - // } + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), + // 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.5710244Z"); return t}()), + // }, + // }, + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01/ExportsGetByBillingAccount.json +func ExampleExportsClient_NewListPager_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) + } + pager := clientFactory.NewExportsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/123456", 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 = armcostmanagement.ExportsClientListResponse{ + // 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"), + // Identity: &armcostmanagement.SystemAssignedServiceIdentity{ + // Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // Location: to.Ptr("centralus"), + // Properties: &armcostmanagement.ExportProperties{ + // Format: to.Ptr(armcostmanagement.FormatTypeCSV), + // CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + // DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), + // Definition: &armcostmanagement.ExportDefinition{ + // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), + // DataSet: &armcostmanagement.ExportDataset{ + // Configuration: &armcostmanagement.ExportDatasetConfiguration{ + // DataVersion: to.Ptr("2023-05-01"), + // }, + // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + // }, + // TimePeriod: &armcostmanagement.ExportTimePeriod{ + // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); 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"), + // }, + // }, + // ExportDescription: to.Ptr("This is a test export."), + // PartitionData: to.Ptr(true), + // }, + // }, + // { + // Name: to.Ptr("TestExport2"), + // Type: to.Ptr("Microsoft.CostManagement/exports"), + // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/exports/TestExport2"), + // Identity: &armcostmanagement.SystemAssignedServiceIdentity{ + // Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // Location: to.Ptr("centralus"), + // Properties: &armcostmanagement.ExportProperties{ + // Format: to.Ptr(armcostmanagement.FormatTypeCSV), + // CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + // DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), + // Definition: &armcostmanagement.ExportDefinition{ + // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), + // DataSet: &armcostmanagement.ExportDataset{ + // Configuration: &armcostmanagement.ExportDatasetConfiguration{ + // DataVersion: to.Ptr("2023-05-01"), + // }, + // 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"), + // }, + // }, + // ExportDescription: to.Ptr("This is a test export."), + // PartitionData: to.Ptr(true), + // 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:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); return t}()), + // }, + // Status: to.Ptr(armcostmanagement.StatusTypeActive), + // }, + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2025-03-01/ExportsGetByDepartment.json +func ExampleExportsClient_NewListPager_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) + } + pager := clientFactory.NewExportsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12/departments/123", 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 = armcostmanagement.ExportsClientListResponse{ + // 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"), + // Identity: &armcostmanagement.SystemAssignedServiceIdentity{ + // Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // Location: to.Ptr("centralus"), + // Properties: &armcostmanagement.ExportProperties{ + // Format: to.Ptr(armcostmanagement.FormatTypeCSV), + // CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + // DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), + // Definition: &armcostmanagement.ExportDefinition{ + // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), + // DataSet: &armcostmanagement.ExportDataset{ + // Configuration: &armcostmanagement.ExportDatasetConfiguration{ + // DataVersion: to.Ptr("2023-05-01"), + // }, + // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + // }, + // TimePeriod: &armcostmanagement.ExportTimePeriod{ + // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); 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"), + // }, + // }, + // ExportDescription: to.Ptr("This is a test export."), + // PartitionData: to.Ptr(true), + // }, + // }, + // { + // 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"), + // Identity: &armcostmanagement.SystemAssignedServiceIdentity{ + // Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // Location: to.Ptr("centralus"), + // Properties: &armcostmanagement.ExportProperties{ + // Format: to.Ptr(armcostmanagement.FormatTypeCSV), + // CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + // DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), + // Definition: &armcostmanagement.ExportDefinition{ + // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), + // DataSet: &armcostmanagement.ExportDataset{ + // Configuration: &armcostmanagement.ExportDatasetConfiguration{ + // DataVersion: to.Ptr("2023-05-01"), + // }, + // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + // }, + // TimePeriod: &armcostmanagement.ExportTimePeriod{ + // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); 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"), + // }, + // }, + // ExportDescription: to.Ptr("This is a test export."), + // PartitionData: to.Ptr(true), + // 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:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); return t}()), + // }, + // Status: to.Ptr(armcostmanagement.StatusTypeActive), + // }, + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2025-03-01/ExportsGetByEnrollmentAccount.json +func ExampleExportsClient_NewListPager_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) + } + pager := clientFactory.NewExportsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456", 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 = armcostmanagement.ExportsClientListResponse{ + // 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"), + // Identity: &armcostmanagement.SystemAssignedServiceIdentity{ + // Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // Location: to.Ptr("centralus"), + // Properties: &armcostmanagement.ExportProperties{ + // Format: to.Ptr(armcostmanagement.FormatTypeCSV), + // CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + // DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), + // Definition: &armcostmanagement.ExportDefinition{ + // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), + // DataSet: &armcostmanagement.ExportDataset{ + // Configuration: &armcostmanagement.ExportDatasetConfiguration{ + // DataVersion: to.Ptr("2023-05-01"), + // }, + // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + // }, + // TimePeriod: &armcostmanagement.ExportTimePeriod{ + // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); 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"), + // }, + // }, + // ExportDescription: to.Ptr("This is a test export."), + // PartitionData: to.Ptr(true), + // }, + // }, + // { + // 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"), + // Identity: &armcostmanagement.SystemAssignedServiceIdentity{ + // Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // Location: to.Ptr("centralus"), + // Properties: &armcostmanagement.ExportProperties{ + // Format: to.Ptr(armcostmanagement.FormatTypeCSV), + // CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + // DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), + // Definition: &armcostmanagement.ExportDefinition{ + // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), + // DataSet: &armcostmanagement.ExportDataset{ + // Configuration: &armcostmanagement.ExportDatasetConfiguration{ + // DataVersion: to.Ptr("2023-05-01"), + // }, + // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + // }, + // TimePeriod: &armcostmanagement.ExportTimePeriod{ + // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); 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"), + // }, + // }, + // ExportDescription: to.Ptr("This is a test export."), + // PartitionData: to.Ptr(true), + // 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:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); return t}()), + // }, + // Status: to.Ptr(armcostmanagement.StatusTypeActive), + // }, + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2025-03-01/ExportsGetByManagementGroup.json +func ExampleExportsClient_NewListPager_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) + } + pager := clientFactory.NewExportsClient().NewListPager("providers/Microsoft.Management/managementGroups/TestMG", 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 = armcostmanagement.ExportsClientListResponse{ + // 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"), + // Identity: &armcostmanagement.SystemAssignedServiceIdentity{ + // Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // Location: to.Ptr("centralus"), + // Properties: &armcostmanagement.ExportProperties{ + // Format: to.Ptr(armcostmanagement.FormatTypeCSV), + // CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + // DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), + // Definition: &armcostmanagement.ExportDefinition{ + // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), + // DataSet: &armcostmanagement.ExportDataset{ + // Configuration: &armcostmanagement.ExportDatasetConfiguration{ + // DataVersion: to.Ptr("2023-05-01"), + // }, + // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + // }, + // TimePeriod: &armcostmanagement.ExportTimePeriod{ + // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); 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"), + // }, + // }, + // ExportDescription: to.Ptr("This is a test export."), + // PartitionData: to.Ptr(true), + // }, + // }, + // { + // Name: to.Ptr("TestExport2"), + // Type: to.Ptr("Microsoft.CostManagement/exports"), + // ID: to.Ptr("/providers/Microsoft.Management/managementGroups/TestMG/providers/Microsoft.CostManagement/exports/TestExport2"), + // Identity: &armcostmanagement.SystemAssignedServiceIdentity{ + // Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // Location: to.Ptr("centralus"), + // Properties: &armcostmanagement.ExportProperties{ + // Format: to.Ptr(armcostmanagement.FormatTypeCSV), + // CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + // DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), + // Definition: &armcostmanagement.ExportDefinition{ + // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), + // DataSet: &armcostmanagement.ExportDataset{ + // Configuration: &armcostmanagement.ExportDatasetConfiguration{ + // DataVersion: to.Ptr("2023-05-01"), + // }, + // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + // }, + // TimePeriod: &armcostmanagement.ExportTimePeriod{ + // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); 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"), + // }, + // }, + // ExportDescription: to.Ptr("This is a test export."), + // PartitionData: to.Ptr(true), + // 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:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); return t}()), + // }, + // Status: to.Ptr(armcostmanagement.StatusTypeActive), + // }, + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2025-03-01/ExportsGetByResourceGroup.json +func ExampleExportsClient_NewListPager_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) + } + pager := clientFactory.NewExportsClient().NewListPager("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 = armcostmanagement.ExportsClientListResponse{ + // 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"), + // Identity: &armcostmanagement.SystemAssignedServiceIdentity{ + // Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // Location: to.Ptr("centralus"), + // Properties: &armcostmanagement.ExportProperties{ + // Format: to.Ptr(armcostmanagement.FormatTypeCSV), + // CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + // DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), + // Definition: &armcostmanagement.ExportDefinition{ + // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), + // DataSet: &armcostmanagement.ExportDataset{ + // Configuration: &armcostmanagement.ExportDatasetConfiguration{ + // DataVersion: to.Ptr("2023-05-01"), + // }, + // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + // }, + // TimePeriod: &armcostmanagement.ExportTimePeriod{ + // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); 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"), + // }, + // }, + // ExportDescription: to.Ptr("This is a test export."), + // PartitionData: to.Ptr(true), + // }, + // }, + // { + // 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"), + // Identity: &armcostmanagement.SystemAssignedServiceIdentity{ + // Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // Location: to.Ptr("centralus"), + // Properties: &armcostmanagement.ExportProperties{ + // Format: to.Ptr(armcostmanagement.FormatTypeCSV), + // CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + // DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), + // Definition: &armcostmanagement.ExportDefinition{ + // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), + // DataSet: &armcostmanagement.ExportDataset{ + // Configuration: &armcostmanagement.ExportDatasetConfiguration{ + // DataVersion: to.Ptr("2023-05-01"), + // }, + // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + // }, + // TimePeriod: &armcostmanagement.ExportTimePeriod{ + // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); 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"), + // }, + // }, + // ExportDescription: to.Ptr("This is a test export."), + // PartitionData: to.Ptr(true), + // 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:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); return t}()), + // }, + // Status: to.Ptr(armcostmanagement.StatusTypeActive), + // }, + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2025-03-01/ExportsGetBySubscription.json +func ExampleExportsClient_NewListPager_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) + } + pager := clientFactory.NewExportsClient().NewListPager("subscriptions/00000000-0000-0000-0000-000000000000", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armcostmanagement.ExportsClientListResponse{ + // 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"), + // Identity: &armcostmanagement.SystemAssignedServiceIdentity{ + // Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // Location: to.Ptr("centralus"), + // Properties: &armcostmanagement.ExportProperties{ + // Format: to.Ptr(armcostmanagement.FormatTypeCSV), + // CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + // DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), + // Definition: &armcostmanagement.ExportDefinition{ + // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), + // DataSet: &armcostmanagement.ExportDataset{ + // Configuration: &armcostmanagement.ExportDatasetConfiguration{ + // DataVersion: to.Ptr("2023-05-01"), + // }, + // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + // }, + // TimePeriod: &armcostmanagement.ExportTimePeriod{ + // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); 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"), + // }, + // }, + // ExportDescription: to.Ptr("This is a test export."), + // PartitionData: to.Ptr(true), + // }, + // }, + // { + // Name: to.Ptr("TestExport2"), + // Type: to.Ptr("Microsoft.CostManagement/exports"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/exports/TestExport2"), + // Identity: &armcostmanagement.SystemAssignedServiceIdentity{ + // Type: to.Ptr(armcostmanagement.SystemAssignedServiceIdentityTypeSystemAssigned), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // Location: to.Ptr("centralus"), + // Properties: &armcostmanagement.ExportProperties{ + // Format: to.Ptr(armcostmanagement.FormatTypeCSV), + // CompressionMode: to.Ptr(armcostmanagement.CompressionModeTypeGzip), + // DataOverwriteBehavior: to.Ptr(armcostmanagement.DataOverwriteBehaviorTypeOverwritePreviousReport), + // Definition: &armcostmanagement.ExportDefinition{ + // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), + // DataSet: &armcostmanagement.ExportDataset{ + // Configuration: &armcostmanagement.ExportDatasetConfiguration{ + // DataVersion: to.Ptr("2023-05-01"), + // }, + // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + // }, + // TimePeriod: &armcostmanagement.ExportTimePeriod{ + // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); 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"), + // }, + // }, + // ExportDescription: to.Ptr("This is a test export."), + // PartitionData: to.Ptr(true), + // 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:00Z"); return t}()), + // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-30T00:00:00Z"); return t}()), + // }, + // Status: to.Ptr(armcostmanagement.StatusTypeActive), + // }, + // }, + // }, + // }, + // }, + // } + } } diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/alerts_server.go b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/alerts_server.go index 393f595ea794..80b93c733255 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/alerts_server.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/alerts_server.go @@ -1,7 +1,6 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -12,7 +11,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" @@ -22,32 +21,36 @@ import ( type AlertsServer struct { // Dismiss is the fake for method AlertsClient.Dismiss // HTTP status codes to indicate success: http.StatusOK - Dismiss func(ctx context.Context, scope string, alertID string, parameters armcostmanagement.DismissAlertPayload, options *armcostmanagement.AlertsClientDismissOptions) (resp azfake.Responder[armcostmanagement.AlertsClientDismissResponse], errResp azfake.ErrorResponder) + Dismiss func(ctx context.Context, scope string, alertID string, parameters armcostmanagement.DismissAlertPayload, options *armcostmanagement.AlertsClientDismissOptions) (resp azfake.Responder[armcostmanagement.AlertsClientDismissResponse], errResp azfake.ErrorResponder) // Get is the fake for method AlertsClient.Get // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, scope string, alertID string, options *armcostmanagement.AlertsClientGetOptions) (resp azfake.Responder[armcostmanagement.AlertsClientGetResponse], errResp azfake.ErrorResponder) + Get func(ctx context.Context, scope string, alertID string, options *armcostmanagement.AlertsClientGetOptions) (resp azfake.Responder[armcostmanagement.AlertsClientGetResponse], errResp azfake.ErrorResponder) - // List is the fake for method AlertsClient.List + // NewListPager is the fake for method AlertsClient.NewListPager // HTTP status codes to indicate success: http.StatusOK - List func(ctx context.Context, scope string, options *armcostmanagement.AlertsClientListOptions) (resp azfake.Responder[armcostmanagement.AlertsClientListResponse], errResp azfake.ErrorResponder) + NewListPager func(scope string, options *armcostmanagement.AlertsClientListOptions) (resp azfake.PagerResponder[armcostmanagement.AlertsClientListResponse]) // ListExternal is the fake for method AlertsClient.ListExternal // HTTP status codes to indicate success: http.StatusOK - ListExternal func(ctx context.Context, externalCloudProviderType armcostmanagement.ExternalCloudProviderType, externalCloudProviderID string, options *armcostmanagement.AlertsClientListExternalOptions) (resp azfake.Responder[armcostmanagement.AlertsClientListExternalResponse], errResp azfake.ErrorResponder) + ListExternal func(ctx context.Context, externalCloudProviderType armcostmanagement.ExternalCloudProviderType, externalCloudProviderID string, options *armcostmanagement.AlertsClientListExternalOptions) (resp azfake.Responder[armcostmanagement.AlertsClientListExternalResponse], errResp azfake.ErrorResponder) } // NewAlertsServerTransport creates a new instance of AlertsServerTransport with the provided implementation. // The returned AlertsServerTransport instance is connected to an instance of armcostmanagement.AlertsClient via the // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewAlertsServerTransport(srv *AlertsServer) *AlertsServerTransport { - return &AlertsServerTransport{srv: srv} + return &AlertsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armcostmanagement.AlertsClientListResponse]](), + } } // AlertsServerTransport connects instances of armcostmanagement.AlertsClient to instances of AlertsServer. // Don't use this type directly, use NewAlertsServerTransport instead. type AlertsServerTransport struct { - srv *AlertsServer + srv *AlertsServer + newListPager *tracker[azfake.PagerResponder[armcostmanagement.AlertsClientListResponse]] } // Do implements the policy.Transporter interface for AlertsServerTransport. @@ -58,27 +61,46 @@ func (a *AlertsServerTransport) Do(req *http.Request) (*http.Response, error) { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return a.dispatchToMethodFake(req, method) +} - switch method { - case "AlertsClient.Dismiss": - resp, err = a.dispatchDismiss(req) - case "AlertsClient.Get": - resp, err = a.dispatchGet(req) - case "AlertsClient.List": - resp, err = a.dispatchList(req) - case "AlertsClient.ListExternal": - resp, err = a.dispatchListExternal(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (a *AlertsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if alertsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = alertsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "AlertsClient.Dismiss": + res.resp, res.err = a.dispatchDismiss(req) + case "AlertsClient.Get": + res.resp, res.err = a.dispatchGet(req) + case "AlertsClient.NewListPager": + res.resp, res.err = a.dispatchNewListPager(req) + case "AlertsClient.ListExternal": + res.resp, res.err = a.dispatchListExternal(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (a *AlertsServerTransport) dispatchDismiss(req *http.Request) (*http.Response, error) { @@ -88,7 +110,7 @@ func (a *AlertsServerTransport) dispatchDismiss(req *http.Request) (*http.Respon const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/alerts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armcostmanagement.DismissAlertPayload](req) @@ -125,7 +147,7 @@ func (a *AlertsServerTransport) dispatchGet(req *http.Request) (*http.Response, const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/alerts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) @@ -151,31 +173,36 @@ func (a *AlertsServerTransport) dispatchGet(req *http.Request) (*http.Response, return resp, nil } -func (a *AlertsServerTransport) dispatchList(req *http.Request) (*http.Response, error) { - if a.srv.List == nil { - return nil, &nonRetriableError{errors.New("fake for method List not implemented")} - } - const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/alerts` - 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) +func (a *AlertsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if a.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := a.newListPager.get(req) + if newListPager == nil { + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/alerts` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if 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 + } + resp := a.srv.NewListPager(scopeParam, nil) + newListPager = &resp + a.newListPager.add(req, newListPager) } - scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) + resp, err := server.PagerResponderNext(newListPager, req) if err != nil { return nil, err } - respr, errRespr := a.srv.List(req.Context(), scopeParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr + if !contains([]int{http.StatusOK}, resp.StatusCode) { + a.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } - 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).AlertsResult, req) - if err != nil { - return nil, err + if !server.PagerResponderMore(newListPager) { + a.newListPager.remove(req) } return resp, nil } @@ -187,7 +214,7 @@ func (a *AlertsServerTransport) dispatchListExternal(req *http.Request) (*http.R const regexStr = `/providers/Microsoft\.CostManagement/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/alerts` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } externalCloudProviderTypeParam, err := parseWithCast(matches[regex.SubexpIndex("externalCloudProviderType")], func(v string) (armcostmanagement.ExternalCloudProviderType, error) { @@ -218,3 +245,9 @@ func (a *AlertsServerTransport) dispatchListExternal(req *http.Request) (*http.R } return resp, nil } + +// set this to conditionally intercept incoming requests to AlertsServerTransport +var alertsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/benefitrecommendations_server.go b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/benefitrecommendations_server.go index 0daf1a44b2b3..c51bfdbd4b67 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/benefitrecommendations_server.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/benefitrecommendations_server.go @@ -1,7 +1,6 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -12,7 +11,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" @@ -30,16 +29,16 @@ type BenefitRecommendationsServer struct { // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewBenefitRecommendationsServerTransport(srv *BenefitRecommendationsServer) *BenefitRecommendationsServerTransport { return &BenefitRecommendationsServerTransport{ - srv: srv, - newListPager: newTracker[azfake.PagerResponder[armcostmanagement.BenefitRecommendationsClientListResponse]](), + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armcostmanagement.BenefitRecommendationsClientListResponse]](), } } // BenefitRecommendationsServerTransport connects instances of armcostmanagement.BenefitRecommendationsClient to instances of BenefitRecommendationsServer. // Don't use this type directly, use NewBenefitRecommendationsServerTransport instead. type BenefitRecommendationsServerTransport struct { - srv *BenefitRecommendationsServer - newListPager *tracker[azfake.PagerResponder[armcostmanagement.BenefitRecommendationsClientListResponse]] + srv *BenefitRecommendationsServer + newListPager *tracker[azfake.PagerResponder[armcostmanagement.BenefitRecommendationsClientListResponse]] } // Do implements the policy.Transporter interface for BenefitRecommendationsServerTransport. @@ -50,21 +49,40 @@ func (b *BenefitRecommendationsServerTransport) Do(req *http.Request) (*http.Res return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return b.dispatchToMethodFake(req, method) +} - switch method { - case "BenefitRecommendationsClient.NewListPager": - resp, err = b.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (b *BenefitRecommendationsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if benefitRecommendationsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = benefitRecommendationsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "BenefitRecommendationsClient.NewListPager": + res.resp, res.err = b.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (b *BenefitRecommendationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { @@ -76,7 +94,7 @@ func (b *BenefitRecommendationsServerTransport) dispatchNewListPager(req *http.R const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/benefitRecommendations` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() @@ -102,9 +120,9 @@ func (b *BenefitRecommendationsServerTransport) dispatchNewListPager(req *http.R var options *armcostmanagement.BenefitRecommendationsClientListOptions if filterParam != nil || orderbyParam != nil || expandParam != nil { options = &armcostmanagement.BenefitRecommendationsClientListOptions{ - Filter: filterParam, - Orderby: orderbyParam, - Expand: expandParam, + Filter: filterParam, + Orderby: orderbyParam, + Expand: expandParam, } } resp := b.srv.NewListPager(billingScopeParam, options) @@ -127,3 +145,9 @@ func (b *BenefitRecommendationsServerTransport) dispatchNewListPager(req *http.R } return resp, nil } + +// set this to conditionally intercept incoming requests to BenefitRecommendationsServerTransport +var benefitRecommendationsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/benefitutilizationsummaries_server.go b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/benefitutilizationsummaries_server.go index c9779f3bae31..09046f55e7e8 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/benefitutilizationsummaries_server.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/benefitutilizationsummaries_server.go @@ -1,7 +1,6 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -12,7 +11,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" @@ -22,19 +21,19 @@ import ( type BenefitUtilizationSummariesServer struct { // NewListByBillingAccountIDPager is the fake for method BenefitUtilizationSummariesClient.NewListByBillingAccountIDPager // HTTP status codes to indicate success: http.StatusOK - NewListByBillingAccountIDPager func(billingAccountID string, options *armcostmanagement.BenefitUtilizationSummariesClientListByBillingAccountIDOptions) (resp azfake.PagerResponder[armcostmanagement.BenefitUtilizationSummariesClientListByBillingAccountIDResponse]) + NewListByBillingAccountIDPager func(billingAccountID string, options *armcostmanagement.BenefitUtilizationSummariesClientListByBillingAccountIDOptions) (resp azfake.PagerResponder[armcostmanagement.BenefitUtilizationSummariesClientListByBillingAccountIDResponse]) // NewListByBillingProfileIDPager is the fake for method BenefitUtilizationSummariesClient.NewListByBillingProfileIDPager // HTTP status codes to indicate success: http.StatusOK - NewListByBillingProfileIDPager func(billingAccountID string, billingProfileID string, options *armcostmanagement.BenefitUtilizationSummariesClientListByBillingProfileIDOptions) (resp azfake.PagerResponder[armcostmanagement.BenefitUtilizationSummariesClientListByBillingProfileIDResponse]) + NewListByBillingProfileIDPager func(billingAccountID string, billingProfileID string, options *armcostmanagement.BenefitUtilizationSummariesClientListByBillingProfileIDOptions) (resp azfake.PagerResponder[armcostmanagement.BenefitUtilizationSummariesClientListByBillingProfileIDResponse]) // NewListBySavingsPlanIDPager is the fake for method BenefitUtilizationSummariesClient.NewListBySavingsPlanIDPager // HTTP status codes to indicate success: http.StatusOK - NewListBySavingsPlanIDPager func(savingsPlanOrderID string, savingsPlanID string, options *armcostmanagement.BenefitUtilizationSummariesClientListBySavingsPlanIDOptions) (resp azfake.PagerResponder[armcostmanagement.BenefitUtilizationSummariesClientListBySavingsPlanIDResponse]) + NewListBySavingsPlanIDPager func(savingsPlanOrderID string, savingsPlanID string, options *armcostmanagement.BenefitUtilizationSummariesClientListBySavingsPlanIDOptions) (resp azfake.PagerResponder[armcostmanagement.BenefitUtilizationSummariesClientListBySavingsPlanIDResponse]) // NewListBySavingsPlanOrderPager is the fake for method BenefitUtilizationSummariesClient.NewListBySavingsPlanOrderPager // HTTP status codes to indicate success: http.StatusOK - NewListBySavingsPlanOrderPager func(savingsPlanOrderID string, options *armcostmanagement.BenefitUtilizationSummariesClientListBySavingsPlanOrderOptions) (resp azfake.PagerResponder[armcostmanagement.BenefitUtilizationSummariesClientListBySavingsPlanOrderResponse]) + NewListBySavingsPlanOrderPager func(savingsPlanOrderID string, options *armcostmanagement.BenefitUtilizationSummariesClientListBySavingsPlanOrderOptions) (resp azfake.PagerResponder[armcostmanagement.BenefitUtilizationSummariesClientListBySavingsPlanOrderResponse]) } // NewBenefitUtilizationSummariesServerTransport creates a new instance of BenefitUtilizationSummariesServerTransport with the provided implementation. @@ -42,22 +41,22 @@ type BenefitUtilizationSummariesServer struct { // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewBenefitUtilizationSummariesServerTransport(srv *BenefitUtilizationSummariesServer) *BenefitUtilizationSummariesServerTransport { return &BenefitUtilizationSummariesServerTransport{ - srv: srv, - newListByBillingAccountIDPager: newTracker[azfake.PagerResponder[armcostmanagement.BenefitUtilizationSummariesClientListByBillingAccountIDResponse]](), - newListByBillingProfileIDPager: newTracker[azfake.PagerResponder[armcostmanagement.BenefitUtilizationSummariesClientListByBillingProfileIDResponse]](), - newListBySavingsPlanIDPager: newTracker[azfake.PagerResponder[armcostmanagement.BenefitUtilizationSummariesClientListBySavingsPlanIDResponse]](), - newListBySavingsPlanOrderPager: newTracker[azfake.PagerResponder[armcostmanagement.BenefitUtilizationSummariesClientListBySavingsPlanOrderResponse]](), + srv: srv, + newListByBillingAccountIDPager: newTracker[azfake.PagerResponder[armcostmanagement.BenefitUtilizationSummariesClientListByBillingAccountIDResponse]](), + newListByBillingProfileIDPager: newTracker[azfake.PagerResponder[armcostmanagement.BenefitUtilizationSummariesClientListByBillingProfileIDResponse]](), + newListBySavingsPlanIDPager: newTracker[azfake.PagerResponder[armcostmanagement.BenefitUtilizationSummariesClientListBySavingsPlanIDResponse]](), + newListBySavingsPlanOrderPager: newTracker[azfake.PagerResponder[armcostmanagement.BenefitUtilizationSummariesClientListBySavingsPlanOrderResponse]](), } } // BenefitUtilizationSummariesServerTransport connects instances of armcostmanagement.BenefitUtilizationSummariesClient to instances of BenefitUtilizationSummariesServer. // Don't use this type directly, use NewBenefitUtilizationSummariesServerTransport instead. type BenefitUtilizationSummariesServerTransport struct { - srv *BenefitUtilizationSummariesServer - newListByBillingAccountIDPager *tracker[azfake.PagerResponder[armcostmanagement.BenefitUtilizationSummariesClientListByBillingAccountIDResponse]] - newListByBillingProfileIDPager *tracker[azfake.PagerResponder[armcostmanagement.BenefitUtilizationSummariesClientListByBillingProfileIDResponse]] - newListBySavingsPlanIDPager *tracker[azfake.PagerResponder[armcostmanagement.BenefitUtilizationSummariesClientListBySavingsPlanIDResponse]] - newListBySavingsPlanOrderPager *tracker[azfake.PagerResponder[armcostmanagement.BenefitUtilizationSummariesClientListBySavingsPlanOrderResponse]] + srv *BenefitUtilizationSummariesServer + newListByBillingAccountIDPager *tracker[azfake.PagerResponder[armcostmanagement.BenefitUtilizationSummariesClientListByBillingAccountIDResponse]] + newListByBillingProfileIDPager *tracker[azfake.PagerResponder[armcostmanagement.BenefitUtilizationSummariesClientListByBillingProfileIDResponse]] + newListBySavingsPlanIDPager *tracker[azfake.PagerResponder[armcostmanagement.BenefitUtilizationSummariesClientListBySavingsPlanIDResponse]] + newListBySavingsPlanOrderPager *tracker[azfake.PagerResponder[armcostmanagement.BenefitUtilizationSummariesClientListBySavingsPlanOrderResponse]] } // Do implements the policy.Transporter interface for BenefitUtilizationSummariesServerTransport. @@ -68,27 +67,46 @@ func (b *BenefitUtilizationSummariesServerTransport) Do(req *http.Request) (*htt return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return b.dispatchToMethodFake(req, method) +} - switch method { - case "BenefitUtilizationSummariesClient.NewListByBillingAccountIDPager": - resp, err = b.dispatchNewListByBillingAccountIDPager(req) - case "BenefitUtilizationSummariesClient.NewListByBillingProfileIDPager": - resp, err = b.dispatchNewListByBillingProfileIDPager(req) - case "BenefitUtilizationSummariesClient.NewListBySavingsPlanIDPager": - resp, err = b.dispatchNewListBySavingsPlanIDPager(req) - case "BenefitUtilizationSummariesClient.NewListBySavingsPlanOrderPager": - resp, err = b.dispatchNewListBySavingsPlanOrderPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (b *BenefitUtilizationSummariesServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if benefitUtilizationSummariesServerTransportInterceptor != nil { + res.resp, res.err, intercepted = benefitUtilizationSummariesServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "BenefitUtilizationSummariesClient.NewListByBillingAccountIDPager": + res.resp, res.err = b.dispatchNewListByBillingAccountIDPager(req) + case "BenefitUtilizationSummariesClient.NewListByBillingProfileIDPager": + res.resp, res.err = b.dispatchNewListByBillingProfileIDPager(req) + case "BenefitUtilizationSummariesClient.NewListBySavingsPlanIDPager": + res.resp, res.err = b.dispatchNewListBySavingsPlanIDPager(req) + case "BenefitUtilizationSummariesClient.NewListBySavingsPlanOrderPager": + res.resp, res.err = b.dispatchNewListBySavingsPlanOrderPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (b *BenefitUtilizationSummariesServerTransport) dispatchNewListByBillingAccountIDPager(req *http.Request) (*http.Response, error) { @@ -97,10 +115,10 @@ func (b *BenefitUtilizationSummariesServerTransport) dispatchNewListByBillingAcc } newListByBillingAccountIDPager := b.newListByBillingAccountIDPager.get(req) if newListByBillingAccountIDPager == nil { - const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/benefitUtilizationSummaries` + const regexStr = `/providers/microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/benefitUtilizationSummaries` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() @@ -121,8 +139,8 @@ func (b *BenefitUtilizationSummariesServerTransport) dispatchNewListByBillingAcc var options *armcostmanagement.BenefitUtilizationSummariesClientListByBillingAccountIDOptions if grainParameterParam != nil || filterParam != nil { options = &armcostmanagement.BenefitUtilizationSummariesClientListByBillingAccountIDOptions{ - GrainParameter: grainParameterParam, - Filter: filterParam, + GrainParameter: grainParameterParam, + Filter: filterParam, } } resp := b.srv.NewListByBillingAccountIDPager(billingAccountIDParam, options) @@ -152,10 +170,10 @@ func (b *BenefitUtilizationSummariesServerTransport) dispatchNewListByBillingPro } newListByBillingProfileIDPager := b.newListByBillingProfileIDPager.get(req) if newListByBillingProfileIDPager == nil { - const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/benefitUtilizationSummaries` + const regexStr = `/providers/microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/benefitUtilizationSummaries` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() @@ -180,8 +198,8 @@ func (b *BenefitUtilizationSummariesServerTransport) dispatchNewListByBillingPro var options *armcostmanagement.BenefitUtilizationSummariesClientListByBillingProfileIDOptions if grainParameterParam != nil || filterParam != nil { options = &armcostmanagement.BenefitUtilizationSummariesClientListByBillingProfileIDOptions{ - GrainParameter: grainParameterParam, - Filter: filterParam, + GrainParameter: grainParameterParam, + Filter: filterParam, } } resp := b.srv.NewListByBillingProfileIDPager(billingAccountIDParam, billingProfileIDParam, options) @@ -211,10 +229,10 @@ func (b *BenefitUtilizationSummariesServerTransport) dispatchNewListBySavingsPla } newListBySavingsPlanIDPager := b.newListBySavingsPlanIDPager.get(req) if newListBySavingsPlanIDPager == nil { - const regexStr = `/providers/Microsoft\.BillingBenefits/savingsPlanOrders/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/savingsPlans/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/benefitUtilizationSummaries` + const regexStr = `/providers/microsoft\.BillingBenefits/savingsPlanOrders/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/savingsPlans/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/benefitUtilizationSummaries` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() @@ -239,8 +257,8 @@ func (b *BenefitUtilizationSummariesServerTransport) dispatchNewListBySavingsPla var options *armcostmanagement.BenefitUtilizationSummariesClientListBySavingsPlanIDOptions if filterParam != nil || grainParameterParam != nil { options = &armcostmanagement.BenefitUtilizationSummariesClientListBySavingsPlanIDOptions{ - Filter: filterParam, - GrainParameter: grainParameterParam, + Filter: filterParam, + GrainParameter: grainParameterParam, } } resp := b.srv.NewListBySavingsPlanIDPager(savingsPlanOrderIDParam, savingsPlanIDParam, options) @@ -270,10 +288,10 @@ func (b *BenefitUtilizationSummariesServerTransport) dispatchNewListBySavingsPla } newListBySavingsPlanOrderPager := b.newListBySavingsPlanOrderPager.get(req) if newListBySavingsPlanOrderPager == nil { - const regexStr = `/providers/Microsoft\.BillingBenefits/savingsPlanOrders/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/benefitUtilizationSummaries` + const regexStr = `/providers/microsoft\.BillingBenefits/savingsPlanOrders/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/benefitUtilizationSummaries` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() @@ -294,8 +312,8 @@ func (b *BenefitUtilizationSummariesServerTransport) dispatchNewListBySavingsPla var options *armcostmanagement.BenefitUtilizationSummariesClientListBySavingsPlanOrderOptions if filterParam != nil || grainParameterParam != nil { options = &armcostmanagement.BenefitUtilizationSummariesClientListBySavingsPlanOrderOptions{ - Filter: filterParam, - GrainParameter: grainParameterParam, + Filter: filterParam, + GrainParameter: grainParameterParam, } } resp := b.srv.NewListBySavingsPlanOrderPager(savingsPlanOrderIDParam, options) @@ -318,3 +336,9 @@ func (b *BenefitUtilizationSummariesServerTransport) dispatchNewListBySavingsPla } return resp, nil } + +// set this to conditionally intercept incoming requests to BenefitUtilizationSummariesServerTransport +var benefitUtilizationSummariesServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/budgets_server.go b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/budgets_server.go new file mode 100644 index 000000000000..b35c2dfd1361 --- /dev/null +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/budgets_server.go @@ -0,0 +1,263 @@ +// 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) Go Code Generator. DO NOT EDIT. + +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")} + } + + return b.dispatchToMethodFake(req, method) +} + +func (b *BudgetsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if budgetsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = budgetsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "BudgetsClient.CreateOrUpdate": + res.resp, res.err = b.dispatchCreateOrUpdate(req) + case "BudgetsClient.Delete": + res.resp, res.err = b.dispatchDelete(req) + case "BudgetsClient.Get": + res.resp, res.err = b.dispatchGet(req) + case "BudgetsClient.NewListPager": + res.resp, res.err = b.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (b *BudgetsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + 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 len(matches) < 3 { + 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 len(matches) < 3 { + 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 len(matches) < 3 { + 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 len(matches) < 2 { + 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 +} + +// set this to conditionally intercept incoming requests to BudgetsServerTransport +var budgetsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/costallocationrules_server.go b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/costallocationrules_server.go new file mode 100644 index 000000000000..6d529a8ac14e --- /dev/null +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/costallocationrules_server.go @@ -0,0 +1,290 @@ +// 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) Go Code Generator. DO NOT EDIT. + +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")} + } + + return c.dispatchToMethodFake(req, method) +} + +func (c *CostAllocationRulesServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if costAllocationRulesServerTransportInterceptor != nil { + res.resp, res.err, intercepted = costAllocationRulesServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "CostAllocationRulesClient.CheckNameAvailability": + res.resp, res.err = c.dispatchCheckNameAvailability(req) + case "CostAllocationRulesClient.CreateOrUpdate": + res.resp, res.err = c.dispatchCreateOrUpdate(req) + case "CostAllocationRulesClient.Delete": + res.resp, res.err = c.dispatchDelete(req) + case "CostAllocationRulesClient.Get": + res.resp, res.err = c.dispatchGet(req) + case "CostAllocationRulesClient.NewListPager": + res.resp, res.err = c.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (c *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 len(matches) < 2 { + 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 len(matches) < 3 { + 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 len(matches) < 3 { + 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 len(matches) < 3 { + 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 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 + } + 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 +} + +// set this to conditionally intercept incoming requests to CostAllocationRulesServerTransport +var costAllocationRulesServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/dimensions_server.go b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/dimensions_server.go index 7b902ad0e01b..cd3ecea470cb 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/dimensions_server.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/dimensions_server.go @@ -1,7 +1,6 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -11,7 +10,8 @@ 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/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v3" "net/http" "net/url" "regexp" @@ -22,11 +22,11 @@ import ( type DimensionsServer struct { // NewByExternalCloudProviderTypePager is the fake for method DimensionsClient.NewByExternalCloudProviderTypePager // HTTP status codes to indicate success: http.StatusOK - NewByExternalCloudProviderTypePager func(externalCloudProviderType armcostmanagement.ExternalCloudProviderType, externalCloudProviderID string, options *armcostmanagement.DimensionsClientByExternalCloudProviderTypeOptions) (resp azfake.PagerResponder[armcostmanagement.DimensionsClientByExternalCloudProviderTypeResponse]) + NewByExternalCloudProviderTypePager func(externalCloudProviderType armcostmanagement.ExternalCloudProviderType, externalCloudProviderID string, options *armcostmanagement.DimensionsClientByExternalCloudProviderTypeOptions) (resp azfake.PagerResponder[armcostmanagement.DimensionsClientByExternalCloudProviderTypeResponse]) // NewListPager is the fake for method DimensionsClient.NewListPager // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent - NewListPager func(scope string, options *armcostmanagement.DimensionsClientListOptions) (resp azfake.PagerResponder[armcostmanagement.DimensionsClientListResponse]) + NewListPager func(scope string, options *armcostmanagement.DimensionsClientListOptions) (resp azfake.PagerResponder[armcostmanagement.DimensionsClientListResponse]) } // NewDimensionsServerTransport creates a new instance of DimensionsServerTransport with the provided implementation. @@ -34,18 +34,18 @@ type DimensionsServer struct { // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewDimensionsServerTransport(srv *DimensionsServer) *DimensionsServerTransport { return &DimensionsServerTransport{ - srv: srv, - newByExternalCloudProviderTypePager: newTracker[azfake.PagerResponder[armcostmanagement.DimensionsClientByExternalCloudProviderTypeResponse]](), - newListPager: newTracker[azfake.PagerResponder[armcostmanagement.DimensionsClientListResponse]](), + srv: srv, + newByExternalCloudProviderTypePager: newTracker[azfake.PagerResponder[armcostmanagement.DimensionsClientByExternalCloudProviderTypeResponse]](), + newListPager: newTracker[azfake.PagerResponder[armcostmanagement.DimensionsClientListResponse]](), } } // DimensionsServerTransport connects instances of armcostmanagement.DimensionsClient to instances of DimensionsServer. // Don't use this type directly, use NewDimensionsServerTransport instead. type DimensionsServerTransport struct { - srv *DimensionsServer - newByExternalCloudProviderTypePager *tracker[azfake.PagerResponder[armcostmanagement.DimensionsClientByExternalCloudProviderTypeResponse]] - newListPager *tracker[azfake.PagerResponder[armcostmanagement.DimensionsClientListResponse]] + srv *DimensionsServer + newByExternalCloudProviderTypePager *tracker[azfake.PagerResponder[armcostmanagement.DimensionsClientByExternalCloudProviderTypeResponse]] + newListPager *tracker[azfake.PagerResponder[armcostmanagement.DimensionsClientListResponse]] } // Do implements the policy.Transporter interface for DimensionsServerTransport. @@ -56,23 +56,42 @@ func (d *DimensionsServerTransport) Do(req *http.Request) (*http.Response, error return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return d.dispatchToMethodFake(req, method) +} - switch method { - case "DimensionsClient.NewByExternalCloudProviderTypePager": - resp, err = d.dispatchNewByExternalCloudProviderTypePager(req) - case "DimensionsClient.NewListPager": - resp, err = d.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (d *DimensionsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if dimensionsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = dimensionsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "DimensionsClient.NewByExternalCloudProviderTypePager": + res.resp, res.err = d.dispatchNewByExternalCloudProviderTypePager(req) + case "DimensionsClient.NewListPager": + res.resp, res.err = d.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (d *DimensionsServerTransport) dispatchNewByExternalCloudProviderTypePager(req *http.Request) (*http.Response, error) { @@ -84,7 +103,7 @@ func (d *DimensionsServerTransport) dispatchNewByExternalCloudProviderTypePager( const regexStr = `/providers/Microsoft\.CostManagement/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/dimensions` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() @@ -134,15 +153,18 @@ func (d *DimensionsServerTransport) dispatchNewByExternalCloudProviderTypePager( var options *armcostmanagement.DimensionsClientByExternalCloudProviderTypeOptions if filterParam != nil || expandParam != nil || skiptokenParam != nil || topParam != nil { options = &armcostmanagement.DimensionsClientByExternalCloudProviderTypeOptions{ - Filter: filterParam, - Expand: expandParam, - Skiptoken: skiptokenParam, - Top: topParam, + Filter: filterParam, + Expand: expandParam, + Skiptoken: skiptokenParam, + Top: topParam, } } resp := d.srv.NewByExternalCloudProviderTypePager(externalCloudProviderTypeParam, externalCloudProviderIDParam, options) newByExternalCloudProviderTypePager = &resp d.newByExternalCloudProviderTypePager.add(req, newByExternalCloudProviderTypePager) + server.PagerResponderInjectNextLinks(newByExternalCloudProviderTypePager, req, func(page *armcostmanagement.DimensionsClientByExternalCloudProviderTypeResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) } resp, err := server.PagerResponderNext(newByExternalCloudProviderTypePager, req) if err != nil { @@ -167,7 +189,7 @@ func (d *DimensionsServerTransport) dispatchNewListPager(req *http.Request) (*ht const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/dimensions` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() @@ -207,15 +229,18 @@ func (d *DimensionsServerTransport) dispatchNewListPager(req *http.Request) (*ht var options *armcostmanagement.DimensionsClientListOptions if filterParam != nil || expandParam != nil || skiptokenParam != nil || topParam != nil { options = &armcostmanagement.DimensionsClientListOptions{ - Filter: filterParam, - Expand: expandParam, - Skiptoken: skiptokenParam, - Top: topParam, + Filter: filterParam, + Expand: expandParam, + Skiptoken: skiptokenParam, + Top: topParam, } } resp := d.srv.NewListPager(scopeParam, options) newListPager = &resp d.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armcostmanagement.DimensionsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) } resp, err := server.PagerResponderNext(newListPager, req) if err != nil { @@ -230,3 +255,9 @@ func (d *DimensionsServerTransport) dispatchNewListPager(req *http.Request) (*ht } return resp, nil } + +// set this to conditionally intercept incoming requests to DimensionsServerTransport +var dimensionsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/exports_server.go b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/exports_server.go index 6168ddc1793a..077c7cfc181f 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/exports_server.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/exports_server.go @@ -1,7 +1,6 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -12,9 +11,10 @@ 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" + "reflect" "regexp" ) @@ -22,40 +22,44 @@ import ( type ExportsServer struct { // CreateOrUpdate is the fake for method ExportsClient.CreateOrUpdate // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - CreateOrUpdate func(ctx context.Context, scope string, exportName string, parameters armcostmanagement.Export, options *armcostmanagement.ExportsClientCreateOrUpdateOptions) (resp azfake.Responder[armcostmanagement.ExportsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + CreateOrUpdate func(ctx context.Context, scope string, exportName string, parameters armcostmanagement.Export, options *armcostmanagement.ExportsClientCreateOrUpdateOptions) (resp azfake.Responder[armcostmanagement.ExportsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) // Delete is the fake for method ExportsClient.Delete // HTTP status codes to indicate success: http.StatusOK - Delete func(ctx context.Context, scope string, exportName string, options *armcostmanagement.ExportsClientDeleteOptions) (resp azfake.Responder[armcostmanagement.ExportsClientDeleteResponse], errResp azfake.ErrorResponder) + Delete func(ctx context.Context, scope string, exportName string, options *armcostmanagement.ExportsClientDeleteOptions) (resp azfake.Responder[armcostmanagement.ExportsClientDeleteResponse], errResp azfake.ErrorResponder) // Execute is the fake for method ExportsClient.Execute // HTTP status codes to indicate success: http.StatusOK - Execute func(ctx context.Context, scope string, exportName string, options *armcostmanagement.ExportsClientExecuteOptions) (resp azfake.Responder[armcostmanagement.ExportsClientExecuteResponse], errResp azfake.ErrorResponder) + Execute func(ctx context.Context, scope string, exportName string, options *armcostmanagement.ExportsClientExecuteOptions) (resp azfake.Responder[armcostmanagement.ExportsClientExecuteResponse], errResp azfake.ErrorResponder) // Get is the fake for method ExportsClient.Get // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, scope string, exportName string, options *armcostmanagement.ExportsClientGetOptions) (resp azfake.Responder[armcostmanagement.ExportsClientGetResponse], errResp azfake.ErrorResponder) + Get func(ctx context.Context, scope string, exportName string, options *armcostmanagement.ExportsClientGetOptions) (resp azfake.Responder[armcostmanagement.ExportsClientGetResponse], errResp azfake.ErrorResponder) // GetExecutionHistory is the fake for method ExportsClient.GetExecutionHistory // HTTP status codes to indicate success: http.StatusOK - GetExecutionHistory func(ctx context.Context, scope string, exportName string, options *armcostmanagement.ExportsClientGetExecutionHistoryOptions) (resp azfake.Responder[armcostmanagement.ExportsClientGetExecutionHistoryResponse], errResp azfake.ErrorResponder) + GetExecutionHistory func(ctx context.Context, scope string, exportName string, options *armcostmanagement.ExportsClientGetExecutionHistoryOptions) (resp azfake.Responder[armcostmanagement.ExportsClientGetExecutionHistoryResponse], errResp azfake.ErrorResponder) - // List is the fake for method ExportsClient.List + // NewListPager is the fake for method ExportsClient.NewListPager // HTTP status codes to indicate success: http.StatusOK - List func(ctx context.Context, scope string, options *armcostmanagement.ExportsClientListOptions) (resp azfake.Responder[armcostmanagement.ExportsClientListResponse], errResp azfake.ErrorResponder) + NewListPager func(scope string, options *armcostmanagement.ExportsClientListOptions) (resp azfake.PagerResponder[armcostmanagement.ExportsClientListResponse]) } // NewExportsServerTransport creates a new instance of ExportsServerTransport with the provided implementation. // The returned ExportsServerTransport instance is connected to an instance of armcostmanagement.ExportsClient via the // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewExportsServerTransport(srv *ExportsServer) *ExportsServerTransport { - return &ExportsServerTransport{srv: srv} + return &ExportsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armcostmanagement.ExportsClientListResponse]](), + } } // ExportsServerTransport connects instances of armcostmanagement.ExportsClient to instances of ExportsServer. // Don't use this type directly, use NewExportsServerTransport instead. type ExportsServerTransport struct { - srv *ExportsServer + srv *ExportsServer + newListPager *tracker[azfake.PagerResponder[armcostmanagement.ExportsClientListResponse]] } // Do implements the policy.Transporter interface for ExportsServerTransport. @@ -66,31 +70,50 @@ func (e *ExportsServerTransport) Do(req *http.Request) (*http.Response, error) { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return e.dispatchToMethodFake(req, method) +} - switch method { - case "ExportsClient.CreateOrUpdate": - resp, err = e.dispatchCreateOrUpdate(req) - case "ExportsClient.Delete": - resp, err = e.dispatchDelete(req) - case "ExportsClient.Execute": - resp, err = e.dispatchExecute(req) - case "ExportsClient.Get": - resp, err = e.dispatchGet(req) - case "ExportsClient.GetExecutionHistory": - resp, err = e.dispatchGetExecutionHistory(req) - case "ExportsClient.List": - resp, err = e.dispatchList(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (e *ExportsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if exportsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = exportsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ExportsClient.CreateOrUpdate": + res.resp, res.err = e.dispatchCreateOrUpdate(req) + case "ExportsClient.Delete": + res.resp, res.err = e.dispatchDelete(req) + case "ExportsClient.Execute": + res.resp, res.err = e.dispatchExecute(req) + case "ExportsClient.Get": + res.resp, res.err = e.dispatchGet(req) + case "ExportsClient.GetExecutionHistory": + res.resp, res.err = e.dispatchGetExecutionHistory(req) + case "ExportsClient.NewListPager": + res.resp, res.err = e.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (e *ExportsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -100,7 +123,7 @@ func (e *ExportsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*htt const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/exports/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armcostmanagement.Export](req) @@ -137,7 +160,7 @@ func (e *ExportsServerTransport) dispatchDelete(req *http.Request) (*http.Respon const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/exports/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) @@ -170,9 +193,13 @@ func (e *ExportsServerTransport) dispatchExecute(req *http.Request) (*http.Respo const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/exports/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/run` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } + body, err := server.UnmarshalRequestAsJSON[armcostmanagement.ExportRunRequest](req) + if err != nil { + return nil, err + } scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) if err != nil { return nil, err @@ -181,7 +208,13 @@ func (e *ExportsServerTransport) dispatchExecute(req *http.Request) (*http.Respo if err != nil { return nil, err } - respr, errRespr := e.srv.Execute(req.Context(), scopeParam, exportNameParam, nil) + var options *armcostmanagement.ExportsClientExecuteOptions + if !reflect.ValueOf(body).IsZero() { + options = &armcostmanagement.ExportsClientExecuteOptions{ + Parameters: &body, + } + } + respr, errRespr := e.srv.Execute(req.Context(), scopeParam, exportNameParam, options) if respErr := server.GetError(errRespr, req); respErr != nil { return nil, respErr } @@ -203,7 +236,7 @@ func (e *ExportsServerTransport) dispatchGet(req *http.Request) (*http.Response, const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/exports/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() @@ -248,7 +281,7 @@ func (e *ExportsServerTransport) dispatchGetExecutionHistory(req *http.Request) const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/exports/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/runHistory` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) @@ -274,43 +307,54 @@ func (e *ExportsServerTransport) dispatchGetExecutionHistory(req *http.Request) return resp, nil } -func (e *ExportsServerTransport) dispatchList(req *http.Request) (*http.Response, error) { - if e.srv.List == nil { - return nil, &nonRetriableError{errors.New("fake for method List not implemented")} - } - const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/exports` - 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 +func (e *ExportsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if e.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := e.newListPager.get(req) + if newListPager == nil { + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/exports` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if len(matches) < 2 { + 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 + } + expandUnescaped, err := url.QueryUnescape(qp.Get("$expand")) + if err != nil { + return nil, err + } + expandParam := getOptional(expandUnescaped) + var options *armcostmanagement.ExportsClientListOptions + if expandParam != nil { + options = &armcostmanagement.ExportsClientListOptions{ + Expand: expandParam, + } + } + resp := e.srv.NewListPager(scopeParam, options) + newListPager = &resp + e.newListPager.add(req, newListPager) } - expandUnescaped, err := url.QueryUnescape(qp.Get("$expand")) + resp, err := server.PagerResponderNext(newListPager, req) if err != nil { return nil, err } - expandParam := getOptional(expandUnescaped) - var options *armcostmanagement.ExportsClientListOptions - if expandParam != nil { - options = &armcostmanagement.ExportsClientListOptions{ - Expand: expandParam, - } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + e.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } - respr, errRespr := e.srv.List(req.Context(), scopeParam, options) - 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).ExportListResult, req) - if err != nil { - return nil, err + if !server.PagerResponderMore(newListPager) { + e.newListPager.remove(req) } return resp, nil } + +// set this to conditionally intercept incoming requests to ExportsServerTransport +var exportsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/forecast_server.go b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/forecast_server.go index a34dca6ffa59..8ed8fb28b6f1 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/forecast_server.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/forecast_server.go @@ -1,7 +1,6 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -12,7 +11,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" @@ -22,11 +21,11 @@ import ( type ForecastServer struct { // ExternalCloudProviderUsage is the fake for method ForecastClient.ExternalCloudProviderUsage // HTTP status codes to indicate success: http.StatusOK - ExternalCloudProviderUsage func(ctx context.Context, externalCloudProviderType armcostmanagement.ExternalCloudProviderType, externalCloudProviderID string, parameters armcostmanagement.ForecastDefinition, options *armcostmanagement.ForecastClientExternalCloudProviderUsageOptions) (resp azfake.Responder[armcostmanagement.ForecastClientExternalCloudProviderUsageResponse], errResp azfake.ErrorResponder) + ExternalCloudProviderUsage func(ctx context.Context, externalCloudProviderType armcostmanagement.ExternalCloudProviderType, externalCloudProviderID string, parameters armcostmanagement.ForecastDefinition, options *armcostmanagement.ForecastClientExternalCloudProviderUsageOptions) (resp azfake.Responder[armcostmanagement.ForecastClientExternalCloudProviderUsageResponse], errResp azfake.ErrorResponder) // Usage is the fake for method ForecastClient.Usage // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent - Usage func(ctx context.Context, scope string, parameters armcostmanagement.ForecastDefinition, options *armcostmanagement.ForecastClientUsageOptions) (resp azfake.Responder[armcostmanagement.ForecastClientUsageResponse], errResp azfake.ErrorResponder) + Usage func(ctx context.Context, scope string, parameters armcostmanagement.ForecastDefinition, options *armcostmanagement.ForecastClientUsageOptions) (resp azfake.Responder[armcostmanagement.ForecastClientUsageResponse], errResp azfake.ErrorResponder) } // NewForecastServerTransport creates a new instance of ForecastServerTransport with the provided implementation. @@ -50,23 +49,42 @@ func (f *ForecastServerTransport) Do(req *http.Request) (*http.Response, error) return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return f.dispatchToMethodFake(req, method) +} - switch method { - case "ForecastClient.ExternalCloudProviderUsage": - resp, err = f.dispatchExternalCloudProviderUsage(req) - case "ForecastClient.Usage": - resp, err = f.dispatchUsage(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (f *ForecastServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if forecastServerTransportInterceptor != nil { + res.resp, res.err, intercepted = forecastServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ForecastClient.ExternalCloudProviderUsage": + res.resp, res.err = f.dispatchExternalCloudProviderUsage(req) + case "ForecastClient.Usage": + res.resp, res.err = f.dispatchUsage(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (f *ForecastServerTransport) dispatchExternalCloudProviderUsage(req *http.Request) (*http.Response, error) { @@ -76,7 +94,7 @@ func (f *ForecastServerTransport) dispatchExternalCloudProviderUsage(req *http.R const regexStr = `/providers/Microsoft\.CostManagement/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/forecast` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() @@ -131,7 +149,7 @@ func (f *ForecastServerTransport) dispatchUsage(req *http.Request) (*http.Respon const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/forecast` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() @@ -168,3 +186,9 @@ func (f *ForecastServerTransport) dispatchUsage(req *http.Request) (*http.Respon } return resp, nil } + +// set this to conditionally intercept incoming requests to ForecastServerTransport +var forecastServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatebenefitutilizationsummariesreport_server.go b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatebenefitutilizationsummariesreport_server.go new file mode 100644 index 000000000000..2231b3992922 --- /dev/null +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatebenefitutilizationsummariesreport_server.go @@ -0,0 +1,408 @@ +// 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) Go Code Generator. DO NOT EDIT. + +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")} + } + + return g.dispatchToMethodFake(req, method) +} + +func (g *GenerateBenefitUtilizationSummariesReportServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if generateBenefitUtilizationSummariesReportServerTransportInterceptor != nil { + res.resp, res.err, intercepted = generateBenefitUtilizationSummariesReportServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByBillingAccount": + res.resp, res.err = g.dispatchBeginGenerateByBillingAccount(req) + case "GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByBillingProfile": + res.resp, res.err = g.dispatchBeginGenerateByBillingProfile(req) + case "GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByReservationID": + res.resp, res.err = g.dispatchBeginGenerateByReservationID(req) + case "GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByReservationOrderID": + res.resp, res.err = g.dispatchBeginGenerateByReservationOrderID(req) + case "GenerateBenefitUtilizationSummariesReportClient.BeginGenerateBySavingsPlanID": + res.resp, res.err = g.dispatchBeginGenerateBySavingsPlanID(req) + case "GenerateBenefitUtilizationSummariesReportClient.BeginGenerateBySavingsPlanOrderID": + res.resp, res.err = g.dispatchBeginGenerateBySavingsPlanOrderID(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (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 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 + } + 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 len(matches) < 3 { + 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 len(matches) < 3 { + 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 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 + } + 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 len(matches) < 3 { + 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 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 + } + 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 +} + +// set this to conditionally intercept incoming requests to GenerateBenefitUtilizationSummariesReportServerTransport +var generateBenefitUtilizationSummariesReportServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatecostdetailsreport_server.go b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatecostdetailsreport_server.go index 87bb1a582cd8..193d75ce0e9c 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatecostdetailsreport_server.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatecostdetailsreport_server.go @@ -1,7 +1,6 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -12,7 +11,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" @@ -22,11 +21,11 @@ import ( type GenerateCostDetailsReportServer struct { // BeginCreateOperation is the fake for method GenerateCostDetailsReportClient.BeginCreateOperation // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent - BeginCreateOperation func(ctx context.Context, scope string, parameters armcostmanagement.GenerateCostDetailsReportRequestDefinition, options *armcostmanagement.GenerateCostDetailsReportClientBeginCreateOperationOptions) (resp azfake.PollerResponder[armcostmanagement.GenerateCostDetailsReportClientCreateOperationResponse], errResp azfake.ErrorResponder) + BeginCreateOperation func(ctx context.Context, scope string, parameters armcostmanagement.GenerateCostDetailsReportRequestDefinition, options *armcostmanagement.GenerateCostDetailsReportClientBeginCreateOperationOptions) (resp azfake.PollerResponder[armcostmanagement.GenerateCostDetailsReportClientCreateOperationResponse], errResp azfake.ErrorResponder) // BeginGetOperationResults is the fake for method GenerateCostDetailsReportClient.BeginGetOperationResults // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted - BeginGetOperationResults func(ctx context.Context, scope string, operationID string, options *armcostmanagement.GenerateCostDetailsReportClientBeginGetOperationResultsOptions) (resp azfake.PollerResponder[armcostmanagement.GenerateCostDetailsReportClientGetOperationResultsResponse], errResp azfake.ErrorResponder) + BeginGetOperationResults func(ctx context.Context, scope string, operationID string, options *armcostmanagement.GenerateCostDetailsReportClientBeginGetOperationResultsOptions) (resp azfake.PollerResponder[armcostmanagement.GenerateCostDetailsReportClientGetOperationResultsResponse], errResp azfake.ErrorResponder) } // NewGenerateCostDetailsReportServerTransport creates a new instance of GenerateCostDetailsReportServerTransport with the provided implementation. @@ -34,18 +33,18 @@ type GenerateCostDetailsReportServer struct { // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewGenerateCostDetailsReportServerTransport(srv *GenerateCostDetailsReportServer) *GenerateCostDetailsReportServerTransport { return &GenerateCostDetailsReportServerTransport{ - srv: srv, - beginCreateOperation: newTracker[azfake.PollerResponder[armcostmanagement.GenerateCostDetailsReportClientCreateOperationResponse]](), - beginGetOperationResults: newTracker[azfake.PollerResponder[armcostmanagement.GenerateCostDetailsReportClientGetOperationResultsResponse]](), + srv: srv, + beginCreateOperation: newTracker[azfake.PollerResponder[armcostmanagement.GenerateCostDetailsReportClientCreateOperationResponse]](), + beginGetOperationResults: newTracker[azfake.PollerResponder[armcostmanagement.GenerateCostDetailsReportClientGetOperationResultsResponse]](), } } // GenerateCostDetailsReportServerTransport connects instances of armcostmanagement.GenerateCostDetailsReportClient to instances of GenerateCostDetailsReportServer. // Don't use this type directly, use NewGenerateCostDetailsReportServerTransport instead. type GenerateCostDetailsReportServerTransport struct { - srv *GenerateCostDetailsReportServer - beginCreateOperation *tracker[azfake.PollerResponder[armcostmanagement.GenerateCostDetailsReportClientCreateOperationResponse]] - beginGetOperationResults *tracker[azfake.PollerResponder[armcostmanagement.GenerateCostDetailsReportClientGetOperationResultsResponse]] + srv *GenerateCostDetailsReportServer + beginCreateOperation *tracker[azfake.PollerResponder[armcostmanagement.GenerateCostDetailsReportClientCreateOperationResponse]] + beginGetOperationResults *tracker[azfake.PollerResponder[armcostmanagement.GenerateCostDetailsReportClientGetOperationResultsResponse]] } // Do implements the policy.Transporter interface for GenerateCostDetailsReportServerTransport. @@ -56,23 +55,42 @@ func (g *GenerateCostDetailsReportServerTransport) Do(req *http.Request) (*http. return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return g.dispatchToMethodFake(req, method) +} - switch method { - case "GenerateCostDetailsReportClient.BeginCreateOperation": - resp, err = g.dispatchBeginCreateOperation(req) - case "GenerateCostDetailsReportClient.BeginGetOperationResults": - resp, err = g.dispatchBeginGetOperationResults(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (g *GenerateCostDetailsReportServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if generateCostDetailsReportServerTransportInterceptor != nil { + res.resp, res.err, intercepted = generateCostDetailsReportServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "GenerateCostDetailsReportClient.BeginCreateOperation": + res.resp, res.err = g.dispatchBeginCreateOperation(req) + case "GenerateCostDetailsReportClient.BeginGetOperationResults": + res.resp, res.err = g.dispatchBeginGetOperationResults(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (g *GenerateCostDetailsReportServerTransport) dispatchBeginCreateOperation(req *http.Request) (*http.Response, error) { @@ -84,7 +102,7 @@ func (g *GenerateCostDetailsReportServerTransport) dispatchBeginCreateOperation( const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/generateCostDetailsReport` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armcostmanagement.GenerateCostDetailsReportRequestDefinition](req) @@ -128,7 +146,7 @@ func (g *GenerateCostDetailsReportServerTransport) dispatchBeginGetOperationResu const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/costDetailsOperationResults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) @@ -162,3 +180,9 @@ func (g *GenerateCostDetailsReportServerTransport) dispatchBeginGetOperationResu return resp, nil } + +// set this to conditionally intercept incoming requests to GenerateCostDetailsReportServerTransport +var generateCostDetailsReportServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatedetailedcostreport_server.go b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatedetailedcostreport_server.go index 1d34d03a83b9..be8a4e5f455c 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatedetailedcostreport_server.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatedetailedcostreport_server.go @@ -1,7 +1,6 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -12,7 +11,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" @@ -30,16 +29,16 @@ type GenerateDetailedCostReportServer struct { // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewGenerateDetailedCostReportServerTransport(srv *GenerateDetailedCostReportServer) *GenerateDetailedCostReportServerTransport { return &GenerateDetailedCostReportServerTransport{ - srv: srv, - beginCreateOperation: newTracker[azfake.PollerResponder[armcostmanagement.GenerateDetailedCostReportClientCreateOperationResponse]](), + srv: srv, + beginCreateOperation: newTracker[azfake.PollerResponder[armcostmanagement.GenerateDetailedCostReportClientCreateOperationResponse]](), } } // GenerateDetailedCostReportServerTransport connects instances of armcostmanagement.GenerateDetailedCostReportClient to instances of GenerateDetailedCostReportServer. // Don't use this type directly, use NewGenerateDetailedCostReportServerTransport instead. type GenerateDetailedCostReportServerTransport struct { - srv *GenerateDetailedCostReportServer - beginCreateOperation *tracker[azfake.PollerResponder[armcostmanagement.GenerateDetailedCostReportClientCreateOperationResponse]] + srv *GenerateDetailedCostReportServer + beginCreateOperation *tracker[azfake.PollerResponder[armcostmanagement.GenerateDetailedCostReportClientCreateOperationResponse]] } // Do implements the policy.Transporter interface for GenerateDetailedCostReportServerTransport. @@ -50,21 +49,40 @@ func (g *GenerateDetailedCostReportServerTransport) Do(req *http.Request) (*http return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return g.dispatchToMethodFake(req, method) +} - switch method { - case "GenerateDetailedCostReportClient.BeginCreateOperation": - resp, err = g.dispatchBeginCreateOperation(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (g *GenerateDetailedCostReportServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if generateDetailedCostReportServerTransportInterceptor != nil { + res.resp, res.err, intercepted = generateDetailedCostReportServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "GenerateDetailedCostReportClient.BeginCreateOperation": + res.resp, res.err = g.dispatchBeginCreateOperation(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (g *GenerateDetailedCostReportServerTransport) dispatchBeginCreateOperation(req *http.Request) (*http.Response, error) { @@ -76,7 +94,7 @@ func (g *GenerateDetailedCostReportServerTransport) dispatchBeginCreateOperation const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/generateDetailedCostReport` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armcostmanagement.GenerateDetailedCostReportDefinition](req) @@ -110,3 +128,9 @@ func (g *GenerateDetailedCostReportServerTransport) dispatchBeginCreateOperation return resp, nil } + +// set this to conditionally intercept incoming requests to GenerateDetailedCostReportServerTransport +var generateDetailedCostReportServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatedetailedcostreportoperationresults_server.go b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatedetailedcostreportoperationresults_server.go index d693c24012a5..1fe8ec80fd66 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatedetailedcostreportoperationresults_server.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatedetailedcostreportoperationresults_server.go @@ -1,7 +1,6 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -12,7 +11,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" @@ -30,16 +29,16 @@ type GenerateDetailedCostReportOperationResultsServer struct { // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewGenerateDetailedCostReportOperationResultsServerTransport(srv *GenerateDetailedCostReportOperationResultsServer) *GenerateDetailedCostReportOperationResultsServerTransport { return &GenerateDetailedCostReportOperationResultsServerTransport{ - srv: srv, - beginGet: newTracker[azfake.PollerResponder[armcostmanagement.GenerateDetailedCostReportOperationResultsClientGetResponse]](), + srv: srv, + beginGet: newTracker[azfake.PollerResponder[armcostmanagement.GenerateDetailedCostReportOperationResultsClientGetResponse]](), } } // GenerateDetailedCostReportOperationResultsServerTransport connects instances of armcostmanagement.GenerateDetailedCostReportOperationResultsClient to instances of GenerateDetailedCostReportOperationResultsServer. // Don't use this type directly, use NewGenerateDetailedCostReportOperationResultsServerTransport instead. type GenerateDetailedCostReportOperationResultsServerTransport struct { - srv *GenerateDetailedCostReportOperationResultsServer - beginGet *tracker[azfake.PollerResponder[armcostmanagement.GenerateDetailedCostReportOperationResultsClientGetResponse]] + srv *GenerateDetailedCostReportOperationResultsServer + beginGet *tracker[azfake.PollerResponder[armcostmanagement.GenerateDetailedCostReportOperationResultsClientGetResponse]] } // Do implements the policy.Transporter interface for GenerateDetailedCostReportOperationResultsServerTransport. @@ -50,21 +49,40 @@ func (g *GenerateDetailedCostReportOperationResultsServerTransport) Do(req *http return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return g.dispatchToMethodFake(req, method) +} - switch method { - case "GenerateDetailedCostReportOperationResultsClient.BeginGet": - resp, err = g.dispatchBeginGet(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (g *GenerateDetailedCostReportOperationResultsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if generateDetailedCostReportOperationResultsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = generateDetailedCostReportOperationResultsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "GenerateDetailedCostReportOperationResultsClient.BeginGet": + res.resp, res.err = g.dispatchBeginGet(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (g *GenerateDetailedCostReportOperationResultsServerTransport) dispatchBeginGet(req *http.Request) (*http.Response, error) { @@ -76,7 +94,7 @@ func (g *GenerateDetailedCostReportOperationResultsServerTransport) dispatchBegi const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/operationResults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } operationIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("operationId")]) @@ -110,3 +128,9 @@ func (g *GenerateDetailedCostReportOperationResultsServerTransport) dispatchBegi return resp, nil } + +// set this to conditionally intercept incoming requests to GenerateDetailedCostReportOperationResultsServerTransport +var generateDetailedCostReportOperationResultsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatedetailedcostreportoperationstatus_server.go b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatedetailedcostreportoperationstatus_server.go index c7e7ac40b355..477888efd476 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatedetailedcostreportoperationstatus_server.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatedetailedcostreportoperationstatus_server.go @@ -1,7 +1,6 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -12,7 +11,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" @@ -46,21 +45,40 @@ func (g *GenerateDetailedCostReportOperationStatusServerTransport) Do(req *http. return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return g.dispatchToMethodFake(req, method) +} - switch method { - case "GenerateDetailedCostReportOperationStatusClient.Get": - resp, err = g.dispatchGet(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (g *GenerateDetailedCostReportOperationStatusServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if generateDetailedCostReportOperationStatusServerTransportInterceptor != nil { + res.resp, res.err, intercepted = generateDetailedCostReportOperationStatusServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "GenerateDetailedCostReportOperationStatusClient.Get": + res.resp, res.err = g.dispatchGet(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (g *GenerateDetailedCostReportOperationStatusServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { @@ -70,7 +88,7 @@ func (g *GenerateDetailedCostReportOperationStatusServerTransport) dispatchGet(r const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/operationStatus/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } operationIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("operationId")]) @@ -95,3 +113,9 @@ func (g *GenerateDetailedCostReportOperationStatusServerTransport) dispatchGet(r } return resp, nil } + +// set this to conditionally intercept incoming requests to GenerateDetailedCostReportOperationStatusServerTransport +var generateDetailedCostReportOperationStatusServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatereservationdetailsreport_server.go b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatereservationdetailsreport_server.go index 3cd74740f55b..25b10f61202f 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatereservationdetailsreport_server.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/generatereservationdetailsreport_server.go @@ -1,7 +1,6 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -12,7 +11,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" @@ -22,11 +21,11 @@ import ( type GenerateReservationDetailsReportServer struct { // BeginByBillingAccountID is the fake for method GenerateReservationDetailsReportClient.BeginByBillingAccountID // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted - BeginByBillingAccountID func(ctx context.Context, billingAccountID string, startDate string, endDate string, options *armcostmanagement.GenerateReservationDetailsReportClientBeginByBillingAccountIDOptions) (resp azfake.PollerResponder[armcostmanagement.GenerateReservationDetailsReportClientByBillingAccountIDResponse], errResp azfake.ErrorResponder) + BeginByBillingAccountID func(ctx context.Context, billingAccountID string, startDate string, endDate string, options *armcostmanagement.GenerateReservationDetailsReportClientBeginByBillingAccountIDOptions) (resp azfake.PollerResponder[armcostmanagement.GenerateReservationDetailsReportClientByBillingAccountIDResponse], errResp azfake.ErrorResponder) // BeginByBillingProfileID is the fake for method GenerateReservationDetailsReportClient.BeginByBillingProfileID // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted - BeginByBillingProfileID func(ctx context.Context, billingAccountID string, billingProfileID string, startDate string, endDate string, options *armcostmanagement.GenerateReservationDetailsReportClientBeginByBillingProfileIDOptions) (resp azfake.PollerResponder[armcostmanagement.GenerateReservationDetailsReportClientByBillingProfileIDResponse], errResp azfake.ErrorResponder) + BeginByBillingProfileID func(ctx context.Context, billingAccountID string, billingProfileID string, startDate string, endDate string, options *armcostmanagement.GenerateReservationDetailsReportClientBeginByBillingProfileIDOptions) (resp azfake.PollerResponder[armcostmanagement.GenerateReservationDetailsReportClientByBillingProfileIDResponse], errResp azfake.ErrorResponder) } // NewGenerateReservationDetailsReportServerTransport creates a new instance of GenerateReservationDetailsReportServerTransport with the provided implementation. @@ -34,18 +33,18 @@ type GenerateReservationDetailsReportServer struct { // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewGenerateReservationDetailsReportServerTransport(srv *GenerateReservationDetailsReportServer) *GenerateReservationDetailsReportServerTransport { return &GenerateReservationDetailsReportServerTransport{ - srv: srv, - beginByBillingAccountID: newTracker[azfake.PollerResponder[armcostmanagement.GenerateReservationDetailsReportClientByBillingAccountIDResponse]](), - beginByBillingProfileID: newTracker[azfake.PollerResponder[armcostmanagement.GenerateReservationDetailsReportClientByBillingProfileIDResponse]](), + srv: srv, + beginByBillingAccountID: newTracker[azfake.PollerResponder[armcostmanagement.GenerateReservationDetailsReportClientByBillingAccountIDResponse]](), + beginByBillingProfileID: newTracker[azfake.PollerResponder[armcostmanagement.GenerateReservationDetailsReportClientByBillingProfileIDResponse]](), } } // GenerateReservationDetailsReportServerTransport connects instances of armcostmanagement.GenerateReservationDetailsReportClient to instances of GenerateReservationDetailsReportServer. // Don't use this type directly, use NewGenerateReservationDetailsReportServerTransport instead. type GenerateReservationDetailsReportServerTransport struct { - srv *GenerateReservationDetailsReportServer - beginByBillingAccountID *tracker[azfake.PollerResponder[armcostmanagement.GenerateReservationDetailsReportClientByBillingAccountIDResponse]] - beginByBillingProfileID *tracker[azfake.PollerResponder[armcostmanagement.GenerateReservationDetailsReportClientByBillingProfileIDResponse]] + srv *GenerateReservationDetailsReportServer + beginByBillingAccountID *tracker[azfake.PollerResponder[armcostmanagement.GenerateReservationDetailsReportClientByBillingAccountIDResponse]] + beginByBillingProfileID *tracker[azfake.PollerResponder[armcostmanagement.GenerateReservationDetailsReportClientByBillingProfileIDResponse]] } // Do implements the policy.Transporter interface for GenerateReservationDetailsReportServerTransport. @@ -56,23 +55,42 @@ func (g *GenerateReservationDetailsReportServerTransport) Do(req *http.Request) return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return g.dispatchToMethodFake(req, method) +} - switch method { - case "GenerateReservationDetailsReportClient.BeginByBillingAccountID": - resp, err = g.dispatchBeginByBillingAccountID(req) - case "GenerateReservationDetailsReportClient.BeginByBillingProfileID": - resp, err = g.dispatchBeginByBillingProfileID(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (g *GenerateReservationDetailsReportServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if generateReservationDetailsReportServerTransportInterceptor != nil { + res.resp, res.err, intercepted = generateReservationDetailsReportServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "GenerateReservationDetailsReportClient.BeginByBillingAccountID": + res.resp, res.err = g.dispatchBeginByBillingAccountID(req) + case "GenerateReservationDetailsReportClient.BeginByBillingProfileID": + res.resp, res.err = g.dispatchBeginByBillingProfileID(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (g *GenerateReservationDetailsReportServerTransport) dispatchBeginByBillingAccountID(req *http.Request) (*http.Response, error) { @@ -81,10 +99,10 @@ func (g *GenerateReservationDetailsReportServerTransport) dispatchBeginByBilling } beginByBillingAccountID := g.beginByBillingAccountID.get(req) if beginByBillingAccountID == nil { - const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/generateReservationDetailsReport` + const regexStr = `/providers/microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/generateReservationDetailsReport` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() @@ -130,10 +148,10 @@ func (g *GenerateReservationDetailsReportServerTransport) dispatchBeginByBilling } beginByBillingProfileID := g.beginByBillingProfileID.get(req) if beginByBillingProfileID == nil { - const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/generateReservationDetailsReport` + const regexStr = `/providers/microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/generateReservationDetailsReport` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() @@ -176,3 +194,9 @@ func (g *GenerateReservationDetailsReportServerTransport) dispatchBeginByBilling return resp, nil } + +// set this to conditionally intercept incoming requests to GenerateReservationDetailsReportServerTransport +var generateReservationDetailsReportServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/internal.go b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/internal.go index 1e60cc498b4d..fad19d771c3b 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/internal.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/internal.go @@ -1,17 +1,22 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "io" "net/http" "reflect" "sync" ) +type result struct { + resp *http.Response + err error +} + type nonRetriableError struct { error } @@ -63,6 +68,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 9140ed675742..e02a4987c921 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/operations_server.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/operations_server.go @@ -1,7 +1,6 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -12,7 +11,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" ) @@ -28,16 +27,16 @@ type OperationsServer struct { // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewOperationsServerTransport(srv *OperationsServer) *OperationsServerTransport { return &OperationsServerTransport{ - srv: srv, - newListPager: newTracker[azfake.PagerResponder[armcostmanagement.OperationsClientListResponse]](), + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armcostmanagement.OperationsClientListResponse]](), } } // OperationsServerTransport connects instances of armcostmanagement.OperationsClient to instances of OperationsServer. // Don't use this type directly, use NewOperationsServerTransport instead. type OperationsServerTransport struct { - srv *OperationsServer - newListPager *tracker[azfake.PagerResponder[armcostmanagement.OperationsClientListResponse]] + srv *OperationsServer + newListPager *tracker[azfake.PagerResponder[armcostmanagement.OperationsClientListResponse]] } // Do implements the policy.Transporter interface for OperationsServerTransport. @@ -48,21 +47,40 @@ func (o *OperationsServerTransport) Do(req *http.Request) (*http.Response, error return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return o.dispatchToMethodFake(req, method) +} - switch method { - case "OperationsClient.NewListPager": - resp, err = o.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (o *OperationsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if operationsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = operationsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "OperationsClient.NewListPager": + res.resp, res.err = o.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { @@ -91,3 +109,9 @@ func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*ht } return resp, nil } + +// set this to conditionally intercept incoming requests to OperationsServerTransport +var operationsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/polymorphic_helpers.go b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/polymorphic_helpers.go new file mode 100644 index 000000000000..3b836ec00041 --- /dev/null +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/polymorphic_helpers.go @@ -0,0 +1,31 @@ +// 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) Go Code Generator. DO NOT EDIT. + +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 7b1068c9fa0b..918e7a460615 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/pricesheet_server.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/pricesheet_server.go @@ -1,7 +1,6 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -12,7 +11,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" @@ -20,13 +19,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) + 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. @@ -34,18 +37,20 @@ type PriceSheetServer struct { // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewPriceSheetServerTransport(srv *PriceSheetServer) *PriceSheetServerTransport { return &PriceSheetServerTransport{ - srv: srv, - beginDownload: newTracker[azfake.PollerResponder[armcostmanagement.PriceSheetClientDownloadResponse]](), - beginDownloadByBillingProfile: newTracker[azfake.PollerResponder[armcostmanagement.PriceSheetClientDownloadByBillingProfileResponse]](), + srv: srv, + beginDownloadByBillingAccount: newTracker[azfake.PollerResponder[armcostmanagement.PriceSheetClientDownloadByBillingAccountResponse]](), + beginDownloadByBillingProfile: newTracker[azfake.PollerResponder[armcostmanagement.PriceSheetClientDownloadByBillingProfileResponse]](), + beginDownloadByInvoice: newTracker[azfake.PollerResponder[armcostmanagement.PriceSheetClientDownloadByInvoiceResponse]](), } } // PriceSheetServerTransport connects instances of armcostmanagement.PriceSheetClient to instances of PriceSheetServer. // Don't use this type directly, use NewPriceSheetServerTransport instead. type PriceSheetServerTransport struct { - srv *PriceSheetServer - beginDownload *tracker[azfake.PollerResponder[armcostmanagement.PriceSheetClientDownloadResponse]] - beginDownloadByBillingProfile *tracker[azfake.PollerResponder[armcostmanagement.PriceSheetClientDownloadByBillingProfileResponse]] + srv *PriceSheetServer + 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. @@ -56,68 +61,85 @@ func (p *PriceSheetServerTransport) Do(req *http.Request) (*http.Response, error return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return p.dispatchToMethodFake(req, method) +} - switch method { - case "PriceSheetClient.BeginDownload": - resp, err = p.dispatchBeginDownload(req) - case "PriceSheetClient.BeginDownloadByBillingProfile": - resp, err = p.dispatchBeginDownloadByBillingProfile(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (p *PriceSheetServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if priceSheetServerTransportInterceptor != nil { + res.resp, res.err, intercepted = priceSheetServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "PriceSheetClient.BeginDownloadByBillingAccount": + res.resp, res.err = p.dispatchBeginDownloadByBillingAccount(req) + case "PriceSheetClient.BeginDownloadByBillingProfile": + res.resp, res.err = p.dispatchBeginDownloadByBillingProfile(req) + case "PriceSheetClient.BeginDownloadByInvoice": + res.resp, res.err = p.dispatchBeginDownloadByInvoice(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } -func (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 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")]) + 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 @@ -129,10 +151,10 @@ func (p *PriceSheetServerTransport) dispatchBeginDownloadByBillingProfile(req *h } beginDownloadByBillingProfile := p.beginDownloadByBillingProfile.get(req) if beginDownloadByBillingProfile == nil { - const regexStr = `/providers/Microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/pricesheets/default/download` + const regexStr = `/providers/microsoft\.Billing/billingAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/billingProfiles/(?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) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } billingAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("billingAccountName")]) @@ -166,3 +188,57 @@ 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 len(matches) < 4 { + 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 +} + +// set this to conditionally intercept incoming requests to PriceSheetServerTransport +var priceSheetServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/query_server.go b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/query_server.go index a6083b8978e0..9ca1e24a04e1 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/query_server.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/query_server.go @@ -1,7 +1,6 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -12,7 +11,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" @@ -22,11 +21,11 @@ import ( type QueryServer struct { // Usage is the fake for method QueryClient.Usage // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent - Usage func(ctx context.Context, scope string, parameters armcostmanagement.QueryDefinition, options *armcostmanagement.QueryClientUsageOptions) (resp azfake.Responder[armcostmanagement.QueryClientUsageResponse], errResp azfake.ErrorResponder) + Usage func(ctx context.Context, scope string, parameters armcostmanagement.QueryDefinition, options *armcostmanagement.QueryClientUsageOptions) (resp azfake.Responder[armcostmanagement.QueryClientUsageResponse], errResp azfake.ErrorResponder) // UsageByExternalCloudProviderType is the fake for method QueryClient.UsageByExternalCloudProviderType // HTTP status codes to indicate success: http.StatusOK - UsageByExternalCloudProviderType func(ctx context.Context, externalCloudProviderType armcostmanagement.ExternalCloudProviderType, externalCloudProviderID string, parameters armcostmanagement.QueryDefinition, options *armcostmanagement.QueryClientUsageByExternalCloudProviderTypeOptions) (resp azfake.Responder[armcostmanagement.QueryClientUsageByExternalCloudProviderTypeResponse], errResp azfake.ErrorResponder) + UsageByExternalCloudProviderType func(ctx context.Context, externalCloudProviderType armcostmanagement.ExternalCloudProviderType, externalCloudProviderID string, parameters armcostmanagement.QueryDefinition, options *armcostmanagement.QueryClientUsageByExternalCloudProviderTypeOptions) (resp azfake.Responder[armcostmanagement.QueryClientUsageByExternalCloudProviderTypeResponse], errResp azfake.ErrorResponder) } // NewQueryServerTransport creates a new instance of QueryServerTransport with the provided implementation. @@ -50,23 +49,42 @@ func (q *QueryServerTransport) Do(req *http.Request) (*http.Response, error) { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return q.dispatchToMethodFake(req, method) +} - switch method { - case "QueryClient.Usage": - resp, err = q.dispatchUsage(req) - case "QueryClient.UsageByExternalCloudProviderType": - resp, err = q.dispatchUsageByExternalCloudProviderType(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (q *QueryServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if queryServerTransportInterceptor != nil { + res.resp, res.err, intercepted = queryServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "QueryClient.Usage": + res.resp, res.err = q.dispatchUsage(req) + case "QueryClient.UsageByExternalCloudProviderType": + res.resp, res.err = q.dispatchUsageByExternalCloudProviderType(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (q *QueryServerTransport) dispatchUsage(req *http.Request) (*http.Response, error) { @@ -76,7 +94,7 @@ func (q *QueryServerTransport) dispatchUsage(req *http.Request) (*http.Response, const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/query` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armcostmanagement.QueryDefinition](req) @@ -109,7 +127,7 @@ func (q *QueryServerTransport) dispatchUsageByExternalCloudProviderType(req *htt const regexStr = `/providers/Microsoft\.CostManagement/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/query` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armcostmanagement.QueryDefinition](req) @@ -144,3 +162,9 @@ func (q *QueryServerTransport) dispatchUsageByExternalCloudProviderType(req *htt } return resp, nil } + +// set this to conditionally intercept incoming requests to QueryServerTransport +var queryServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/scheduledactions_server.go b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/scheduledactions_server.go index c1dc89486855..08be7816df6b 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/scheduledactions_server.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/scheduledactions_server.go @@ -1,7 +1,6 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -13,7 +12,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v3" "net/http" "net/url" "regexp" @@ -23,51 +22,51 @@ import ( type ScheduledActionsServer struct { // CheckNameAvailability is the fake for method ScheduledActionsClient.CheckNameAvailability // HTTP status codes to indicate success: http.StatusOK - CheckNameAvailability func(ctx context.Context, checkNameAvailabilityRequest armcostmanagement.CheckNameAvailabilityRequest, options *armcostmanagement.ScheduledActionsClientCheckNameAvailabilityOptions) (resp azfake.Responder[armcostmanagement.ScheduledActionsClientCheckNameAvailabilityResponse], errResp azfake.ErrorResponder) + CheckNameAvailability func(ctx context.Context, checkNameAvailabilityRequest armcostmanagement.CheckNameAvailabilityRequest, options *armcostmanagement.ScheduledActionsClientCheckNameAvailabilityOptions) (resp azfake.Responder[armcostmanagement.ScheduledActionsClientCheckNameAvailabilityResponse], errResp azfake.ErrorResponder) // CheckNameAvailabilityByScope is the fake for method ScheduledActionsClient.CheckNameAvailabilityByScope // HTTP status codes to indicate success: http.StatusOK - CheckNameAvailabilityByScope func(ctx context.Context, scope string, checkNameAvailabilityRequest armcostmanagement.CheckNameAvailabilityRequest, options *armcostmanagement.ScheduledActionsClientCheckNameAvailabilityByScopeOptions) (resp azfake.Responder[armcostmanagement.ScheduledActionsClientCheckNameAvailabilityByScopeResponse], errResp azfake.ErrorResponder) + CheckNameAvailabilityByScope func(ctx context.Context, scope string, checkNameAvailabilityRequest armcostmanagement.CheckNameAvailabilityRequest, options *armcostmanagement.ScheduledActionsClientCheckNameAvailabilityByScopeOptions) (resp azfake.Responder[armcostmanagement.ScheduledActionsClientCheckNameAvailabilityByScopeResponse], errResp azfake.ErrorResponder) // CreateOrUpdate is the fake for method ScheduledActionsClient.CreateOrUpdate // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - CreateOrUpdate func(ctx context.Context, name string, scheduledAction armcostmanagement.ScheduledAction, options *armcostmanagement.ScheduledActionsClientCreateOrUpdateOptions) (resp azfake.Responder[armcostmanagement.ScheduledActionsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + CreateOrUpdate func(ctx context.Context, name string, scheduledAction armcostmanagement.ScheduledAction, options *armcostmanagement.ScheduledActionsClientCreateOrUpdateOptions) (resp azfake.Responder[armcostmanagement.ScheduledActionsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) // CreateOrUpdateByScope is the fake for method ScheduledActionsClient.CreateOrUpdateByScope // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - CreateOrUpdateByScope func(ctx context.Context, scope string, name string, scheduledAction armcostmanagement.ScheduledAction, options *armcostmanagement.ScheduledActionsClientCreateOrUpdateByScopeOptions) (resp azfake.Responder[armcostmanagement.ScheduledActionsClientCreateOrUpdateByScopeResponse], errResp azfake.ErrorResponder) + CreateOrUpdateByScope func(ctx context.Context, scope string, name string, scheduledAction armcostmanagement.ScheduledAction, options *armcostmanagement.ScheduledActionsClientCreateOrUpdateByScopeOptions) (resp azfake.Responder[armcostmanagement.ScheduledActionsClientCreateOrUpdateByScopeResponse], errResp azfake.ErrorResponder) // Delete is the fake for method ScheduledActionsClient.Delete // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent - Delete func(ctx context.Context, name string, options *armcostmanagement.ScheduledActionsClientDeleteOptions) (resp azfake.Responder[armcostmanagement.ScheduledActionsClientDeleteResponse], errResp azfake.ErrorResponder) + Delete func(ctx context.Context, name string, options *armcostmanagement.ScheduledActionsClientDeleteOptions) (resp azfake.Responder[armcostmanagement.ScheduledActionsClientDeleteResponse], errResp azfake.ErrorResponder) // DeleteByScope is the fake for method ScheduledActionsClient.DeleteByScope // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent - DeleteByScope func(ctx context.Context, scope string, name string, options *armcostmanagement.ScheduledActionsClientDeleteByScopeOptions) (resp azfake.Responder[armcostmanagement.ScheduledActionsClientDeleteByScopeResponse], errResp azfake.ErrorResponder) + DeleteByScope func(ctx context.Context, scope string, name string, options *armcostmanagement.ScheduledActionsClientDeleteByScopeOptions) (resp azfake.Responder[armcostmanagement.ScheduledActionsClientDeleteByScopeResponse], errResp azfake.ErrorResponder) // Get is the fake for method ScheduledActionsClient.Get // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, name string, options *armcostmanagement.ScheduledActionsClientGetOptions) (resp azfake.Responder[armcostmanagement.ScheduledActionsClientGetResponse], errResp azfake.ErrorResponder) + Get func(ctx context.Context, name string, options *armcostmanagement.ScheduledActionsClientGetOptions) (resp azfake.Responder[armcostmanagement.ScheduledActionsClientGetResponse], errResp azfake.ErrorResponder) // GetByScope is the fake for method ScheduledActionsClient.GetByScope // HTTP status codes to indicate success: http.StatusOK - GetByScope func(ctx context.Context, scope string, name string, options *armcostmanagement.ScheduledActionsClientGetByScopeOptions) (resp azfake.Responder[armcostmanagement.ScheduledActionsClientGetByScopeResponse], errResp azfake.ErrorResponder) + GetByScope func(ctx context.Context, scope string, name string, options *armcostmanagement.ScheduledActionsClientGetByScopeOptions) (resp azfake.Responder[armcostmanagement.ScheduledActionsClientGetByScopeResponse], errResp azfake.ErrorResponder) // NewListPager is the fake for method ScheduledActionsClient.NewListPager // HTTP status codes to indicate success: http.StatusOK - NewListPager func(options *armcostmanagement.ScheduledActionsClientListOptions) (resp azfake.PagerResponder[armcostmanagement.ScheduledActionsClientListResponse]) + NewListPager func(options *armcostmanagement.ScheduledActionsClientListOptions) (resp azfake.PagerResponder[armcostmanagement.ScheduledActionsClientListResponse]) // NewListByScopePager is the fake for method ScheduledActionsClient.NewListByScopePager // HTTP status codes to indicate success: http.StatusOK - NewListByScopePager func(scope string, options *armcostmanagement.ScheduledActionsClientListByScopeOptions) (resp azfake.PagerResponder[armcostmanagement.ScheduledActionsClientListByScopeResponse]) + NewListByScopePager func(scope string, options *armcostmanagement.ScheduledActionsClientListByScopeOptions) (resp azfake.PagerResponder[armcostmanagement.ScheduledActionsClientListByScopeResponse]) // Run is the fake for method ScheduledActionsClient.Run // HTTP status codes to indicate success: http.StatusOK - Run func(ctx context.Context, name string, options *armcostmanagement.ScheduledActionsClientRunOptions) (resp azfake.Responder[armcostmanagement.ScheduledActionsClientRunResponse], errResp azfake.ErrorResponder) + Run func(ctx context.Context, name string, options *armcostmanagement.ScheduledActionsClientRunOptions) (resp azfake.Responder[armcostmanagement.ScheduledActionsClientRunResponse], errResp azfake.ErrorResponder) // RunByScope is the fake for method ScheduledActionsClient.RunByScope // HTTP status codes to indicate success: http.StatusOK - RunByScope func(ctx context.Context, scope string, name string, options *armcostmanagement.ScheduledActionsClientRunByScopeOptions) (resp azfake.Responder[armcostmanagement.ScheduledActionsClientRunByScopeResponse], errResp azfake.ErrorResponder) + RunByScope func(ctx context.Context, scope string, name string, options *armcostmanagement.ScheduledActionsClientRunByScopeOptions) (resp azfake.Responder[armcostmanagement.ScheduledActionsClientRunByScopeResponse], errResp azfake.ErrorResponder) } // NewScheduledActionsServerTransport creates a new instance of ScheduledActionsServerTransport with the provided implementation. @@ -75,18 +74,18 @@ type ScheduledActionsServer struct { // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewScheduledActionsServerTransport(srv *ScheduledActionsServer) *ScheduledActionsServerTransport { return &ScheduledActionsServerTransport{ - srv: srv, - newListPager: newTracker[azfake.PagerResponder[armcostmanagement.ScheduledActionsClientListResponse]](), - newListByScopePager: newTracker[azfake.PagerResponder[armcostmanagement.ScheduledActionsClientListByScopeResponse]](), + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armcostmanagement.ScheduledActionsClientListResponse]](), + newListByScopePager: newTracker[azfake.PagerResponder[armcostmanagement.ScheduledActionsClientListByScopeResponse]](), } } // ScheduledActionsServerTransport connects instances of armcostmanagement.ScheduledActionsClient to instances of ScheduledActionsServer. // Don't use this type directly, use NewScheduledActionsServerTransport instead. type ScheduledActionsServerTransport struct { - srv *ScheduledActionsServer - newListPager *tracker[azfake.PagerResponder[armcostmanagement.ScheduledActionsClientListResponse]] - newListByScopePager *tracker[azfake.PagerResponder[armcostmanagement.ScheduledActionsClientListByScopeResponse]] + srv *ScheduledActionsServer + newListPager *tracker[azfake.PagerResponder[armcostmanagement.ScheduledActionsClientListResponse]] + newListByScopePager *tracker[azfake.PagerResponder[armcostmanagement.ScheduledActionsClientListByScopeResponse]] } // Do implements the policy.Transporter interface for ScheduledActionsServerTransport. @@ -97,43 +96,62 @@ func (s *ScheduledActionsServerTransport) Do(req *http.Request) (*http.Response, return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error - - switch method { - case "ScheduledActionsClient.CheckNameAvailability": - resp, err = s.dispatchCheckNameAvailability(req) - case "ScheduledActionsClient.CheckNameAvailabilityByScope": - resp, err = s.dispatchCheckNameAvailabilityByScope(req) - case "ScheduledActionsClient.CreateOrUpdate": - resp, err = s.dispatchCreateOrUpdate(req) - case "ScheduledActionsClient.CreateOrUpdateByScope": - resp, err = s.dispatchCreateOrUpdateByScope(req) - case "ScheduledActionsClient.Delete": - resp, err = s.dispatchDelete(req) - case "ScheduledActionsClient.DeleteByScope": - resp, err = s.dispatchDeleteByScope(req) - case "ScheduledActionsClient.Get": - resp, err = s.dispatchGet(req) - case "ScheduledActionsClient.GetByScope": - resp, err = s.dispatchGetByScope(req) - case "ScheduledActionsClient.NewListPager": - resp, err = s.dispatchNewListPager(req) - case "ScheduledActionsClient.NewListByScopePager": - resp, err = s.dispatchNewListByScopePager(req) - case "ScheduledActionsClient.Run": - resp, err = s.dispatchRun(req) - case "ScheduledActionsClient.RunByScope": - resp, err = s.dispatchRunByScope(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } + return s.dispatchToMethodFake(req, method) +} - if err != nil { - return nil, err - } +func (s *ScheduledActionsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - return resp, nil + go func() { + var intercepted bool + var res result + if scheduledActionsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = scheduledActionsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ScheduledActionsClient.CheckNameAvailability": + res.resp, res.err = s.dispatchCheckNameAvailability(req) + case "ScheduledActionsClient.CheckNameAvailabilityByScope": + res.resp, res.err = s.dispatchCheckNameAvailabilityByScope(req) + case "ScheduledActionsClient.CreateOrUpdate": + res.resp, res.err = s.dispatchCreateOrUpdate(req) + case "ScheduledActionsClient.CreateOrUpdateByScope": + res.resp, res.err = s.dispatchCreateOrUpdateByScope(req) + case "ScheduledActionsClient.Delete": + res.resp, res.err = s.dispatchDelete(req) + case "ScheduledActionsClient.DeleteByScope": + res.resp, res.err = s.dispatchDeleteByScope(req) + case "ScheduledActionsClient.Get": + res.resp, res.err = s.dispatchGet(req) + case "ScheduledActionsClient.GetByScope": + res.resp, res.err = s.dispatchGetByScope(req) + case "ScheduledActionsClient.NewListPager": + res.resp, res.err = s.dispatchNewListPager(req) + case "ScheduledActionsClient.NewListByScopePager": + res.resp, res.err = s.dispatchNewListByScopePager(req) + case "ScheduledActionsClient.Run": + res.resp, res.err = s.dispatchRun(req) + case "ScheduledActionsClient.RunByScope": + res.resp, res.err = s.dispatchRunByScope(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (s *ScheduledActionsServerTransport) dispatchCheckNameAvailability(req *http.Request) (*http.Response, error) { @@ -166,7 +184,7 @@ func (s *ScheduledActionsServerTransport) dispatchCheckNameAvailabilityByScope(r const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/checkNameAvailability` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armcostmanagement.CheckNameAvailabilityRequest](req) @@ -199,7 +217,7 @@ func (s *ScheduledActionsServerTransport) dispatchCreateOrUpdate(req *http.Reque const regexStr = `/providers/Microsoft\.CostManagement/scheduledActions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armcostmanagement.ScheduledAction](req) @@ -239,7 +257,7 @@ func (s *ScheduledActionsServerTransport) dispatchCreateOrUpdateByScope(req *htt const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/scheduledActions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armcostmanagement.ScheduledAction](req) @@ -283,7 +301,7 @@ func (s *ScheduledActionsServerTransport) dispatchDelete(req *http.Request) (*ht const regexStr = `/providers/Microsoft\.CostManagement/scheduledActions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } nameParam, err := url.PathUnescape(matches[regex.SubexpIndex("name")]) @@ -312,7 +330,7 @@ func (s *ScheduledActionsServerTransport) dispatchDeleteByScope(req *http.Reques const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/scheduledActions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) @@ -345,7 +363,7 @@ func (s *ScheduledActionsServerTransport) dispatchGet(req *http.Request) (*http. const regexStr = `/providers/Microsoft\.CostManagement/scheduledActions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } nameParam, err := url.PathUnescape(matches[regex.SubexpIndex("name")]) @@ -374,7 +392,7 @@ func (s *ScheduledActionsServerTransport) dispatchGetByScope(req *http.Request) const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/scheduledActions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) @@ -448,7 +466,7 @@ func (s *ScheduledActionsServerTransport) dispatchNewListByScopePager(req *http. const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/scheduledActions` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } qp := req.URL.Query() @@ -495,7 +513,7 @@ func (s *ScheduledActionsServerTransport) dispatchRun(req *http.Request) (*http. const regexStr = `/providers/Microsoft\.CostManagement/scheduledActions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/execute` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } nameParam, err := url.PathUnescape(matches[regex.SubexpIndex("name")]) @@ -524,7 +542,7 @@ func (s *ScheduledActionsServerTransport) dispatchRunByScope(req *http.Request) const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/scheduledActions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/execute` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) @@ -549,3 +567,9 @@ func (s *ScheduledActionsServerTransport) dispatchRunByScope(req *http.Request) } return resp, nil } + +// set this to conditionally intercept incoming requests to ScheduledActionsServerTransport +var scheduledActionsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/server_factory.go b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/server_factory.go index 37e556c7e6d4..9565305a261b 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/server_factory.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/server_factory.go @@ -1,7 +1,6 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -16,22 +15,65 @@ import ( // ServerFactory is a fake server for instances of the armcostmanagement.ClientFactory type. type ServerFactory struct { - AlertsServer AlertsServer - BenefitRecommendationsServer BenefitRecommendationsServer - BenefitUtilizationSummariesServer BenefitUtilizationSummariesServer - DimensionsServer DimensionsServer - ExportsServer ExportsServer - ForecastServer ForecastServer - GenerateCostDetailsReportServer GenerateCostDetailsReportServer - GenerateDetailedCostReportServer GenerateDetailedCostReportServer + // AlertsServer contains the fakes for client AlertsClient + AlertsServer AlertsServer + + // BenefitRecommendationsServer contains the fakes for client BenefitRecommendationsClient + BenefitRecommendationsServer BenefitRecommendationsServer + + // BenefitUtilizationSummariesServer contains the fakes for client BenefitUtilizationSummariesClient + BenefitUtilizationSummariesServer BenefitUtilizationSummariesServer + + // BudgetsServer contains the fakes for client BudgetsClient + BudgetsServer BudgetsServer + + // CostAllocationRulesServer contains the fakes for client CostAllocationRulesClient + CostAllocationRulesServer CostAllocationRulesServer + + // DimensionsServer contains the fakes for client DimensionsClient + DimensionsServer DimensionsServer + + // ExportsServer contains the fakes for client ExportsClient + ExportsServer ExportsServer + + // ForecastServer contains the fakes for client ForecastClient + ForecastServer ForecastServer + + // GenerateBenefitUtilizationSummariesReportServer contains the fakes for client GenerateBenefitUtilizationSummariesReportClient + GenerateBenefitUtilizationSummariesReportServer GenerateBenefitUtilizationSummariesReportServer + + // GenerateCostDetailsReportServer contains the fakes for client GenerateCostDetailsReportClient + GenerateCostDetailsReportServer GenerateCostDetailsReportServer + + // GenerateDetailedCostReportServer contains the fakes for client GenerateDetailedCostReportClient + GenerateDetailedCostReportServer GenerateDetailedCostReportServer + + // GenerateDetailedCostReportOperationResultsServer contains the fakes for client GenerateDetailedCostReportOperationResultsClient GenerateDetailedCostReportOperationResultsServer GenerateDetailedCostReportOperationResultsServer - GenerateDetailedCostReportOperationStatusServer GenerateDetailedCostReportOperationStatusServer - GenerateReservationDetailsReportServer GenerateReservationDetailsReportServer - OperationsServer OperationsServer - PriceSheetServer PriceSheetServer - QueryServer QueryServer - ScheduledActionsServer ScheduledActionsServer - ViewsServer ViewsServer + + // GenerateDetailedCostReportOperationStatusServer contains the fakes for client GenerateDetailedCostReportOperationStatusClient + GenerateDetailedCostReportOperationStatusServer GenerateDetailedCostReportOperationStatusServer + + // GenerateReservationDetailsReportServer contains the fakes for client GenerateReservationDetailsReportClient + GenerateReservationDetailsReportServer GenerateReservationDetailsReportServer + + // OperationsServer contains the fakes for client OperationsClient + OperationsServer OperationsServer + + // PriceSheetServer contains the fakes for client PriceSheetClient + PriceSheetServer PriceSheetServer + + // QueryServer contains the fakes for client QueryClient + QueryServer QueryServer + + // ScheduledActionsServer contains the fakes for client ScheduledActionsClient + ScheduledActionsServer ScheduledActionsServer + + // SettingsServer contains the fakes for client SettingsClient + SettingsServer SettingsServer + + // ViewsServer contains the fakes for client ViewsClient + ViewsServer ViewsServer } // NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. @@ -51,9 +93,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 @@ -63,6 +108,7 @@ type ServerFactoryTransport struct { trPriceSheetServer *PriceSheetServerTransport trQueryServer *QueryServerTransport trScheduledActionsServer *ScheduledActionsServerTransport + trSettingsServer *SettingsServerTransport trViewsServer *ViewsServerTransport } @@ -92,6 +138,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) @@ -101,6 +155,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) @@ -140,6 +199,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..dbd0e0a9e72e --- /dev/null +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/settings_server.go @@ -0,0 +1,269 @@ +// 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) Go Code Generator. DO NOT EDIT. + +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) + + // NewListPager is the fake for method SettingsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(scope string, options *armcostmanagement.SettingsClientListOptions) (resp azfake.PagerResponder[armcostmanagement.SettingsClientListResponse]) +} + +// 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, + newListPager: newTracker[azfake.PagerResponder[armcostmanagement.SettingsClientListResponse]](), + } +} + +// SettingsServerTransport connects instances of armcostmanagement.SettingsClient to instances of SettingsServer. +// Don't use this type directly, use NewSettingsServerTransport instead. +type SettingsServerTransport struct { + srv *SettingsServer + newListPager *tracker[azfake.PagerResponder[armcostmanagement.SettingsClientListResponse]] +} + +// 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")} + } + + return s.dispatchToMethodFake(req, method) +} + +func (s *SettingsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if settingsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = settingsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "SettingsClient.CreateOrUpdateByScope": + res.resp, res.err = s.dispatchCreateOrUpdateByScope(req) + case "SettingsClient.DeleteByScope": + res.resp, res.err = s.dispatchDeleteByScope(req) + case "SettingsClient.GetByScope": + res.resp, res.err = s.dispatchGetByScope(req) + case "SettingsClient.NewListPager": + res.resp, res.err = s.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (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 len(matches) < 3 { + 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 len(matches) < 3 { + 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 len(matches) < 3 { + 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) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := s.newListPager.get(req) + if newListPager == nil { + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/settings` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if 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 + } + resp := s.srv.NewListPager(scopeParam, nil) + newListPager = &resp + s.newListPager.add(req, newListPager) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + s.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + s.newListPager.remove(req) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to SettingsServerTransport +var settingsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/time_rfc3339.go b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/time_rfc3339.go deleted file mode 100644 index b98c0b0402be..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/time_rfc3339.go +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package fake - -import ( - "encoding/json" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" - "regexp" - "strings" - "time" -) - -// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. -var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) - -const ( - utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` - utcDateTime = "2006-01-02T15:04:05.999999999" - dateTimeJSON = `"` + time.RFC3339Nano + `"` -) - -type dateTimeRFC3339 time.Time - -func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { - tt := time.Time(t) - return tt.MarshalJSON() -} - -func (t dateTimeRFC3339) MarshalText() ([]byte, error) { - tt := time.Time(t) - return tt.MarshalText() -} - -func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcDateTimeJSON - if tzOffsetRegex.Match(data) { - layout = dateTimeJSON - } - return t.Parse(layout, string(data)) -} - -func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { - layout := utcDateTime - if tzOffsetRegex.Match(data) { - layout = time.RFC3339Nano - } - return t.Parse(layout, string(data)) -} - -func (t *dateTimeRFC3339) Parse(layout, value string) error { - p, err := time.Parse(layout, strings.ToUpper(value)) - *t = dateTimeRFC3339(p) - return err -} - -func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { - if t == nil { - return - } else if azcore.IsNullValue(t) { - m[k] = nil - return - } else if reflect.ValueOf(t).IsNil() { - return - } - m[k] = (*dateTimeRFC3339)(t) -} - -func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { - if data == nil || strings.EqualFold(string(data), "null") { - return nil - } - var aux dateTimeRFC3339 - if err := json.Unmarshal(data, &aux); err != nil { - return fmt.Errorf("struct field %s: %v", fn, err) - } - *t = (*time.Time)(&aux) - return nil -} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/views_server.go b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/views_server.go index a56f6b76eebf..94fbb6f8f0c7 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/fake/views_server.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/fake/views_server.go @@ -1,7 +1,6 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -13,7 +12,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v2" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v3" "net/http" "net/url" "regexp" @@ -23,35 +22,35 @@ import ( type ViewsServer struct { // CreateOrUpdate is the fake for method ViewsClient.CreateOrUpdate // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - CreateOrUpdate func(ctx context.Context, viewName string, parameters armcostmanagement.View, options *armcostmanagement.ViewsClientCreateOrUpdateOptions) (resp azfake.Responder[armcostmanagement.ViewsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + CreateOrUpdate func(ctx context.Context, viewName string, parameters armcostmanagement.View, options *armcostmanagement.ViewsClientCreateOrUpdateOptions) (resp azfake.Responder[armcostmanagement.ViewsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) // CreateOrUpdateByScope is the fake for method ViewsClient.CreateOrUpdateByScope // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - CreateOrUpdateByScope func(ctx context.Context, scope string, viewName string, parameters armcostmanagement.View, options *armcostmanagement.ViewsClientCreateOrUpdateByScopeOptions) (resp azfake.Responder[armcostmanagement.ViewsClientCreateOrUpdateByScopeResponse], errResp azfake.ErrorResponder) + CreateOrUpdateByScope func(ctx context.Context, scope string, viewName string, parameters armcostmanagement.View, options *armcostmanagement.ViewsClientCreateOrUpdateByScopeOptions) (resp azfake.Responder[armcostmanagement.ViewsClientCreateOrUpdateByScopeResponse], errResp azfake.ErrorResponder) // Delete is the fake for method ViewsClient.Delete // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent - Delete func(ctx context.Context, viewName string, options *armcostmanagement.ViewsClientDeleteOptions) (resp azfake.Responder[armcostmanagement.ViewsClientDeleteResponse], errResp azfake.ErrorResponder) + Delete func(ctx context.Context, viewName string, options *armcostmanagement.ViewsClientDeleteOptions) (resp azfake.Responder[armcostmanagement.ViewsClientDeleteResponse], errResp azfake.ErrorResponder) // DeleteByScope is the fake for method ViewsClient.DeleteByScope // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent - DeleteByScope func(ctx context.Context, scope string, viewName string, options *armcostmanagement.ViewsClientDeleteByScopeOptions) (resp azfake.Responder[armcostmanagement.ViewsClientDeleteByScopeResponse], errResp azfake.ErrorResponder) + DeleteByScope func(ctx context.Context, scope string, viewName string, options *armcostmanagement.ViewsClientDeleteByScopeOptions) (resp azfake.Responder[armcostmanagement.ViewsClientDeleteByScopeResponse], errResp azfake.ErrorResponder) // Get is the fake for method ViewsClient.Get // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, viewName string, options *armcostmanagement.ViewsClientGetOptions) (resp azfake.Responder[armcostmanagement.ViewsClientGetResponse], errResp azfake.ErrorResponder) + Get func(ctx context.Context, viewName string, options *armcostmanagement.ViewsClientGetOptions) (resp azfake.Responder[armcostmanagement.ViewsClientGetResponse], errResp azfake.ErrorResponder) // GetByScope is the fake for method ViewsClient.GetByScope // HTTP status codes to indicate success: http.StatusOK - GetByScope func(ctx context.Context, scope string, viewName string, options *armcostmanagement.ViewsClientGetByScopeOptions) (resp azfake.Responder[armcostmanagement.ViewsClientGetByScopeResponse], errResp azfake.ErrorResponder) + GetByScope func(ctx context.Context, scope string, viewName string, options *armcostmanagement.ViewsClientGetByScopeOptions) (resp azfake.Responder[armcostmanagement.ViewsClientGetByScopeResponse], errResp azfake.ErrorResponder) // NewListPager is the fake for method ViewsClient.NewListPager // HTTP status codes to indicate success: http.StatusOK - NewListPager func(options *armcostmanagement.ViewsClientListOptions) (resp azfake.PagerResponder[armcostmanagement.ViewsClientListResponse]) + NewListPager func(options *armcostmanagement.ViewsClientListOptions) (resp azfake.PagerResponder[armcostmanagement.ViewsClientListResponse]) // NewListByScopePager is the fake for method ViewsClient.NewListByScopePager // HTTP status codes to indicate success: http.StatusOK - NewListByScopePager func(scope string, options *armcostmanagement.ViewsClientListByScopeOptions) (resp azfake.PagerResponder[armcostmanagement.ViewsClientListByScopeResponse]) + NewListByScopePager func(scope string, options *armcostmanagement.ViewsClientListByScopeOptions) (resp azfake.PagerResponder[armcostmanagement.ViewsClientListByScopeResponse]) } // NewViewsServerTransport creates a new instance of ViewsServerTransport with the provided implementation. @@ -59,18 +58,18 @@ type ViewsServer struct { // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewViewsServerTransport(srv *ViewsServer) *ViewsServerTransport { return &ViewsServerTransport{ - srv: srv, - newListPager: newTracker[azfake.PagerResponder[armcostmanagement.ViewsClientListResponse]](), - newListByScopePager: newTracker[azfake.PagerResponder[armcostmanagement.ViewsClientListByScopeResponse]](), + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armcostmanagement.ViewsClientListResponse]](), + newListByScopePager: newTracker[azfake.PagerResponder[armcostmanagement.ViewsClientListByScopeResponse]](), } } // ViewsServerTransport connects instances of armcostmanagement.ViewsClient to instances of ViewsServer. // Don't use this type directly, use NewViewsServerTransport instead. type ViewsServerTransport struct { - srv *ViewsServer - newListPager *tracker[azfake.PagerResponder[armcostmanagement.ViewsClientListResponse]] - newListByScopePager *tracker[azfake.PagerResponder[armcostmanagement.ViewsClientListByScopeResponse]] + srv *ViewsServer + newListPager *tracker[azfake.PagerResponder[armcostmanagement.ViewsClientListResponse]] + newListByScopePager *tracker[azfake.PagerResponder[armcostmanagement.ViewsClientListByScopeResponse]] } // Do implements the policy.Transporter interface for ViewsServerTransport. @@ -81,35 +80,54 @@ func (v *ViewsServerTransport) Do(req *http.Request) (*http.Response, error) { return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return v.dispatchToMethodFake(req, method) +} - switch method { - case "ViewsClient.CreateOrUpdate": - resp, err = v.dispatchCreateOrUpdate(req) - case "ViewsClient.CreateOrUpdateByScope": - resp, err = v.dispatchCreateOrUpdateByScope(req) - case "ViewsClient.Delete": - resp, err = v.dispatchDelete(req) - case "ViewsClient.DeleteByScope": - resp, err = v.dispatchDeleteByScope(req) - case "ViewsClient.Get": - resp, err = v.dispatchGet(req) - case "ViewsClient.GetByScope": - resp, err = v.dispatchGetByScope(req) - case "ViewsClient.NewListPager": - resp, err = v.dispatchNewListPager(req) - case "ViewsClient.NewListByScopePager": - resp, err = v.dispatchNewListByScopePager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (v *ViewsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if viewsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = viewsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ViewsClient.CreateOrUpdate": + res.resp, res.err = v.dispatchCreateOrUpdate(req) + case "ViewsClient.CreateOrUpdateByScope": + res.resp, res.err = v.dispatchCreateOrUpdateByScope(req) + case "ViewsClient.Delete": + res.resp, res.err = v.dispatchDelete(req) + case "ViewsClient.DeleteByScope": + res.resp, res.err = v.dispatchDeleteByScope(req) + case "ViewsClient.Get": + res.resp, res.err = v.dispatchGet(req) + case "ViewsClient.GetByScope": + res.resp, res.err = v.dispatchGetByScope(req) + case "ViewsClient.NewListPager": + res.resp, res.err = v.dispatchNewListPager(req) + case "ViewsClient.NewListByScopePager": + res.resp, res.err = v.dispatchNewListByScopePager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (v *ViewsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { @@ -119,7 +137,7 @@ func (v *ViewsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http. const regexStr = `/providers/Microsoft\.CostManagement/views/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armcostmanagement.View](req) @@ -152,7 +170,7 @@ func (v *ViewsServerTransport) dispatchCreateOrUpdateByScope(req *http.Request) const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/views/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } body, err := server.UnmarshalRequestAsJSON[armcostmanagement.View](req) @@ -189,7 +207,7 @@ func (v *ViewsServerTransport) dispatchDelete(req *http.Request) (*http.Response const regexStr = `/providers/Microsoft\.CostManagement/views/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } viewNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("viewName")]) @@ -218,7 +236,7 @@ func (v *ViewsServerTransport) dispatchDeleteByScope(req *http.Request) (*http.R const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/views/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) @@ -251,7 +269,7 @@ func (v *ViewsServerTransport) dispatchGet(req *http.Request) (*http.Response, e const regexStr = `/providers/Microsoft\.CostManagement/views/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } viewNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("viewName")]) @@ -280,7 +298,7 @@ func (v *ViewsServerTransport) dispatchGetByScope(req *http.Request) (*http.Resp const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/views/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { + if len(matches) < 3 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) @@ -342,7 +360,7 @@ func (v *ViewsServerTransport) dispatchNewListByScopePager(req *http.Request) (* const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.CostManagement/views` regex := regexp.MustCompile(regexStr) matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { + if len(matches) < 2 { return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) } scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) @@ -369,3 +387,9 @@ func (v *ViewsServerTransport) dispatchNewListByScopePager(req *http.Request) (* } return resp, nil } + +// set this to conditionally intercept incoming requests to ViewsServerTransport +var viewsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/forecast_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/forecast_client.go index d42c83bd3df2..810276d3d483 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/forecast_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/forecast_client.go @@ -1,7 +1,6 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armcostmanagement @@ -25,7 +24,7 @@ type ForecastClient struct { // NewForecastClient creates a new instance of ForecastClient with the specified values. // - credential - used to authorize requests. Usually a credential from azidentity. -// - options - pass nil to accept the default values. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewForecastClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*ForecastClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -40,12 +39,12 @@ 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 2025-03-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 // consolidated account used with dimension/query operations. -// - parameters - Parameters supplied to the CreateOrUpdate Forecast Config operation. +// - parameters - The request body // - options - ForecastClientExternalCloudProviderUsageOptions contains the optional parameters for the ForecastClient.ExternalCloudProviderUsage // method. func (client *ForecastClient) ExternalCloudProviderUsage(ctx context.Context, externalCloudProviderType ExternalCloudProviderType, externalCloudProviderID string, parameters ForecastDefinition, options *ForecastClientExternalCloudProviderUsageOptions) (ForecastClientExternalCloudProviderUsageResponse, error) { @@ -89,9 +88,10 @@ 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", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -110,17 +110,16 @@ 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 2025-03-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 -// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope, -// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount -// scope, -// '/providers/Microsoft.Management/managementGroups/{managementGroupId} for Management Group scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' -// for billingProfile scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' -// for invoiceSection scope, and -// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for partners. +// scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' +// for Billing Account scope and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' +// for Department scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' +// for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId} for Management Group +// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile +// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' +// for invoiceSection scope, and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' +// specific for partners. // - parameters - Parameters supplied to the CreateOrUpdate Forecast Config operation. // - options - ForecastClientUsageOptions contains the optional parameters for the ForecastClient.Usage method. func (client *ForecastClient) Usage(ctx context.Context, scope string, parameters ForecastDefinition, options *ForecastClientUsageOptions) (ForecastClientUsageResponse, error) { @@ -148,6 +147,9 @@ func (client *ForecastClient) Usage(ctx context.Context, scope string, parameter // usageCreateRequest creates the Usage request. func (client *ForecastClient) usageCreateRequest(ctx context.Context, scope string, parameters ForecastDefinition, options *ForecastClientUsageOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.CostManagement/forecast" + if scope == "" { + return nil, errors.New("parameter scope cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { @@ -157,9 +159,10 @@ 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", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/forecast_client_example_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/forecast_client_example_test.go index 8c9ca53174ee..e5f89026076d 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/forecast_client_example_test.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/forecast_client_example_test.go @@ -1,24 +1,20 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. 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" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v3" + "log" + "time" ) -// Generated from 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() { +// Generated from example definition: 2025-03-01/ExternalBillingAccountForecast.json +func ExampleForecastClient_ExternalCloudProviderUsage_externalBillingAccountForecast() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -28,13 +24,13 @@ func ExampleForecastClient_Usage_billingAccountForecast() { 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), + 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), + Name: to.Ptr(armcostmanagement.FunctionNameCost), + Function: to.Ptr(armcostmanagement.FunctionTypeSum), }, }, Filter: &armcostmanagement.ForecastFilter{ @@ -43,97 +39,100 @@ func ExampleForecastClient_Usage_billingAccountForecast() { Or: []*armcostmanagement.ForecastFilter{ { Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), + Name: to.Ptr("ResourceLocation"), + Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), Values: []*string{ to.Ptr("East US"), - to.Ptr("West Europe")}, + to.Ptr("West Europe"), + }, }, }, { Tags: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), + Name: to.Ptr("Environment"), + Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), Values: []*string{ to.Ptr("UAT"), - to.Ptr("Prod")}, + to.Ptr("Prod"), + }, }, - }}, + }, + }, }, { Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), + Name: to.Ptr("ResourceGroup"), + Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), Values: []*string{ - to.Ptr("API")}, + to.Ptr("API"), + }, }, - }}, + }, + }, }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + 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 }()), + From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T00:00:00+00:00"); return t }()), + To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-31T23:59:59+00:00"); return t }()), }, - Timeframe: to.Ptr(armcostmanagement.ForecastTimeframeCustom), - }, &armcostmanagement.ForecastClientUsageOptions{Filter: nil}) + Timeframe: to.Ptr(armcostmanagement.ForecastTimeframeCustom), + }, 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"), + // res = armcostmanagement.ForecastClientExternalCloudProviderUsageResponse{ + // 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"), + // }, // }, - // { - // 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"}, + // Rows: [][]any{ + // []any{ + // 0, + // "Forecast", + // "USD", + // }, + // []any{ + // 30.2572751438, + // "Forecast", + // "USD", + // }, + // []any{ + // 0.07675760200000002, + // "Forecast", + // "USD", + // }, // []any{ - // float64(218.68795741935486), - // float64(20180331), + // 50.43096419040001, // "Forecast", - // "USD"}, - // []any{ - // float64(0.14384913581657052), - // float64(20180401), - // "Forecast", - // "USD"}, - // []any{ - // float64(0.009865586851323632), - // float64(20180429), - // "Forecast", - // "USD"}}, - // }, - // } + // "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() { +// Generated from example definition: 2025-03-01/ExternalSubscriptionForecast.json +func ExampleForecastClient_ExternalCloudProviderUsage_externalSubscriptionForecast() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -143,13 +142,13 @@ func ExampleForecastClient_Usage_billingProfileForecast() { 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), + 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), + Name: to.Ptr(armcostmanagement.FunctionNameCost), + Function: to.Ptr(armcostmanagement.FunctionTypeSum), }, }, Filter: &armcostmanagement.ForecastFilter{ @@ -158,97 +157,84 @@ func ExampleForecastClient_Usage_billingProfileForecast() { Or: []*armcostmanagement.ForecastFilter{ { Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), + Name: to.Ptr("ResourceLocation"), + Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), Values: []*string{ to.Ptr("East US"), - to.Ptr("West Europe")}, + to.Ptr("West Europe"), + }, }, }, { Tags: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), + Name: to.Ptr("Environment"), + Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), Values: []*string{ to.Ptr("UAT"), - to.Ptr("Prod")}, + to.Ptr("Prod"), + }, }, - }}, + }, + }, }, { Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), + Name: to.Ptr("ResourceGroup"), + Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), Values: []*string{ - to.Ptr("API")}, + to.Ptr("API"), + }, }, - }}, + }, + }, }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + 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 }()), + From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T00:00:00+00:00"); return t }()), + To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-31T23:59:59+00:00"); return t }()), }, - Timeframe: to.Ptr(armcostmanagement.ForecastTimeframeCustom), - }, &armcostmanagement.ForecastClientUsageOptions{Filter: nil}) + Timeframe: to.Ptr(armcostmanagement.ForecastTimeframeCustom), + }, 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"), + // res = armcostmanagement.ForecastClientExternalCloudProviderUsageResponse{ + // 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"), + // }, // }, - // { - // Name: to.Ptr("CostStatus"), - // Type: to.Ptr("String"), + // Rows: [][]any{ // }, - // { - // 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() { +// Generated from example definition: 2025-03-01/BillingAccountForecast.json +func ExampleForecastClient_Usage_billingAccountForecast() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -258,13 +244,13 @@ func ExampleForecastClient_Usage_departmentForecast() { 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), + 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), + Name: to.Ptr(armcostmanagement.FunctionNameCost), + Function: to.Ptr(armcostmanagement.FunctionTypeSum), }, }, Filter: &armcostmanagement.ForecastFilter{ @@ -273,97 +259,111 @@ func ExampleForecastClient_Usage_departmentForecast() { Or: []*armcostmanagement.ForecastFilter{ { Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), + Name: to.Ptr("ResourceLocation"), + Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), Values: []*string{ to.Ptr("East US"), - to.Ptr("West Europe")}, + to.Ptr("West Europe"), + }, }, }, { Tags: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), + Name: to.Ptr("Environment"), + Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), Values: []*string{ to.Ptr("UAT"), - to.Ptr("Prod")}, + to.Ptr("Prod"), + }, }, - }}, + }, + }, }, { Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), + Name: to.Ptr("ResourceGroup"), + Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), Values: []*string{ - to.Ptr("API")}, + to.Ptr("API"), + }, }, - }}, + }, + }, }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), }, - IncludeActualCost: to.Ptr(false), - IncludeFreshPartialCost: to.Ptr(false), + 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 }()), + From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T00:00:00+00:00"); return t }()), + To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-31T23:59:59+00:00"); return t }()), }, - Timeframe: to.Ptr(armcostmanagement.ForecastTimeframeCustom), - }, &armcostmanagement.ForecastClientUsageOptions{Filter: nil}) + Timeframe: to.Ptr(armcostmanagement.ForecastTimeframeCustom), + }, 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"), + // res = armcostmanagement.ForecastClientUsageResponse{ + // 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"), + // }, // }, - // { - // 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"}, + // NextLink: to.Ptr("https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/providers/Microsoft.CostManagement/Forecast?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D"), + // Rows: [][]any{ + // []any{ + // 2.10333307059661, + // 20180331, + // "Forecast", + // "USD", + // }, + // []any{ + // 218.68795741935486, + // 20180331, + // "Forecast", + // "USD", + // }, // []any{ - // float64(218.68795741935486), - // float64(20180331), + // 0.14384913581657052, + // 20180401, // "Forecast", - // "USD"}, - // []any{ - // float64(0.14384913581657052), - // float64(20180401), - // "Forecast", - // "USD"}, - // []any{ - // float64(0.009865586851323632), - // float64(20180429), - // "Forecast", - // "USD"}}, - // }, - // } + // "USD", + // }, + // []any{ + // 0.009865586851323632, + // 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() { +// Generated from example definition: 2025-03-01/BillingProfileForecast.json +func ExampleForecastClient_Usage_billingProfileForecast() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -373,13 +373,13 @@ func ExampleForecastClient_Usage_enrollmentAccountForecast() { 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), + 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), + Name: to.Ptr(armcostmanagement.FunctionNameCost), + Function: to.Ptr(armcostmanagement.FunctionTypeSum), }, }, Filter: &armcostmanagement.ForecastFilter{ @@ -388,97 +388,111 @@ func ExampleForecastClient_Usage_enrollmentAccountForecast() { Or: []*armcostmanagement.ForecastFilter{ { Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), + Name: to.Ptr("ResourceLocation"), + Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), Values: []*string{ to.Ptr("East US"), - to.Ptr("West Europe")}, + to.Ptr("West Europe"), + }, }, }, { Tags: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), + Name: to.Ptr("Environment"), + Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), Values: []*string{ to.Ptr("UAT"), - to.Ptr("Prod")}, + to.Ptr("Prod"), + }, }, - }}, + }, + }, }, { Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), + Name: to.Ptr("ResourceGroup"), + Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), Values: []*string{ - to.Ptr("API")}, + to.Ptr("API"), + }, }, - }}, + }, + }, }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), }, - IncludeActualCost: to.Ptr(false), - IncludeFreshPartialCost: to.Ptr(false), + 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 }()), + From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T00:00:00+00:00"); return t }()), + To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-31T23:59:59+00:00"); return t }()), }, - Timeframe: to.Ptr(armcostmanagement.ForecastTimeframeCustom), - }, &armcostmanagement.ForecastClientUsageOptions{Filter: nil}) + Timeframe: to.Ptr(armcostmanagement.ForecastTimeframeCustom), + }, 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"), + // res = armcostmanagement.ForecastClientUsageResponse{ + // 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"), + // }, // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(2.10333307059661), - // float64(20180331), - // "Forecast", - // "USD"}, + // NextLink: to.Ptr("https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/providers/Microsoft.CostManagement/Forecast?api-version=2019-10-01&$skiptoken=AQAAAA%3D%3D"), + // Rows: [][]any{ + // []any{ + // 2.10333307059661, + // 20180331, + // "Forecast", + // "USD", + // }, + // []any{ + // 218.68795741935486, + // 20180331, + // "Forecast", + // "USD", + // }, + // []any{ + // 0.14384913581657052, + // 20180401, + // "Forecast", + // "USD", + // }, // []any{ - // float64(218.68795741935486), - // float64(20180331), + // 0.009865586851323632, + // 20180429, // "Forecast", - // "USD"}, - // []any{ - // float64(0.14384913581657052), - // float64(20180401), - // "Forecast", - // "USD"}, - // []any{ - // float64(0.009865586851323632), - // float64(20180429), - // "Forecast", - // "USD"}}, - // }, - // } + // "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() { +// Generated from example definition: 2025-03-01/DepartmentForecast.json +func ExampleForecastClient_Usage_departmentForecast() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -488,13 +502,13 @@ func ExampleForecastClient_Usage_invoiceSectionForecast() { 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), + 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), + Name: to.Ptr(armcostmanagement.FunctionNameCost), + Function: to.Ptr(armcostmanagement.FunctionTypeSum), }, }, Filter: &armcostmanagement.ForecastFilter{ @@ -503,97 +517,111 @@ func ExampleForecastClient_Usage_invoiceSectionForecast() { Or: []*armcostmanagement.ForecastFilter{ { Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), + Name: to.Ptr("ResourceLocation"), + Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), Values: []*string{ to.Ptr("East US"), - to.Ptr("West Europe")}, + to.Ptr("West Europe"), + }, }, }, { Tags: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), + Name: to.Ptr("Environment"), + Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), Values: []*string{ to.Ptr("UAT"), - to.Ptr("Prod")}, + to.Ptr("Prod"), + }, }, - }}, + }, + }, }, { Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), + Name: to.Ptr("ResourceGroup"), + Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), Values: []*string{ - to.Ptr("API")}, + to.Ptr("API"), + }, }, - }}, + }, + }, }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), }, - IncludeActualCost: to.Ptr(false), - IncludeFreshPartialCost: to.Ptr(false), + 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 }()), + From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T00:00:00+00:00"); return t }()), + To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-31T23:59:59+00:00"); return t }()), }, - Timeframe: to.Ptr(armcostmanagement.ForecastTimeframeCustom), - }, &armcostmanagement.ForecastClientUsageOptions{Filter: nil}) + Timeframe: to.Ptr(armcostmanagement.ForecastTimeframeCustom), + }, 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"), + // res = armcostmanagement.ForecastClientUsageResponse{ + // 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"), + // }, // }, - // { - // 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"}, + // NextLink: to.Ptr("https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/departments/123/providers/Microsoft.CostManagement/Forecast?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D"), + // Rows: [][]any{ + // []any{ + // 2.10333307059661, + // 20180331, + // "Forecast", + // "USD", + // }, + // []any{ + // 218.68795741935486, + // 20180331, + // "Forecast", + // "USD", + // }, // []any{ - // float64(218.68795741935486), - // float64(20180331), + // 0.14384913581657052, + // 20180401, // "Forecast", - // "USD"}, - // []any{ - // float64(0.14384913581657052), - // float64(20180401), - // "Forecast", - // "USD"}, - // []any{ - // float64(0.009865586851323632), - // float64(20180429), - // "Forecast", - // "USD"}}, - // }, - // } + // "USD", + // }, + // []any{ + // 0.009865586851323632, + // 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() { +// Generated from example definition: 2025-03-01/EnrollmentAccountForecast.json +func ExampleForecastClient_Usage_enrollmentAccountForecast() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -603,13 +631,13 @@ func ExampleForecastClient_Usage_resourceGroupForecast() { 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), + 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), + Name: to.Ptr(armcostmanagement.FunctionNameCost), + Function: to.Ptr(armcostmanagement.FunctionTypeSum), }, }, Filter: &armcostmanagement.ForecastFilter{ @@ -618,82 +646,111 @@ func ExampleForecastClient_Usage_resourceGroupForecast() { Or: []*armcostmanagement.ForecastFilter{ { Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), + Name: to.Ptr("ResourceLocation"), + Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), Values: []*string{ to.Ptr("East US"), - to.Ptr("West Europe")}, + to.Ptr("West Europe"), + }, }, }, { Tags: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), + Name: to.Ptr("Environment"), + Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), Values: []*string{ to.Ptr("UAT"), - to.Ptr("Prod")}, + to.Ptr("Prod"), + }, }, - }}, + }, + }, }, { Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), + Name: to.Ptr("ResourceGroup"), + Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), Values: []*string{ - to.Ptr("API")}, + to.Ptr("API"), + }, }, - }}, + }, + }, }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), }, - IncludeActualCost: to.Ptr(false), - IncludeFreshPartialCost: to.Ptr(false), + 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 }()), + From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T00:00:00+00:00"); return t }()), + To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-31T23:59:59+00:00"); return t }()), }, - Timeframe: to.Ptr(armcostmanagement.ForecastTimeframeCustom), - }, &armcostmanagement.ForecastClientUsageOptions{Filter: nil}) + Timeframe: to.Ptr(armcostmanagement.ForecastTimeframeCustom), + }, 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"), + // res = armcostmanagement.ForecastClientUsageResponse{ + // 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"), + // }, // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(2.10333307059661), - // float64(20180331), - // "Forecast", - // "USD"}}, + // NextLink: to.Ptr("https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/enrollmentAccounts/456/providers/Microsoft.CostManagement/Forecast?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D"), + // Rows: [][]any{ + // []any{ + // 2.10333307059661, + // 20180331, + // "Forecast", + // "USD", + // }, + // []any{ + // 218.68795741935486, + // 20180331, + // "Forecast", + // "USD", + // }, + // []any{ + // 0.14384913581657052, + // 20180401, + // "Forecast", + // "USD", + // }, + // []any{ + // 0.009865586851323632, + // 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/SubscriptionForecast.json -func ExampleForecastClient_Usage_subscriptionForecast() { +// Generated from example definition: 2025-03-01/InvoiceSectionForecast.json +func ExampleForecastClient_Usage_invoiceSectionForecast() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -703,13 +760,13 @@ func ExampleForecastClient_Usage_subscriptionForecast() { 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), + 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), + Name: to.Ptr(armcostmanagement.FunctionNameCost), + Function: to.Ptr(armcostmanagement.FunctionTypeSum), }, }, Filter: &armcostmanagement.ForecastFilter{ @@ -718,97 +775,111 @@ func ExampleForecastClient_Usage_subscriptionForecast() { Or: []*armcostmanagement.ForecastFilter{ { Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), + Name: to.Ptr("ResourceLocation"), + Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), Values: []*string{ to.Ptr("East US"), - to.Ptr("West Europe")}, + to.Ptr("West Europe"), + }, }, }, { Tags: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), + Name: to.Ptr("Environment"), + Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), Values: []*string{ to.Ptr("UAT"), - to.Ptr("Prod")}, + to.Ptr("Prod"), + }, }, - }}, + }, + }, }, { Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), + Name: to.Ptr("ResourceGroup"), + Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), Values: []*string{ - to.Ptr("API")}, + to.Ptr("API"), + }, }, - }}, + }, + }, }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), }, - IncludeActualCost: to.Ptr(false), - IncludeFreshPartialCost: to.Ptr(false), + 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 }()), + From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T00:00:00+00:00"); return t }()), + To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-31T23:59:59+00:00"); return t }()), }, - Timeframe: to.Ptr(armcostmanagement.ForecastTimeframeCustom), - }, &armcostmanagement.ForecastClientUsageOptions{Filter: nil}) + Timeframe: to.Ptr(armcostmanagement.ForecastTimeframeCustom), + }, 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"), + // res = armcostmanagement.ForecastClientUsageResponse{ + // 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"), + // }, // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(2.10333307059661), - // float64(20180331), - // "Forecast", - // "USD"}, + // NextLink: to.Ptr("https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876/providers/Microsoft.CostManagement/Forecast?api-version=2019-10-01&$skiptoken=AQAAAA%3D%3D"), + // Rows: [][]any{ + // []any{ + // 2.10333307059661, + // 20180331, + // "Forecast", + // "USD", + // }, + // []any{ + // 218.68795741935486, + // 20180331, + // "Forecast", + // "USD", + // }, + // []any{ + // 0.14384913581657052, + // 20180401, + // "Forecast", + // "USD", + // }, // []any{ - // float64(218.68795741935486), - // float64(20180331), + // 0.009865586851323632, + // 20180429, // "Forecast", - // "USD"}, - // []any{ - // float64(0.14384913581657052), - // float64(20180401), - // "Forecast", - // "USD"}, - // []any{ - // float64(0.009865586851323632), - // float64(20180429), - // "Forecast", - // "USD"}}, - // }, - // } + // "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() { +// Generated from example definition: 2025-03-01/ResourceGroupForecast.json +func ExampleForecastClient_Usage_resourceGroupForecast() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -818,13 +889,13 @@ func ExampleForecastClient_ExternalCloudProviderUsage_externalBillingAccountFore 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), + 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), + Name: to.Ptr(armcostmanagement.FunctionNameCost), + Function: to.Ptr(armcostmanagement.FunctionTypeSum), }, }, Filter: &armcostmanagement.ForecastFilter{ @@ -833,87 +904,92 @@ func ExampleForecastClient_ExternalCloudProviderUsage_externalBillingAccountFore Or: []*armcostmanagement.ForecastFilter{ { Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), + Name: to.Ptr("ResourceLocation"), + Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), Values: []*string{ to.Ptr("East US"), - to.Ptr("West Europe")}, + to.Ptr("West Europe"), + }, }, }, { Tags: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), + Name: to.Ptr("Environment"), + Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), Values: []*string{ to.Ptr("UAT"), - to.Ptr("Prod")}, + to.Ptr("Prod"), + }, }, - }}, + }, + }, }, { Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), + Name: to.Ptr("ResourceGroup"), + Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), Values: []*string{ - to.Ptr("API")}, + to.Ptr("API"), + }, }, - }}, + }, + }, }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + 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 }()), + From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T00:00:00+00:00"); return t }()), + To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-31T23:59:59+00:00"); return t }()), }, - Timeframe: to.Ptr(armcostmanagement.ForecastTimeframeCustom), - }, &armcostmanagement.ForecastClientExternalCloudProviderUsageOptions{Filter: nil}) + Timeframe: to.Ptr(armcostmanagement.ForecastTimeframeCustom), + }, 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"), + // res = armcostmanagement.ForecastClientUsageResponse{ + // 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"), + // }, // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(0), - // "Forecast", - // "USD"}, + // Rows: [][]any{ // []any{ - // float64(30.2572751438), + // 2.10333307059661, + // 20180331, // "Forecast", - // "USD"}, - // []any{ - // float64(0.07675760200000002), - // "Forecast", - // "USD"}, - // []any{ - // float64(50.43096419040001), - // "Forecast", - // "USD"}}, - // }, - // } + // "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() { +// Generated from example definition: 2025-03-01/SubscriptionForecast.json +func ExampleForecastClient_Usage_subscriptionForecast() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -923,13 +999,13 @@ func ExampleForecastClient_ExternalCloudProviderUsage_externalSubscriptionForeca 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), + 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), + Name: to.Ptr(armcostmanagement.FunctionNameCost), + Function: to.Ptr(armcostmanagement.FunctionTypeSum), }, }, Filter: &armcostmanagement.ForecastFilter{ @@ -938,69 +1014,103 @@ func ExampleForecastClient_ExternalCloudProviderUsage_externalSubscriptionForeca Or: []*armcostmanagement.ForecastFilter{ { Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), + Name: to.Ptr("ResourceLocation"), + Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), Values: []*string{ to.Ptr("East US"), - to.Ptr("West Europe")}, + to.Ptr("West Europe"), + }, }, }, { Tags: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), + Name: to.Ptr("Environment"), + Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), Values: []*string{ to.Ptr("UAT"), - to.Ptr("Prod")}, + to.Ptr("Prod"), + }, }, - }}, + }, + }, }, { Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), + Name: to.Ptr("ResourceGroup"), + Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), Values: []*string{ - to.Ptr("API")}, + to.Ptr("API"), + }, }, - }}, + }, + }, }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + 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 }()), + From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T00:00:00+00:00"); return t }()), + To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-31T23:59:59+00:00"); return t }()), }, - Timeframe: to.Ptr(armcostmanagement.ForecastTimeframeCustom), - }, &armcostmanagement.ForecastClientExternalCloudProviderUsageOptions{Filter: nil}) + Timeframe: to.Ptr(armcostmanagement.ForecastTimeframeCustom), + }, 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"), + // res = armcostmanagement.ForecastClientUsageResponse{ + // 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"), + // }, // }, - // { - // Name: to.Ptr("CostStatus"), - // Type: to.Ptr("String"), + // Rows: [][]any{ + // []any{ + // 2.10333307059661, + // 20180331, + // "Forecast", + // "USD", + // }, + // []any{ + // 218.68795741935486, + // 20180331, + // "Forecast", + // "USD", + // }, + // []any{ + // 0.14384913581657052, + // 20180401, + // "Forecast", + // "USD", + // }, + // []any{ + // 0.009865586851323632, + // 20180429, + // "Forecast", + // "USD", + // }, // }, - // { - // 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..9c391eea1e69 --- /dev/null +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/generatebenefitutilizationsummariesreport_client.go @@ -0,0 +1,493 @@ +// 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) Go Code Generator. DO NOT EDIT. + +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 - Contains optional client configuration. 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 2025-03-01 +// - billingAccountID - BillingAccount 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]{ + 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 2025-03-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, _ *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", "2025-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []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 2025-03-01 +// - billingAccountID - BillingAccount 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]{ + 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 2025-03-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, _ *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", "2025-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []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 2025-03-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]{ + 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 2025-03-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, _ *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", "2025-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []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 2025-03-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]{ + 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 2025-03-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, _ *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", "2025-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []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 2025-03-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]{ + 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 2025-03-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, _ *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", "2025-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []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 2025-03-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]{ + 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 2025-03-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, _ *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", "2025-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, benefitUtilizationSummariesRequest); err != nil { + return nil, err + } + return req, nil +} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/generatebenefitutilizationsummariesreport_client_example_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/generatebenefitutilizationsummariesreport_client_example_test.go new file mode 100644 index 000000000000..68ebad85a963 --- /dev/null +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/generatebenefitutilizationsummariesreport_client_example_test.go @@ -0,0 +1,289 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armcostmanagement_test + +import ( + "context" + "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/v3" + "log" + "time" +) + +// Generated from example definition: 2025-03-01/BenefitUtilizationSummaries/Async/GenerateBenefitUtilizationSummariesReportByBillingAccount.json +func ExampleGenerateBenefitUtilizationSummariesReportClient_BeginGenerateByBillingAccount() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain 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.NewGenerateBenefitUtilizationSummariesReportClient().BeginGenerateByBillingAccount(ctx, "8099099", armcostmanagement.BenefitUtilizationSummariesRequest{ + EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-31T00:00:00Z"); return t }()), + Grain: to.Ptr(armcostmanagement.GrainDaily), + Kind: to.Ptr(armcostmanagement.BenefitKindReservation), + StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-06-01T00:00:00Z"); return t }()), + }, 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 = armcostmanagement.GenerateBenefitUtilizationSummariesReportClientGenerateByBillingAccountResponse{ + // BenefitUtilizationSummariesOperationStatus: &armcostmanagement.BenefitUtilizationSummariesOperationStatus{ + // Input: &armcostmanagement.BenefitUtilizationSummariesRequest{ + // BillingAccountID: to.Ptr("8099099"), + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-31T00:00:00Z"); return t}()), + // Grain: to.Ptr(armcostmanagement.GrainDaily), + // Kind: to.Ptr(armcostmanagement.BenefitKindReservation), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-06-01T00:00:00Z"); return t}()), + // }, + // Properties: &armcostmanagement.AsyncOperationStatusProperties{ + // ReportURL: to.Ptr(armcostmanagement.BenefitUtilizationSummaryReportSchema("https://storage.blob.core.windows.net/details/20220611/00000000-0000-0000-0000-000000000000?sv=2016-05-31&sr=b&sig=jep8HT2aphfUkyERRZa5LRfd9RPzjXbzB%2F9TNiQ")), + // SecondaryReportURL: to.Ptr(armcostmanagement.BenefitUtilizationSummaryReportSchema("https://storage-secondary.blob.core.windows.net/details/20220611/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, "2022-06-12T02:56:55.5021869Z"); return t}()), + // }, + // Status: to.Ptr(armcostmanagement.OperationStatusType("Complete")), + // }, + // } +} + +// Generated from example definition: 2025-03-01/BenefitUtilizationSummaries/Async/GenerateBenefitUtilizationSummariesReportByBillingProfile.json +func ExampleGenerateBenefitUtilizationSummariesReportClient_BeginGenerateByBillingProfile() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain 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.NewGenerateBenefitUtilizationSummariesReportClient().BeginGenerateByBillingProfile(ctx, "00000000-0000-0000-0000-000000000000", "CZSFR-SDFXC-DSDF", armcostmanagement.BenefitUtilizationSummariesRequest{ + EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-31T00:00:00Z"); return t }()), + Grain: to.Ptr(armcostmanagement.GrainDaily), + Kind: to.Ptr(armcostmanagement.BenefitKindReservation), + StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-06-01T00:00:00Z"); return t }()), + }, 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 = armcostmanagement.GenerateBenefitUtilizationSummariesReportClientGenerateByBillingProfileResponse{ + // BenefitUtilizationSummariesOperationStatus: &armcostmanagement.BenefitUtilizationSummariesOperationStatus{ + // Input: &armcostmanagement.BenefitUtilizationSummariesRequest{ + // BillingAccountID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // BillingProfileID: to.Ptr("CZSFR-SDFXC-DSDF"), + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-31T00:00:00Z"); return t}()), + // Grain: to.Ptr(armcostmanagement.GrainDaily), + // Kind: to.Ptr(armcostmanagement.BenefitKindReservation), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-06-01T00:00:00Z"); return t}()), + // }, + // Properties: &armcostmanagement.AsyncOperationStatusProperties{ + // ReportURL: to.Ptr(armcostmanagement.BenefitUtilizationSummaryReportSchema("https://storage.blob.core.windows.net/details/20220611/00000000-0000-0000-0000-000000000000?sv=2016-05-31&sr=b&sig=jep8HT2aphfUkyERRZa5LRfd9RPzjXbzB%2F9TNiQ")), + // SecondaryReportURL: to.Ptr(armcostmanagement.BenefitUtilizationSummaryReportSchema("https://storage-secondary.blob.core.windows.net/details/20220611/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, "2022-06-12T02:56:55.5021869Z"); return t}()), + // }, + // Status: to.Ptr(armcostmanagement.OperationStatusType("Complete")), + // }, + // } +} + +// Generated from example definition: 2025-03-01/BenefitUtilizationSummaries/Async/GenerateBenefitUtilizationSummariesReportByReservation.json +func ExampleGenerateBenefitUtilizationSummariesReportClient_BeginGenerateByReservationID() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain 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.NewGenerateBenefitUtilizationSummariesReportClient().BeginGenerateByReservationID(ctx, "00000000-0000-0000-0000-000000000000", "00000000-0000-0000-0000-000000000000", armcostmanagement.BenefitUtilizationSummariesRequest{ + EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-31T00:00:00Z"); return t }()), + Grain: to.Ptr(armcostmanagement.GrainDaily), + StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-06-01T00:00:00Z"); return t }()), + }, 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 = armcostmanagement.GenerateBenefitUtilizationSummariesReportClientGenerateByReservationIDResponse{ + // BenefitUtilizationSummariesOperationStatus: &armcostmanagement.BenefitUtilizationSummariesOperationStatus{ + // Input: &armcostmanagement.BenefitUtilizationSummariesRequest{ + // BenefitID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // BenefitOrderID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-31T00:00:00Z"); return t}()), + // Grain: to.Ptr(armcostmanagement.GrainDaily), + // Kind: to.Ptr(armcostmanagement.BenefitKindReservation), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-06-01T00:00:00Z"); return t}()), + // }, + // Properties: &armcostmanagement.AsyncOperationStatusProperties{ + // ReportURL: to.Ptr(armcostmanagement.BenefitUtilizationSummaryReportSchema("https://storage.blob.core.windows.net/details/20220611/00000000-0000-0000-0000-000000000000?sv=2016-05-31&sr=b&sig=jep8HT2aphfUkyERRZa5LRfd9RPzjXbzB%2F9TNiQ")), + // SecondaryReportURL: to.Ptr(armcostmanagement.BenefitUtilizationSummaryReportSchema("https://storage-secondary.blob.core.windows.net/details/20220611/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, "2022-06-12T02:56:55.5021869Z"); return t}()), + // }, + // Status: to.Ptr(armcostmanagement.OperationStatusType("Complete")), + // }, + // } +} + +// Generated from example definition: 2025-03-01/BenefitUtilizationSummaries/Async/GenerateBenefitUtilizationSummariesReportByReservationOrder.json +func ExampleGenerateBenefitUtilizationSummariesReportClient_BeginGenerateByReservationOrderID() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain 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.NewGenerateBenefitUtilizationSummariesReportClient().BeginGenerateByReservationOrderID(ctx, "00000000-0000-0000-0000-000000000000", armcostmanagement.BenefitUtilizationSummariesRequest{ + EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-31T00:00:00Z"); return t }()), + Grain: to.Ptr(armcostmanagement.GrainDaily), + StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-06-01T00:00:00Z"); return t }()), + }, 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 = armcostmanagement.GenerateBenefitUtilizationSummariesReportClientGenerateByReservationOrderIDResponse{ + // BenefitUtilizationSummariesOperationStatus: &armcostmanagement.BenefitUtilizationSummariesOperationStatus{ + // Input: &armcostmanagement.BenefitUtilizationSummariesRequest{ + // BenefitOrderID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-31T00:00:00Z"); return t}()), + // Grain: to.Ptr(armcostmanagement.GrainDaily), + // Kind: to.Ptr(armcostmanagement.BenefitKindReservation), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-06-01T00:00:00Z"); return t}()), + // }, + // Properties: &armcostmanagement.AsyncOperationStatusProperties{ + // ReportURL: to.Ptr(armcostmanagement.BenefitUtilizationSummaryReportSchema("https://storage.blob.core.windows.net/details/20220611/00000000-0000-0000-0000-000000000000?sv=2016-05-31&sr=b&sig=jep8HT2aphfUkyERRZa5LRfd9RPzjXbzB%2F9TNiQ")), + // SecondaryReportURL: to.Ptr(armcostmanagement.BenefitUtilizationSummaryReportSchema("https://storage-secondary.blob.core.windows.net/details/20220611/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, "2022-06-12T02:56:55.5021869Z"); return t}()), + // }, + // Status: to.Ptr(armcostmanagement.OperationStatusType("Complete")), + // }, + // } +} + +// Generated from example definition: 2025-03-01/BenefitUtilizationSummaries/Async/GenerateBenefitUtilizationSummariesReportBySavingsPlan.json +func ExampleGenerateBenefitUtilizationSummariesReportClient_BeginGenerateBySavingsPlanID() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain 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.NewGenerateBenefitUtilizationSummariesReportClient().BeginGenerateBySavingsPlanID(ctx, "00000000-0000-0000-0000-000000000000", "00000000-0000-0000-0000-000000000000", armcostmanagement.BenefitUtilizationSummariesRequest{ + EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-31T00:00:00Z"); return t }()), + Grain: to.Ptr(armcostmanagement.GrainDaily), + StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-06-01T00:00:00Z"); return t }()), + }, 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 = armcostmanagement.GenerateBenefitUtilizationSummariesReportClientGenerateBySavingsPlanIDResponse{ + // BenefitUtilizationSummariesOperationStatus: &armcostmanagement.BenefitUtilizationSummariesOperationStatus{ + // Input: &armcostmanagement.BenefitUtilizationSummariesRequest{ + // BenefitID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // BenefitOrderID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-31T00:00:00Z"); return t}()), + // Grain: to.Ptr(armcostmanagement.GrainDaily), + // Kind: to.Ptr(armcostmanagement.BenefitKindSavingsPlan), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-06-01T00:00:00Z"); return t}()), + // }, + // Properties: &armcostmanagement.AsyncOperationStatusProperties{ + // ReportURL: to.Ptr(armcostmanagement.BenefitUtilizationSummaryReportSchema("https://storage.blob.core.windows.net/details/20220611/00000000-0000-0000-0000-000000000000?sv=2016-05-31&sr=b&sig=jep8HT2aphfUkyERRZa5LRfd9RPzjXbzB%2F9TNiQ")), + // SecondaryReportURL: to.Ptr(armcostmanagement.BenefitUtilizationSummaryReportSchema("https://storage-secondary.blob.core.windows.net/details/20220611/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, "2022-06-12T02:56:55.5021869Z"); return t}()), + // }, + // Status: to.Ptr(armcostmanagement.OperationStatusType("Complete")), + // }, + // } +} + +// Generated from example definition: 2025-03-01/BenefitUtilizationSummaries/Async/GenerateBenefitUtilizationSummariesReportBySavingsPlanOrder.json +func ExampleGenerateBenefitUtilizationSummariesReportClient_BeginGenerateBySavingsPlanOrderID() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain 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.NewGenerateBenefitUtilizationSummariesReportClient().BeginGenerateBySavingsPlanOrderID(ctx, "00000000-0000-0000-0000-000000000000", armcostmanagement.BenefitUtilizationSummariesRequest{ + EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-31T00:00:00Z"); return t }()), + Grain: to.Ptr(armcostmanagement.GrainDaily), + StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-06-01T00:00:00Z"); return t }()), + }, 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 = armcostmanagement.GenerateBenefitUtilizationSummariesReportClientGenerateBySavingsPlanOrderIDResponse{ + // BenefitUtilizationSummariesOperationStatus: &armcostmanagement.BenefitUtilizationSummariesOperationStatus{ + // Input: &armcostmanagement.BenefitUtilizationSummariesRequest{ + // BenefitOrderID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-31T00:00:00Z"); return t}()), + // Grain: to.Ptr(armcostmanagement.GrainDaily), + // Kind: to.Ptr(armcostmanagement.BenefitKindSavingsPlan), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-06-01T00:00:00Z"); return t}()), + // }, + // Properties: &armcostmanagement.AsyncOperationStatusProperties{ + // ReportURL: to.Ptr(armcostmanagement.BenefitUtilizationSummaryReportSchema("https://storage.blob.core.windows.net/details/20220611/00000000-0000-0000-0000-000000000000?sv=2016-05-31&sr=b&sig=jep8HT2aphfUkyERRZa5LRfd9RPzjXbzB%2F9TNiQ")), + // SecondaryReportURL: to.Ptr(armcostmanagement.BenefitUtilizationSummaryReportSchema("https://storage-secondary.blob.core.windows.net/details/20220611/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, "2022-06-12T02:56:55.5021869Z"); return t}()), + // }, + // Status: to.Ptr(armcostmanagement.OperationStatusType("Complete")), + // }, + // } +} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/generatecostdetailsreport_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/generatecostdetailsreport_client.go index 705ba5040dc6..8b96d18d0e70 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/generatecostdetailsreport_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/generatecostdetailsreport_client.go @@ -1,7 +1,6 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armcostmanagement @@ -25,7 +24,7 @@ type GenerateCostDetailsReportClient struct { // NewGenerateCostDetailsReportClient creates a new instance of GenerateCostDetailsReportClient with the specified values. // - credential - used to authorize requests. Usually a credential from azidentity. -// - options - pass nil to accept the default values. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewGenerateCostDetailsReportClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*GenerateCostDetailsReportClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -38,21 +37,19 @@ func NewGenerateCostDetailsReportClient(credential azcore.TokenCredential, optio } // BeginCreateOperation - This API is the replacement for all previously release Usage Details APIs. Request to generate a -// cost details report for the provided date range, billing period (Only enterprise customers) or Invoice -// Id asynchronously at a certain scope. The initial call to request a report will return a 202 with a 'Location' and 'Retry-After' -// header. The 'Location' header will provide the endpoint to poll to get -// the result of the report generation. The 'Retry-After' provides the duration to wait before polling for the generated report. -// A call to poll the report operation will provide a 202 response with a -// 'Location' header if the operation is still in progress. Once the report generation operation completes, the polling endpoint -// will provide a 200 response along with details on the report blob(s) that -// are available for download. The details on the file(s) available for download will be available in the polling response -// body. To Understand cost details (formerly known as usage details) fields found -// in files ,see https://learn.microsoft.com/en-us/azure/cost-management-billing/automate/understand-usage-details-fields +// cost details report for the provided date range, billing period (Only enterprise customers) or Invoice Id asynchronously +// at a certain scope. The initial call to request a report will return a 202 with a 'Location' and 'Retry-After' header. +// The 'Location' header will provide the endpoint to poll to get the result of the report generation. The 'Retry-After' provides +// the duration to wait before polling for the generated report. A call to poll the report operation will provide a 202 response +// with a 'Location' header if the operation is still in progress. Once the report generation operation completes, the polling +// endpoint will provide a 200 response along with details on the report blob(s) that are available for download. The details +// on the file(s) available for download will be available in the polling response body. To Understand cost details (formerly +// known as usage details) fields found 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 2025-03-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. @@ -63,8 +60,7 @@ func (client *GenerateCostDetailsReportClient) BeginCreateOperation(ctx context. return nil, err } poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[GenerateCostDetailsReportClientCreateOperationResponse]{ - FinalStateVia: runtime.FinalStateViaLocation, - Tracer: client.internal.Tracer(), + Tracer: client.internal.Tracer(), }) return poller, err } else { @@ -75,19 +71,17 @@ func (client *GenerateCostDetailsReportClient) BeginCreateOperation(ctx context. } // CreateOperation - This API is the replacement for all previously release Usage Details APIs. Request to generate a cost -// details report for the provided date range, billing period (Only enterprise customers) or Invoice -// Id asynchronously at a certain scope. The initial call to request a report will return a 202 with a 'Location' and 'Retry-After' -// header. The 'Location' header will provide the endpoint to poll to get -// the result of the report generation. The 'Retry-After' provides the duration to wait before polling for the generated report. -// A call to poll the report operation will provide a 202 response with a -// 'Location' header if the operation is still in progress. Once the report generation operation completes, the polling endpoint -// will provide a 200 response along with details on the report blob(s) that -// are available for download. The details on the file(s) available for download will be available in the polling response -// body. To Understand cost details (formerly known as usage details) fields found -// in files ,see https://learn.microsoft.com/en-us/azure/cost-management-billing/automate/understand-usage-details-fields +// details report for the provided date range, billing period (Only enterprise customers) or Invoice Id asynchronously at +// a certain scope. The initial call to request a report will return a 202 with a 'Location' and 'Retry-After' header. The +// 'Location' header will provide the endpoint to poll to get the result of the report generation. The 'Retry-After' provides +// the duration to wait before polling for the generated report. A call to poll the report operation will provide a 202 response +// with a 'Location' header if the operation is still in progress. Once the report generation operation completes, the polling +// endpoint will provide a 200 response along with details on the report blob(s) that are available for download. The details +// on the file(s) available for download will be available in the polling response body. To Understand cost details (formerly +// known as usage details) fields found 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 2025-03-01 func (client *GenerateCostDetailsReportClient) createOperation(ctx context.Context, scope string, parameters GenerateCostDetailsReportRequestDefinition, options *GenerateCostDetailsReportClientBeginCreateOperationOptions) (*http.Response, error) { var err error const operationName = "GenerateCostDetailsReportClient.BeginCreateOperation" @@ -110,17 +104,21 @@ func (client *GenerateCostDetailsReportClient) createOperation(ctx context.Conte } // createOperationCreateRequest creates the CreateOperation request. -func (client *GenerateCostDetailsReportClient) createOperationCreateRequest(ctx context.Context, scope string, parameters GenerateCostDetailsReportRequestDefinition, options *GenerateCostDetailsReportClientBeginCreateOperationOptions) (*policy.Request, error) { +func (client *GenerateCostDetailsReportClient) createOperationCreateRequest(ctx context.Context, scope string, parameters GenerateCostDetailsReportRequestDefinition, _ *GenerateCostDetailsReportClientBeginCreateOperationOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.CostManagement/generateCostDetailsReport" + if scope == "" { + return nil, errors.New("parameter scope cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) 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", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -131,9 +129,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 2025-03-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. @@ -144,8 +142,7 @@ func (client *GenerateCostDetailsReportClient) BeginGetOperationResults(ctx cont return nil, err } poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[GenerateCostDetailsReportClientGetOperationResultsResponse]{ - FinalStateVia: runtime.FinalStateViaLocation, - Tracer: client.internal.Tracer(), + Tracer: client.internal.Tracer(), }) return poller, err } else { @@ -159,7 +156,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 2025-03-01 func (client *GenerateCostDetailsReportClient) getOperationResults(ctx context.Context, scope string, operationID string, options *GenerateCostDetailsReportClientBeginGetOperationResultsOptions) (*http.Response, error) { var err error const operationName = "GenerateCostDetailsReportClient.BeginGetOperationResults" @@ -182,8 +179,11 @@ func (client *GenerateCostDetailsReportClient) getOperationResults(ctx context.C } // getOperationResultsCreateRequest creates the GetOperationResults request. -func (client *GenerateCostDetailsReportClient) getOperationResultsCreateRequest(ctx context.Context, scope string, operationID string, options *GenerateCostDetailsReportClientBeginGetOperationResultsOptions) (*policy.Request, error) { +func (client *GenerateCostDetailsReportClient) getOperationResultsCreateRequest(ctx context.Context, scope string, operationID string, _ *GenerateCostDetailsReportClientBeginGetOperationResultsOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.CostManagement/costDetailsOperationResults/{operationId}" + if scope == "" { + return nil, errors.New("parameter scope cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) if operationID == "" { return nil, errors.New("parameter operationID cannot be empty") @@ -194,7 +194,7 @@ func (client *GenerateCostDetailsReportClient) getOperationResultsCreateRequest( return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2025-03-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 index 023047988d07..9b57c3552d20 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/generatecostdetailsreport_client_example_test.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/generatecostdetailsreport_client_example_test.go @@ -1,21 +1,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. +// Code generated by Microsoft (R) Go Code Generator. 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" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v3" + "log" ) -// Generated from 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 +// Generated from example definition: 2025-03-01/GenerateCostDetailsReportByBillingAccountEnterpriseAgreementCustomerAndBillingPeriod.json func ExampleGenerateCostDetailsReportClient_BeginCreateOperation_generateCostDetailsReportByBillingAccountEnterpriseAgreementCustomerAndBillingPeriod() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -27,8 +24,8 @@ func ExampleGenerateCostDetailsReportClient_BeginCreateOperation_generateCostDet 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), + BillingPeriod: to.Ptr("202205"), + Metric: to.Ptr(armcostmanagement.CostDetailsMetricTypeActualCostCostDetailsMetricType), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) @@ -40,34 +37,37 @@ func ExampleGenerateCostDetailsReportClient_BeginCreateOperation_generateCostDet // 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), + // res = armcostmanagement.GenerateCostDetailsReportClientCreateOperationResponse{ + // 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("2025-03-01"), + // RequestContext: &armcostmanagement.RequestContext{ + // RequestBody: &armcostmanagement.GenerateCostDetailsReportRequestDefinition{ + // BillingPeriod: to.Ptr("202205"), + // Metric: to.Ptr(armcostmanagement.CostDetailsMetricTypeActualCostCostDetailsMetricType), + // }, + // RequestScope: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345"), // }, - // 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.1973252Z"); return t}()), // }, - // 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 +// Generated from example definition: 2025-03-01/GenerateCostDetailsReportByBillingProfileAndInvoiceId.json func ExampleGenerateCostDetailsReportClient_BeginCreateOperation_generateCostDetailsReportByBillingProfileAndInvoiceId() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -79,8 +79,8 @@ func ExampleGenerateCostDetailsReportClient_BeginCreateOperation_generateCostDet 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), + InvoiceID: to.Ptr("M1234567"), + Metric: to.Ptr(armcostmanagement.CostDetailsMetricTypeActualCostCostDetailsMetricType), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) @@ -92,34 +92,37 @@ func ExampleGenerateCostDetailsReportClient_BeginCreateOperation_generateCostDet // 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), + // res = armcostmanagement.GenerateCostDetailsReportClientCreateOperationResponse{ + // 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("2025-03-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"), // }, - // 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.1973252Z"); return t}()), // }, - // 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 +// Generated from example definition: 2025-03-01/GenerateCostDetailsReportByBillingProfileAndInvoiceIdAndCustomerId.json func ExampleGenerateCostDetailsReportClient_BeginCreateOperation_generateCostDetailsReportByBillingProfileAndInvoiceIdAndCustomerId() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -131,8 +134,8 @@ func ExampleGenerateCostDetailsReportClient_BeginCreateOperation_generateCostDet 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), + InvoiceID: to.Ptr("M1234567"), + Metric: to.Ptr(armcostmanagement.CostDetailsMetricTypeActualCostCostDetailsMetricType), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) @@ -144,34 +147,37 @@ func ExampleGenerateCostDetailsReportClient_BeginCreateOperation_generateCostDet // 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), + // res = armcostmanagement.GenerateCostDetailsReportClientCreateOperationResponse{ + // 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("2025-03-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"), // }, - // 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.1973252Z"); return t}()), // }, - // 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 +// Generated from example definition: 2025-03-01/GenerateCostDetailsReportByCustomerAndTimePeriod.json func ExampleGenerateCostDetailsReportClient_BeginCreateOperation_generateCostDetailsReportByCustomerAndTimePeriod() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -183,10 +189,10 @@ func ExampleGenerateCostDetailsReportClient_BeginCreateOperation_generateCostDet 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), + Metric: to.Ptr(armcostmanagement.CostDetailsMetricTypeActualCostCostDetailsMetricType), TimePeriod: &armcostmanagement.CostDetailsTimePeriod{ - End: to.Ptr("2020-03-15"), - Start: to.Ptr("2020-03-01"), + End: to.Ptr("2020-03-15"), + Start: to.Ptr("2020-03-01"), }, }, nil) if err != nil { @@ -199,37 +205,40 @@ func ExampleGenerateCostDetailsReportClient_BeginCreateOperation_generateCostDet // 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"), + // res = armcostmanagement.GenerateCostDetailsReportClientCreateOperationResponse{ + // 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("2025-03-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"), // }, - // 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.1973252Z"); return t}()), // }, - // 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 +// Generated from example definition: 2025-03-01/GenerateCostDetailsReportByDepartmentsAndTimePeriod.json func ExampleGenerateCostDetailsReportClient_BeginCreateOperation_generateCostDetailsReportByDepartmentsAndTimePeriod() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -241,10 +250,10 @@ func ExampleGenerateCostDetailsReportClient_BeginCreateOperation_generateCostDet 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), + Metric: to.Ptr(armcostmanagement.CostDetailsMetricTypeActualCostCostDetailsMetricType), TimePeriod: &armcostmanagement.CostDetailsTimePeriod{ - End: to.Ptr("2020-03-15"), - Start: to.Ptr("2020-03-01"), + End: to.Ptr("2020-03-15"), + Start: to.Ptr("2020-03-01"), }, }, nil) if err != nil { @@ -257,37 +266,40 @@ func ExampleGenerateCostDetailsReportClient_BeginCreateOperation_generateCostDet // 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"), + // res = armcostmanagement.GenerateCostDetailsReportClientCreateOperationResponse{ + // 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), // }, // }, - // RequestScope: to.Ptr("providers/Microsoft.Billing/departments/12345"), + // ByteCount: to.Ptr[int64](32741), + // CompressData: to.Ptr(false), + // DataFormat: to.Ptr(armcostmanagement.CostDetailsDataFormatCSVCostDetailsDataFormat), + // ManifestVersion: to.Ptr("2025-03-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.1973252Z"); return t}()), // }, - // 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 +// Generated from example definition: 2025-03-01/GenerateCostDetailsReportByEnrollmentAccountsAndTimePeriod.json func ExampleGenerateCostDetailsReportClient_BeginCreateOperation_generateCostDetailsReportByEnrollmentAccountsAndTimePeriod() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -299,10 +311,10 @@ func ExampleGenerateCostDetailsReportClient_BeginCreateOperation_generateCostDet 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), + Metric: to.Ptr(armcostmanagement.CostDetailsMetricTypeActualCostCostDetailsMetricType), TimePeriod: &armcostmanagement.CostDetailsTimePeriod{ - End: to.Ptr("2020-03-15"), - Start: to.Ptr("2020-03-01"), + End: to.Ptr("2020-03-15"), + Start: to.Ptr("2020-03-01"), }, }, nil) if err != nil { @@ -315,37 +327,40 @@ func ExampleGenerateCostDetailsReportClient_BeginCreateOperation_generateCostDet // 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"), + // res = armcostmanagement.GenerateCostDetailsReportClientCreateOperationResponse{ + // 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), // }, // }, - // RequestScope: to.Ptr("providers/Microsoft.Billing/enrollmentAccounts/1234"), + // ByteCount: to.Ptr[int64](32741), + // CompressData: to.Ptr(false), + // DataFormat: to.Ptr(armcostmanagement.CostDetailsDataFormatCSVCostDetailsDataFormat), + // ManifestVersion: to.Ptr("2025-03-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.1973252Z"); return t}()), // }, - // 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 +// Generated from example definition: 2025-03-01/GenerateCostDetailsReportBySubscriptionAndTimePeriod.json func ExampleGenerateCostDetailsReportClient_BeginCreateOperation_generateCostDetailsReportBySubscriptionAndTimePeriod() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -357,10 +372,10 @@ func ExampleGenerateCostDetailsReportClient_BeginCreateOperation_generateCostDet 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), + Metric: to.Ptr(armcostmanagement.CostDetailsMetricTypeActualCostCostDetailsMetricType), TimePeriod: &armcostmanagement.CostDetailsTimePeriod{ - End: to.Ptr("2020-03-15"), - Start: to.Ptr("2020-03-01"), + End: to.Ptr("2020-03-15"), + Start: to.Ptr("2020-03-01"), }, }, nil) if err != nil { @@ -373,37 +388,40 @@ func ExampleGenerateCostDetailsReportClient_BeginCreateOperation_generateCostDet // 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"), + // res = armcostmanagement.GenerateCostDetailsReportClientCreateOperationResponse{ + // 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("2025-03-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"), // }, - // 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.1973252Z"); return t}()), // }, - // 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 +// Generated from example definition: 2025-03-01/CostDetailsOperationResultsBySubscriptionScope.json func ExampleGenerateCostDetailsReportClient_BeginGetOperationResults() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -425,32 +443,35 @@ func ExampleGenerateCostDetailsReportClient_BeginGetOperationResults() { // 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"), + // res = armcostmanagement.GenerateCostDetailsReportClientGetOperationResultsResponse{ + // 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("2025-03-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"), // }, - // 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.1973252Z"); return t}()), // }, - // 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 a1d9750df137..2396d50bd9b4 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreport_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreport_client.go @@ -1,12 +1,12 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. 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" @@ -23,7 +23,7 @@ type GenerateDetailedCostReportClient struct { // NewGenerateDetailedCostReportClient creates a new instance of GenerateDetailedCostReportClient with the specified values. // - credential - used to authorize requests. Usually a credential from azidentity. -// - options - pass nil to accept the default values. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewGenerateDetailedCostReportClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*GenerateDetailedCostReportClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -36,13 +36,12 @@ func NewGenerateDetailedCostReportClient(credential azcore.TokenCredential, opti } // BeginCreateOperation - Generates the detailed cost report for provided date range, billing period(only enterprise customers) -// or Invoice ID asynchronously at a certain scope. Call returns a 202 with header -// Azure-Consumption-AsyncOperation providing a link to the operation created. A call on the operation will provide the status -// and if the operation is completed the blob file where generated detailed -// cost report is being stored. +// or Invoice ID asynchronously at a certain scope. Call returns a 202 with header Azure-Consumption-AsyncOperation providing +// a link to the operation created. A call on the operation will provide the status and if the operation is completed the +// blob file where generated detailed 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 2025-03-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. @@ -55,8 +54,7 @@ func (client *GenerateDetailedCostReportClient) BeginCreateOperation(ctx context return nil, err } poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[GenerateDetailedCostReportClientCreateOperationResponse]{ - FinalStateVia: runtime.FinalStateViaLocation, - Tracer: client.internal.Tracer(), + Tracer: client.internal.Tracer(), }) return poller, err } else { @@ -67,13 +65,12 @@ func (client *GenerateDetailedCostReportClient) BeginCreateOperation(ctx context } // CreateOperation - Generates the detailed cost report for provided date range, billing period(only enterprise customers) -// or Invoice ID asynchronously at a certain scope. Call returns a 202 with header -// Azure-Consumption-AsyncOperation providing a link to the operation created. A call on the operation will provide the status -// and if the operation is completed the blob file where generated detailed -// cost report is being stored. +// or Invoice ID asynchronously at a certain scope. Call returns a 202 with header Azure-Consumption-AsyncOperation providing +// a link to the operation created. A call on the operation will provide the status and if the operation is completed the +// blob file where generated detailed 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 2025-03-01 func (client *GenerateDetailedCostReportClient) createOperation(ctx context.Context, scope string, parameters GenerateDetailedCostReportDefinition, options *GenerateDetailedCostReportClientBeginCreateOperationOptions) (*http.Response, error) { var err error const operationName = "GenerateDetailedCostReportClient.BeginCreateOperation" @@ -96,17 +93,21 @@ func (client *GenerateDetailedCostReportClient) createOperation(ctx context.Cont } // createOperationCreateRequest creates the CreateOperation request. -func (client *GenerateDetailedCostReportClient) createOperationCreateRequest(ctx context.Context, scope string, parameters GenerateDetailedCostReportDefinition, options *GenerateDetailedCostReportClientBeginCreateOperationOptions) (*policy.Request, error) { +func (client *GenerateDetailedCostReportClient) createOperationCreateRequest(ctx context.Context, scope string, parameters GenerateDetailedCostReportDefinition, _ *GenerateDetailedCostReportClientBeginCreateOperationOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.CostManagement/generateDetailedCostReport" + if scope == "" { + return nil, errors.New("parameter scope cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) 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", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreport_client_example_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreport_client_example_test.go index 980707a82eb4..4c5e6690d16d 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreport_client_example_test.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreport_client_example_test.go @@ -1,21 +1,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. +// Code generated by Microsoft (R) Go Code Generator. 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" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v3" + "log" ) -// Generated from 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 +// Generated from example definition: 2025-03-01/GenerateDetailedCostReportByBillingAccountLegacyAndBillingPeriod.json func ExampleGenerateDetailedCostReportClient_BeginCreateOperation_generateDetailedCostReportByBillingAccountLegacyAndBillingPeriod() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -27,8 +24,8 @@ func ExampleGenerateDetailedCostReportClient_BeginCreateOperation_generateDetail 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), + BillingPeriod: to.Ptr("202008"), + Metric: to.Ptr(armcostmanagement.GenerateDetailedCostReportMetricTypeActualCost), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) @@ -40,18 +37,20 @@ func ExampleGenerateDetailedCostReportClient_BeginCreateOperation_generateDetail // 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}()), + // res = armcostmanagement.GenerateDetailedCostReportClientCreateOperationResponse{ + // 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.4394737Z"); 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 +// Generated from example definition: 2025-03-01/GenerateDetailedCostReportByBillingProfileAndInvoiceId.json func ExampleGenerateDetailedCostReportClient_BeginCreateOperation_generateDetailedCostReportByBillingProfileAndInvoiceId() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -63,8 +62,8 @@ func ExampleGenerateDetailedCostReportClient_BeginCreateOperation_generateDetail 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), + InvoiceID: to.Ptr("M1234567"), + Metric: to.Ptr(armcostmanagement.GenerateDetailedCostReportMetricTypeActualCost), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) @@ -76,18 +75,20 @@ func ExampleGenerateDetailedCostReportClient_BeginCreateOperation_generateDetail // 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}()), + // res = armcostmanagement.GenerateDetailedCostReportClientCreateOperationResponse{ + // 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.4394737Z"); 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 +// Generated from example definition: 2025-03-01/GenerateDetailedCostReportByBillingProfileAndInvoiceIdAndCustomerId.json func ExampleGenerateDetailedCostReportClient_BeginCreateOperation_generateDetailedCostReportByBillingProfileAndInvoiceIdAndCustomerId() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -99,9 +100,9 @@ func ExampleGenerateDetailedCostReportClient_BeginCreateOperation_generateDetail 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), + 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) @@ -113,18 +114,20 @@ func ExampleGenerateDetailedCostReportClient_BeginCreateOperation_generateDetail // 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}()), + // res = armcostmanagement.GenerateDetailedCostReportClientCreateOperationResponse{ + // 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.4394737Z"); 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 +// Generated from example definition: 2025-03-01/GenerateDetailedCostReportByCustomerAndTimePeriod.json func ExampleGenerateDetailedCostReportClient_BeginCreateOperation_generateDetailedCostReportByCustomerAndTimePeriod() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -136,10 +139,10 @@ func ExampleGenerateDetailedCostReportClient_BeginCreateOperation_generateDetail 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), + Metric: to.Ptr(armcostmanagement.GenerateDetailedCostReportMetricTypeActualCost), TimePeriod: &armcostmanagement.GenerateDetailedCostReportTimePeriod{ - End: to.Ptr("2020-03-15"), - Start: to.Ptr("2020-03-01"), + End: to.Ptr("2020-03-15"), + Start: to.Ptr("2020-03-01"), }, }, nil) if err != nil { @@ -152,18 +155,20 @@ func ExampleGenerateDetailedCostReportClient_BeginCreateOperation_generateDetail // 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}()), + // res = armcostmanagement.GenerateDetailedCostReportClientCreateOperationResponse{ + // 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.4394737Z"); 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 +// Generated from example definition: 2025-03-01/GenerateDetailedCostReportBySubscriptionAndTimePeriod.json func ExampleGenerateDetailedCostReportClient_BeginCreateOperation_generateDetailedCostReportBySubscriptionAndTimePeriod() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -175,10 +180,10 @@ func ExampleGenerateDetailedCostReportClient_BeginCreateOperation_generateDetail 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), + Metric: to.Ptr(armcostmanagement.GenerateDetailedCostReportMetricTypeActualCost), TimePeriod: &armcostmanagement.GenerateDetailedCostReportTimePeriod{ - End: to.Ptr("2020-03-15"), - Start: to.Ptr("2020-03-01"), + End: to.Ptr("2020-03-15"), + Start: to.Ptr("2020-03-01"), }, }, nil) if err != nil { @@ -191,13 +196,15 @@ func ExampleGenerateDetailedCostReportClient_BeginCreateOperation_generateDetail // 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}()), + // res = armcostmanagement.GenerateDetailedCostReportClientCreateOperationResponse{ + // 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.4394737Z"); return t}()), + // }, // }, // } } diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationresults_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationresults_client.go index 7f8d5ba42b17..4c5d50264584 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationresults_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationresults_client.go @@ -1,7 +1,6 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armcostmanagement @@ -17,7 +16,8 @@ import ( "strings" ) -// GenerateDetailedCostReportOperationResultsClient contains the methods for the GenerateDetailedCostReportOperationResults group. +// GenerateDetailedCostReportOperationResultsClient contains the methods for the GenerateDetailedCostReportOperationResults +// group. // Don't use this type directly, use NewGenerateDetailedCostReportOperationResultsClient() instead. type GenerateDetailedCostReportOperationResultsClient struct { internal *arm.Client @@ -25,7 +25,7 @@ type GenerateDetailedCostReportOperationResultsClient struct { // NewGenerateDetailedCostReportOperationResultsClient creates a new instance of GenerateDetailedCostReportOperationResultsClient with the specified values. // - credential - used to authorize requests. Usually a credential from azidentity. -// - options - pass nil to accept the default values. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewGenerateDetailedCostReportOperationResultsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*GenerateDetailedCostReportOperationResultsClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -41,10 +41,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 -// - 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. +// Generated from API version 2025-03-01 // - options - GenerateDetailedCostReportOperationResultsClientBeginGetOptions contains the optional parameters for the GenerateDetailedCostReportOperationResultsClient.BeginGet // method. func (client *GenerateDetailedCostReportOperationResultsClient) BeginGet(ctx context.Context, operationID string, scope string, options *GenerateDetailedCostReportOperationResultsClientBeginGetOptions) (*runtime.Poller[GenerateDetailedCostReportOperationResultsClientGetResponse], error) { @@ -68,7 +65,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 2025-03-01 func (client *GenerateDetailedCostReportOperationResultsClient) get(ctx context.Context, operationID string, scope string, options *GenerateDetailedCostReportOperationResultsClientBeginGetOptions) (*http.Response, error) { var err error const operationName = "GenerateDetailedCostReportOperationResultsClient.BeginGet" @@ -91,19 +88,22 @@ func (client *GenerateDetailedCostReportOperationResultsClient) get(ctx context. } // getCreateRequest creates the Get request. -func (client *GenerateDetailedCostReportOperationResultsClient) getCreateRequest(ctx context.Context, operationID string, scope string, options *GenerateDetailedCostReportOperationResultsClientBeginGetOptions) (*policy.Request, error) { +func (client *GenerateDetailedCostReportOperationResultsClient) getCreateRequest(ctx context.Context, operationID string, scope string, _ *GenerateDetailedCostReportOperationResultsClientBeginGetOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.CostManagement/operationResults/{operationId}" if operationID == "" { return nil, errors.New("parameter operationID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + if scope == "" { + return nil, errors.New("parameter scope cannot be empty") + } 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() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2025-03-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 index 3e029c6db129..7b9a64c0f434 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationresults_client_example_test.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationresults_client_example_test.go @@ -1,20 +1,17 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. 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" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v3" + "log" ) -// Generated from 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 +// Generated from example definition: 2025-03-01/GenerateDetailedCostReportOperationResultsBySubscriptionScope.json func ExampleGenerateDetailedCostReportOperationResultsClient_BeginGet() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -36,13 +33,15 @@ func ExampleGenerateDetailedCostReportOperationResultsClient_BeginGet() { // 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}()), + // res = armcostmanagement.GenerateDetailedCostReportOperationResultsClientGetResponse{ + // 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.4394737Z"); return t}()), + // }, // }, // } } diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationstatus_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationstatus_client.go index a70cef64ecd1..11448b8ff1e7 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationstatus_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationstatus_client.go @@ -1,7 +1,6 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armcostmanagement @@ -17,7 +16,8 @@ import ( "strings" ) -// GenerateDetailedCostReportOperationStatusClient contains the methods for the GenerateDetailedCostReportOperationStatus group. +// GenerateDetailedCostReportOperationStatusClient contains the methods for the GenerateDetailedCostReportOperationStatus +// group. // Don't use this type directly, use NewGenerateDetailedCostReportOperationStatusClient() instead. type GenerateDetailedCostReportOperationStatusClient struct { internal *arm.Client @@ -25,7 +25,7 @@ type GenerateDetailedCostReportOperationStatusClient struct { // NewGenerateDetailedCostReportOperationStatusClient creates a new instance of GenerateDetailedCostReportOperationStatusClient with the specified values. // - credential - used to authorize requests. Usually a credential from azidentity. -// - options - pass nil to accept the default values. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewGenerateDetailedCostReportOperationStatusClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*GenerateDetailedCostReportOperationStatusClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -41,10 +41,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 -// - 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. +// Generated from API version 2025-03-01 // - options - GenerateDetailedCostReportOperationStatusClientGetOptions contains the optional parameters for the GenerateDetailedCostReportOperationStatusClient.Get // method. func (client *GenerateDetailedCostReportOperationStatusClient) Get(ctx context.Context, operationID string, scope string, options *GenerateDetailedCostReportOperationStatusClientGetOptions) (GenerateDetailedCostReportOperationStatusClientGetResponse, error) { @@ -70,19 +67,22 @@ func (client *GenerateDetailedCostReportOperationStatusClient) Get(ctx context.C } // getCreateRequest creates the Get request. -func (client *GenerateDetailedCostReportOperationStatusClient) getCreateRequest(ctx context.Context, operationID string, scope string, options *GenerateDetailedCostReportOperationStatusClientGetOptions) (*policy.Request, error) { +func (client *GenerateDetailedCostReportOperationStatusClient) getCreateRequest(ctx context.Context, operationID string, scope string, _ *GenerateDetailedCostReportOperationStatusClientGetOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.CostManagement/operationStatus/{operationId}" if operationID == "" { return nil, errors.New("parameter operationID cannot be empty") } urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + if scope == "" { + return nil, errors.New("parameter scope cannot be empty") + } 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() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2025-03-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 index b1e1c92b5c26..23e48e7848b5 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationstatus_client_example_test.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationstatus_client_example_test.go @@ -1,20 +1,17 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. 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" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v3" + "log" ) -// Generated from 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 +// Generated from example definition: 2025-03-01/GenerateDetailedCostReportOperationStatusBySubscriptionScope.json func ExampleGenerateDetailedCostReportOperationStatusClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -32,18 +29,21 @@ func ExampleGenerateDetailedCostReportOperationStatusClient_Get() { // 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{ + // res = armcostmanagement.GenerateDetailedCostReportOperationStatusClientGetResponse{ + // 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.4394737Z"); return t}()), + // }, + // Status: &armcostmanagement.Status{ + // Status: to.Ptr(armcostmanagement.ReportOperationStatusTypeCompleted), + // }, // }, // } } diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/generatereservationdetailsreport_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/generatereservationdetailsreport_client.go index 706dc55ae489..63985e18d25d 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/generatereservationdetailsreport_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/generatereservationdetailsreport_client.go @@ -1,7 +1,6 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armcostmanagement @@ -25,7 +24,7 @@ type GenerateReservationDetailsReportClient struct { // NewGenerateReservationDetailsReportClient creates a new instance of GenerateReservationDetailsReportClient with the specified values. // - credential - used to authorize requests. Usually a credential from azidentity. -// - options - pass nil to accept the default values. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewGenerateReservationDetailsReportClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*GenerateReservationDetailsReportClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -38,12 +37,11 @@ func NewGenerateReservationDetailsReportClient(credential azcore.TokenCredential } // BeginByBillingAccountID - Generates the reservations details report for provided date range asynchronously based on enrollment -// id. The Reservation usage details can be viewed only by certain enterprise roles. For more details -// on the roles see, https://docs.microsoft.com/en-us/azure/cost-management-billing/manage/understand-ea-roles#usage-and-costs-access-by-role +// id. The Reservation usage details can be viewed only by certain enterprise roles. For more details 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 -// - billingAccountID - Enrollment ID (Legacy BillingAccount ID) +// Generated from API version 2025-03-01 +// - billingAccountID - BillingAccount ID // - startDate - Start Date // - endDate - End Date // - options - GenerateReservationDetailsReportClientBeginByBillingAccountIDOptions contains the optional parameters for the @@ -55,8 +53,7 @@ func (client *GenerateReservationDetailsReportClient) BeginByBillingAccountID(ct return nil, err } poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[GenerateReservationDetailsReportClientByBillingAccountIDResponse]{ - FinalStateVia: runtime.FinalStateViaLocation, - Tracer: client.internal.Tracer(), + Tracer: client.internal.Tracer(), }) return poller, err } else { @@ -67,11 +64,10 @@ func (client *GenerateReservationDetailsReportClient) BeginByBillingAccountID(ct } // ByBillingAccountID - Generates the reservations details report for provided date range asynchronously based on enrollment -// id. The Reservation usage details can be viewed only by certain enterprise roles. For more details -// on the roles see, https://docs.microsoft.com/en-us/azure/cost-management-billing/manage/understand-ea-roles#usage-and-costs-access-by-role +// id. The Reservation usage details can be viewed only by certain enterprise roles. For more details 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 2025-03-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" @@ -94,8 +90,8 @@ func (client *GenerateReservationDetailsReportClient) byBillingAccountID(ctx con } // byBillingAccountIDCreateRequest creates the ByBillingAccountID request. -func (client *GenerateReservationDetailsReportClient) byBillingAccountIDCreateRequest(ctx context.Context, billingAccountID string, startDate string, endDate string, options *GenerateReservationDetailsReportClientBeginByBillingAccountIDOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.CostManagement/generateReservationDetailsReport" +func (client *GenerateReservationDetailsReportClient) byBillingAccountIDCreateRequest(ctx context.Context, billingAccountID string, startDate string, endDate string, _ *GenerateReservationDetailsReportClientBeginByBillingAccountIDOptions) (*policy.Request, error) { + urlPath := "/providers/microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.CostManagement/generateReservationDetailsReport" if billingAccountID == "" { return nil, errors.New("parameter billingAccountID cannot be empty") } @@ -105,22 +101,22 @@ func (client *GenerateReservationDetailsReportClient) byBillingAccountIDCreateRe return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("startDate", startDate) + reqQP.Set("api-version", "2025-03-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 } // BeginByBillingProfileID - Generates the reservations details report for provided date range asynchronously by billing profile. -// The Reservation usage details can be viewed by only certain enterprise roles by default. For more -// 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 +// The Reservation usage details can be viewed by only certain enterprise roles by default. For more 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 -// - billingAccountID - Billing account ID -// - billingProfileID - Billing profile ID. +// Generated from API version 2025-03-01 +// - billingAccountID - BillingAccount ID +// - billingProfileID - Billing Profile ID. // - startDate - Start Date // - endDate - End Date // - options - GenerateReservationDetailsReportClientBeginByBillingProfileIDOptions contains the optional parameters for the @@ -132,8 +128,7 @@ func (client *GenerateReservationDetailsReportClient) BeginByBillingProfileID(ct return nil, err } poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[GenerateReservationDetailsReportClientByBillingProfileIDResponse]{ - FinalStateVia: runtime.FinalStateViaLocation, - Tracer: client.internal.Tracer(), + Tracer: client.internal.Tracer(), }) return poller, err } else { @@ -144,11 +139,11 @@ func (client *GenerateReservationDetailsReportClient) BeginByBillingProfileID(ct } // ByBillingProfileID - Generates the reservations details report for provided date range asynchronously by billing profile. -// The Reservation usage details can be viewed by only certain enterprise roles by default. For more -// 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 +// The Reservation usage details can be viewed by only certain enterprise roles by default. For more 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 2025-03-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" @@ -171,8 +166,8 @@ func (client *GenerateReservationDetailsReportClient) byBillingProfileID(ctx con } // byBillingProfileIDCreateRequest creates the ByBillingProfileID request. -func (client *GenerateReservationDetailsReportClient) byBillingProfileIDCreateRequest(ctx context.Context, billingAccountID string, billingProfileID string, startDate string, endDate string, options *GenerateReservationDetailsReportClientBeginByBillingProfileIDOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.CostManagement/generateReservationDetailsReport" +func (client *GenerateReservationDetailsReportClient) byBillingProfileIDCreateRequest(ctx context.Context, billingAccountID string, billingProfileID string, startDate string, endDate string, _ *GenerateReservationDetailsReportClientBeginByBillingProfileIDOptions) (*policy.Request, error) { + urlPath := "/providers/microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.CostManagement/generateReservationDetailsReport" if billingAccountID == "" { return nil, errors.New("parameter billingAccountID cannot be empty") } @@ -186,9 +181,9 @@ func (client *GenerateReservationDetailsReportClient) byBillingProfileIDCreateRe return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("startDate", startDate) + reqQP.Set("api-version", "2025-03-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 index b8c5ffd427fe..d8063ca2c46c 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/generatereservationdetailsreport_client_example_test.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/generatereservationdetailsreport_client_example_test.go @@ -1,20 +1,17 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. 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" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v3" + "log" ) -// Generated from 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 +// Generated from example definition: 2025-03-01/GenerateReservationDetailsReportByBillingAccount.json func ExampleGenerateReservationDetailsReportClient_BeginByBillingAccountID() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -36,16 +33,18 @@ func ExampleGenerateReservationDetailsReportClient_BeginByBillingAccountID() { // 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}()), + // res = armcostmanagement.GenerateReservationDetailsReportClientByBillingAccountIDResponse{ + // 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.5021869Z"); return t}()), + // }, + // Status: to.Ptr(armcostmanagement.OperationStatusTypeCompleted), // }, - // 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 +// Generated from example definition: 2025-03-01/GenerateReservationDetailsReportByBillingProfile.json func ExampleGenerateReservationDetailsReportClient_BeginByBillingProfileID() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -67,11 +66,13 @@ func ExampleGenerateReservationDetailsReportClient_BeginByBillingProfileID() { // 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}()), + // res = armcostmanagement.GenerateReservationDetailsReportClientByBillingProfileIDResponse{ + // 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.5021869Z"); return t}()), + // }, + // Status: to.Ptr(armcostmanagement.OperationStatusTypeCompleted), // }, - // Status: to.Ptr(armcostmanagement.OperationStatusTypeCompleted), // } } diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/go.mod b/sdk/resourcemanager/costmanagement/armcostmanagement/go.mod index a7511c500638..52414046a845 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/go.mod +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/go.mod @@ -1,4 +1,4 @@ -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.24.0 diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/interfaces.go b/sdk/resourcemanager/costmanagement/armcostmanagement/interfaces.go index b03bf735c6a7..5e1fef58c24b 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/interfaces.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/interfaces.go @@ -1,7 +1,6 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armcostmanagement @@ -22,3 +21,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 8d37c8e7c05a..fcb7bca87f33 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/models.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/models.go @@ -1,28 +1,33 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armcostmanagement -import "time" +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "time" +) // Alert - An individual alert. type Alert 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 + ETag *azcore.ETag // Alert properties. Properties *AlertProperties - // READ-ONLY; Resource Id. + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} ID *string - // READ-ONLY; Resource name. + // READ-ONLY; The name of the resource Name *string - // READ-ONLY; Resource type. + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } @@ -194,6 +199,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. @@ -208,6 +226,9 @@ type BenefitRecommendationModel struct { // READ-ONLY; The name of the resource Name *string + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } @@ -235,7 +256,7 @@ type BenefitRecommendationProperties struct { // READ-ONLY; The list of all benefit recommendations with the recommendation details. AllRecommendationDetails *AllSavingsList - // READ-ONLY; ARM SKU name. 'ComputeSavingsPlan' for SavingsPlan. + // READ-ONLY; ARM SKU name. 'Compute_Savings_Plan' for SavingsPlan. ArmSKUName *string // READ-ONLY; The current cost without benefit, corresponds to 'totalHours' in the look-back period. @@ -261,7 +282,7 @@ func (b *BenefitRecommendationProperties) GetBenefitRecommendationProperties() * // BenefitRecommendationsListResult - Result of listing benefit recommendations. type BenefitRecommendationsListResult struct { - // READ-ONLY; The link (URL) to the next page of results. + // The link (url) to the next page of results. NextLink *string // READ-ONLY; The list of benefit recommendations. @@ -270,13 +291,59 @@ type BenefitRecommendationsListResult struct { // BenefitUtilizationSummariesListResult - List of benefit utilization summaries. type BenefitUtilizationSummariesListResult struct { - // READ-ONLY; The link (URL) to the next page of results. + // The link (URL) to the next page of results. NextLink *string // READ-ONLY; The list of benefit utilization summaries. 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'. @@ -288,6 +355,9 @@ type BenefitUtilizationSummary struct { // READ-ONLY; The name of the resource Name *string + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } @@ -306,6 +376,157 @@ 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 *azcore.ETag + + // The properties of the budget. + Properties *BudgetProperties + + // 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; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + 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 { + // The link (url) to the next page of results.\r\nIt'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. @@ -317,7 +538,7 @@ type CheckNameAvailabilityRequest struct { // CheckNameAvailabilityResponse - The check availability result. type CheckNameAvailabilityResponse struct { - // Detailed reason why the given name is available. + // Detailed reason why the given name is not available. Message *string // Indicates if the resource name is available. @@ -335,12 +556,21 @@ type CommonExportProperties struct { // REQUIRED; Has delivery information for the export. DeliveryInfo *ExportDeliveryInfo - // The format of the export being delivered. Currently only 'Csv' is supported. + // Allow customers to select compress data for exports. This setting will enable destination file compression scheme at runtime. + // By default set to None. Gzip is for csv and snappy for parquet. + CompressionMode *CompressionModeType + + // Allow customers to select overwrite data(OverwritePreviousReport) for exports. This setting will enable overwrite data + // for the same month in customer storage account. By default set to CreateNewReport. + DataOverwriteBehavior *DataOverwriteBehaviorType + + // The export description set by customer at time of export creation/update. + ExportDescription *string + + // The format of the export being delivered. Format *FormatType // If set to true, exported data will be partitioned by size and placed in a blob directory together with a manifest file. - // Note: this option is currently available only for Microsoft Customer Agreement - // commerce scopes. PartitionData *bool // If requested, has the most recent run history for the export. @@ -348,6 +578,95 @@ type CommonExportProperties struct { // READ-ONLY; If the export has an active schedule, provides an estimate of the next run time. NextRunTimeEstimate *time.Time + + // READ-ONLY; The export suspension reason if export is in SystemSuspended state. This is not populated currently. + SystemSuspensionContext *ExportSuspensionContext +} + +// 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; 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; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + 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 { + // URL to get the next set of rule list results if there are any. + NextLink *string + + // The list of cost allocation rules. + Value []*CostAllocationRuleDefinition +} + +// 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. @@ -384,6 +703,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. @@ -443,6 +772,9 @@ type DimensionProperties struct { // DimensionsListResult - Result of listing dimensions. It contains a list of available dimensions. type DimensionsListResult struct { + // The link (url) to the next page of results. + NextLink *string + // READ-ONLY; The list of dimensions. Value []*Dimension } @@ -478,18 +810,27 @@ type ErrorDetails struct { type Export 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 + ETag *azcore.ETag + + // 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 - // READ-ONLY; Resource Id. + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} ID *string - // READ-ONLY; Resource name. + // READ-ONLY; The name of the resource Name *string - // READ-ONLY; Resource type. + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } @@ -498,16 +839,21 @@ type ExportDataset struct { // The export dataset configuration. Configuration *ExportDatasetConfiguration - // The granularity of rows in the export. Currently only 'Daily' is supported. + // The granularity of rows in the export. Currently 'Daily' is supported for most cases. Granularity *GranularityType } -// ExportDatasetConfiguration - The export dataset configuration. Allows columns to be selected for the export. If not provided -// then the export will include all available columns. +// ExportDatasetConfiguration - This is on path to deprecation and will not be supported going forward. type ExportDatasetConfiguration struct { // Array of column names to be included in the export. If not provided then the export will include all available columns. // The available columns can vary by customer channel (see examples). Columns []*string + + // The data version for the selected for the export. If not provided then the export will default to latest data version. + DataVersion *string + + // Filters associated with the data sets. + Filters []*FilterItems } // ExportDefinition - The definition of an export. @@ -527,18 +873,16 @@ type ExportDefinition struct { } // ExportDeliveryDestination - This represents the blob storage account location where exports of costs will be delivered. -// There are two ways to configure the destination. The approach recommended for most customers is to specify -// the resourceId of the storage account. This requires a one-time registration of the account's subscription with the Microsoft.CostManagementExports -// resource provider in order to give Cost Management -// services access to the storage. When creating an export in the Azure portal this registration is performed automatically -// but API users may need to register the subscription explicitly (for more -// information see https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-supported-services ). Another -// way to configure the destination is available ONLY to Partners with a -// Microsoft Partner Agreement plan who are global admins of their billing account. These Partners, instead of specifying -// the resourceId of a storage account, can specify the storage account name along -// with a SAS token for the account. This allows exports of costs to a storage account in any tenant. The SAS token should -// be created for the blob service with Service/Container/Object resource types and -// with Read/Write/Delete/List/Add/Create permissions (for more information see https://docs.microsoft.com/en-us/azure/cost-management-billing/costs/export-cost-data-storage-account-sas-key +// There are two ways to configure the destination. The approach recommended for most customers is to specify the resourceId +// of the storage account. This requires a one-time registration of the account's subscription with the Microsoft.CostManagementExports +// resource provider in order to give Cost Management services access to the storage. When creating an export in the Azure +// portal this registration is performed automatically but API users may need to register the subscription explicitly (for +// more information see https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-supported-services +// ). Another way to configure the destination is available ONLY to Partners with a Microsoft Partner Agreement plan who are +// global admins of their billing account. These Partners, instead of specifying the resourceId of a storage account, can +// specify the storage account name along with a SAS token for the account. This allows exports of costs to a storage account +// in any tenant. The SAS token should be created for the blob service with Service/Container/Object resource types and with +// Read/Write/Delete/List/Add/Create permissions (for more information see https://docs.microsoft.com/en-us/azure/cost-management-billing/costs/export-cost-data-storage-account-sas-key // ). type ExportDeliveryDestination struct { // REQUIRED; The name of the container where exports will be uploaded. If the container does not exist it will be created. @@ -552,14 +896,16 @@ type ExportDeliveryDestination struct { RootFolderPath *string // A SAS token for the storage account. For a restricted set of Azure customers this together with storageAccount can be specified - // instead of resourceId. Note: the value returned by the API for this - // property will always be obfuscated. Returning this same obfuscated value will not result in the SAS token being updated. - // To update this value a new SAS token must be specified. + // instead of resourceId. Note: the value returned by the API for this property will always be obfuscated. Returning this + // same obfuscated value will not result in the SAS token being updated. To update this value a new SAS token must be specified. SasToken *string // The storage account where exports will be uploaded. For a restricted set of Azure customers this together with sasToken // can be specified instead of resourceId. StorageAccount *string + + // The export delivery destination type. Currently only 'AzureBlob' is supported. + Type *DestinationType } // ExportDeliveryInfo - The delivery information associated with a export. @@ -588,12 +934,21 @@ type ExportProperties struct { // REQUIRED; Has delivery information for the export. DeliveryInfo *ExportDeliveryInfo - // The format of the export being delivered. Currently only 'Csv' is supported. + // Allow customers to select compress data for exports. This setting will enable destination file compression scheme at runtime. + // By default set to None. Gzip is for csv and snappy for parquet. + CompressionMode *CompressionModeType + + // Allow customers to select overwrite data(OverwritePreviousReport) for exports. This setting will enable overwrite data + // for the same month in customer storage account. By default set to CreateNewReport. + DataOverwriteBehavior *DataOverwriteBehaviorType + + // The export description set by customer at time of export creation/update. + ExportDescription *string + + // The format of the export being delivered. Format *FormatType // If set to true, exported data will be partitioned by size and placed in a blob directory together with a manifest file. - // Note: this option is currently available only for Microsoft Customer Agreement - // commerce scopes. PartitionData *bool // If requested, has the most recent run history for the export. @@ -604,6 +959,9 @@ type ExportProperties struct { // READ-ONLY; If the export has an active schedule, provides an estimate of the next run time. NextRunTimeEstimate *time.Time + + // READ-ONLY; The export suspension reason if export is in SystemSuspended state. This is not populated currently. + SystemSuspensionContext *ExportSuspensionContext } // ExportRecurrencePeriod - The start and end date for recurrence schedule. @@ -636,6 +994,9 @@ type ExportRun struct { // ExportRunProperties - The properties of the export run. type ExportRunProperties struct { + // The end datetime for the export. + EndDate *time.Time + // The details of any error. Error *ErrorDetails @@ -645,6 +1006,9 @@ type ExportRunProperties struct { // The name of the exported file. FileName *string + // The manifest file location(URI location) for the exported files. + ManifestFile *string + // The time when the export run finished. ProcessingEndTime *time.Time @@ -654,6 +1018,9 @@ type ExportRunProperties struct { // The export settings that were in effect for this run. RunSettings *CommonExportProperties + // The start datetime for the export. + StartDate *time.Time + // The last known status of the export run. Status *ExecutionStatus @@ -665,6 +1032,12 @@ type ExportRunProperties struct { SubmittedTime *time.Time } +// ExportRunRequest - The export run request. +type ExportRunRequest struct { + // Has time period for pulling data for the export. + TimePeriod *ExportTimePeriod +} + // ExportSchedule - The schedule associated with the export. type ExportSchedule struct { // The schedule recurrence. @@ -674,12 +1047,25 @@ type ExportSchedule struct { // start date. RecurrencePeriod *ExportRecurrencePeriod - // The status of the export's schedule. If 'Inactive', the export's schedule is paused. + // The status of the export's schedule. If 'Inactive', the export's schedule is paused. To enable export set the status to + // be Active and then make a PUT request. Status *StatusType } +// ExportSuspensionContext - The properties of the export run. This is not populated currently. +type ExportSuspensionContext struct { + // The code for export suspension. + SuspensionCode *string + + // The detailed reason for export suspension. + SuspensionReason *string + + // The time when the export was suspended. + SuspensionTime *time.Time +} + // ExportTimePeriod - The date range for data in the export. This should only be specified with timeFrame set to 'Custom'. -// The maximum date range is 3 months. +// The maximum date range is 1 calendar month. type ExportTimePeriod struct { // REQUIRED; The start date for export data. From *time.Time @@ -694,6 +1080,20 @@ type FileDestination struct { FileFormats []*FileFormat } +// FilterItems - Will contain the filter name and value to operate on. This is currently only supported for Export Definition +// type of ReservationRecommendations. +type FilterItems struct { + // The name of the filter. This is currently only supported for Export Definition type of ReservationRecommendations. Supported + // names are ['ReservationScope', 'LookBackPeriod', 'ResourceType'] + Name *FilterItemNames + + // Value to filter by. Currently values supported per name are, for 'ReservationScope' supported values are ['Single', 'Shared'], + // for 'LookBackPeriod' supported values are ['Last7Days', 'Last30Days', 'Last60Days'] and for 'ResourceType' supported values + // are ['VirtualMachines', 'SQLDatabases', 'PostgreSQL', 'ManagedDisk', 'MySQL', 'RedHat', 'MariaDB', 'RedisCache', 'CosmosDB', + // 'SqlDataWarehouse', 'SUSELinux', 'AppService', 'BlockBlob', 'AzureDataExplorer', 'VMwareCloudSimple']. + Value *string +} + // ForecastAggregation - The aggregation expression to be used in the forecast. type ForecastAggregation struct { // REQUIRED; The name of the aggregation function to use. @@ -823,6 +1223,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. @@ -835,33 +1246,30 @@ type ForecastTimePeriod struct { // GenerateCostDetailsReportRequestDefinition - The definition of a cost detailed report. type GenerateCostDetailsReportRequestDefinition struct { // This parameter can be used only by Enterprise Agreement customers. Use the YearMonth(e.g. 202008) format. This parameter - // cannot be used alongside either the invoiceId or timePeriod parameters. If a - // timePeriod, invoiceId or billingPeriod parameter is not provided in the request body the API will return the current month's - // cost. + // cannot be used alongside either the invoiceId or timePeriod parameters. If a timePeriod, invoiceId or billingPeriod parameter + // is not provided in the request body the API will return the current month's cost. BillingPeriod *string // This parameter can only be used by Microsoft Customer Agreement customers. Additionally, it can only be used at the Billing - // Profile or Customer scope. This parameter cannot be used alongside either - // the billingPeriod or timePeriod parameters. If a timePeriod, invoiceId or billingPeriod parameter is not provided in the - // request body the API will return the current month's cost. + // Profile or Customer scope. This parameter cannot be used alongside either the billingPeriod or timePeriod parameters. If + // a timePeriod, invoiceId or billingPeriod parameter is not provided in the request body the API will return the current + // month's cost. InvoiceID *string // The type of the detailed report. By default ActualCost is provided Metric *CostDetailsMetricType // The specific date range of cost details requested for the report. This parameter cannot be used alongside either the invoiceId - // or billingPeriod parameters. If a timePeriod, invoiceId or billingPeriod - // parameter is not provided in the request body the API will return the current month's cost. API only allows data to be - // pulled for 1 month or less and no older than 13 months. If no timePeriod or - // billingPeriod or invoiceId is provided the API defaults to the open month time period + // or billingPeriod parameters. If a timePeriod, invoiceId or billingPeriod parameter is not provided in the request body + // the API will return the current month's cost. API only allows data to be pulled for 1 month or less and no older than 13 + // months. If no timePeriod or billingPeriod or invoiceId is provided the API defaults to the open month time period TimePeriod *CostDetailsTimePeriod } // GenerateDetailedCostReportDefinition - The definition of a cost detailed report. type GenerateDetailedCostReportDefinition struct { // Billing period in YearMonth(e.g. 202008) format. Only for legacy enterprise customers can use this. Can only have one of - // either timePeriod or invoiceId or billingPeriod parameters. If none provided - // current month cost is provided. + // either timePeriod or invoiceId or billingPeriod parameters. If none provided current month cost is provided. BillingPeriod *string // Customer ID for Microsoft Customer Agreement scopes (Invoice Id is also required for this). @@ -881,16 +1289,19 @@ type GenerateDetailedCostReportDefinition struct { // GenerateDetailedCostReportOperationResult - The result of the long running operation for cost detailed report. type GenerateDetailedCostReportOperationResult struct { - // The ARM resource id of the long running operation. + // The properties of the resource generated. + Properties *DownloadURL + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} ID *string - // The name of the long running operation. + // READ-ONLY; The name of the resource Name *string - // The properties of the resource generated. - Properties *DownloadURL + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData - // The type of the long running operation. + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } @@ -902,12 +1313,6 @@ type GenerateDetailedCostReportOperationStatuses struct { // The details of the error. Error *ErrorDetails - // The ID of the long running operation. - ID *string - - // The name of the long running operation. - Name *string - // The properties of the usage file generated. Properties *DownloadURL @@ -917,7 +1322,16 @@ type GenerateDetailedCostReportOperationStatuses struct { // The status of the long running operation. Status *Status - // The type of the long running operation. + // 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; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } @@ -944,6 +1358,9 @@ type IncludedQuantityUtilizationSummary struct { // READ-ONLY; The name of the resource Name *string + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } @@ -951,10 +1368,11 @@ type IncludedQuantityUtilizationSummary struct { // GetBenefitUtilizationSummary implements the BenefitUtilizationSummaryClassification interface for type IncludedQuantityUtilizationSummary. func (i *IncludedQuantityUtilizationSummary) GetBenefitUtilizationSummary() *BenefitUtilizationSummary { return &BenefitUtilizationSummary{ - ID: i.ID, - Kind: i.Kind, - Name: i.Name, - Type: i.Type, + ID: i.ID, + Kind: i.Kind, + Name: i.Name, + SystemData: i.SystemData, + Type: i.Type, } } @@ -963,7 +1381,7 @@ type IncludedQuantityUtilizationSummaryProperties struct { // The benefit type. Supported values: 'SavingsPlan'. BenefitType *BenefitKind - // READ-ONLY; ARM SKU name. For example, 'ComputeSavingsPlan' for savings plan. + // READ-ONLY; ARM SKU name. For example, 'Compute_Savings_Plan' for savings plan. ArmSKUName *string // READ-ONLY; The benefit ID is the identifier of the benefit. @@ -989,7 +1407,161 @@ type KpiProperties struct { ID *string // KPI type (Forecast, Budget). - Type *KpiType + Type *KpiTypeType +} + +// 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; 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; 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. @@ -1010,37 +1582,19 @@ type NotificationProperties struct { RegionalFormat *string } -// OperationDisplay - Localized display information for this particular operation. -type OperationDisplay struct { - // READ-ONLY; The short, localized friendly description of the operation; suitable for tool tips and detailed views. - Description *string - - // READ-ONLY; The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual - // Machine", "Restart Virtual Machine". - Operation *string - - // READ-ONLY; The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft - // Compute". - Provider *string - - // READ-ONLY; The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job - // Schedule Collections". - Resource *string -} - -// OperationForCostManagement - A Cost management REST API operation. -type OperationForCostManagement struct { +// Operation - A Cost management REST API operation. +type Operation struct { // Localized display information for this particular operation. Display *OperationDisplay - // READ-ONLY; Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + // READ-ONLY; Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. ActionType *ActionType // READ-ONLY; Operation id: {provider}/{resource}/{operation}. ID *string - // READ-ONLY; Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for ARM/control-plane - // operations. + // READ-ONLY; Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for Azure + // Resource Manager/control-plane operations. IsDataAction *bool // READ-ONLY; The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", @@ -1052,6 +1606,24 @@ type OperationForCostManagement struct { Origin *Origin } +// OperationDisplay - Localized display information for and operation. +type OperationDisplay struct { + // READ-ONLY; The short, localized friendly description of the operation; suitable for tool tips and detailed views. + Description *string + + // READ-ONLY; The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual + // Machine", "Restart Virtual Machine". + Operation *string + + // READ-ONLY; The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft + // Compute". + Provider *string + + // READ-ONLY; The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job + // Schedule Collections". + Resource *string +} + // OperationListResult - Result of listing cost management operations. It contains a list of operations and a URL link to // get the next set of results. type OperationListResult struct { @@ -1059,7 +1631,7 @@ type OperationListResult struct { NextLink *string // READ-ONLY; List of cost management operations supported by the Microsoft.CostManagement resource provider. - Value []*OperationForCostManagement + Value []*Operation } // OperationStatus - The status of the long running operation. @@ -1077,7 +1649,19 @@ type PivotProperties struct { Name *string // Data type to show in view. - Type *PivotType + Type *PivotTypeType +} + +// 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. @@ -1293,8 +1877,7 @@ type ReportConfigDefinition struct { Timeframe *ReportTimeframeType // REQUIRED; The type of the report. Usage represents actual usage, forecast represents forecasted data and UsageAndForecast - // represents both usage and forecasted data. Actual usage and forecasted data can be - // differentiated based on dates. + // represents both usage and forecasted data. Actual usage and forecasted data can be differentiated based on dates. Type *ReportType // Has definition for data in this report config. @@ -1405,6 +1988,9 @@ type SavingsPlanUtilizationSummary struct { // READ-ONLY; The name of the resource Name *string + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } @@ -1412,10 +1998,11 @@ type SavingsPlanUtilizationSummary struct { // GetBenefitUtilizationSummary implements the BenefitUtilizationSummaryClassification interface for type SavingsPlanUtilizationSummary. func (s *SavingsPlanUtilizationSummary) GetBenefitUtilizationSummary() *BenefitUtilizationSummary { return &BenefitUtilizationSummary{ - ID: s.ID, - Kind: s.Kind, - Name: s.Name, - Type: s.Type, + ID: s.ID, + Kind: s.Kind, + Name: s.Name, + SystemData: s.SystemData, + Type: s.Type, } } @@ -1424,14 +2011,13 @@ type SavingsPlanUtilizationSummaryProperties struct { // The benefit type. Supported values: 'SavingsPlan'. BenefitType *BenefitKind - // READ-ONLY; ARM SKU name. For example, 'ComputeSavingsPlan' for savings plan. + // READ-ONLY; ARM SKU name. For example, 'Compute_Savings_Plan' for savings plan. 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 - // 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. + // Suppose the API call is for usageDate > 2025-03-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. AvgUtilizationPercentage *float64 // READ-ONLY; The benefit ID is the identifier of the benefit. @@ -1441,21 +2027,19 @@ 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 - // 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 - // was 90% at hour 5, then the value for the maxUtilizationPercentage in + // Suppose the API call is for usageDate > 2025-03-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 was 90% at hour 5, then the value for the maxUtilizationPercentage in // the response will be 90%. 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 - // 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 - // was 10% at hour 4, then the value for the minUtilizationPercentage in - // the response will be 10%. + // Suppose the API call is for usageDate > 2025-03-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 was 10% at hour 4, then the value for the minUtilizationPercentage + // in the response will be 10%. MinUtilizationPercentage *float64 // READ-ONLY; Date corresponding to the utilization summary record. If the grain of data is monthly, value for this field @@ -1492,24 +2076,24 @@ type ScheduleProperties struct { // ScheduledAction - Scheduled action definition. type ScheduledAction struct { + // Resource Etag. For update calls, eTag is optional and can be specified to achieve optimistic concurrency. Fetch the resource's + // eTag by doing a 'GET' call first and then including the latest eTag as part of the request body or 'If-Match' header while + // performing the update. For create calls, eTag is not required. + ETag *azcore.ETag + // Kind of the scheduled action. Kind *ScheduledActionKind // The properties of the scheduled action. Properties *ScheduledActionProperties - // READ-ONLY; Resource Etag. For update calls, eTag is optional and can be specified to achieve optimistic concurrency. Fetch - // the resource's eTag by doing a 'GET' call first and then including the latest eTag as - // part of the request body or 'If-Match' header while performing the update. For create calls, eTag is not required. - ETag *string - // 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; Kind of the scheduled action. + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. SystemData *SystemData // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" @@ -1518,7 +2102,7 @@ type ScheduledAction struct { // ScheduledActionListResult - Scheduled actions list result. It contains a list of scheduled actions. type ScheduledActionListResult struct { - // READ-ONLY; The link (url) to the next page of results. + // The link (url) to the next page of results. NextLink *string // READ-ONLY; The list of scheduled actions. @@ -1548,22 +2132,46 @@ 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 - // scope, - // 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for BillingProfile - // scope, - // 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' for InvoiceSection - // scope, - // '/providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for ExternalBillingAccount scope, - // and - // '/providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for ExternalSubscription scope. + // 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, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + // for InvoiceSection scope, '/providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for + // ExternalBillingAccount scope, and '/providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' + // for ExternalSubscription scope. Scope *string } +// Setting definition. +type Setting struct { + // REQUIRED; Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps + // are a kind of Microsoft.Web/sites type. If supported, the resource provider must validate and persist this value. + 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; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // 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. @@ -1587,7 +2195,7 @@ type SharedScopeBenefitRecommendationProperties struct { // READ-ONLY; The list of all benefit recommendations with the recommendation details. AllRecommendationDetails *AllSavingsList - // READ-ONLY; ARM SKU name. 'ComputeSavingsPlan' for SavingsPlan. + // READ-ONLY; ARM SKU name. 'Compute_Savings_Plan' for SavingsPlan. ArmSKUName *string // READ-ONLY; The current cost without benefit, corresponds to 'totalHours' in the look-back period. @@ -1648,7 +2256,7 @@ type SingleScopeBenefitRecommendationProperties struct { // READ-ONLY; The list of all benefit recommendations with the recommendation details. AllRecommendationDetails *AllSavingsList - // READ-ONLY; ARM SKU name. 'ComputeSavingsPlan' for SavingsPlan. + // READ-ONLY; ARM SKU name. 'Compute_Savings_Plan' for SavingsPlan. ArmSKUName *string // READ-ONLY; The current cost without benefit, corresponds to 'totalHours' in the look-back period. @@ -1694,12 +2302,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; The type of managed identity assigned to this resource. + 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). @@ -1721,28 +2355,90 @@ 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 { + // CONSTANT; Specifies the kind of settings. + // Field has constant value SettingsKindTaginheritance, any specified value is ignored. + 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; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // 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, + SystemData: t.SystemData, + 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 // the latest version or not. - ETag *string + ETag *azcore.ETag // The properties of the view. Properties *ViewProperties - // READ-ONLY; Resource Id. + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} ID *string - // READ-ONLY; Resource name. + // READ-ONLY; The name of the resource Name *string - // READ-ONLY; Resource type. + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" Type *string } // ViewListResult - Result of listing views. It contains a list of available views. type ViewListResult struct { - // READ-ONLY; The link (url) to the next page of results. + // The link (url) to the next page of results. NextLink *string // READ-ONLY; The list of views. @@ -1757,6 +2453,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 @@ -1766,6 +2465,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 @@ -1773,18 +2475,13 @@ type ViewProperties struct { Query *ReportConfigDefinition // Cost Management scope to save the view on. 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}' - // for - // Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' - // for EnrollmentAccount scope, - // 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for BillingProfile - // scope, - // 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' for InvoiceSection - // scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for - // Management Group scope, '/providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for - // ExternalBillingAccount scope, and - // '/providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for ExternalSubscription scope. + // 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, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' + // for InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, + // '/providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for ExternalBillingAccount scope, + // and '/providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for ExternalSubscription scope. Scope *string // READ-ONLY; Date the user created this view. @@ -1792,10 +2489,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 3ea89fdcdb7f..7ff78e8aa108 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/models_serde.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/models_serde.go @@ -1,7 +1,6 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armcostmanagement @@ -19,6 +18,7 @@ func (a Alert) MarshalJSON() ([]byte, error) { populate(objectMap, "id", a.ID) populate(objectMap, "name", a.Name) populate(objectMap, "properties", a.Properties) + populate(objectMap, "systemData", a.SystemData) populate(objectMap, "type", a.Type) return json.Marshal(objectMap) } @@ -44,6 +44,9 @@ func (a *Alert) UnmarshalJSON(data []byte) error { case "properties": err = unpopulate(val, "Properties", &a.Properties) delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &a.SystemData) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &a.Type) delete(rawMsg, key) @@ -389,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) @@ -396,6 +434,7 @@ func (b BenefitRecommendationModel) MarshalJSON() ([]byte, error) { populate(objectMap, "kind", b.Kind) populate(objectMap, "name", b.Name) populate(objectMap, "properties", b.Properties) + populate(objectMap, "systemData", b.SystemData) populate(objectMap, "type", b.Type) return json.Marshal(objectMap) } @@ -421,6 +460,9 @@ func (b *BenefitRecommendationModel) UnmarshalJSON(data []byte) error { case "properties": b.Properties, err = unmarshalBenefitRecommendationPropertiesClassification(val) delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &b.SystemData) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &b.Type) delete(rawMsg, key) @@ -444,7 +486,7 @@ func (b BenefitRecommendationProperties) MarshalJSON() ([]byte, error) { populateDateTimeRFC3339(objectMap, "lastConsumptionDate", b.LastConsumptionDate) populate(objectMap, "lookBackPeriod", b.LookBackPeriod) populate(objectMap, "recommendationDetails", b.RecommendationDetails) - objectMap["scope"] = b.Scope + populate(objectMap, "scope", b.Scope) populate(objectMap, "term", b.Term) populate(objectMap, "totalHours", b.TotalHours) populate(objectMap, "usage", b.Usage) @@ -569,12 +611,103 @@ 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) populate(objectMap, "id", b.ID) - objectMap["kind"] = b.Kind + populate(objectMap, "kind", b.Kind) populate(objectMap, "name", b.Name) + populate(objectMap, "systemData", b.SystemData) populate(objectMap, "type", b.Type) return json.Marshal(objectMap) } @@ -597,6 +730,9 @@ func (b *BenefitUtilizationSummary) UnmarshalJSON(data []byte) error { case "name": err = unpopulate(val, "Name", &b.Name) delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &b.SystemData) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &b.Type) delete(rawMsg, key) @@ -639,6 +775,271 @@ func (b *BlobInfo) UnmarshalJSON(data []byte) error { 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, "systemData", b.SystemData) + 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 "systemData": + err = unpopulate(val, "SystemData", &b.SystemData) + 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) @@ -708,12 +1109,16 @@ func (c *CheckNameAvailabilityResponse) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type CommonExportProperties. func (c CommonExportProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "compressionMode", c.CompressionMode) + populate(objectMap, "dataOverwriteBehavior", c.DataOverwriteBehavior) populate(objectMap, "definition", c.Definition) populate(objectMap, "deliveryInfo", c.DeliveryInfo) + populate(objectMap, "exportDescription", c.ExportDescription) populate(objectMap, "format", c.Format) populateDateTimeRFC3339(objectMap, "nextRunTimeEstimate", c.NextRunTimeEstimate) populate(objectMap, "partitionData", c.PartitionData) populate(objectMap, "runHistory", c.RunHistory) + populate(objectMap, "systemSuspensionContext", c.SystemSuspensionContext) return json.Marshal(objectMap) } @@ -726,12 +1131,21 @@ func (c *CommonExportProperties) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "compressionMode": + err = unpopulate(val, "CompressionMode", &c.CompressionMode) + delete(rawMsg, key) + case "dataOverwriteBehavior": + err = unpopulate(val, "DataOverwriteBehavior", &c.DataOverwriteBehavior) + delete(rawMsg, key) case "definition": err = unpopulate(val, "Definition", &c.Definition) delete(rawMsg, key) case "deliveryInfo": err = unpopulate(val, "DeliveryInfo", &c.DeliveryInfo) delete(rawMsg, key) + case "exportDescription": + err = unpopulate(val, "ExportDescription", &c.ExportDescription) + delete(rawMsg, key) case "format": err = unpopulate(val, "Format", &c.Format) delete(rawMsg, key) @@ -744,6 +1158,254 @@ func (c *CommonExportProperties) UnmarshalJSON(data []byte) error { case "runHistory": err = unpopulate(val, "RunHistory", &c.RunHistory) delete(rawMsg, key) + case "systemSuspensionContext": + err = unpopulate(val, "SystemSuspensionContext", &c.SystemSuspensionContext) + 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, "systemData", c.SystemData) + 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 "systemData": + err = unpopulate(val, "SystemData", &c.SystemData) + 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 CostAllocationRuleDetails. +func (c CostAllocationRuleDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "sourceResources", c.SourceResources) + populate(objectMap, "targetResources", c.TargetResources) + return json.Marshal(objectMap) +} + +// 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) + } + for key, val := range rawMsg { + var err error + switch key { + case "sourceResources": + err = unpopulate(val, "SourceResources", &c.SourceResources) + delete(rawMsg, key) + case "targetResources": + err = unpopulate(val, "TargetResources", &c.TargetResources) + 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 CostAllocationRuleList. +func (c CostAllocationRuleList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// 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) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &c.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &c.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CostAllocationRuleProperties. +func (c CostAllocationRuleProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + 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 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) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdDate": + err = unpopulateDateTimeRFC3339(val, "CreatedDate", &c.CreatedDate) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &c.Description) + delete(rawMsg, key) + case "details": + err = unpopulate(val, "Details", &c.Details) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &c.Status) + delete(rawMsg, key) + case "updatedDate": + err = unpopulateDateTimeRFC3339(val, "UpdatedDate", &c.UpdatedDate) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", c, err) @@ -834,6 +1496,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) @@ -951,6 +1644,7 @@ func (d *DimensionProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DimensionsListResult. func (d DimensionsListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "nextLink", d.NextLink) populate(objectMap, "value", d.Value) return json.Marshal(objectMap) } @@ -964,6 +1658,9 @@ func (d *DimensionsListResult) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &d.NextLink) + delete(rawMsg, key) case "value": err = unpopulate(val, "Value", &d.Value) delete(rawMsg, key) @@ -1073,8 +1770,11 @@ 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, "systemData", e.SystemData) populate(objectMap, "type", e.Type) return json.Marshal(objectMap) } @@ -1094,12 +1794,21 @@ 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) case "properties": err = unpopulate(val, "Properties", &e.Properties) delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &e.SystemData) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &e.Type) delete(rawMsg, key) @@ -1146,6 +1855,8 @@ func (e *ExportDataset) UnmarshalJSON(data []byte) error { func (e ExportDatasetConfiguration) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "columns", e.Columns) + populate(objectMap, "dataVersion", e.DataVersion) + populate(objectMap, "filters", e.Filters) return json.Marshal(objectMap) } @@ -1161,6 +1872,12 @@ func (e *ExportDatasetConfiguration) UnmarshalJSON(data []byte) error { case "columns": err = unpopulate(val, "Columns", &e.Columns) delete(rawMsg, key) + case "dataVersion": + err = unpopulate(val, "DataVersion", &e.DataVersion) + delete(rawMsg, key) + case "filters": + err = unpopulate(val, "Filters", &e.Filters) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", e, err) @@ -1216,6 +1933,7 @@ func (e ExportDeliveryDestination) MarshalJSON() ([]byte, error) { populate(objectMap, "rootFolderPath", e.RootFolderPath) populate(objectMap, "sasToken", e.SasToken) populate(objectMap, "storageAccount", e.StorageAccount) + populate(objectMap, "type", e.Type) return json.Marshal(objectMap) } @@ -1243,6 +1961,9 @@ func (e *ExportDeliveryDestination) UnmarshalJSON(data []byte) error { case "storageAccount": err = unpopulate(val, "StorageAccount", &e.StorageAccount) delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &e.Type) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", e, err) @@ -1335,13 +2056,17 @@ func (e *ExportListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ExportProperties. func (e ExportProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populate(objectMap, "compressionMode", e.CompressionMode) + populate(objectMap, "dataOverwriteBehavior", e.DataOverwriteBehavior) populate(objectMap, "definition", e.Definition) populate(objectMap, "deliveryInfo", e.DeliveryInfo) + populate(objectMap, "exportDescription", e.ExportDescription) populate(objectMap, "format", e.Format) populateDateTimeRFC3339(objectMap, "nextRunTimeEstimate", e.NextRunTimeEstimate) populate(objectMap, "partitionData", e.PartitionData) populate(objectMap, "runHistory", e.RunHistory) populate(objectMap, "schedule", e.Schedule) + populate(objectMap, "systemSuspensionContext", e.SystemSuspensionContext) return json.Marshal(objectMap) } @@ -1354,12 +2079,21 @@ func (e *ExportProperties) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "compressionMode": + err = unpopulate(val, "CompressionMode", &e.CompressionMode) + delete(rawMsg, key) + case "dataOverwriteBehavior": + err = unpopulate(val, "DataOverwriteBehavior", &e.DataOverwriteBehavior) + delete(rawMsg, key) case "definition": err = unpopulate(val, "Definition", &e.Definition) delete(rawMsg, key) case "deliveryInfo": err = unpopulate(val, "DeliveryInfo", &e.DeliveryInfo) delete(rawMsg, key) + case "exportDescription": + err = unpopulate(val, "ExportDescription", &e.ExportDescription) + delete(rawMsg, key) case "format": err = unpopulate(val, "Format", &e.Format) delete(rawMsg, key) @@ -1375,6 +2109,9 @@ func (e *ExportProperties) UnmarshalJSON(data []byte) error { case "schedule": err = unpopulate(val, "Schedule", &e.Schedule) delete(rawMsg, key) + case "systemSuspensionContext": + err = unpopulate(val, "SystemSuspensionContext", &e.SystemSuspensionContext) + delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", e, err) @@ -1460,12 +2197,15 @@ func (e *ExportRun) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ExportRunProperties. func (e ExportRunProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "endDate", e.EndDate) populate(objectMap, "error", e.Error) populate(objectMap, "executionType", e.ExecutionType) populate(objectMap, "fileName", e.FileName) + populate(objectMap, "manifestFile", e.ManifestFile) populateDateTimeRFC3339(objectMap, "processingEndTime", e.ProcessingEndTime) populateDateTimeRFC3339(objectMap, "processingStartTime", e.ProcessingStartTime) populate(objectMap, "runSettings", e.RunSettings) + populateDateTimeRFC3339(objectMap, "startDate", e.StartDate) populate(objectMap, "status", e.Status) populate(objectMap, "submittedBy", e.SubmittedBy) populateDateTimeRFC3339(objectMap, "submittedTime", e.SubmittedTime) @@ -1481,6 +2221,9 @@ func (e *ExportRunProperties) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "endDate": + err = unpopulateDateTimeRFC3339(val, "EndDate", &e.EndDate) + delete(rawMsg, key) case "error": err = unpopulate(val, "Error", &e.Error) delete(rawMsg, key) @@ -1490,6 +2233,9 @@ func (e *ExportRunProperties) UnmarshalJSON(data []byte) error { case "fileName": err = unpopulate(val, "FileName", &e.FileName) delete(rawMsg, key) + case "manifestFile": + err = unpopulate(val, "ManifestFile", &e.ManifestFile) + delete(rawMsg, key) case "processingEndTime": err = unpopulateDateTimeRFC3339(val, "ProcessingEndTime", &e.ProcessingEndTime) delete(rawMsg, key) @@ -1499,6 +2245,9 @@ func (e *ExportRunProperties) UnmarshalJSON(data []byte) error { case "runSettings": err = unpopulate(val, "RunSettings", &e.RunSettings) delete(rawMsg, key) + case "startDate": + err = unpopulateDateTimeRFC3339(val, "StartDate", &e.StartDate) + delete(rawMsg, key) case "status": err = unpopulate(val, "Status", &e.Status) delete(rawMsg, key) @@ -1516,6 +2265,33 @@ func (e *ExportRunProperties) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type ExportRunRequest. +func (e ExportRunRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "timePeriod", e.TimePeriod) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExportRunRequest. +func (e *ExportRunRequest) 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 "timePeriod": + err = unpopulate(val, "TimePeriod", &e.TimePeriod) + 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 ExportSchedule. func (e ExportSchedule) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1551,6 +2327,41 @@ func (e *ExportSchedule) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type ExportSuspensionContext. +func (e ExportSuspensionContext) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "suspensionCode", e.SuspensionCode) + populate(objectMap, "suspensionReason", e.SuspensionReason) + populateDateTimeRFC3339(objectMap, "suspensionTime", e.SuspensionTime) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExportSuspensionContext. +func (e *ExportSuspensionContext) 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 "suspensionCode": + err = unpopulate(val, "SuspensionCode", &e.SuspensionCode) + delete(rawMsg, key) + case "suspensionReason": + err = unpopulate(val, "SuspensionReason", &e.SuspensionReason) + delete(rawMsg, key) + case "suspensionTime": + err = unpopulateDateTimeRFC3339(val, "SuspensionTime", &e.SuspensionTime) + 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 ExportTimePeriod. func (e ExportTimePeriod) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1609,6 +2420,37 @@ func (f *FileDestination) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type FilterItems. +func (f FilterItems) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", f.Name) + populate(objectMap, "value", f.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FilterItems. +func (f *FilterItems) 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 "name": + err = unpopulate(val, "Name", &f.Name) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &f.Value) + 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 ForecastAggregation. func (f ForecastAggregation) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -1948,6 +2790,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) @@ -2067,6 +2940,7 @@ func (g GenerateDetailedCostReportOperationResult) MarshalJSON() ([]byte, error) populate(objectMap, "id", g.ID) populate(objectMap, "name", g.Name) populate(objectMap, "properties", g.Properties) + populate(objectMap, "systemData", g.SystemData) populate(objectMap, "type", g.Type) return json.Marshal(objectMap) } @@ -2089,6 +2963,9 @@ func (g *GenerateDetailedCostReportOperationResult) UnmarshalJSON(data []byte) e case "properties": err = unpopulate(val, "Properties", &g.Properties) delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &g.SystemData) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &g.Type) delete(rawMsg, key) @@ -2110,6 +2987,7 @@ func (g GenerateDetailedCostReportOperationStatuses) MarshalJSON() ([]byte, erro populate(objectMap, "properties", g.Properties) populate(objectMap, "startTime", g.StartTime) populate(objectMap, "status", g.Status) + populate(objectMap, "systemData", g.SystemData) populate(objectMap, "type", g.Type) return json.Marshal(objectMap) } @@ -2144,6 +3022,9 @@ func (g *GenerateDetailedCostReportOperationStatuses) UnmarshalJSON(data []byte) case "status": err = unpopulate(val, "Status", &g.Status) delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &g.SystemData) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &g.Type) delete(rawMsg, key) @@ -2193,6 +3074,7 @@ func (i IncludedQuantityUtilizationSummary) MarshalJSON() ([]byte, error) { objectMap["kind"] = BenefitKindIncludedQuantity populate(objectMap, "name", i.Name) populate(objectMap, "properties", i.Properties) + populate(objectMap, "systemData", i.SystemData) populate(objectMap, "type", i.Type) return json.Marshal(objectMap) } @@ -2218,6 +3100,9 @@ func (i *IncludedQuantityUtilizationSummary) UnmarshalJSON(data []byte) error { case "properties": err = unpopulate(val, "Properties", &i.Properties) delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &i.SystemData) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &i.Type) delete(rawMsg, key) @@ -2311,19 +3196,150 @@ func (k *KpiProperties) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type NotificationProperties. -func (n NotificationProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type MCAPriceSheetProperties. +func (m MCAPriceSheetProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "language", n.Language) - populate(objectMap, "message", n.Message) - populate(objectMap, "regionalFormat", n.RegionalFormat) - populate(objectMap, "subject", n.Subject) - populate(objectMap, "to", n.To) + 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, "meterId", m.MeterID) + 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 NotificationProperties. -func (n *NotificationProperties) UnmarshalJSON(data []byte) error { +// 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 "meterId": + err = unpopulate(val, "MeterID", &m.MeterID) + 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 Notification. +func (n Notification) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + 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 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", n, err) @@ -2331,20 +3347,32 @@ func (n *NotificationProperties) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "language": - err = unpopulate(val, "Language", &n.Language) + case "contactEmails": + err = unpopulate(val, "ContactEmails", &n.ContactEmails) delete(rawMsg, key) - case "message": - err = unpopulate(val, "Message", &n.Message) + case "contactGroups": + err = unpopulate(val, "ContactGroups", &n.ContactGroups) delete(rawMsg, key) - case "regionalFormat": - err = unpopulate(val, "RegionalFormat", &n.RegionalFormat) + case "contactRoles": + err = unpopulate(val, "ContactRoles", &n.ContactRoles) delete(rawMsg, key) - case "subject": - err = unpopulate(val, "Subject", &n.Subject) + case "enabled": + err = unpopulate(val, "Enabled", &n.Enabled) delete(rawMsg, key) - case "to": - err = unpopulate(val, "To", &n.To) + case "frequency": + err = unpopulate(val, "Frequency", &n.Frequency) + delete(rawMsg, key) + 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 { @@ -2354,47 +3382,51 @@ func (n *NotificationProperties) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. -func (o OperationDisplay) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type NotificationProperties. +func (n NotificationProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "description", o.Description) - populate(objectMap, "operation", o.Operation) - populate(objectMap, "provider", o.Provider) - populate(objectMap, "resource", o.Resource) + populate(objectMap, "language", n.Language) + populate(objectMap, "message", n.Message) + populate(objectMap, "regionalFormat", n.RegionalFormat) + populate(objectMap, "subject", n.Subject) + populate(objectMap, "to", n.To) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay. -func (o *OperationDisplay) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type NotificationProperties. +func (n *NotificationProperties) 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) + return fmt.Errorf("unmarshalling type %T: %v", n, err) } for key, val := range rawMsg { var err error switch key { - case "description": - err = unpopulate(val, "Description", &o.Description) + case "language": + err = unpopulate(val, "Language", &n.Language) delete(rawMsg, key) - case "operation": - err = unpopulate(val, "Operation", &o.Operation) + case "message": + err = unpopulate(val, "Message", &n.Message) delete(rawMsg, key) - case "provider": - err = unpopulate(val, "Provider", &o.Provider) + case "regionalFormat": + err = unpopulate(val, "RegionalFormat", &n.RegionalFormat) delete(rawMsg, key) - case "resource": - err = unpopulate(val, "Resource", &o.Resource) + case "subject": + err = unpopulate(val, "Subject", &n.Subject) + delete(rawMsg, key) + case "to": + err = unpopulate(val, "To", &n.To) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) + return fmt.Errorf("unmarshalling type %T: %v", n, err) } } return nil } -// MarshalJSON implements the json.Marshaller interface for type OperationForCostManagement. -func (o OperationForCostManagement) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "actionType", o.ActionType) populate(objectMap, "display", o.Display) @@ -2405,8 +3437,8 @@ func (o OperationForCostManagement) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type OperationForCostManagement. -func (o *OperationForCostManagement) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. +func (o *Operation) 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) @@ -2440,6 +3472,45 @@ func (o *OperationForCostManagement) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", o.Description) + populate(objectMap, "operation", o.Operation) + populate(objectMap, "provider", o.Provider) + populate(objectMap, "resource", o.Resource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay. +func (o *OperationDisplay) 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 "description": + err = unpopulate(val, "Description", &o.Description) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &o.Operation) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &o.Provider) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &o.Resource) + 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 OperationListResult. func (o OperationListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -2533,6 +3604,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) @@ -3396,6 +4502,7 @@ func (s SavingsPlanUtilizationSummary) MarshalJSON() ([]byte, error) { objectMap["kind"] = BenefitKindSavingsPlan populate(objectMap, "name", s.Name) populate(objectMap, "properties", s.Properties) + populate(objectMap, "systemData", s.SystemData) populate(objectMap, "type", s.Type) return json.Marshal(objectMap) } @@ -3421,6 +4528,9 @@ func (s *SavingsPlanUtilizationSummary) UnmarshalJSON(data []byte) error { case "properties": err = unpopulate(val, "Properties", &s.Properties) delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &s.SystemData) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &s.Type) delete(rawMsg, key) @@ -3675,6 +4785,76 @@ 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) + populate(objectMap, "kind", s.Kind) + populate(objectMap, "name", s.Name) + populate(objectMap, "systemData", s.SystemData) + 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 "systemData": + err = unpopulate(val, "SystemData", &s.SystemData) + 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) @@ -3833,6 +5013,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) @@ -3860,6 +5075,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) @@ -3907,6 +5157,119 @@ 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, "systemData", t.SystemData) + 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 "systemData": + err = unpopulate(val, "SystemData", &t.SystemData) + 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) @@ -3914,6 +5277,7 @@ func (v View) MarshalJSON() ([]byte, error) { populate(objectMap, "id", v.ID) populate(objectMap, "name", v.Name) populate(objectMap, "properties", v.Properties) + populate(objectMap, "systemData", v.SystemData) populate(objectMap, "type", v.Type) return json.Marshal(objectMap) } @@ -3939,6 +5303,9 @@ func (v *View) UnmarshalJSON(data []byte) error { case "properties": err = unpopulate(val, "Properties", &v.Properties) delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &v.SystemData) + delete(rawMsg, key) case "type": err = unpopulate(val, "Type", &v.Type) delete(rawMsg, key) @@ -4073,7 +5440,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 f74b832af8d5..f4cd03b9a882 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/operations_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/operations_client.go @@ -1,7 +1,6 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armcostmanagement @@ -22,7 +21,7 @@ type OperationsClient struct { // NewOperationsClient creates a new instance of OperationsClient with the specified values. // - credential - used to authorize requests. Usually a credential from azidentity. -// - options - pass nil to accept the default values. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -34,9 +33,9 @@ func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientO return client, nil } -// NewListPager - Lists all of the available cost management REST API operations. +// NewListPager - List the operations for the provider // -// Generated from API version 2022-10-01 +// Generated from API version 2025-03-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]{ @@ -62,14 +61,14 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption } // listCreateRequest creates the List request. -func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { +func (client *OperationsClient) listCreateRequest(ctx context.Context, _ *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.CostManagement/operations" req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2025-03-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 index 377c857323ff..2069c14b19a1 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/operations_client_example_test.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/operations_client_example_test.go @@ -1,20 +1,17 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. 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" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v3" + "log" ) -// Generated from 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 +// Generated from example definition: 2025-03-01/OperationList.json func ExampleOperationsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -36,108 +33,111 @@ func ExampleOperationsClient_NewListPager() { _ = 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"), + // page = armcostmanagement.OperationsClientListResponse{ + // OperationListResult: armcostmanagement.OperationListResult{ + // Value: []*armcostmanagement.Operation{ + // { + // 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"), // }, - // 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"), + // { + // 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"), // }, - // 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"), + // { + // 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"), // }, - // 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"), + // { + // 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"), // }, - // 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"), + // { + // 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"), // }, - // 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"), + // { + // 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"), // }, - // 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"), + // { + // 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"), // }, - // 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"), + // { + // 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"), // }, - // 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"), + // { + // 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"), // }, - // 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"), + // { + // 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"), // }, - // ID: to.Ptr("Microsoft.CostManagement/views/write"), - // }}, + // }, + // }, // } } } diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/options.go b/sdk/resourcemanager/costmanagement/armcostmanagement/options.go index 123950713d2a..5bd3674729a3 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/options.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/options.go @@ -1,7 +1,6 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armcostmanagement @@ -20,7 +19,7 @@ type AlertsClientListExternalOptions struct { // placeholder for future optional parameters } -// AlertsClientListOptions contains the optional parameters for the AlertsClient.List method. +// AlertsClientListOptions contains the optional parameters for the AlertsClient.NewListPager method. type AlertsClientListOptions struct { // placeholder for future optional parameters } @@ -32,9 +31,9 @@ type BenefitRecommendationsClientListOptions struct { Expand *string // Can be used to filter benefitRecommendations by: properties/scope with allowed values ['Single', 'Shared'] and default - // value 'Shared'; and properties/lookBackPeriod with allowed values ['Last7Days', - // 'Last30Days', 'Last60Days'] and default value 'Last60Days'; properties/term with allowed values ['P1Y', 'P3Y'] and default - // value 'P3Y'; properties/subscriptionId; properties/resourceGroup + // value 'Shared'; and properties/lookBackPeriod with allowed values ['Last7Days', 'Last30Days', 'Last60Days'] and default + // value 'Last60Days'; properties/term with allowed values ['P1Y', 'P3Y'] and default value 'P3Y'; properties/subscriptionId; + // properties/resourceGroup Filter *string // May be used to order the recommendations by: properties/armSkuName. For the savings plan, the results are in order by default. @@ -82,6 +81,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 { @@ -93,8 +140,8 @@ type DimensionsClientByExternalCloudProviderTypeOptions struct { Filter *string // Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, - // the value of the nextLink element will include a skiptoken parameter that - // specifies a starting point to use for subsequent calls. + // the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent + // calls. Skiptoken *string // May be used to limit the number of results to the most recent N dimension data. @@ -111,8 +158,8 @@ type DimensionsClientListOptions struct { Filter *string // Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, - // the value of the nextLink element will include a skiptoken parameter that - // specifies a starting point to use for subsequent calls. + // the value of the nextLink element will include a skiptoken parameter that specifies a starting point to use for subsequent + // calls. Skiptoken *string // May be used to limit the number of results to the most recent N dimension data. @@ -131,7 +178,8 @@ type ExportsClientDeleteOptions struct { // ExportsClientExecuteOptions contains the optional parameters for the ExportsClient.Execute method. type ExportsClientExecuteOptions struct { - // placeholder for future optional parameters + // Parameters supplied to the Execute Export operation. + Parameters *ExportRunRequest } // ExportsClientGetExecutionHistoryOptions contains the optional parameters for the ExportsClient.GetExecutionHistory method. @@ -146,7 +194,7 @@ type ExportsClientGetOptions struct { Expand *string } -// ExportsClientListOptions contains the optional parameters for the ExportsClient.List method. +// ExportsClientListOptions contains the optional parameters for the ExportsClient.NewListPager method. type ExportsClientListOptions struct { // May be used to expand the properties within an export. Currently only 'runHistory' is supported and will return information // for the last run of each export. @@ -157,44 +205,84 @@ type ExportsClientListOptions struct { // method. type ForecastClientExternalCloudProviderUsageOptions struct { // May be used to filter forecasts by properties/usageDate (Utc time), properties/chargeType or properties/grain. The filter - // supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently - // support 'ne', 'or', or 'not'. + // supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Filter *string } // ForecastClientUsageOptions contains the optional parameters for the ForecastClient.Usage method. type ForecastClientUsageOptions struct { // May be used to filter forecasts by properties/usageDate (Utc time), properties/chargeType or properties/grain. The filter - // supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently - // support 'ne', 'or', or 'not'. + // supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support 'ne', 'or', or 'not'. Filter *string } +// GenerateBenefitUtilizationSummariesReportClientBeginGenerateByBillingAccountOptions contains the optional parameters for +// the GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByBillingAccount method. +type GenerateBenefitUtilizationSummariesReportClientBeginGenerateByBillingAccountOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// GenerateBenefitUtilizationSummariesReportClientBeginGenerateByBillingProfileOptions contains the optional parameters for +// the GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByBillingProfile method. +type GenerateBenefitUtilizationSummariesReportClientBeginGenerateByBillingProfileOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// GenerateBenefitUtilizationSummariesReportClientBeginGenerateByReservationIDOptions contains the optional parameters for +// the GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByReservationID method. +type GenerateBenefitUtilizationSummariesReportClientBeginGenerateByReservationIDOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// GenerateBenefitUtilizationSummariesReportClientBeginGenerateByReservationOrderIDOptions contains the optional parameters +// for the GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByReservationOrderID method. +type GenerateBenefitUtilizationSummariesReportClientBeginGenerateByReservationOrderIDOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// GenerateBenefitUtilizationSummariesReportClientBeginGenerateBySavingsPlanIDOptions contains the optional parameters for +// the GenerateBenefitUtilizationSummariesReportClient.BeginGenerateBySavingsPlanID method. +type GenerateBenefitUtilizationSummariesReportClientBeginGenerateBySavingsPlanIDOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// GenerateBenefitUtilizationSummariesReportClientBeginGenerateBySavingsPlanOrderIDOptions contains the optional parameters +// for the GenerateBenefitUtilizationSummariesReportClient.BeginGenerateBySavingsPlanOrderID method. +type GenerateBenefitUtilizationSummariesReportClientBeginGenerateBySavingsPlanOrderIDOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + // GenerateCostDetailsReportClientBeginCreateOperationOptions contains the optional parameters for the GenerateCostDetailsReportClient.BeginCreateOperation // method. type GenerateCostDetailsReportClientBeginCreateOperationOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } // GenerateCostDetailsReportClientBeginGetOperationResultsOptions contains the optional parameters for the GenerateCostDetailsReportClient.BeginGetOperationResults // method. type GenerateCostDetailsReportClientBeginGetOperationResultsOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } // GenerateDetailedCostReportClientBeginCreateOperationOptions contains the optional parameters for the GenerateDetailedCostReportClient.BeginCreateOperation // method. type GenerateDetailedCostReportClientBeginCreateOperationOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } // GenerateDetailedCostReportOperationResultsClientBeginGetOptions contains the optional parameters for the GenerateDetailedCostReportOperationResultsClient.BeginGet // method. type GenerateDetailedCostReportOperationResultsClientBeginGetOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } @@ -207,14 +295,14 @@ type GenerateDetailedCostReportOperationStatusClientGetOptions struct { // GenerateReservationDetailsReportClientBeginByBillingAccountIDOptions contains the optional parameters for the GenerateReservationDetailsReportClient.BeginByBillingAccountID // method. type GenerateReservationDetailsReportClientBeginByBillingAccountIDOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } // GenerateReservationDetailsReportClientBeginByBillingProfileIDOptions contains the optional parameters for the GenerateReservationDetailsReportClient.BeginByBillingProfileID // method. type GenerateReservationDetailsReportClientBeginByBillingProfileIDOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } @@ -223,16 +311,24 @@ type OperationsClientListOptions struct { // placeholder for future optional parameters } +// PriceSheetClientBeginDownloadByBillingAccountOptions contains the optional parameters for the PriceSheetClient.BeginDownloadByBillingAccount +// method. +type PriceSheetClientBeginDownloadByBillingAccountOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + // PriceSheetClientBeginDownloadByBillingProfileOptions contains the optional parameters for the PriceSheetClient.BeginDownloadByBillingProfile // method. type PriceSheetClientBeginDownloadByBillingProfileOptions struct { - // Resumes the LRO from the provided token. + // Resumes the long-running operation from the provided token. ResumeToken string } -// PriceSheetClientBeginDownloadOptions contains the optional parameters for the PriceSheetClient.BeginDownload method. -type PriceSheetClientBeginDownloadOptions struct { - // Resumes the LRO from the provided token. +// PriceSheetClientBeginDownloadByInvoiceOptions contains the optional parameters for the PriceSheetClient.BeginDownloadByInvoice +// method. +type PriceSheetClientBeginDownloadByInvoiceOptions struct { + // Resumes the long-running operation from the provided token. ResumeToken string } @@ -319,6 +415,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.NewListPager 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 a3fe4a744c9f..0ad267be31c0 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/polymorphic_helpers.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/polymorphic_helpers.go @@ -1,14 +1,13 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. 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 @@ -17,10 +16,10 @@ func unmarshalBenefitRecommendationPropertiesClassification(rawMsg json.RawMessa } var b BenefitRecommendationPropertiesClassification switch m["scope"] { - case string(ScopeShared): - b = &SharedScopeBenefitRecommendationProperties{} case string(ScopeSingle): b = &SingleScopeBenefitRecommendationProperties{} + case string(ScopeShared): + b = &SharedScopeBenefitRecommendationProperties{} default: b = &BenefitRecommendationProperties{} } @@ -31,7 +30,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 @@ -54,7 +53,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 @@ -71,3 +70,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 c67616fe8870..8d1243977135 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/pricesheet_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/pricesheet_client.go @@ -1,7 +1,6 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armcostmanagement @@ -25,7 +24,7 @@ type PriceSheetClient struct { // NewPriceSheetClient creates a new instance of PriceSheetClient with the specified values. // - credential - used to authorize requests. Usually a credential from azidentity. -// - options - pass nil to accept the default values. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewPriceSheetClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*PriceSheetClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -37,46 +36,72 @@ 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 2025-03-01** +// You can use the 2025-03-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 2025-03-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]{ - FinalStateVia: runtime.FinalStateViaLocation, - Tracer: client.internal.Tracer(), + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PriceSheetClientDownloadByBillingAccountResponse]{ + 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 2025-03-01** +// You can use the 2025-03-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 2025-03-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 } @@ -91,42 +116,39 @@ 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") +// downloadByBillingAccountCreateRequest creates the DownloadByBillingAccount request. +func (client *PriceSheetClient) downloadByBillingAccountCreateRequest(ctx context.Context, billingAccountID string, billingPeriodName string, _ *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, "{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, "{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", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } // 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. +// is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer 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 -// - billingAccountName - The ID that uniquely identifies a billing account. -// - billingProfileName - The ID that uniquely identifies a billing profile. +// Generated from API version 2025-03-01 +// - billingAccountName - BillingAccount ID +// - billingProfileName - Billing Profile Name. // - options - PriceSheetClientBeginDownloadByBillingProfileOptions contains the optional parameters for the PriceSheetClient.BeginDownloadByBillingProfile // method. func (client *PriceSheetClient) BeginDownloadByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string, options *PriceSheetClientBeginDownloadByBillingProfileOptions) (*runtime.Poller[PriceSheetClientDownloadByBillingProfileResponse], error) { @@ -136,8 +158,7 @@ func (client *PriceSheetClient) BeginDownloadByBillingProfile(ctx context.Contex return nil, err } poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PriceSheetClientDownloadByBillingProfileResponse]{ - FinalStateVia: runtime.FinalStateViaLocation, - Tracer: client.internal.Tracer(), + Tracer: client.internal.Tracer(), }) return poller, err } else { @@ -148,13 +169,14 @@ 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. +// supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer 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 2025-03-01 func (client *PriceSheetClient) downloadByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string, options *PriceSheetClientBeginDownloadByBillingProfileOptions) (*http.Response, error) { var err error const operationName = "PriceSheetClient.BeginDownloadByBillingProfile" @@ -177,8 +199,83 @@ func (client *PriceSheetClient) downloadByBillingProfile(ctx context.Context, bi } // downloadByBillingProfileCreateRequest creates the DownloadByBillingProfile request. -func (client *PriceSheetClient) downloadByBillingProfileCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, options *PriceSheetClientBeginDownloadByBillingProfileOptions) (*policy.Request, error) { - urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/providers/Microsoft.CostManagement/pricesheets/default/download" +func (client *PriceSheetClient) downloadByBillingProfileCreateRequest(ctx context.Context, billingAccountName string, billingProfileName string, _ *PriceSheetClientBeginDownloadByBillingProfileOptions) (*policy.Request, error) { + urlPath := "/providers/microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/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)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-03-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 2025-03-01 +// - billingAccountName - BillingAccount ID +// - billingProfileName - Billing Profile Name. +// - 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]{ + 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 2025-03-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, _ *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") } @@ -187,12 +284,16 @@ func (client *PriceSheetClient) downloadByBillingProfileCreateRequest(ctx contex 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", "2022-10-01") + reqQP.Set("api-version", "2025-03-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 index 551234cca2c2..60cd030952a1 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/pricesheet_client_example_test.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/pricesheet_client_example_test.go @@ -1,21 +1,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. +// Code generated by Microsoft (R) Go Code Generator. 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" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v3" + "log" ) -// Generated from 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() { +// Generated from example definition: 2025-03-01/EAPriceSheetForBillingPeriod.json +func ExamplePriceSheetClient_BeginDownloadByBillingAccount() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -25,7 +22,7 @@ func ExamplePriceSheetClient_BeginDownload() { 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) + poller, err := clientFactory.NewPriceSheetClient().BeginDownloadByBillingAccount(ctx, "0000000", "202311", nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) } @@ -36,13 +33,18 @@ func ExamplePriceSheetClient_BeginDownload() { // 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}()), + // res = armcostmanagement.PriceSheetClientDownloadByBillingAccountResponse{ + // OperationStatus: &armcostmanagement.OperationStatus{ + // Properties: &armcostmanagement.ReportURL{ + // ReportURL: to.Ptr(armcostmanagement.ReservationReportSchema("https://myaccount.blob.core.windows.net/reportfile.csv?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")), + // ValidUntil: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-09-30T17:32:28Z"); 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/PricesheetDownloadByBillingProfile.json +// Generated from example definition: 2025-03-01/PricesheetDownloadByBillingProfile.json func ExamplePriceSheetClient_BeginDownloadByBillingProfile() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -64,8 +66,40 @@ func ExamplePriceSheetClient_BeginDownloadByBillingProfile() { // 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}()), + // res = armcostmanagement.PriceSheetClientDownloadByBillingProfileResponse{ + // PricesheetDownloadProperties: &armcostmanagement.PricesheetDownloadProperties{ + // 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:28Z"); return t}()), + // }, + // } +} + +// Generated from example definition: 2025-03-01/PricesheetDownload.json +func ExamplePriceSheetClient_BeginDownloadByInvoice() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain 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().BeginDownloadByInvoice(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 = armcostmanagement.PriceSheetClientDownloadByInvoiceResponse{ + // 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:28Z"); return t}()), + // }, // } } diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/query_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/query_client.go index 4172909d1f46..49351fd16adc 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/query_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/query_client.go @@ -1,7 +1,6 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armcostmanagement @@ -25,7 +24,7 @@ type QueryClient struct { // NewQueryClient creates a new instance of QueryClient with the specified values. // - credential - used to authorize requests. Usually a credential from azidentity. -// - options - pass nil to accept the default values. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewQueryClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*QueryClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -40,17 +39,16 @@ 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 2025-03-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 -// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope, -// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount -// scope, -// '/providers/Microsoft.Management/managementGroups/{managementGroupId} for Management Group scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' -// for billingProfile scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' -// for invoiceSection scope, and -// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for partners. +// scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' +// for Billing Account scope and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' +// for Department scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' +// for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId} for Management Group +// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile +// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' +// for invoiceSection scope, and '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' +// specific for partners. // - parameters - Parameters supplied to the CreateOrUpdate Query Config operation. // - options - QueryClientUsageOptions contains the optional parameters for the QueryClient.Usage method. func (client *QueryClient) Usage(ctx context.Context, scope string, parameters QueryDefinition, options *QueryClientUsageOptions) (QueryClientUsageResponse, error) { @@ -76,17 +74,21 @@ func (client *QueryClient) Usage(ctx context.Context, scope string, parameters Q } // usageCreateRequest creates the Usage request. -func (client *QueryClient) usageCreateRequest(ctx context.Context, scope string, parameters QueryDefinition, options *QueryClientUsageOptions) (*policy.Request, error) { +func (client *QueryClient) usageCreateRequest(ctx context.Context, scope string, parameters QueryDefinition, _ *QueryClientUsageOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.CostManagement/query" + if scope == "" { + return nil, errors.New("parameter scope cannot be empty") + } urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) 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", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -105,12 +107,12 @@ 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 2025-03-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 // consolidated account used with dimension/query operations. -// - parameters - Parameters supplied to the CreateOrUpdate Query Config operation. +// - parameters - The request body // - options - QueryClientUsageByExternalCloudProviderTypeOptions contains the optional parameters for the QueryClient.UsageByExternalCloudProviderType // method. func (client *QueryClient) UsageByExternalCloudProviderType(ctx context.Context, externalCloudProviderType ExternalCloudProviderType, externalCloudProviderID string, parameters QueryDefinition, options *QueryClientUsageByExternalCloudProviderTypeOptions) (QueryClientUsageByExternalCloudProviderTypeResponse, error) { @@ -136,7 +138,7 @@ func (client *QueryClient) UsageByExternalCloudProviderType(ctx context.Context, } // usageByExternalCloudProviderTypeCreateRequest creates the UsageByExternalCloudProviderType request. -func (client *QueryClient) usageByExternalCloudProviderTypeCreateRequest(ctx context.Context, externalCloudProviderType ExternalCloudProviderType, externalCloudProviderID string, parameters QueryDefinition, options *QueryClientUsageByExternalCloudProviderTypeOptions) (*policy.Request, error) { +func (client *QueryClient) usageByExternalCloudProviderTypeCreateRequest(ctx context.Context, externalCloudProviderType ExternalCloudProviderType, externalCloudProviderID string, parameters QueryDefinition, _ *QueryClientUsageByExternalCloudProviderTypeOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.CostManagement/{externalCloudProviderType}/{externalCloudProviderId}/query" if externalCloudProviderType == "" { return nil, errors.New("parameter externalCloudProviderType cannot be empty") @@ -151,9 +153,10 @@ 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", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/query_client_example_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/query_client_example_test.go index dce66cd25999..e672d7e02fb7 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/query_client_example_test.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/query_client_example_test.go @@ -1,21 +1,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. +// Code generated by Microsoft (R) Go Code Generator. 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" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v3" + "log" ) -// Generated from 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 +// Generated from example definition: 2025-03-01/BillingAccountQuery.json func ExampleQueryClient_Usage_billingAccountQueryLegacy() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -27,7 +24,7 @@ func ExampleQueryClient_Usage_billingAccountQueryLegacy() { 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), + Type: to.Ptr(armcostmanagement.ExportTypeUsage), Dataset: &armcostmanagement.QueryDataset{ Filter: &armcostmanagement.QueryFilter{ And: []*armcostmanagement.QueryFilter{ @@ -35,35 +32,40 @@ func ExampleQueryClient_Usage_billingAccountQueryLegacy() { Or: []*armcostmanagement.QueryFilter{ { Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), + Name: to.Ptr("ResourceLocation"), + Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), Values: []*string{ to.Ptr("East US"), - to.Ptr("West Europe")}, + to.Ptr("West Europe"), + }, }, }, { Tags: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), + Name: to.Ptr("Environment"), + Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), Values: []*string{ to.Ptr("UAT"), - to.Ptr("Prod")}, + to.Ptr("Prod"), + }, }, - }}, + }, + }, }, { Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), + Name: to.Ptr("ResourceGroup"), + Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), Values: []*string{ - to.Ptr("API")}, + to.Ptr("API"), + }, }, - }}, + }, + }, }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), + Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) @@ -71,55 +73,64 @@ func ExampleQueryClient_Usage_billingAccountQueryLegacy() { // 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"), + // res = armcostmanagement.QueryClientUsageResponse{ + // 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"), + // }, // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // float64(20180331), - // "USD"}, - // []any{ - // float64(173.41979241290323), + // NextLink: to.Ptr("https://management.azure.com/providers/Microsoft.Billing/billingAccounts/70664866/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D"), + // Rows: [][]any{ + // []any{ + // 19.545363672276512, + // "JapanUnifia-Trial", + // 20180331, + // "USD", + // }, + // []any{ + // 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"}}, - // }, - // } + // 20180331, + // "USD", + // }, + // []any{ + // 20.35941656262545, + // "VSTSHOL-1595322048000", + // 20180331, + // "USD", + // }, + // []any{ + // 0.16677720329728665, + // "gs-stms-dev", + // 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() { +// Generated from example definition: 2025-03-01/BillingAccountQueryGrouping.json +func ExampleQueryClient_Usage_billingAccountQueryGroupingLegacy() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -129,44 +140,24 @@ func ExampleQueryClient_Usage_billingAccountQueryMca() { 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), + 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")}, - }, - }}, + 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), + }, }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), + Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheLastMonth), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) @@ -174,55 +165,51 @@ func ExampleQueryClient_Usage_billingAccountQueryMca() { // 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"), + // res = armcostmanagement.QueryClientUsageResponse{ + // 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"), + // }, // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // float64(20180331), - // "USD"}, - // []any{ - // float64(173.41979241290323), + // NextLink: to.Ptr("https://management.azure.com/providers/Microsoft.Billing/billingAccounts/70664866/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D"), + // Rows: [][]any{ + // []any{ + // 19.545363672276512, + // "JapanUnifia-Trial", + // "USD", + // }, + // []any{ + // 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"}}, - // }, - // } + // "USD", + // }, + // []any{ + // 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/BillingAccountQueryGrouping.json -func ExampleQueryClient_Usage_billingAccountQueryGroupingLegacy() { +// Generated from example definition: 2025-03-01/DepartmentQuery.json +func ExampleQueryClient_Usage_departmentQueryLegacy() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -232,23 +219,49 @@ func ExampleQueryClient_Usage_billingAccountQueryGroupingLegacy() { 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), + 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), + 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.GranularityType("None")), - Grouping: []*armcostmanagement.QueryGrouping{ - { - Name: to.Ptr("ResourceGroup"), - Type: to.Ptr(armcostmanagement.QueryColumnTypeDimension), - }}, + Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheLastMonth), + Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) @@ -256,43 +269,64 @@ func ExampleQueryClient_Usage_billingAccountQueryGroupingLegacy() { // 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"), + // res = armcostmanagement.QueryClientUsageResponse{ + // 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"), + // }, // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // "USD"}, - // []any{ - // float64(173.41979241290323), + // NextLink: to.Ptr("https://management.azure.com/providers/Microsoft.Billing/billingAccounts/70664866/departments/123/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D"), + // Rows: [][]any{ + // []any{ + // 19.545363672276512, + // "JapanUnifia-Trial", + // 20180331, + // "USD", + // }, + // []any{ + // 173.41979241290323, // "RVIIOT-TRIAL", - // "USD"}, - // []any{ - // float64(20.35941656262545), - // "VSTSHOL-1595322048000", - // "USD"}}, - // }, - // } + // 20180331, + // "USD", + // }, + // []any{ + // 20.35941656262545, + // "VSTSHOL-1595322048000", + // 20180331, + // "USD", + // }, + // []any{ + // 0.16677720329728665, + // "gs-stms-dev", + // 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/MCABillingAccountQueryGrouping.json -func ExampleQueryClient_Usage_billingAccountQueryGroupingMca() { +// Generated from example definition: 2025-03-01/DepartmentQueryGrouping.json +func ExampleQueryClient_Usage_departmentQueryGroupingLegacy() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -302,23 +336,24 @@ func ExampleQueryClient_Usage_billingAccountQueryGroupingMca() { 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), + 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), + Name: to.Ptr("PreTaxCost"), + Function: to.Ptr(armcostmanagement.FunctionTypeSum), }, }, - Granularity: to.Ptr(armcostmanagement.GranularityType("None")), + Granularity: to.Ptr(armcostmanagement.GranularityType("None")), Grouping: []*armcostmanagement.QueryGrouping{ { - Name: to.Ptr("ResourceGroup"), - Type: to.Ptr(armcostmanagement.QueryColumnTypeDimension), - }}, + Name: to.Ptr("ResourceGroup"), + Type: to.Ptr(armcostmanagement.QueryColumnTypeDimension), + }, + }, }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheLastMonth), + Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheLastMonth), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) @@ -326,43 +361,51 @@ func ExampleQueryClient_Usage_billingAccountQueryGroupingMca() { // 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"), + // res = armcostmanagement.QueryClientUsageResponse{ + // 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"), + // }, // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // "USD"}, - // []any{ - // float64(173.41979241290323), + // NextLink: to.Ptr("https://management.azure.com/providers/Microsoft.Billing/billingAccounts/70664866/departments/123/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D"), + // Rows: [][]any{ + // []any{ + // 19.545363672276512, + // "JapanUnifia-Trial", + // "USD", + // }, + // []any{ + // 173.41979241290323, // "RVIIOT-TRIAL", - // "USD"}, - // []any{ - // float64(20.35941656262545), - // "VSTSHOL-1595322048000", - // "USD"}}, - // }, - // } + // "USD", + // }, + // []any{ + // 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() { +// Generated from example definition: 2025-03-01/EnrollmentAccountQuery.json +func ExampleQueryClient_Usage_enrollmentAccountQueryLegacy() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -372,8 +415,8 @@ func ExampleQueryClient_Usage_billingProfileQueryMca() { 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), + 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{ @@ -381,35 +424,40 @@ func ExampleQueryClient_Usage_billingProfileQueryMca() { Or: []*armcostmanagement.QueryFilter{ { Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), + Name: to.Ptr("ResourceLocation"), + Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), Values: []*string{ to.Ptr("East US"), - to.Ptr("West Europe")}, + to.Ptr("West Europe"), + }, }, }, { Tags: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), + Name: to.Ptr("Environment"), + Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), Values: []*string{ to.Ptr("UAT"), - to.Ptr("Prod")}, + to.Ptr("Prod"), + }, }, - }}, + }, + }, }, { Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), + Name: to.Ptr("ResourceGroup"), + Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), Values: []*string{ - to.Ptr("API")}, + to.Ptr("API"), + }, }, - }}, + }, + }, }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), + Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) @@ -417,55 +465,64 @@ func ExampleQueryClient_Usage_billingProfileQueryMca() { // 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"), + // res = armcostmanagement.QueryClientUsageResponse{ + // 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"), + // }, // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // float64(20180331), - // "USD"}, - // []any{ - // float64(173.41979241290323), + // NextLink: to.Ptr("https://management.azure.com/providers/Microsoft.Billing/billingAccounts/70664866/enrollmentAccounts/456/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D"), + // Rows: [][]any{ + // []any{ + // 19.545363672276512, + // "JapanUnifia-Trial", + // 20180331, + // "USD", + // }, + // []any{ + // 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"}}, - // }, - // } + // 20180331, + // "USD", + // }, + // []any{ + // 20.35941656262545, + // "VSTSHOL-1595322048000", + // 20180331, + // "USD", + // }, + // []any{ + // 0.16677720329728665, + // "gs-stms-dev", + // 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() { +// Generated from example definition: 2025-03-01/EnrollmentAccountQueryGrouping.json +func ExampleQueryClient_Usage_enrollmentAccountQueryGroupingLegacy() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -475,23 +532,24 @@ func ExampleQueryClient_Usage_billingProfileQueryGroupingMca() { 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), + 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), + Name: to.Ptr("PreTaxCost"), + Function: to.Ptr(armcostmanagement.FunctionTypeSum), }, }, - Granularity: to.Ptr(armcostmanagement.GranularityType("None")), + Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), Grouping: []*armcostmanagement.QueryGrouping{ { - Name: to.Ptr("ResourceGroup"), - Type: to.Ptr(armcostmanagement.QueryColumnTypeDimension), - }}, + Name: to.Ptr("ResourceGroup"), + Type: to.Ptr(armcostmanagement.QueryColumnTypeDimension), + }, + }, }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheLastMonth), + Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheLastMonth), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) @@ -499,43 +557,58 @@ func ExampleQueryClient_Usage_billingProfileQueryGroupingMca() { // 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"), + // res = armcostmanagement.QueryClientUsageResponse{ + // 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"), + // }, // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // "USD"}, - // []any{ - // float64(173.41979241290323), + // NextLink: to.Ptr("https://management.azure.com/providers/Microsoft.Billing/billingAccounts/70664866/enrollmentAccounts/456/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D"), + // Rows: [][]any{ + // []any{ + // 19.545363672276512, + // "JapanUnifia-Trial", + // 20180331, + // "USD", + // }, + // []any{ + // 173.41979241290323, // "RVIIOT-TRIAL", - // "USD"}, - // []any{ - // float64(20.35941656262545), - // "VSTSHOL-1595322048000", - // "USD"}}, - // }, - // } + // 20180331, + // "USD", + // }, + // []any{ + // 20.35941656262545, + // "VSTSHOL-1595322048000", + // 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/MCACustomerQuery.json -func ExampleQueryClient_Usage_customerQueryMca() { +// Generated from example definition: 2025-03-01/MCABillingAccountQuery.json +func ExampleQueryClient_Usage_billingAccountQueryMca() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -545,8 +618,8 @@ func ExampleQueryClient_Usage_customerQueryMca() { 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), + 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{ @@ -554,35 +627,40 @@ func ExampleQueryClient_Usage_customerQueryMca() { Or: []*armcostmanagement.QueryFilter{ { Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), + Name: to.Ptr("ResourceLocation"), + Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), Values: []*string{ to.Ptr("East US"), - to.Ptr("West Europe")}, + to.Ptr("West Europe"), + }, }, }, { Tags: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), + Name: to.Ptr("Environment"), + Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), Values: []*string{ to.Ptr("UAT"), - to.Ptr("Prod")}, + to.Ptr("Prod"), + }, }, - }}, + }, + }, }, { Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), + Name: to.Ptr("ResourceGroup"), + Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), Values: []*string{ - to.Ptr("API")}, + to.Ptr("API"), + }, }, - }}, + }, + }, }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), + Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) @@ -590,55 +668,64 @@ func ExampleQueryClient_Usage_customerQueryMca() { // 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"), + // res = armcostmanagement.QueryClientUsageResponse{ + // 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"), + // }, // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // float64(20180331), - // "USD"}, - // []any{ - // float64(173.41979241290323), + // NextLink: to.Ptr("https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D"), + // Rows: [][]any{ + // []any{ + // 19.545363672276512, + // "JapanUnifia-Trial", + // 20180331, + // "USD", + // }, + // []any{ + // 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"}}, - // }, - // } + // 20180331, + // "USD", + // }, + // []any{ + // 20.35941656262545, + // "VSTSHOL-1595322048000", + // 20180331, + // "USD", + // }, + // []any{ + // 0.16677720329728665, + // "gs-stms-dev", + // 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() { +// Generated from example definition: 2025-03-01/MCABillingAccountQueryGrouping.json +func ExampleQueryClient_Usage_billingAccountQueryGroupingMca() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -648,23 +735,24 @@ func ExampleQueryClient_Usage_customerQueryGroupingMca() { 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), + 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), + Name: to.Ptr("PreTaxCost"), + Function: to.Ptr(armcostmanagement.FunctionTypeSum), }, }, - Granularity: to.Ptr(armcostmanagement.GranularityType("None")), + Granularity: to.Ptr(armcostmanagement.GranularityType("None")), Grouping: []*armcostmanagement.QueryGrouping{ { - Name: to.Ptr("ResourceGroup"), - Type: to.Ptr(armcostmanagement.QueryColumnTypeDimension), - }}, + Name: to.Ptr("ResourceGroup"), + Type: to.Ptr(armcostmanagement.QueryColumnTypeDimension), + }, + }, }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheLastMonth), + Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheLastMonth), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) @@ -672,43 +760,51 @@ func ExampleQueryClient_Usage_customerQueryGroupingMca() { // 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"), + // res = armcostmanagement.QueryClientUsageResponse{ + // 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"), + // }, // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // "USD"}, - // []any{ - // float64(173.41979241290323), + // NextLink: to.Ptr("https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D"), + // Rows: [][]any{ + // []any{ + // 19.545363672276512, + // "JapanUnifia-Trial", + // "USD", + // }, + // []any{ + // 173.41979241290323, // "RVIIOT-TRIAL", - // "USD"}, - // []any{ - // float64(20.35941656262545), - // "VSTSHOL-1595322048000", - // "USD"}}, - // }, - // } + // "USD", + // }, + // []any{ + // 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() { +// Generated from example definition: 2025-03-01/MCABillingProfileQuery.json +func ExampleQueryClient_Usage_billingProfileQueryMca() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -718,8 +814,8 @@ func ExampleQueryClient_Usage_departmentQueryLegacy() { 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), + 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{ @@ -727,35 +823,40 @@ func ExampleQueryClient_Usage_departmentQueryLegacy() { Or: []*armcostmanagement.QueryFilter{ { Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), + Name: to.Ptr("ResourceLocation"), + Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), Values: []*string{ to.Ptr("East US"), - to.Ptr("West Europe")}, + to.Ptr("West Europe"), + }, }, }, { Tags: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), + Name: to.Ptr("Environment"), + Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), Values: []*string{ to.Ptr("UAT"), - to.Ptr("Prod")}, + to.Ptr("Prod"), + }, }, - }}, + }, + }, }, { Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), + Name: to.Ptr("ResourceGroup"), + Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), Values: []*string{ - to.Ptr("API")}, + to.Ptr("API"), + }, }, - }}, + }, + }, }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), + Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) @@ -763,55 +864,64 @@ func ExampleQueryClient_Usage_departmentQueryLegacy() { // 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"), + // res = armcostmanagement.QueryClientUsageResponse{ + // 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"), + // }, // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // float64(20180331), - // "USD"}, - // []any{ - // float64(173.41979241290323), + // NextLink: to.Ptr("https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D"), + // Rows: [][]any{ + // []any{ + // 19.545363672276512, + // "JapanUnifia-Trial", + // 20180331, + // "USD", + // }, + // []any{ + // 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"}}, - // }, - // } + // 20180331, + // "USD", + // }, + // []any{ + // 20.35941656262545, + // "VSTSHOL-1595322048000", + // 20180331, + // "USD", + // }, + // []any{ + // 0.16677720329728665, + // "gs-stms-dev", + // 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() { +// Generated from example definition: 2025-03-01/MCABillingProfileQueryGrouping.json +func ExampleQueryClient_Usage_billingProfileQueryGroupingMca() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -821,23 +931,24 @@ func ExampleQueryClient_Usage_departmentQueryGroupingLegacy() { 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), + 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), + Name: to.Ptr("PreTaxCost"), + Function: to.Ptr(armcostmanagement.FunctionTypeSum), }, }, - Granularity: to.Ptr(armcostmanagement.GranularityType("None")), + Granularity: to.Ptr(armcostmanagement.GranularityType("None")), Grouping: []*armcostmanagement.QueryGrouping{ { - Name: to.Ptr("ResourceGroup"), - Type: to.Ptr(armcostmanagement.QueryColumnTypeDimension), - }}, + Name: to.Ptr("ResourceGroup"), + Type: to.Ptr(armcostmanagement.QueryColumnTypeDimension), + }, + }, }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheLastMonth), + Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheLastMonth), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) @@ -845,43 +956,51 @@ func ExampleQueryClient_Usage_departmentQueryGroupingLegacy() { // 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"), + // res = armcostmanagement.QueryClientUsageResponse{ + // 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"), + // }, // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // "USD"}, - // []any{ - // float64(173.41979241290323), + // NextLink: to.Ptr("https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D"), + // Rows: [][]any{ + // []any{ + // 19.545363672276512, + // "JapanUnifia-Trial", + // "USD", + // }, + // []any{ + // 173.41979241290323, // "RVIIOT-TRIAL", - // "USD"}, - // []any{ - // float64(20.35941656262545), - // "VSTSHOL-1595322048000", - // "USD"}}, - // }, - // } + // "USD", + // }, + // []any{ + // 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() { +// Generated from example definition: 2025-03-01/MCACustomerQuery.json +func ExampleQueryClient_Usage_customerQueryMca() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -891,8 +1010,8 @@ func ExampleQueryClient_Usage_enrollmentAccountQueryLegacy() { 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), + 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{ @@ -900,35 +1019,40 @@ func ExampleQueryClient_Usage_enrollmentAccountQueryLegacy() { Or: []*armcostmanagement.QueryFilter{ { Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), + Name: to.Ptr("ResourceLocation"), + Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), Values: []*string{ to.Ptr("East US"), - to.Ptr("West Europe")}, + to.Ptr("West Europe"), + }, }, }, { Tags: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), + Name: to.Ptr("Environment"), + Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), Values: []*string{ to.Ptr("UAT"), - to.Ptr("Prod")}, + to.Ptr("Prod"), + }, }, - }}, + }, + }, }, { Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), + Name: to.Ptr("ResourceGroup"), + Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), Values: []*string{ - to.Ptr("API")}, + to.Ptr("API"), + }, }, - }}, + }, + }, }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), + Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) @@ -936,55 +1060,64 @@ func ExampleQueryClient_Usage_enrollmentAccountQueryLegacy() { // 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"), + // res = armcostmanagement.QueryClientUsageResponse{ + // 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"), + // }, // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // float64(20180331), - // "USD"}, - // []any{ - // float64(173.41979241290323), + // NextLink: to.Ptr("https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D"), + // Rows: [][]any{ + // []any{ + // 19.545363672276512, + // "JapanUnifia-Trial", + // 20180331, + // "USD", + // }, + // []any{ + // 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"}}, - // }, - // } + // 20180331, + // "USD", + // }, + // []any{ + // 20.35941656262545, + // "VSTSHOL-1595322048000", + // 20180331, + // "USD", + // }, + // []any{ + // 0.16677720329728665, + // "gs-stms-dev", + // 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() { +// Generated from example definition: 2025-03-01/MCACustomerQueryGrouping.json +func ExampleQueryClient_Usage_customerQueryGroupingMca() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -994,23 +1127,24 @@ func ExampleQueryClient_Usage_enrollmentAccountQueryGroupingLegacy() { 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), + 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), + Name: to.Ptr("PreTaxCost"), + Function: to.Ptr(armcostmanagement.FunctionTypeSum), }, }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + Granularity: to.Ptr(armcostmanagement.GranularityType("None")), Grouping: []*armcostmanagement.QueryGrouping{ { - Name: to.Ptr("ResourceGroup"), - Type: to.Ptr(armcostmanagement.QueryColumnTypeDimension), - }}, + Name: to.Ptr("ResourceGroup"), + Type: to.Ptr(armcostmanagement.QueryColumnTypeDimension), + }, + }, }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheLastMonth), + Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheLastMonth), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) @@ -1018,49 +1152,50 @@ func ExampleQueryClient_Usage_enrollmentAccountQueryGroupingLegacy() { // 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"), + // res = armcostmanagement.QueryClientUsageResponse{ + // 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"), + // }, // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // float64(20180331), - // "USD"}, - // []any{ - // float64(173.41979241290323), + // NextLink: to.Ptr("https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D"), + // Rows: [][]any{ + // []any{ + // 19.545363672276512, + // "JapanUnifia-Trial", + // "USD", + // }, + // []any{ + // 173.41979241290323, // "RVIIOT-TRIAL", - // float64(20180331), - // "USD"}, - // []any{ - // float64(20.35941656262545), - // "VSTSHOL-1595322048000", - // float64(20180331), - // "USD"}}, - // }, - // } + // "USD", + // }, + // []any{ + // 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/MCAInvoiceSectionQuery.json +// Generated from example definition: 2025-03-01/MCAInvoiceSectionQuery.json func ExampleQueryClient_Usage_invoiceSectionQueryMca() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -1072,7 +1207,7 @@ func ExampleQueryClient_Usage_invoiceSectionQueryMca() { 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), + Type: to.Ptr(armcostmanagement.ExportTypeUsage), Dataset: &armcostmanagement.QueryDataset{ Filter: &armcostmanagement.QueryFilter{ And: []*armcostmanagement.QueryFilter{ @@ -1080,35 +1215,40 @@ func ExampleQueryClient_Usage_invoiceSectionQueryMca() { Or: []*armcostmanagement.QueryFilter{ { Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), + Name: to.Ptr("ResourceLocation"), + Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), Values: []*string{ to.Ptr("East US"), - to.Ptr("West Europe")}, + to.Ptr("West Europe"), + }, }, }, { Tags: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), + Name: to.Ptr("Environment"), + Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), Values: []*string{ to.Ptr("UAT"), - to.Ptr("Prod")}, + to.Ptr("Prod"), + }, }, - }}, + }, + }, }, { Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), + Name: to.Ptr("ResourceGroup"), + Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), Values: []*string{ - to.Ptr("API")}, + to.Ptr("API"), + }, }, - }}, + }, + }, }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), + Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) @@ -1116,54 +1256,63 @@ func ExampleQueryClient_Usage_invoiceSectionQueryMca() { // 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"), + // res = armcostmanagement.QueryClientUsageResponse{ + // 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"), + // }, // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // float64(20180331), - // "USD"}, - // []any{ - // float64(173.41979241290323), + // NextLink: to.Ptr("https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D"), + // Rows: [][]any{ + // []any{ + // 19.545363672276512, + // "JapanUnifia-Trial", + // 20180331, + // "USD", + // }, + // []any{ + // 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"}}, - // }, - // } + // 20180331, + // "USD", + // }, + // []any{ + // 20.35941656262545, + // "VSTSHOL-1595322048000", + // 20180331, + // "USD", + // }, + // []any{ + // 0.16677720329728665, + // "gs-stms-dev", + // 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 +// Generated from example definition: 2025-03-01/MCAInvoiceSectionQueryGrouping.json func ExampleQueryClient_Usage_invoiceSectionQueryGroupingMca() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -1175,22 +1324,23 @@ func ExampleQueryClient_Usage_invoiceSectionQueryGroupingMca() { 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), + Type: to.Ptr(armcostmanagement.ExportTypeUsage), Dataset: &armcostmanagement.QueryDataset{ Aggregation: map[string]*armcostmanagement.QueryAggregation{ "totalCost": { - Name: to.Ptr("PreTaxCost"), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), + Name: to.Ptr("PreTaxCost"), + Function: to.Ptr(armcostmanagement.FunctionTypeSum), }, }, - Granularity: to.Ptr(armcostmanagement.GranularityType("None")), + Granularity: to.Ptr(armcostmanagement.GranularityType("None")), Grouping: []*armcostmanagement.QueryGrouping{ { - Name: to.Ptr("ResourceGroup"), - Type: to.Ptr(armcostmanagement.QueryColumnTypeDimension), - }}, + Name: to.Ptr("ResourceGroup"), + Type: to.Ptr(armcostmanagement.QueryColumnTypeDimension), + }, + }, }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheLastMonth), + Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheLastMonth), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) @@ -1198,42 +1348,50 @@ func ExampleQueryClient_Usage_invoiceSectionQueryGroupingMca() { // 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"), + // res = armcostmanagement.QueryClientUsageResponse{ + // 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"), + // }, // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // "USD"}, - // []any{ - // float64(173.41979241290323), + // NextLink: to.Ptr("https://management.azure.com/providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D"), + // Rows: [][]any{ + // []any{ + // 19.545363672276512, + // "JapanUnifia-Trial", + // "USD", + // }, + // []any{ + // 173.41979241290323, // "RVIIOT-TRIAL", - // "USD"}, - // []any{ - // float64(20.35941656262545), - // "VSTSHOL-1595322048000", - // "USD"}}, - // }, - // } + // "USD", + // }, + // []any{ + // 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 +// Generated from example definition: 2025-03-01/ManagementGroupQuery.json func ExampleQueryClient_Usage_managementGroupQueryLegacy() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -1245,7 +1403,7 @@ func ExampleQueryClient_Usage_managementGroupQueryLegacy() { 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), + Type: to.Ptr(armcostmanagement.ExportTypeUsage), Dataset: &armcostmanagement.QueryDataset{ Filter: &armcostmanagement.QueryFilter{ And: []*armcostmanagement.QueryFilter{ @@ -1253,35 +1411,40 @@ func ExampleQueryClient_Usage_managementGroupQueryLegacy() { Or: []*armcostmanagement.QueryFilter{ { Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), + Name: to.Ptr("ResourceLocation"), + Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), Values: []*string{ to.Ptr("East US"), - to.Ptr("West Europe")}, + to.Ptr("West Europe"), + }, }, }, { Tags: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), + Name: to.Ptr("Environment"), + Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), Values: []*string{ to.Ptr("UAT"), - to.Ptr("Prod")}, + to.Ptr("Prod"), + }, }, - }}, + }, + }, }, { Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), + Name: to.Ptr("ResourceGroup"), + Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), Values: []*string{ - to.Ptr("API")}, + to.Ptr("API"), + }, }, - }}, + }, + }, }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), + Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) @@ -1289,54 +1452,63 @@ func ExampleQueryClient_Usage_managementGroupQueryLegacy() { // 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"), + // res = armcostmanagement.QueryClientUsageResponse{ + // 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"), + // }, // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // float64(20180331), - // "USD"}, - // []any{ - // float64(173.41979241290323), + // NextLink: to.Ptr("https://management.azure.com/providers/Microsoft.Management/managementGroups/MyMgId/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D"), + // Rows: [][]any{ + // []any{ + // 19.545363672276512, + // "JapanUnifia-Trial", + // 20180331, + // "USD", + // }, + // []any{ + // 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"}}, - // }, - // } + // 20180331, + // "USD", + // }, + // []any{ + // 20.35941656262545, + // "VSTSHOL-1595322048000", + // 20180331, + // "USD", + // }, + // []any{ + // 0.16677720329728665, + // "gs-stms-dev", + // 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 +// Generated from example definition: 2025-03-01/ManagementGroupQueryGrouping.json func ExampleQueryClient_Usage_managementGroupQueryGroupingLegacy() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -1348,22 +1520,23 @@ func ExampleQueryClient_Usage_managementGroupQueryGroupingLegacy() { 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), + Type: to.Ptr(armcostmanagement.ExportTypeUsage), Dataset: &armcostmanagement.QueryDataset{ Aggregation: map[string]*armcostmanagement.QueryAggregation{ "totalCost": { - Name: to.Ptr("PreTaxCost"), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), + Name: to.Ptr("PreTaxCost"), + Function: to.Ptr(armcostmanagement.FunctionTypeSum), }, }, - Granularity: to.Ptr(armcostmanagement.GranularityType("None")), + Granularity: to.Ptr(armcostmanagement.GranularityType("None")), Grouping: []*armcostmanagement.QueryGrouping{ { - Name: to.Ptr("ResourceGroup"), - Type: to.Ptr(armcostmanagement.QueryColumnTypeDimension), - }}, + Name: to.Ptr("ResourceGroup"), + Type: to.Ptr(armcostmanagement.QueryColumnTypeDimension), + }, + }, }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheLastMonth), + Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheLastMonth), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) @@ -1371,49 +1544,57 @@ func ExampleQueryClient_Usage_managementGroupQueryGroupingLegacy() { // 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"), + // res = armcostmanagement.QueryClientUsageResponse{ + // 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"), + // }, // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(20.35941656262545), - // "VSTSHOL-1595322048000", - // float64(20180331), - // "USD"}, - // []any{ - // float64(173.41979241290323), + // NextLink: to.Ptr("https://management.azure.com/providers/Microsoft.Management/managementGroups/MyMgId/providers/Microsoft.CostManagement/Query?api-version=2021-10-01&$skiptoken=AQAAAA%3D%3D"), + // Rows: [][]any{ + // []any{ + // 20.35941656262545, + // "VSTSHOL-1595322048000", + // 20180331, + // "USD", + // }, + // []any{ + // 173.41979241290323, // "RVIIOT-TRIAL", - // float64(20180331), - // "USD"}, - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // float64(20180331), - // "USD"}}, - // }, - // } + // 20180331, + // "USD", + // }, + // []any{ + // 19.545363672276512, + // "JapanUnifia-Trial", + // 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 +// Generated from example definition: 2025-03-01/ResourceGroupQuery.json func ExampleQueryClient_Usage_resourceGroupQueryLegacy() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -1425,7 +1606,7 @@ func ExampleQueryClient_Usage_resourceGroupQueryLegacy() { 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), + Type: to.Ptr(armcostmanagement.ExportTypeUsage), Dataset: &armcostmanagement.QueryDataset{ Filter: &armcostmanagement.QueryFilter{ And: []*armcostmanagement.QueryFilter{ @@ -1433,35 +1614,40 @@ func ExampleQueryClient_Usage_resourceGroupQueryLegacy() { Or: []*armcostmanagement.QueryFilter{ { Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), + Name: to.Ptr("ResourceLocation"), + Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), Values: []*string{ to.Ptr("East US"), - to.Ptr("West Europe")}, + to.Ptr("West Europe"), + }, }, }, { Tags: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), + Name: to.Ptr("Environment"), + Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), Values: []*string{ to.Ptr("UAT"), - to.Ptr("Prod")}, + to.Ptr("Prod"), + }, }, - }}, + }, + }, }, { Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), + Name: to.Ptr("ResourceGroup"), + Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), Values: []*string{ - to.Ptr("API")}, + to.Ptr("API"), + }, }, - }}, + }, + }, }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), + Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) @@ -1469,44 +1655,50 @@ func ExampleQueryClient_Usage_resourceGroupQueryLegacy() { // 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"), + // res = armcostmanagement.QueryClientUsageResponse{ + // 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"), + // }, // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(2.10333307059661), - // "ScreenSharingTest-peer", - // float64(20180417), - // "USD"}, - // []any{ - // float64(20.10333307059661), + // Rows: [][]any{ + // []any{ + // 2.10333307059661, + // "ScreenSharingTest-peer", + // 20180417, + // "USD", + // }, + // []any{ + // 20.10333307059661, // "ScreenSharingTest-peer", - // float64(20180418), - // "USD"}}, + // 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 +// Generated from example definition: 2025-03-01/ResourceGroupQueryGrouping.json func ExampleQueryClient_Usage_resourceGroupQueryGroupingLegacy() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -1518,22 +1710,23 @@ func ExampleQueryClient_Usage_resourceGroupQueryGroupingLegacy() { 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), + Type: to.Ptr(armcostmanagement.ExportTypeUsage), Dataset: &armcostmanagement.QueryDataset{ Aggregation: map[string]*armcostmanagement.QueryAggregation{ "totalCost": { - Name: to.Ptr("PreTaxCost"), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), + Name: to.Ptr("PreTaxCost"), + Function: to.Ptr(armcostmanagement.FunctionTypeSum), }, }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), Grouping: []*armcostmanagement.QueryGrouping{ { - Name: to.Ptr("ResourceType"), - Type: to.Ptr(armcostmanagement.QueryColumnTypeDimension), - }}, + Name: to.Ptr("ResourceType"), + Type: to.Ptr(armcostmanagement.QueryColumnTypeDimension), + }, + }, }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheLastMonth), + Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheLastMonth), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) @@ -1541,44 +1734,50 @@ func ExampleQueryClient_Usage_resourceGroupQueryGroupingLegacy() { // 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"), + // res = armcostmanagement.QueryClientUsageResponse{ + // 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"), + // }, // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(2.10333307059661), - // "Microsoft.SqlServer", - // float64(20180417), - // "USD"}, - // []any{ - // float64(20.10333307059661), + // Rows: [][]any{ + // []any{ + // 2.10333307059661, + // "Microsoft.SqlServer", + // 20180417, + // "USD", + // }, + // []any{ + // 20.10333307059661, // "Microsoft.Compute", - // float64(20180418), - // "USD"}}, + // 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 +// Generated from example definition: 2025-03-01/SubscriptionQuery.json func ExampleQueryClient_Usage_subscriptionQueryLegacy() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -1590,7 +1789,7 @@ func ExampleQueryClient_Usage_subscriptionQueryLegacy() { 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), + Type: to.Ptr(armcostmanagement.ExportTypeUsage), Dataset: &armcostmanagement.QueryDataset{ Filter: &armcostmanagement.QueryFilter{ And: []*armcostmanagement.QueryFilter{ @@ -1598,35 +1797,40 @@ func ExampleQueryClient_Usage_subscriptionQueryLegacy() { Or: []*armcostmanagement.QueryFilter{ { Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), + Name: to.Ptr("ResourceLocation"), + Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), Values: []*string{ to.Ptr("East US"), - to.Ptr("West Europe")}, + to.Ptr("West Europe"), + }, }, }, { Tags: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), + Name: to.Ptr("Environment"), + Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), Values: []*string{ to.Ptr("UAT"), - to.Ptr("Prod")}, + to.Ptr("Prod"), + }, }, - }}, + }, + }, }, { Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), + Name: to.Ptr("ResourceGroup"), + Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), Values: []*string{ - to.Ptr("API")}, + to.Ptr("API"), + }, }, - }}, + }, + }, }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), + Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) @@ -1634,54 +1838,62 @@ func ExampleQueryClient_Usage_subscriptionQueryLegacy() { // 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"), + // res = armcostmanagement.QueryClientUsageResponse{ + // 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"), + // }, // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(2.10333307059661), - // "ScreenSharingTest-peer", - // float64(20180331), - // "USD"}, - // []any{ - // float64(218.68795741935486), + // Rows: [][]any{ + // []any{ + // 2.10333307059661, + // "ScreenSharingTest-peer", + // 20180331, + // "USD", + // }, + // []any{ + // 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"}}, - // }, - // } + // 20180331, + // "USD", + // }, + // []any{ + // 0.14384913581657052, + // "ssbciotelement01", + // 20180401, + // "USD", + // }, + // []any{ + // 0.009865586851323632, + // "ict_stratandplan_goldsprova_prod", + // 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 +// Generated from example definition: 2025-03-01/SubscriptionQueryGrouping.json func ExampleQueryClient_Usage_subscriptionQueryGroupingLegacy() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -1693,22 +1905,23 @@ func ExampleQueryClient_Usage_subscriptionQueryGroupingLegacy() { 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), + Type: to.Ptr(armcostmanagement.ExportTypeUsage), Dataset: &armcostmanagement.QueryDataset{ Aggregation: map[string]*armcostmanagement.QueryAggregation{ "totalCost": { - Name: to.Ptr("PreTaxCost"), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), + Name: to.Ptr("PreTaxCost"), + Function: to.Ptr(armcostmanagement.FunctionTypeSum), }, }, - Granularity: to.Ptr(armcostmanagement.GranularityType("None")), + Granularity: to.Ptr(armcostmanagement.GranularityType("None")), Grouping: []*armcostmanagement.QueryGrouping{ { - Name: to.Ptr("ResourceGroup"), - Type: to.Ptr(armcostmanagement.QueryColumnTypeDimension), - }}, + Name: to.Ptr("ResourceGroup"), + Type: to.Ptr(armcostmanagement.QueryColumnTypeDimension), + }, + }, }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheLastMonth), + Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheLastMonth), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) @@ -1716,46 +1929,54 @@ func ExampleQueryClient_Usage_subscriptionQueryGroupingLegacy() { // 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"), + // res = armcostmanagement.QueryClientUsageResponse{ + // 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"), + // }, // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(0.009865586851323632), - // "Ict_StratAndPlan_GoldSprova_Prod_0", - // "USD"}, - // []any{ - // float64(218.68795741935486), + // Rows: [][]any{ + // []any{ + // 0.009865586851323632, + // "Ict_StratAndPlan_GoldSprova_Prod_0", + // "USD", + // }, + // []any{ + // 218.68795741935486, // "Ict_StratAndPlan_GoldSprova_Prod_1", - // "USD"}, - // []any{ - // float64(2.10333307059661), - // "ScreenSharingTest-peer1", - // "USD"}, - // []any{ - // float64(0.14384913581657052), - // "Ssbciotelement01", - // "USD"}}, - // }, - // } + // "USD", + // }, + // []any{ + // 2.10333307059661, + // "ScreenSharingTest-peer1", + // "USD", + // }, + // []any{ + // 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 +// Generated from example definition: 2025-03-01/ExternalBillingAccountsQuery.json func ExampleQueryClient_UsageByExternalCloudProviderType_externalBillingAccountQueryList() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -1767,7 +1988,7 @@ func ExampleQueryClient_UsageByExternalCloudProviderType_externalBillingAccountQ log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewQueryClient().UsageByExternalCloudProviderType(ctx, armcostmanagement.ExternalCloudProviderTypeExternalBillingAccounts, "100", armcostmanagement.QueryDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeUsage), + Type: to.Ptr(armcostmanagement.ExportTypeUsage), Dataset: &armcostmanagement.QueryDataset{ Filter: &armcostmanagement.QueryFilter{ And: []*armcostmanagement.QueryFilter{ @@ -1775,35 +1996,40 @@ func ExampleQueryClient_UsageByExternalCloudProviderType_externalBillingAccountQ Or: []*armcostmanagement.QueryFilter{ { Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), + Name: to.Ptr("ResourceLocation"), + Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), Values: []*string{ to.Ptr("East US"), - to.Ptr("West Europe")}, + to.Ptr("West Europe"), + }, }, }, { Tags: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), + Name: to.Ptr("Environment"), + Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), Values: []*string{ to.Ptr("UAT"), - to.Ptr("Prod")}, + to.Ptr("Prod"), + }, }, - }}, + }, + }, }, { Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), + Name: to.Ptr("ResourceGroup"), + Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), Values: []*string{ - to.Ptr("API")}, + to.Ptr("API"), + }, }, - }}, + }, + }, }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), + Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) @@ -1811,46 +2037,54 @@ func ExampleQueryClient_UsageByExternalCloudProviderType_externalBillingAccountQ // 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"), + // res = armcostmanagement.QueryClientUsageByExternalCloudProviderTypeResponse{ + // 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"), + // }, // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(0), - // "abc db", - // "USD"}, - // []any{ - // float64(30.2572751438), + // Rows: [][]any{ + // []any{ + // 0, + // "abc db", + // "USD", + // }, + // []any{ + // 30.2572751438, // "abc compute cloud", - // "USD"}, - // []any{ - // float64(0.07675760200000002), - // "abc file system", - // "USD"}, - // []any{ - // float64(50.43096419040001), - // "abc elasticache", - // "USD"}}, - // }, - // } + // "USD", + // }, + // []any{ + // 0.07675760200000002, + // "abc file system", + // "USD", + // }, + // []any{ + // 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 +// Generated from example definition: 2025-03-01/ExternalSubscriptionsQuery.json func ExampleQueryClient_UsageByExternalCloudProviderType_externalSubscriptionsQuery() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -1862,7 +2096,7 @@ func ExampleQueryClient_UsageByExternalCloudProviderType_externalSubscriptionsQu log.Fatalf("failed to create client: %v", err) } res, err := clientFactory.NewQueryClient().UsageByExternalCloudProviderType(ctx, armcostmanagement.ExternalCloudProviderTypeExternalSubscriptions, "100", armcostmanagement.QueryDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeUsage), + Type: to.Ptr(armcostmanagement.ExportTypeUsage), Dataset: &armcostmanagement.QueryDataset{ Filter: &armcostmanagement.QueryFilter{ And: []*armcostmanagement.QueryFilter{ @@ -1870,35 +2104,40 @@ func ExampleQueryClient_UsageByExternalCloudProviderType_externalSubscriptionsQu Or: []*armcostmanagement.QueryFilter{ { Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), + Name: to.Ptr("ResourceLocation"), + Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), Values: []*string{ to.Ptr("East US"), - to.Ptr("West Europe")}, + to.Ptr("West Europe"), + }, }, }, { Tags: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), + Name: to.Ptr("Environment"), + Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), Values: []*string{ to.Ptr("UAT"), - to.Ptr("Prod")}, + to.Ptr("Prod"), + }, }, - }}, + }, + }, }, { Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), + Name: to.Ptr("ResourceGroup"), + Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), Values: []*string{ - to.Ptr("API")}, + to.Ptr("API"), + }, }, - }}, + }, + }, }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), + Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), + Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) @@ -1906,25 +2145,28 @@ func ExampleQueryClient_UsageByExternalCloudProviderType_externalSubscriptionsQu // 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"), + // res = armcostmanagement.QueryClientUsageByExternalCloudProviderTypeResponse{ + // 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"), + // }, // }, - // { - // Name: to.Ptr("UsageDate"), - // Type: to.Ptr("Number"), + // Rows: [][]any{ // }, - // { - // 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 65% rename from sdk/resourcemanager/costmanagement/armcostmanagement/response_types.go rename to sdk/resourcemanager/costmanagement/armcostmanagement/responses.go index 645c34307fa8..a1c2262a6505 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/response_types.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/responses.go @@ -1,7 +1,6 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armcostmanagement @@ -23,7 +22,7 @@ type AlertsClientListExternalResponse struct { AlertsResult } -// AlertsClientListResponse contains the response from method AlertsClient.List. +// AlertsClientListResponse contains the response from method AlertsClient.NewListPager. type AlertsClientListResponse struct { // Result of alerts. AlertsResult @@ -59,6 +58,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. @@ -99,7 +151,7 @@ type ExportsClientGetResponse struct { Export } -// ExportsClientListResponse contains the response from method ExportsClient.List. +// ExportsClientListResponse contains the response from method ExportsClient.NewListPager. type ExportsClientListResponse struct { // Result of listing exports. It contains a list of available exports in the scope provided. ExportListResult @@ -117,6 +169,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. @@ -133,6 +227,9 @@ type GenerateCostDetailsReportClientGetOperationResultsResponse struct { type GenerateDetailedCostReportClientCreateOperationResponse struct { // The result of the long running operation for cost detailed report. GenerateDetailedCostReportOperationResult + + // The URL to check the status of the asynchronous operation. + AzureConsumptionAsyncOperation *string } // GenerateDetailedCostReportOperationResultsClientGetResponse contains the response from method GenerateDetailedCostReportOperationResultsClient.BeginGet. @@ -165,16 +262,28 @@ type OperationsClientListResponse struct { OperationListResult } +// PriceSheetClientDownloadByBillingAccountResponse contains the response from method PriceSheetClient.BeginDownloadByBillingAccount. +type PriceSheetClientDownloadByBillingAccountResponse struct { + // The status of the long running operation. + OperationStatus +} + // PriceSheetClientDownloadByBillingProfileResponse contains the response from method PriceSheetClient.BeginDownloadByBillingProfile. type PriceSheetClientDownloadByBillingProfileResponse struct { // The URL to download the generated report. - DownloadURL + PricesheetDownloadProperties + + // The operation entity Id GUID. + ODataEntityID *string } -// 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 + + // The operation entity Id GUID. + ODataEntityID *string } // QueryClientUsageByExternalCloudProviderTypeResponse contains the response from method QueryClient.UsageByExternalCloudProviderType. @@ -257,6 +366,29 @@ type ScheduledActionsClientRunResponse struct { // placeholder for future response values } +// SettingsClientCreateOrUpdateByScopeResponse contains the response from method SettingsClient.CreateOrUpdateByScope. +type SettingsClientCreateOrUpdateByScopeResponse struct { + // Setting definition. + SettingClassification +} + +// 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 +} + +// SettingsClientListResponse contains the response from method SettingsClient.NewListPager. +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/responses_serde.go b/sdk/resourcemanager/costmanagement/armcostmanagement/responses_serde.go new file mode 100644 index 000000000000..fe82235b8cda --- /dev/null +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/responses_serde.go @@ -0,0 +1,25 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armcostmanagement + +// 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 +} + +// 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 +} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/scheduledactions_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/scheduledactions_client.go index c55dcd35d2b7..e3cafce397d5 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/scheduledactions_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/scheduledactions_client.go @@ -1,7 +1,6 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armcostmanagement @@ -25,7 +24,7 @@ type ScheduledActionsClient struct { // NewScheduledActionsClient creates a new instance of ScheduledActionsClient with the specified values. // - credential - used to authorize requests. Usually a credential from azidentity. -// - options - pass nil to accept the default values. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewScheduledActionsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*ScheduledActionsClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -40,8 +39,8 @@ 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 -// - checkNameAvailabilityRequest - Scheduled action to be created or updated. +// Generated from API version 2025-03-01 +// - checkNameAvailabilityRequest - The request body // - options - ScheduledActionsClientCheckNameAvailabilityOptions contains the optional parameters for the ScheduledActionsClient.CheckNameAvailability // method. func (client *ScheduledActionsClient) CheckNameAvailability(ctx context.Context, checkNameAvailabilityRequest CheckNameAvailabilityRequest, options *ScheduledActionsClientCheckNameAvailabilityOptions) (ScheduledActionsClientCheckNameAvailabilityResponse, error) { @@ -67,16 +66,17 @@ func (client *ScheduledActionsClient) CheckNameAvailability(ctx context.Context, } // checkNameAvailabilityCreateRequest creates the CheckNameAvailability request. -func (client *ScheduledActionsClient) checkNameAvailabilityCreateRequest(ctx context.Context, checkNameAvailabilityRequest CheckNameAvailabilityRequest, options *ScheduledActionsClientCheckNameAvailabilityOptions) (*policy.Request, error) { +func (client *ScheduledActionsClient) checkNameAvailabilityCreateRequest(ctx context.Context, checkNameAvailabilityRequest CheckNameAvailabilityRequest, _ *ScheduledActionsClientCheckNameAvailabilityOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.CostManagement/checkNameAvailability" 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", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, checkNameAvailabilityRequest); err != nil { return nil, err } @@ -96,21 +96,16 @@ 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 2025-03-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, -// '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, -// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' for InvoiceSection -// scope, -// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for External Billing Account -// scope and -// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for External Subscription scope. -// Note: Insight Alerts are only available on subscription scope. +// 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, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' +// for InvoiceSection scope, 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for +// External Billing Account scope and 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' +// for External Subscription scope. Note: Insight Alerts are only available on subscription scope. // - checkNameAvailabilityRequest - Scheduled action to be created or updated. // - options - ScheduledActionsClientCheckNameAvailabilityByScopeOptions contains the optional parameters for the ScheduledActionsClient.CheckNameAvailabilityByScope // method. @@ -137,7 +132,7 @@ func (client *ScheduledActionsClient) CheckNameAvailabilityByScope(ctx context.C } // checkNameAvailabilityByScopeCreateRequest creates the CheckNameAvailabilityByScope request. -func (client *ScheduledActionsClient) checkNameAvailabilityByScopeCreateRequest(ctx context.Context, scope string, checkNameAvailabilityRequest CheckNameAvailabilityRequest, options *ScheduledActionsClientCheckNameAvailabilityByScopeOptions) (*policy.Request, error) { +func (client *ScheduledActionsClient) checkNameAvailabilityByScopeCreateRequest(ctx context.Context, scope string, checkNameAvailabilityRequest CheckNameAvailabilityRequest, _ *ScheduledActionsClientCheckNameAvailabilityByScopeOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.CostManagement/checkNameAvailability" if scope == "" { return nil, errors.New("parameter scope cannot be empty") @@ -148,9 +143,10 @@ func (client *ScheduledActionsClient) checkNameAvailabilityByScopeCreateRequest( return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, checkNameAvailabilityRequest); err != nil { return nil, err } @@ -169,7 +165,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 2025-03-01 // - name - Scheduled action name. // - scheduledAction - Scheduled action to be created or updated. // - options - ScheduledActionsClientCreateOrUpdateOptions contains the optional parameters for the ScheduledActionsClient.CreateOrUpdate @@ -208,12 +204,13 @@ 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", "2025-03-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"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, scheduledAction); err != nil { return nil, err } @@ -232,21 +229,8 @@ 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 -// - 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, -// '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, -// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' for InvoiceSection -// scope, -// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for External Billing Account -// scope and -// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for External Subscription scope. -// Note: Insight Alerts are only available on subscription scope. +// Generated from API version 2025-03-01 +// - scope - undefined // - name - Scheduled action name. // - scheduledAction - Scheduled action to be created or updated. // - options - ScheduledActionsClientCreateOrUpdateByScopeOptions contains the optional parameters for the ScheduledActionsClient.CreateOrUpdateByScope @@ -289,12 +273,13 @@ 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", "2025-03-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"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, scheduledAction); err != nil { return nil, err } @@ -313,7 +298,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 2025-03-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) { @@ -338,7 +323,7 @@ func (client *ScheduledActionsClient) Delete(ctx context.Context, name string, o } // deleteCreateRequest creates the Delete request. -func (client *ScheduledActionsClient) deleteCreateRequest(ctx context.Context, name string, options *ScheduledActionsClientDeleteOptions) (*policy.Request, error) { +func (client *ScheduledActionsClient) deleteCreateRequest(ctx context.Context, name string, _ *ScheduledActionsClientDeleteOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.CostManagement/scheduledActions/{name}" if name == "" { return nil, errors.New("parameter name cannot be empty") @@ -349,30 +334,16 @@ 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", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } // 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 -// - 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, -// '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, -// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' for InvoiceSection -// scope, -// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for External Billing Account -// scope and -// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for External Subscription scope. -// Note: Insight Alerts are only available on subscription scope. +// Generated from API version 2025-03-01 +// - scope - undefined // - name - Scheduled action name. // - options - ScheduledActionsClientDeleteByScopeOptions contains the optional parameters for the ScheduledActionsClient.DeleteByScope // method. @@ -398,7 +369,7 @@ func (client *ScheduledActionsClient) DeleteByScope(ctx context.Context, scope s } // deleteByScopeCreateRequest creates the DeleteByScope request. -func (client *ScheduledActionsClient) deleteByScopeCreateRequest(ctx context.Context, scope string, name string, options *ScheduledActionsClientDeleteByScopeOptions) (*policy.Request, error) { +func (client *ScheduledActionsClient) deleteByScopeCreateRequest(ctx context.Context, scope string, name string, _ *ScheduledActionsClientDeleteByScopeOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.CostManagement/scheduledActions/{name}" if scope == "" { return nil, errors.New("parameter scope cannot be empty") @@ -413,16 +384,15 @@ 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", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } // 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 2025-03-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) { @@ -448,7 +418,7 @@ func (client *ScheduledActionsClient) Get(ctx context.Context, name string, opti } // getCreateRequest creates the Get request. -func (client *ScheduledActionsClient) getCreateRequest(ctx context.Context, name string, options *ScheduledActionsClientGetOptions) (*policy.Request, error) { +func (client *ScheduledActionsClient) getCreateRequest(ctx context.Context, name string, _ *ScheduledActionsClientGetOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.CostManagement/scheduledActions/{name}" if name == "" { return nil, errors.New("parameter name cannot be empty") @@ -459,7 +429,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", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -477,21 +447,8 @@ 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 -// - 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, -// '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, -// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' for InvoiceSection -// scope, -// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for External Billing Account -// scope and -// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for External Subscription scope. -// Note: Insight Alerts are only available on subscription scope. +// Generated from API version 2025-03-01 +// - scope - undefined // - name - Scheduled action name. // - options - ScheduledActionsClientGetByScopeOptions contains the optional parameters for the ScheduledActionsClient.GetByScope // method. @@ -518,7 +475,7 @@ func (client *ScheduledActionsClient) GetByScope(ctx context.Context, scope stri } // getByScopeCreateRequest creates the GetByScope request. -func (client *ScheduledActionsClient) getByScopeCreateRequest(ctx context.Context, scope string, name string, options *ScheduledActionsClientGetByScopeOptions) (*policy.Request, error) { +func (client *ScheduledActionsClient) getByScopeCreateRequest(ctx context.Context, scope string, name string, _ *ScheduledActionsClientGetByScopeOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.CostManagement/scheduledActions/{name}" if scope == "" { return nil, errors.New("parameter scope cannot be empty") @@ -533,7 +490,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", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -550,7 +507,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 2025-03-01 // - options - ScheduledActionsClientListOptions contains the optional parameters for the ScheduledActionsClient.NewListPager // method. func (client *ScheduledActionsClient) NewListPager(options *ScheduledActionsClientListOptions) *runtime.Pager[ScheduledActionsClientListResponse] { @@ -584,10 +541,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", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -604,21 +561,8 @@ 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 -// - 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, -// '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, -// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' for InvoiceSection -// scope, -// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for External Billing Account -// scope and -// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for External Subscription scope. -// Note: Insight Alerts are only available on subscription scope. +// Generated from API version 2025-03-01 +// - scope - undefined // - options - ScheduledActionsClientListByScopeOptions contains the optional parameters for the ScheduledActionsClient.NewListByScopePager // method. func (client *ScheduledActionsClient) NewListByScopePager(scope string, options *ScheduledActionsClientListByScopeOptions) *runtime.Pager[ScheduledActionsClientListByScopeResponse] { @@ -656,10 +600,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", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -677,7 +621,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 2025-03-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) { @@ -702,7 +646,7 @@ func (client *ScheduledActionsClient) Run(ctx context.Context, name string, opti } // runCreateRequest creates the Run request. -func (client *ScheduledActionsClient) runCreateRequest(ctx context.Context, name string, options *ScheduledActionsClientRunOptions) (*policy.Request, error) { +func (client *ScheduledActionsClient) runCreateRequest(ctx context.Context, name string, _ *ScheduledActionsClientRunOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.CostManagement/scheduledActions/{name}/execute" if name == "" { return nil, errors.New("parameter name cannot be empty") @@ -713,30 +657,16 @@ 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", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } // 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 -// - 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, -// '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, -// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' for InvoiceSection -// scope, -// 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for External Billing Account -// scope and -// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for External Subscription scope. -// Note: Insight Alerts are only available on subscription scope. +// Generated from API version 2025-03-01 +// - scope - undefined // - name - Scheduled action name. // - options - ScheduledActionsClientRunByScopeOptions contains the optional parameters for the ScheduledActionsClient.RunByScope // method. @@ -762,7 +692,7 @@ func (client *ScheduledActionsClient) RunByScope(ctx context.Context, scope stri } // runByScopeCreateRequest creates the RunByScope request. -func (client *ScheduledActionsClient) runByScopeCreateRequest(ctx context.Context, scope string, name string, options *ScheduledActionsClientRunByScopeOptions) (*policy.Request, error) { +func (client *ScheduledActionsClient) runByScopeCreateRequest(ctx context.Context, scope string, name string, _ *ScheduledActionsClientRunByScopeOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.CostManagement/scheduledActions/{name}/execute" if scope == "" { return nil, errors.New("parameter scope cannot be empty") @@ -777,8 +707,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", "2025-03-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 index 7350135511ee..25f83a3e2cf8 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/scheduledactions_client_example_test.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/scheduledactions_client_example_test.go @@ -1,24 +1,20 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. 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" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v3" + "log" + "time" ) -// Generated from 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() { +// Generated from example definition: 2025-03-01/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) @@ -28,195 +24,27 @@ func ExampleScheduledActionsClient_NewListPager_privateScheduledActionsList() { 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) + 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 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"), - // }, - // }}, - // } + 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 = armcostmanagement.ScheduledActionsClientCheckNameAvailabilityResponse{ + // 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/scheduledActions-list-shared.json -func ExampleScheduledActionsClient_NewListByScopePager_scheduledActionsListByScope() { +// Generated from example definition: 2025-03-01/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) @@ -226,96 +54,25 @@ func ExampleScheduledActionsClient_NewListByScopePager_scheduledActionsListBySco 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"), - // }, - // }}, - // } + 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 = armcostmanagement.ScheduledActionsClientCheckNameAvailabilityByScopeResponse{ + // CheckNameAvailabilityResponse: &armcostmanagement.CheckNameAvailabilityResponse{ + // NameAvailable: to.Ptr(true), + // }, + // } } -// Generated from 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() { +// Generated from example definition: 2025-03-01/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) @@ -325,96 +82,90 @@ func ExampleScheduledActionsClient_NewListByScopePager_scheduledActionsListBySco 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"), - // }, - // }}, - // } + 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.1287144Z"); 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.1287144Z"); 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 = armcostmanagement.ScheduledActionsClientCreateOrUpdateResponse{ + // ScheduledAction: &armcostmanagement.ScheduledAction{ + // Name: to.Ptr("monthlyCostByResource"), + // Type: to.Ptr("Microsoft.CostManagement/ScheduledActions"), + // ETag: to.Ptr(azcore.ETag("\"1d4ff9fe66f1d10\"")), + // ID: to.Ptr("/providers/Microsoft.CostManagement/scheduledActions/monthlyCostByResource"), + // Kind: to.Ptr(armcostmanagement.ScheduledActionKindEmail), + // 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.1287144Z"); 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.1287144Z"); 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"), + // }, + // SystemData: &armcostmanagement.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.1287144Z"); 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.1287144Z"); return t}()), + // LastModifiedBy: to.Ptr("testuser"), + // LastModifiedByType: to.Ptr(armcostmanagement.CreatedByTypeUser), + // }, + // }, + // } } -// Generated from 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() { +// Generated from example definition: 2025-03-01/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) @@ -424,81 +175,93 @@ func ExampleScheduledActionsClient_CreateOrUpdate() { 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), + 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"), + 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"), + Subject: to.Ptr("Cost by resource this month"), To: []*string{ to.Ptr("user@gmail.com"), - to.Ptr("team@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 }()), + to.Ptr(armcostmanagement.DaysOfWeekMonday), + }, + EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-19T22:21:51.1287144Z"); 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.1287144Z"); return t }()), WeeksOfMonth: []*armcostmanagement.WeeksOfMonth{ to.Ptr(armcostmanagement.WeeksOfMonthFirst), - to.Ptr(armcostmanagement.WeeksOfMonthThird)}, + to.Ptr(armcostmanagement.WeeksOfMonthThird), + }, }, - Status: to.Ptr(armcostmanagement.ScheduledActionStatusEnabled), - ViewID: to.Ptr("/providers/Microsoft.CostManagement/views/swaggerExample"), + Status: to.Ptr(armcostmanagement.ScheduledActionStatusEnabled), + ViewID: to.Ptr("/providers/Microsoft.CostManagement/views/swaggerExample"), }, - }, &armcostmanagement.ScheduledActionsClientCreateOrUpdateOptions{IfMatch: to.Ptr("")}) + }, &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("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"), + // res = armcostmanagement.ScheduledActionsClientCreateOrUpdateByScopeResponse{ + // ScheduledAction: &armcostmanagement.ScheduledAction{ + // Name: to.Ptr("monthlyCostByResource"), + // Type: to.Ptr("Microsoft.CostManagement/ScheduledActions"), + // ETag: to.Ptr(azcore.ETag("\"1d4ff9fe66f1d10\"")), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/scheduledActions/monthlyCostByResource"), + // 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)}, - // }, - // Scope: to.Ptr(""), - // Status: to.Ptr(armcostmanagement.ScheduledActionStatusEnabled), - // ViewID: to.Ptr("/providers/Microsoft.CostManagement/views/swaggerExample"), + // to.Ptr(armcostmanagement.DaysOfWeekMonday), // }, - // } + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-19T22:21:51.1287144Z"); 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.1287144Z"); 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"), + // }, + // SystemData: &armcostmanagement.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.1287144Z"); 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.1287144Z"); return t}()), + // LastModifiedBy: to.Ptr("testuser"), + // LastModifiedByType: to.Ptr(armcostmanagement.CreatedByTypeUser), + // }, + // }, + // } } -// Generated from 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() { +// Generated from example definition: 2025-03-01/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) @@ -508,54 +271,75 @@ func ExampleScheduledActionsClient_Get() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewScheduledActionsClient().Get(ctx, "monthlyCostByResource", nil) + 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.1287144Z"); return t }()), + Frequency: to.Ptr(armcostmanagement.ScheduleFrequencyDaily), + StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-19T22:21:51.1287144Z"); 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("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")}, + // res = armcostmanagement.ScheduledActionsClientCreateOrUpdateByScopeResponse{ + // ScheduledAction: &armcostmanagement.ScheduledAction{ + // Name: to.Ptr("dailyAnomalyByResource"), + // Type: to.Ptr("Microsoft.CostManagement/ScheduledActions"), + // ETag: to.Ptr(azcore.ETag("\"1d4ff9fe66f1d10\"")), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/scheduledActions/dailyAnomalyByResource"), + // Kind: to.Ptr(armcostmanagement.ScheduledActionKindInsightAlert), + // Properties: &armcostmanagement.ScheduledActionProperties{ + // DisplayName: to.Ptr("Daily anomaly by resource"), + // FileDestination: &armcostmanagement.FileDestination{ + // FileFormats: []*armcostmanagement.FileFormat{ + // }, // }, - // 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"), + // 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.1287144Z"); return t}()), + // Frequency: to.Ptr(armcostmanagement.ScheduleFrequencyDaily), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-19T22:21:51.1287144Z"); return t}()), + // }, + // Scope: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000"), + // Status: to.Ptr(armcostmanagement.ScheduledActionStatusEnabled), + // ViewID: to.Ptr("/providers/Microsoft.CostManagement/views/swaggerExample"), + // }, + // SystemData: &armcostmanagement.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.1287144Z"); 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.1287144Z"); return t}()), + // LastModifiedBy: to.Ptr("testuser"), + // LastModifiedByType: to.Ptr(armcostmanagement.CreatedByTypeUser), + // }, + // }, + // } } -// Generated from 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 +// Generated from example definition: 2025-03-01/scheduledActions/scheduledAction-delete-private.json func ExampleScheduledActionsClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -566,14 +350,19 @@ func ExampleScheduledActionsClient_Delete() { if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = clientFactory.NewScheduledActionsClient().Delete(ctx, "monthlyCostByResource", nil) + res, err := clientFactory.NewScheduledActionsClient().Delete(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 = armcostmanagement.ScheduledActionsClientDeleteResponse{ + // } } -// Generated from 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() { +// Generated from example definition: 2025-03-01/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) @@ -583,71 +372,19 @@ func ExampleScheduledActionsClient_CreateOrUpdateByScope_createOrUpdateInsightAl 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("")}) + res, 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) } // 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"), - // }, - // } + // res = armcostmanagement.ScheduledActionsClientDeleteByScopeResponse{ + // } } -// Generated from 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() { +// Generated from example definition: 2025-03-01/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) @@ -657,82 +394,59 @@ func ExampleScheduledActionsClient_CreateOrUpdateByScope_createOrUpdateScheduled 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("")}) + 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("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")}, + // res = armcostmanagement.ScheduledActionsClientGetResponse{ + // ScheduledAction: &armcostmanagement.ScheduledAction{ + // Name: to.Ptr("monthlyCostByResource"), + // Type: to.Ptr("Microsoft.CostManagement/ScheduledActions"), + // ETag: to.Ptr(azcore.ETag("\"1d4ff9fe66f1d10\"")), + // ID: to.Ptr("/providers/Microsoft.CostManagement/scheduledActions/monthlyCostByResource"), + // 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)}, - // }, - // Scope: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000"), - // Status: to.Ptr(armcostmanagement.ScheduledActionStatusEnabled), - // ViewID: to.Ptr("/providers/Microsoft.CostManagement/views/swaggerExample"), + // to.Ptr(armcostmanagement.DaysOfWeekMonday), // }, - // } + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-19T22:21:51.1287144Z"); 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.1287144Z"); 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"), + // }, + // SystemData: &armcostmanagement.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.1287144Z"); 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.1287144Z"); return t}()), + // LastModifiedBy: to.Ptr("testuser"), + // LastModifiedByType: to.Ptr(armcostmanagement.CreatedByTypeUser), + // }, + // }, + // } } -// Generated from 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 +// Generated from example definition: 2025-03-01/scheduledActions/scheduledAction-get-shared.json func ExampleScheduledActionsClient_GetByScope() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -750,48 +464,53 @@ func ExampleScheduledActionsClient_GetByScope() { // 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")}, + // res = armcostmanagement.ScheduledActionsClientGetByScopeResponse{ + // ScheduledAction: &armcostmanagement.ScheduledAction{ + // Name: to.Ptr("monthlyCostByResource"), + // Type: to.Ptr("Microsoft.CostManagement/ScheduledActions"), + // ETag: to.Ptr(azcore.ETag("\"1d4ff9fe66f1d10\"")), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/scheduledActions/monthlyCostByResource"), + // 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)}, - // }, - // Scope: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000"), - // Status: to.Ptr(armcostmanagement.ScheduledActionStatusEnabled), - // ViewID: to.Ptr("/providers/Microsoft.CostManagement/views/swaggerExample"), + // to.Ptr(armcostmanagement.DaysOfWeekMonday), + // }, + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-19T22:21:51.1287144Z"); 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.1287144Z"); 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"), + // }, + // SystemData: &armcostmanagement.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.1287144Z"); 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.1287144Z"); return t}()), + // LastModifiedBy: to.Ptr("testuser"), + // LastModifiedByType: to.Ptr(armcostmanagement.CreatedByTypeUser), + // }, + // }, + // } } -// Generated from 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() { +// Generated from example definition: 2025-03-01/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) @@ -801,14 +520,103 @@ func ExampleScheduledActionsClient_DeleteByScope() { 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) + pager := clientFactory.NewScheduledActionsClient().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 = armcostmanagement.ScheduledActionsClientListResponse{ + // ScheduledActionListResult: armcostmanagement.ScheduledActionListResult{ + // Value: []*armcostmanagement.ScheduledAction{ + // { + // Name: to.Ptr("monthlyCostByResource"), + // Type: to.Ptr("Microsoft.CostManagement/ScheduledActions"), + // ETag: to.Ptr(azcore.ETag("\"1d4ff9fe66f1d10\"")), + // ID: to.Ptr("/providers/Microsoft.CostManagement/scheduledActions/monthlyCostByResource"), + // 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.1287144Z"); 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.1287144Z"); 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"), + // }, + // SystemData: &armcostmanagement.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.1287144Z"); 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.1287144Z"); return t}()), + // LastModifiedBy: to.Ptr("testuser"), + // LastModifiedByType: to.Ptr(armcostmanagement.CreatedByTypeUser), + // }, + // }, + // { + // Name: to.Ptr("dailyCostByResource"), + // Type: to.Ptr("Microsoft.CostManagement/ScheduledActions"), + // ETag: to.Ptr(azcore.ETag("\"1d4ff9fe66f1d15\"")), + // ID: to.Ptr("/providers/Microsoft.CostManagement/scheduledActions/dailyCostByResource"), + // Kind: to.Ptr(armcostmanagement.ScheduledActionKindEmail), + // 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.1287144Z"); 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.1287144Z"); return t}()), + // }, + // Scope: to.Ptr(""), + // Status: to.Ptr(armcostmanagement.ScheduledActionStatusDisabled), + // ViewID: to.Ptr("/providers/Microsoft.CostManagement/views/swaggerExample"), + // }, + // SystemData: &armcostmanagement.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.1287144Z"); 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.1287144Z"); return t}()), + // LastModifiedBy: to.Ptr("testuser"), + // LastModifiedByType: to.Ptr(armcostmanagement.CreatedByTypeUser), + // }, + // }, + // }, + // }, + // } } } -// Generated from 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() { +// Generated from example definition: 2025-03-01/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) @@ -818,14 +626,104 @@ func ExampleScheduledActionsClient_Run() { 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) + 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 = armcostmanagement.ScheduledActionsClientListResponse{ + // ScheduledActionListResult: armcostmanagement.ScheduledActionListResult{ + // Value: []*armcostmanagement.ScheduledAction{ + // { + // Name: to.Ptr("monthlyCostByResource"), + // Type: to.Ptr("Microsoft.CostManagement/ScheduledActions"), + // ETag: to.Ptr(azcore.ETag("\"1d4ff9fe66f1d10\"")), + // ID: to.Ptr("/providers/Microsoft.CostManagement/scheduledActions/monthlyCostByResource"), + // 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.1287144Z"); 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.1287144Z"); 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"), + // }, + // SystemData: &armcostmanagement.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.1287144Z"); 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.1287144Z"); return t}()), + // LastModifiedBy: to.Ptr("testuser"), + // LastModifiedByType: to.Ptr(armcostmanagement.CreatedByTypeUser), + // }, + // }, + // { + // Name: to.Ptr("dailyCostByResource"), + // Type: to.Ptr("Microsoft.CostManagement/ScheduledActions"), + // ETag: to.Ptr(azcore.ETag("\"1d4ff9fe66f1d15\"")), + // ID: to.Ptr("/providers/Microsoft.CostManagement/scheduledActions/dailyCostByResource"), + // Kind: to.Ptr(armcostmanagement.ScheduledActionKindEmail), + // 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.1287144Z"); 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.1287144Z"); return t}()), + // }, + // Scope: to.Ptr(""), + // Status: to.Ptr(armcostmanagement.ScheduledActionStatusDisabled), + // ViewID: to.Ptr("/providers/Microsoft.CostManagement/views/swaggerExample"), + // }, + // SystemData: &armcostmanagement.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.1287144Z"); 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.1287144Z"); return t}()), + // LastModifiedBy: to.Ptr("testuser"), + // LastModifiedByType: to.Ptr(armcostmanagement.CreatedByTypeUser), + // }, + // }, + // }, + // }, + // } } } -// Generated from 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() { +// Generated from example definition: 2025-03-01/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) @@ -835,14 +733,210 @@ func ExampleScheduledActionsClient_RunByScope() { if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = clientFactory.NewScheduledActionsClient().RunByScope(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", "monthlyCostByResource", nil) + pager := clientFactory.NewScheduledActionsClient().NewListByScopePager("subscriptions/00000000-0000-0000-0000-000000000000", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armcostmanagement.ScheduledActionsClientListByScopeResponse{ + // ScheduledActionListResult: armcostmanagement.ScheduledActionListResult{ + // Value: []*armcostmanagement.ScheduledAction{ + // { + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/scheduledActions/monthlyCostByResource"), + // Name: to.Ptr("monthlyCostByResource"), + // Type: to.Ptr("Microsoft.CostManagement/ScheduledActions"), + // Kind: to.Ptr(armcostmanagement.ScheduledActionKindEmail), + // ETag: to.Ptr(azcore.ETag("\"1d4ff9fe66f1d10\"")), + // SystemData: &armcostmanagement.SystemData{ + // CreatedBy: to.Ptr("testuser"), + // CreatedByType: to.Ptr(armcostmanagement.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.1287144Z"); return t}()), + // LastModifiedBy: to.Ptr("testuser"), + // LastModifiedByType: to.Ptr(armcostmanagement.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.1287144Z"); return t}()), + // }, + // Properties: &armcostmanagement.ScheduledActionProperties{ + // DisplayName: to.Ptr("Monthly Cost By Resource"), + // Scope: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000"), + // Status: to.Ptr(armcostmanagement.ScheduledActionStatusEnabled), + // ViewID: to.Ptr("/providers/Microsoft.CostManagement/views/swaggerExample"), + // Schedule: &armcostmanagement.ScheduleProperties{ + // Frequency: to.Ptr(armcostmanagement.ScheduleFrequencyMonthly), + // WeeksOfMonth: []*armcostmanagement.WeeksOfMonth{ + // to.Ptr(armcostmanagement.WeeksOfMonthFirst), + // to.Ptr(armcostmanagement.WeeksOfMonthThird), + // }, + // DaysOfWeek: []*armcostmanagement.DaysOfWeek{ + // to.Ptr(armcostmanagement.DaysOfWeekMonday), + // }, + // HourOfDay: to.Ptr[int32](10), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-19T22:21:51.1287144Z"); return t}()), + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-19T22:21:51.1287144Z"); return t}()), + // }, + // Notification: &armcostmanagement.NotificationProperties{ + // To: []*string{ + // to.Ptr("user@gmail.com"), + // to.Ptr("team@gmail.com"), + // }, + // Subject: to.Ptr("Cost by resource this month"), + // }, + // }, + // }, + // { + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/scheduledActions/dailyCostByResource"), + // Name: to.Ptr("dailyCostByResource"), + // Type: to.Ptr("Microsoft.CostManagement/ScheduledActions"), + // Kind: to.Ptr(armcostmanagement.ScheduledActionKindEmail), + // ETag: to.Ptr(azcore.ETag("\"1d4ff9fe66f1d15\"")), + // SystemData: &armcostmanagement.SystemData{ + // CreatedBy: to.Ptr("testuser"), + // CreatedByType: to.Ptr(armcostmanagement.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.1287144Z"); return t}()), + // LastModifiedBy: to.Ptr("testuser"), + // LastModifiedByType: to.Ptr(armcostmanagement.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.1287144Z"); return t}()), + // }, + // Properties: &armcostmanagement.ScheduledActionProperties{ + // DisplayName: to.Ptr("Daily Cost By Resource"), + // Scope: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000"), + // Status: to.Ptr(armcostmanagement.ScheduledActionStatusDisabled), + // ViewID: to.Ptr("/providers/Microsoft.CostManagement/views/swaggerExample"), + // Schedule: &armcostmanagement.ScheduleProperties{ + // 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.1287144Z"); return t}()), + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-19T22:21:51.1287144Z"); return t}()), + // }, + // Notification: &armcostmanagement.NotificationProperties{ + // To: []*string{ + // to.Ptr("user@gmail.com"), + // to.Ptr("team@gmail.com"), + // }, + // Subject: to.Ptr("Daily Cost By Resource"), + // }, + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2025-03-01/scheduledActions/scheduledActions-listWithFilter-shared.json +func ExampleScheduledActionsClient_NewListByScopePager_scheduledActionsListByScopeFilterByViewId() { + cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { - log.Fatalf("failed to finish the request: %v", err) + log.Fatalf("failed to obtain 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 = armcostmanagement.ScheduledActionsClientListByScopeResponse{ + // ScheduledActionListResult: armcostmanagement.ScheduledActionListResult{ + // Value: []*armcostmanagement.ScheduledAction{ + // { + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/scheduledActions/monthlyCostByResource"), + // Name: to.Ptr("monthlyCostByResource"), + // Type: to.Ptr("Microsoft.CostManagement/ScheduledActions"), + // Kind: to.Ptr(armcostmanagement.ScheduledActionKindEmail), + // ETag: to.Ptr(azcore.ETag("\"1d4ff9fe66f1d10\"")), + // SystemData: &armcostmanagement.SystemData{ + // CreatedBy: to.Ptr("testuser"), + // CreatedByType: to.Ptr(armcostmanagement.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.1287144Z"); return t}()), + // LastModifiedBy: to.Ptr("testuser"), + // LastModifiedByType: to.Ptr(armcostmanagement.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.1287144Z"); return t}()), + // }, + // Properties: &armcostmanagement.ScheduledActionProperties{ + // DisplayName: to.Ptr("Monthly Cost By Resource"), + // Scope: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000"), + // Status: to.Ptr(armcostmanagement.ScheduledActionStatusEnabled), + // ViewID: to.Ptr("/providers/Microsoft.CostManagement/views/swaggerExample"), + // Schedule: &armcostmanagement.ScheduleProperties{ + // Frequency: to.Ptr(armcostmanagement.ScheduleFrequencyMonthly), + // WeeksOfMonth: []*armcostmanagement.WeeksOfMonth{ + // to.Ptr(armcostmanagement.WeeksOfMonthFirst), + // to.Ptr(armcostmanagement.WeeksOfMonthThird), + // }, + // DaysOfWeek: []*armcostmanagement.DaysOfWeek{ + // to.Ptr(armcostmanagement.DaysOfWeekMonday), + // }, + // HourOfDay: to.Ptr[int32](10), + // StartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-19T22:21:51.1287144Z"); return t}()), + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-19T22:21:51.1287144Z"); return t}()), + // }, + // Notification: &armcostmanagement.NotificationProperties{ + // To: []*string{ + // to.Ptr("user@gmail.com"), + // to.Ptr("team@gmail.com"), + // }, + // Subject: to.Ptr("Cost by resource this month"), + // }, + // }, + // }, + // { + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/scheduledActions/dailyCostByResource"), + // Name: to.Ptr("dailyCostByResource"), + // Type: to.Ptr("Microsoft.CostManagement/ScheduledActions"), + // Kind: to.Ptr(armcostmanagement.ScheduledActionKindEmail), + // ETag: to.Ptr(azcore.ETag("\"1d4ff9fe66f1d15\"")), + // SystemData: &armcostmanagement.SystemData{ + // CreatedBy: to.Ptr("testuser"), + // CreatedByType: to.Ptr(armcostmanagement.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.1287144Z"); return t}()), + // LastModifiedBy: to.Ptr("testuser"), + // LastModifiedByType: to.Ptr(armcostmanagement.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.1287144Z"); return t}()), + // }, + // Properties: &armcostmanagement.ScheduledActionProperties{ + // DisplayName: to.Ptr("Daily Cost By Resource"), + // Scope: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000"), + // Status: to.Ptr(armcostmanagement.ScheduledActionStatusDisabled), + // ViewID: to.Ptr("/providers/Microsoft.CostManagement/views/swaggerExample"), + // Schedule: &armcostmanagement.ScheduleProperties{ + // 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.1287144Z"); return t}()), + // EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-19T22:21:51.1287144Z"); return t}()), + // }, + // Notification: &armcostmanagement.NotificationProperties{ + // To: []*string{ + // to.Ptr("user@gmail.com"), + // to.Ptr("team@gmail.com"), + // }, + // Subject: to.Ptr("Daily Cost By Resource"), + // }, + // }, + // }, + // }, + // }, + // } } } -// Generated from 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() { +// Generated from example definition: 2025-03-01/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) @@ -852,25 +946,19 @@ func ExampleScheduledActionsClient_CheckNameAvailability() { 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) + res, err := clientFactory.NewScheduledActionsClient().Run(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.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), + // res = armcostmanagement.ScheduledActionsClientRunResponse{ // } } -// Generated from 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() { +// Generated from example definition: 2025-03-01/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) @@ -880,17 +968,13 @@ func ExampleScheduledActionsClient_CheckNameAvailabilityByScope() { 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) + res, 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) } // 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), + // res = armcostmanagement.ScheduledActionsClientRunByScopeResponse{ // } } diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/settings_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/settings_client.go new file mode 100644 index 000000000000..0475e55acfa6 --- /dev/null +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/settings_client.go @@ -0,0 +1,268 @@ +// 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) Go Code Generator. DO NOT EDIT. + +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 - Contains optional client configuration. 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 2025-03-01 +// - scope - undefined +// - 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, _ *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", "2025-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []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 2025-03-01 +// - scope - undefined +// - 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, _ *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", "2025-03-01") + req.Raw().URL.RawQuery = reqQP.Encode() + 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 2025-03-01 +// - scope - undefined +// - 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, _ *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", "2025-03-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 +} + +// NewListPager - List all cost management settings in the requested scope. +// +// Generated from API version 2025-03-01 +// - scope - undefined +// - options - SettingsClientListOptions contains the optional parameters for the SettingsClient.NewListPager method. +func (client *SettingsClient) NewListPager(scope string, options *SettingsClientListOptions) *runtime.Pager[SettingsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[SettingsClientListResponse]{ + More: func(page SettingsClientListResponse) bool { + return false + }, + Fetcher: func(ctx context.Context, page *SettingsClientListResponse) (SettingsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "SettingsClient.NewListPager") + req, err := client.listCreateRequest(ctx, scope, options) + if err != nil { + return SettingsClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SettingsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return SettingsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *SettingsClient) listCreateRequest(ctx context.Context, scope string, _ *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", "2025-03-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/settings_client_example_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/settings_client_example_test.go new file mode 100644 index 000000000000..71686ddf9899 --- /dev/null +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/settings_client_example_test.go @@ -0,0 +1,142 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armcostmanagement_test + +import ( + "context" + "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/v3" + "log" +) + +// Generated from example definition: 2025-03-01/settings-createOrUpdate.json +func ExampleSettingsClient_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.NewSettingsClient().CreateOrUpdateByScope(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", armcostmanagement.SettingTypeTaginheritance, &armcostmanagement.TagInheritanceSetting{ + Kind: to.Ptr(armcostmanagement.SettingsKindTaginheritance), + Properties: &armcostmanagement.TagInheritanceProperties{ + PreferContainerTags: to.Ptr(false), + }, + }, 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 = armcostmanagement.SettingsClientCreateOrUpdateByScopeResponse{ + // TagInheritanceSetting: &armcostmanagement.TagInheritanceSetting{ + // Name: to.Ptr("taginheritance"), + // Type: to.Ptr("Microsoft.CostManagement/Settings"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/settings/taginheritance"), + // Kind: to.Ptr(armcostmanagement.SettingsKindTaginheritance), + // Properties: &armcostmanagement.TagInheritanceProperties{ + // PreferContainerTags: to.Ptr(false), + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01/setting-delete.json +func ExampleSettingsClient_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) + } + res, err := clientFactory.NewSettingsClient().DeleteByScope(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", armcostmanagement.SettingTypeTaginheritance, 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 = armcostmanagement.SettingsClientDeleteByScopeResponse{ + // } +} + +// Generated from example definition: 2025-03-01/setting-get.json +func ExampleSettingsClient_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.NewSettingsClient().GetByScope(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", armcostmanagement.SettingTypeTaginheritance, 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 = armcostmanagement.SettingsClientGetByScopeResponse{ + // TagInheritanceSetting: &armcostmanagement.TagInheritanceSetting{ + // Name: to.Ptr("taginheritance"), + // Type: to.Ptr("Microsoft.CostManagement/Settings"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/settings/taginheritance"), + // Kind: to.Ptr(armcostmanagement.SettingsKindTaginheritance), + // Properties: &armcostmanagement.TagInheritanceProperties{ + // PreferContainerTags: to.Ptr(false), + // }, + // }, + // } +} + +// Generated from example definition: 2025-03-01/settingsList.json +func ExampleSettingsClient_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.NewSettingsClient().NewListPager("subscriptions/00000000-0000-0000-0000-000000000000", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armcostmanagement.SettingsClientListResponse{ + // SettingsListResult: armcostmanagement.SettingsListResult{ + // Value: []armcostmanagement.SettingClassification{ + // &armcostmanagement.TagInheritanceSetting{ + // Name: to.Ptr("taginheritance"), + // Type: to.Ptr("Microsoft.CostManagement/Settings"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/settings/taginheritance"), + // Kind: to.Ptr(armcostmanagement.SettingsKindTaginheritance), + // Properties: &armcostmanagement.TagInheritanceProperties{ + // PreferContainerTags: to.Ptr(false), + // }, + // }, + // }, + // }, + // } + } +} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/testdata/_metadata.json b/sdk/resourcemanager/costmanagement/armcostmanagement/testdata/_metadata.json new file mode 100644 index 000000000000..0849e6dffd09 --- /dev/null +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/testdata/_metadata.json @@ -0,0 +1,4 @@ +{ + "apiVersion": "2025-03-01", + "emitterVersion": "0.8.6" +} \ No newline at end of file diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/time_rfc3339.go b/sdk/resourcemanager/costmanagement/armcostmanagement/time_rfc3339.go index 1596c2568987..ace6749f5cd7 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/time_rfc3339.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/time_rfc3339.go @@ -1,7 +1,6 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armcostmanagement @@ -16,12 +15,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 @@ -37,17 +40,36 @@ func (t dateTimeRFC3339) MarshalText() ([]byte, error) { } func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcDateTimeJSON - if tzOffsetRegex.Match(data) { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT } return t.Parse(layout, string(data)) } func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { - layout := utcDateTime - if tzOffsetRegex.Match(data) { + if len(data) == 0 { + return nil + } + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT } return t.Parse(layout, string(data)) } @@ -58,6 +80,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 @@ -71,7 +97,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/tsp-location.yaml b/sdk/resourcemanager/costmanagement/armcostmanagement/tsp-location.yaml new file mode 100644 index 000000000000..b959819b9839 --- /dev/null +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/cost-management/resource-manager/Microsoft.CostManagement/CostManagement +commit: 991d3e1efca511fe7ddea0e039a9014fd7a3fd3a +repo: i-specs +additionalDirectories: diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/version.go b/sdk/resourcemanager/costmanagement/armcostmanagement/version.go new file mode 100644 index 000000000000..2f7bd1c1e79b --- /dev/null +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/version.go @@ -0,0 +1,10 @@ +// 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) Go Code Generator. + +package armcostmanagement + +const ( + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement" + moduleVersion = "v3.0.0" +) diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/views_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/views_client.go index 03ce82b4d075..13b4219c6d07 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/views_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/views_client.go @@ -1,7 +1,6 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armcostmanagement @@ -25,7 +24,7 @@ type ViewsClient struct { // NewViewsClient creates a new instance of ViewsClient with the specified values. // - credential - used to authorize requests. Usually a credential from azidentity. -// - options - pass nil to accept the default values. +// - options - Contains optional client configuration. Pass nil to accept the default values. func NewViewsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*ViewsClient, error) { cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { @@ -38,11 +37,10 @@ func NewViewsClient(credential azcore.TokenCredential, options *arm.ClientOption } // CreateOrUpdate - The operation to create or update a view. Update operation requires latest eTag to be set in the request. -// You may obtain the latest eTag by performing a get operation. Create operation does not -// require eTag. +// You may obtain the latest eTag by performing a get operation. Create operation does not require eTag. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2025-03-01 // - viewName - View name // - parameters - Parameters supplied to the CreateOrUpdate View operation. // - options - ViewsClientCreateOrUpdateOptions contains the optional parameters for the ViewsClient.CreateOrUpdate method. @@ -69,7 +67,7 @@ func (client *ViewsClient) CreateOrUpdate(ctx context.Context, viewName string, } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *ViewsClient) createOrUpdateCreateRequest(ctx context.Context, viewName string, parameters View, options *ViewsClientCreateOrUpdateOptions) (*policy.Request, error) { +func (client *ViewsClient) createOrUpdateCreateRequest(ctx context.Context, viewName string, parameters View, _ *ViewsClientCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.CostManagement/views/{viewName}" if viewName == "" { return nil, errors.New("parameter viewName cannot be empty") @@ -80,9 +78,10 @@ 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", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -99,24 +98,11 @@ func (client *ViewsClient) createOrUpdateHandleResponse(resp *http.Response) (Vi } // CreateOrUpdateByScope - The operation to create or update a view. Update operation requires latest eTag to be set in the -// request. You may obtain the latest eTag by performing a get operation. Create operation does not -// require eTag. +// request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-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}' -// for -// Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' -// for EnrollmentAccount scope, -// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for BillingProfile -// scope, -// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' for InvoiceSection -// scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for -// Management Group scope, 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for External -// Billing Account scope and -// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for External Subscription scope. +// Generated from API version 2025-03-01 +// - scope - undefined // - viewName - View name // - parameters - Parameters supplied to the CreateOrUpdate View operation. // - options - ViewsClientCreateOrUpdateByScopeOptions contains the optional parameters for the ViewsClient.CreateOrUpdateByScope @@ -144,7 +130,7 @@ func (client *ViewsClient) CreateOrUpdateByScope(ctx context.Context, scope stri } // createOrUpdateByScopeCreateRequest creates the CreateOrUpdateByScope request. -func (client *ViewsClient) createOrUpdateByScopeCreateRequest(ctx context.Context, scope string, viewName string, parameters View, options *ViewsClientCreateOrUpdateByScopeOptions) (*policy.Request, error) { +func (client *ViewsClient) createOrUpdateByScopeCreateRequest(ctx context.Context, scope string, viewName string, parameters View, _ *ViewsClientCreateOrUpdateByScopeOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.CostManagement/views/{viewName}" if scope == "" { return nil, errors.New("parameter scope cannot be empty") @@ -159,9 +145,10 @@ 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", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} if err := runtime.MarshalAsJSON(req, parameters); err != nil { return nil, err } @@ -180,7 +167,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 2025-03-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) { @@ -205,7 +192,7 @@ func (client *ViewsClient) Delete(ctx context.Context, viewName string, options } // deleteCreateRequest creates the Delete request. -func (client *ViewsClient) deleteCreateRequest(ctx context.Context, viewName string, options *ViewsClientDeleteOptions) (*policy.Request, error) { +func (client *ViewsClient) deleteCreateRequest(ctx context.Context, viewName string, _ *ViewsClientDeleteOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.CostManagement/views/{viewName}" if viewName == "" { return nil, errors.New("parameter viewName cannot be empty") @@ -216,29 +203,16 @@ 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", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } // DeleteByScope - The operation to delete a view. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-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}' -// for -// Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' -// for EnrollmentAccount scope, -// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for BillingProfile -// scope, -// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' for InvoiceSection -// scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for -// Management Group scope, 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for External -// Billing Account scope and -// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for External Subscription scope. +// Generated from API version 2025-03-01 +// - scope - undefined // - viewName - View name // - options - ViewsClientDeleteByScopeOptions contains the optional parameters for the ViewsClient.DeleteByScope method. func (client *ViewsClient) DeleteByScope(ctx context.Context, scope string, viewName string, options *ViewsClientDeleteByScopeOptions) (ViewsClientDeleteByScopeResponse, error) { @@ -263,7 +237,7 @@ func (client *ViewsClient) DeleteByScope(ctx context.Context, scope string, view } // deleteByScopeCreateRequest creates the DeleteByScope request. -func (client *ViewsClient) deleteByScopeCreateRequest(ctx context.Context, scope string, viewName string, options *ViewsClientDeleteByScopeOptions) (*policy.Request, error) { +func (client *ViewsClient) deleteByScopeCreateRequest(ctx context.Context, scope string, viewName string, _ *ViewsClientDeleteByScopeOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.CostManagement/views/{viewName}" if scope == "" { return nil, errors.New("parameter scope cannot be empty") @@ -278,16 +252,15 @@ 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", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} return req, nil } // 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 2025-03-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) { @@ -313,7 +286,7 @@ func (client *ViewsClient) Get(ctx context.Context, viewName string, options *Vi } // getCreateRequest creates the Get request. -func (client *ViewsClient) getCreateRequest(ctx context.Context, viewName string, options *ViewsClientGetOptions) (*policy.Request, error) { +func (client *ViewsClient) getCreateRequest(ctx context.Context, viewName string, _ *ViewsClientGetOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.CostManagement/views/{viewName}" if viewName == "" { return nil, errors.New("parameter viewName cannot be empty") @@ -324,7 +297,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", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -342,20 +315,8 @@ 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 -// - 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}' -// for -// Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' -// for EnrollmentAccount scope, -// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for BillingProfile -// scope, -// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' for InvoiceSection -// scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for -// Management Group scope, 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for External -// Billing Account scope and -// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for External Subscription scope. +// Generated from API version 2025-03-01 +// - scope - undefined // - viewName - View name // - options - ViewsClientGetByScopeOptions contains the optional parameters for the ViewsClient.GetByScope method. func (client *ViewsClient) GetByScope(ctx context.Context, scope string, viewName string, options *ViewsClientGetByScopeOptions) (ViewsClientGetByScopeResponse, error) { @@ -381,7 +342,7 @@ func (client *ViewsClient) GetByScope(ctx context.Context, scope string, viewNam } // getByScopeCreateRequest creates the GetByScope request. -func (client *ViewsClient) getByScopeCreateRequest(ctx context.Context, scope string, viewName string, options *ViewsClientGetByScopeOptions) (*policy.Request, error) { +func (client *ViewsClient) getByScopeCreateRequest(ctx context.Context, scope string, viewName string, _ *ViewsClientGetByScopeOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.CostManagement/views/{viewName}" if scope == "" { return nil, errors.New("parameter scope cannot be empty") @@ -396,7 +357,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", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -413,7 +374,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 2025-03-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]{ @@ -439,14 +400,14 @@ func (client *ViewsClient) NewListPager(options *ViewsClientListOptions) *runtim } // listCreateRequest creates the List request. -func (client *ViewsClient) listCreateRequest(ctx context.Context, options *ViewsClientListOptions) (*policy.Request, error) { +func (client *ViewsClient) listCreateRequest(ctx context.Context, _ *ViewsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.CostManagement/views" 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", "2022-10-01") + reqQP.Set("api-version", "2025-03-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -463,20 +424,8 @@ func (client *ViewsClient) listHandleResponse(resp *http.Response) (ViewsClientL // NewListByScopePager - Lists all views at the given scope. // -// Generated from API version 2022-10-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}' -// for -// Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' -// for EnrollmentAccount scope, -// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for BillingProfile -// scope, -// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' for InvoiceSection -// scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for -// Management Group scope, 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for External -// Billing Account scope and -// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for External Subscription scope. +// Generated from API version 2025-03-01 +// - scope - undefined // - options - ViewsClientListByScopeOptions contains the optional parameters for the ViewsClient.NewListByScopePager method. func (client *ViewsClient) NewListByScopePager(scope string, options *ViewsClientListByScopeOptions) *runtime.Pager[ViewsClientListByScopeResponse] { return runtime.NewPager(runtime.PagingHandler[ViewsClientListByScopeResponse]{ @@ -502,7 +451,7 @@ func (client *ViewsClient) NewListByScopePager(scope string, options *ViewsClien } // listByScopeCreateRequest creates the ListByScope request. -func (client *ViewsClient) listByScopeCreateRequest(ctx context.Context, scope string, options *ViewsClientListByScopeOptions) (*policy.Request, error) { +func (client *ViewsClient) listByScopeCreateRequest(ctx context.Context, scope string, _ *ViewsClientListByScopeOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.CostManagement/views" if scope == "" { return nil, errors.New("parameter scope cannot be empty") @@ -513,7 +462,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", "2025-03-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 index caadfca92019..97a8efefdaa7 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/views_client_example_test.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/views_client_example_test.go @@ -1,302 +1,20 @@ // 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. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armcostmanagement_test import ( "context" - "log" - + "github.com/Azure/azure-sdk-for-go/sdk/azcore" "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" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v3" + "log" ) -// Generated from 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() { +// Generated from example definition: 2025-03-01/PrivateViewCreateOrUpdate.json +func ExampleViewsClient_CreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -306,73 +24,131 @@ func ExampleViewsClient_Get() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewViewsClient().Get(ctx, "swaggerExample", nil) + res, err := clientFactory.NewViewsClient().CreateOrUpdate(ctx, "swaggerExample", armcostmanagement.View{ + ETag: to.Ptr(azcore.ETag("\"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.KpiTypeTypeForecast), + Enabled: to.Ptr(true), + }, + { + Type: to.Ptr(armcostmanagement.KpiTypeTypeBudget), + 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.PivotTypeTypeDimension), + }, + { + Name: to.Ptr("MeterCategory"), + Type: to.Ptr(armcostmanagement.PivotTypeTypeDimension), + }, + { + Name: to.Ptr("swaggerTagKey"), + Type: to.Ptr(armcostmanagement.PivotTypeTypeTagKey), + }, + }, + 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("\"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), + // res = armcostmanagement.ViewsClientCreateOrUpdateResponse{ + // View: &armcostmanagement.View{ + // Name: to.Ptr("swaggerExample"), + // Type: to.Ptr("Microsoft.CostManagement/Views"), + // ETag: to.Ptr(azcore.ETag("\"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.KpiTypeTypeForecast), + // Enabled: to.Ptr(true), + // }, + // { + // Type: to.Ptr(armcostmanagement.KpiTypeTypeBudget), + // Enabled: to.Ptr(true), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Consumption/budgets/swaggerDemo"), + // }, // }, - // { - // Name: to.Ptr("MeterCategory"), - // Type: to.Ptr(armcostmanagement.PivotTypeDimension), + // Metric: to.Ptr(armcostmanagement.MetricTypeActualCost), + // Pivots: []*armcostmanagement.PivotProperties{ + // { + // Name: to.Ptr("ServiceName"), + // Type: to.Ptr(armcostmanagement.PivotTypeTypeDimension), + // }, + // { + // Name: to.Ptr("MeterCategory"), + // Type: to.Ptr(armcostmanagement.PivotTypeTypeDimension), + // }, + // { + // Name: to.Ptr("swaggerTagKey"), + // Type: to.Ptr(armcostmanagement.PivotTypeTypeTagKey), + // }, // }, - // { - // 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), + // 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), + // }, // }, // }, - // 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), // }, - // Timeframe: to.Ptr(armcostmanagement.ReportTimeframeTypeMonthToDate), + // Scope: to.Ptr(""), // }, - // 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() { +// Generated from example definition: 2025-03-01/ViewCreateOrUpdateByResourceGroup.json +func ExampleViewsClient_CreateOrUpdateByScope() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -382,54 +158,57 @@ func ExampleViewsClient_CreateOrUpdate() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewViewsClient().CreateOrUpdate(ctx, "swaggerExample", armcostmanagement.View{ - ETag: to.Ptr("\"1d4ff9fe66f1d10\""), + res, err := clientFactory.NewViewsClient().CreateOrUpdateByScope(ctx, "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG", "swaggerExample", armcostmanagement.View{ + ETag: to.Ptr(azcore.ETag("\"1d4ff9fe66f1d10\"")), Properties: &armcostmanagement.ViewProperties{ - Accumulated: to.Ptr(armcostmanagement.AccumulatedTypeTrue), - Chart: to.Ptr(armcostmanagement.ChartTypeTable), - DisplayName: to.Ptr("swagger Example"), + 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.KpiTypeTypeForecast), + 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), + Type: to.Ptr(armcostmanagement.KpiTypeTypeBudget), + 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("ServiceName"), + Type: to.Ptr(armcostmanagement.PivotTypeTypeDimension), }, { - Name: to.Ptr("MeterCategory"), - Type: to.Ptr(armcostmanagement.PivotTypeDimension), + Name: to.Ptr("MeterCategory"), + Type: to.Ptr(armcostmanagement.PivotTypeTypeDimension), }, { - Name: to.Ptr("swaggerTagKey"), - Type: to.Ptr(armcostmanagement.PivotTypeTagKey), - }}, + Name: to.Ptr("swaggerTagKey"), + Type: to.Ptr(armcostmanagement.PivotTypeTypeTagKey), + }, + }, Query: &armcostmanagement.ReportConfigDefinition{ - Type: to.Ptr(armcostmanagement.ReportTypeUsage), + Type: to.Ptr(armcostmanagement.ReportTypeUsage), DataSet: &armcostmanagement.ReportConfigDataset{ Aggregation: map[string]*armcostmanagement.ReportConfigAggregation{ "totalCost": { - Name: to.Ptr("PreTaxCost"), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), + Name: to.Ptr("PreTaxCost"), + Function: to.Ptr(armcostmanagement.FunctionTypeSum), }, }, - Granularity: to.Ptr(armcostmanagement.ReportGranularityTypeDaily), - Grouping: []*armcostmanagement.ReportConfigGrouping{}, + Granularity: to.Ptr(armcostmanagement.ReportGranularityTypeDaily), + Grouping: []*armcostmanagement.ReportConfigGrouping{}, Sorting: []*armcostmanagement.ReportConfigSorting{ { - Name: to.Ptr("UsageDate"), - Direction: to.Ptr(armcostmanagement.ReportConfigSortingTypeAscending), - }}, + Name: to.Ptr("UsageDate"), + Direction: to.Ptr(armcostmanagement.ReportConfigSortingTypeAscending), + }, + }, }, - Timeframe: to.Ptr(armcostmanagement.ReportTimeframeTypeMonthToDate), + Timeframe: to.Ptr(armcostmanagement.ReportTimeframeTypeMonthToDate), }, }, }, nil) @@ -439,65 +218,70 @@ func ExampleViewsClient_CreateOrUpdate() { // 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), + // res = armcostmanagement.ViewsClientCreateOrUpdateByScopeResponse{ + // View: &armcostmanagement.View{ + // Name: to.Ptr("swaggerExample"), + // Type: to.Ptr("Microsoft.CostManagement/Views"), + // ETag: to.Ptr(azcore.ETag("\"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.KpiTypeTypeForecast), + // Enabled: to.Ptr(true), + // }, + // { + // Type: to.Ptr(armcostmanagement.KpiTypeTypeBudget), + // Enabled: to.Ptr(true), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Consumption/budgets/swaggerDemo"), + // }, // }, - // { - // Name: to.Ptr("MeterCategory"), - // Type: to.Ptr(armcostmanagement.PivotTypeDimension), + // Metric: to.Ptr(armcostmanagement.MetricTypeActualCost), + // Pivots: []*armcostmanagement.PivotProperties{ + // { + // Name: to.Ptr("ServiceName"), + // Type: to.Ptr(armcostmanagement.PivotTypeTypeDimension), + // }, + // { + // Name: to.Ptr("MeterCategory"), + // Type: to.Ptr(armcostmanagement.PivotTypeTypeDimension), + // }, + // { + // Name: to.Ptr("swaggerTagKey"), + // Type: to.Ptr(armcostmanagement.PivotTypeTypeTagKey), + // }, // }, - // { - // 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), + // 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), + // }, // }, // }, - // 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), // }, - // Timeframe: to.Ptr(armcostmanagement.ReportTimeframeTypeMonthToDate), + // Scope: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG"), // }, - // 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 +// Generated from example definition: 2025-03-01/PrivateViewDelete.json func ExampleViewsClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -508,14 +292,19 @@ func ExampleViewsClient_Delete() { if err != nil { log.Fatalf("failed to create client: %v", err) } - _, err = clientFactory.NewViewsClient().Delete(ctx, "TestView", nil) + res, err := clientFactory.NewViewsClient().Delete(ctx, "TestView", 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 = armcostmanagement.ViewsClientDeleteResponse{ + // } } -// Generated from 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() { +// Generated from example definition: 2025-03-01/ViewDeleteByResourceGroup.json +func ExampleViewsClient_DeleteByScope() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -525,73 +314,100 @@ func ExampleViewsClient_GetByScope() { 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) + res, 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) } // 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), + // res = armcostmanagement.ViewsClientDeleteByScopeResponse{ + // } +} + +// Generated from example definition: 2025-03-01/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 = armcostmanagement.ViewsClientGetResponse{ + // View: &armcostmanagement.View{ + // Name: to.Ptr("swaggerExample"), + // Type: to.Ptr("Microsoft.CostManagement/Views"), + // ETag: to.Ptr(azcore.ETag("\"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.KpiTypeTypeForecast), + // Enabled: to.Ptr(true), + // }, + // { + // Type: to.Ptr(armcostmanagement.KpiTypeTypeBudget), + // Enabled: to.Ptr(true), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Consumption/budgets/swaggerDemo"), + // }, // }, - // { - // Name: to.Ptr("MeterCategory"), - // Type: to.Ptr(armcostmanagement.PivotTypeDimension), + // Metric: to.Ptr(armcostmanagement.MetricTypeActualCost), + // Pivots: []*armcostmanagement.PivotProperties{ + // { + // Name: to.Ptr("ServiceName"), + // Type: to.Ptr(armcostmanagement.PivotTypeTypeDimension), + // }, + // { + // Name: to.Ptr("MeterCategory"), + // Type: to.Ptr(armcostmanagement.PivotTypeTypeDimension), + // }, + // { + // Name: to.Ptr("swaggerTagKey"), + // Type: to.Ptr(armcostmanagement.PivotTypeTypeTagKey), + // }, // }, - // { - // 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), + // 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), + // }, // }, // }, - // 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), // }, - // Timeframe: to.Ptr(armcostmanagement.ReportTimeframeTypeMonthToDate), + // Scope: to.Ptr(""), // }, - // 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() { +// Generated from example definition: 2025-03-01/ViewByResourceGroup.json +func ExampleViewsClient_GetByScope() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -601,123 +417,78 @@ func ExampleViewsClient_CreateOrUpdateByScope() { 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) + 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("\"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), + // res = armcostmanagement.ViewsClientGetByScopeResponse{ + // View: &armcostmanagement.View{ + // Name: to.Ptr("swaggerExample"), + // Type: to.Ptr("Microsoft.CostManagement/Views"), + // ETag: to.Ptr(azcore.ETag("\"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.KpiTypeTypeForecast), + // Enabled: to.Ptr(true), + // }, + // { + // Type: to.Ptr(armcostmanagement.KpiTypeTypeBudget), + // Enabled: to.Ptr(true), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Consumption/budgets/swaggerDemo"), + // }, // }, - // { - // Name: to.Ptr("MeterCategory"), - // Type: to.Ptr(armcostmanagement.PivotTypeDimension), + // Metric: to.Ptr(armcostmanagement.MetricTypeActualCost), + // Pivots: []*armcostmanagement.PivotProperties{ + // { + // Name: to.Ptr("ServiceName"), + // Type: to.Ptr(armcostmanagement.PivotTypeTypeDimension), + // }, + // { + // Name: to.Ptr("MeterCategory"), + // Type: to.Ptr(armcostmanagement.PivotTypeTypeDimension), + // }, + // { + // Name: to.Ptr("swaggerTagKey"), + // Type: to.Ptr(armcostmanagement.PivotTypeTypeTagKey), + // }, // }, - // { - // 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), + // 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), + // }, // }, // }, - // 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), // }, - // Timeframe: to.Ptr(armcostmanagement.ReportTimeframeTypeMonthToDate), + // Scope: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG"), // }, - // 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() { +// Generated from example definition: 2025-03-01/PrivateViewList.json +func ExampleViewsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -727,8 +498,289 @@ func ExampleViewsClient_DeleteByScope() { 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) + 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 = armcostmanagement.ViewsClientListResponse{ + // ViewListResult: armcostmanagement.ViewListResult{ + // Value: []*armcostmanagement.View{ + // { + // Name: to.Ptr("swaggerExample"), + // Type: to.Ptr("Microsoft.CostManagement/Views"), + // ETag: to.Ptr(azcore.ETag("\"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.KpiTypeTypeForecast), + // Enabled: to.Ptr(true), + // }, + // { + // Type: to.Ptr(armcostmanagement.KpiTypeTypeBudget), + // 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.PivotTypeTypeDimension), + // }, + // { + // Name: to.Ptr("MeterCategory"), + // Type: to.Ptr(armcostmanagement.PivotTypeTypeDimension), + // }, + // { + // Name: to.Ptr("swaggerTagKey"), + // Type: to.Ptr(armcostmanagement.PivotTypeTypeTagKey), + // }, + // }, + // 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(azcore.ETag("\"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.KpiTypeTypeForecast), + // Enabled: to.Ptr(true), + // }, + // { + // Type: to.Ptr(armcostmanagement.KpiTypeTypeBudget), + // 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.PivotTypeTypeDimension), + // }, + // { + // Name: to.Ptr("MeterCategory"), + // Type: to.Ptr(armcostmanagement.PivotTypeTypeDimension), + // }, + // { + // Name: to.Ptr("swaggerTagKey"), + // Type: to.Ptr(armcostmanagement.PivotTypeTypeTagKey), + // }, + // }, + // 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: 2025-03-01/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 finish the request: %v", err) + 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 = armcostmanagement.ViewsClientListByScopeResponse{ + // ViewListResult: armcostmanagement.ViewListResult{ + // Value: []*armcostmanagement.View{ + // { + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.CostManagement/views/swaggerExample"), + // Name: to.Ptr("swaggerExample"), + // Type: to.Ptr("Microsoft.CostManagement/Views"), + // ETag: to.Ptr(azcore.ETag("\"1d4ff9fe66f1d10\"")), + // Properties: &armcostmanagement.ViewProperties{ + // DisplayName: to.Ptr("swagger Example"), + // Scope: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG"), + // Query: &armcostmanagement.ReportConfigDefinition{ + // Type: to.Ptr(armcostmanagement.ReportTypeUsage), + // Timeframe: to.Ptr(armcostmanagement.ReportTimeframeTypeMonthToDate), + // DataSet: &armcostmanagement.ReportConfigDataset{ + // Granularity: to.Ptr(armcostmanagement.ReportGranularityTypeDaily), + // Aggregation: map[string]*armcostmanagement.ReportConfigAggregation{ + // "totalCost": &armcostmanagement.ReportConfigAggregation{ + // Name: to.Ptr("PreTaxCost"), + // Function: to.Ptr(armcostmanagement.FunctionTypeSum), + // }, + // }, + // Grouping: []*armcostmanagement.ReportConfigGrouping{ + // }, + // Sorting: []*armcostmanagement.ReportConfigSorting{ + // { + // Direction: to.Ptr(armcostmanagement.ReportConfigSortingTypeAscending), + // Name: to.Ptr("UsageDate"), + // }, + // }, + // }, + // }, + // Chart: to.Ptr(armcostmanagement.ChartTypeTable), + // Accumulated: to.Ptr(armcostmanagement.AccumulatedTypeTrue), + // Metric: to.Ptr(armcostmanagement.MetricTypeActualCost), + // Kpis: []*armcostmanagement.KpiProperties{ + // { + // Type: to.Ptr(armcostmanagement.KpiTypeTypeForecast), + // Enabled: to.Ptr(true), + // }, + // { + // Type: to.Ptr(armcostmanagement.KpiTypeTypeBudget), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Consumption/budgets/swaggerDemo"), + // Enabled: to.Ptr(true), + // }, + // }, + // Pivots: []*armcostmanagement.PivotProperties{ + // { + // Type: to.Ptr(armcostmanagement.PivotTypeTypeDimension), + // Name: to.Ptr("ServiceName"), + // }, + // { + // Type: to.Ptr(armcostmanagement.PivotTypeTypeDimension), + // Name: to.Ptr("MeterCategory"), + // }, + // { + // Type: to.Ptr(armcostmanagement.PivotTypeTypeTagKey), + // Name: to.Ptr("swaggerTagKey"), + // }, + // }, + // }, + // }, + // { + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.CostManagement/views/swaggerExample2"), + // Name: to.Ptr("swaggerExample2"), + // Type: to.Ptr("Microsoft.CostManagement/Views"), + // ETag: to.Ptr(azcore.ETag("\"1d4ffa5a9c2430c\"")), + // Properties: &armcostmanagement.ViewProperties{ + // DisplayName: to.Ptr("swagger Example 2"), + // Scope: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG"), + // Query: &armcostmanagement.ReportConfigDefinition{ + // Type: to.Ptr(armcostmanagement.ReportTypeUsage), + // Timeframe: to.Ptr(armcostmanagement.ReportTimeframeType("LastMonthToDate")), + // DataSet: &armcostmanagement.ReportConfigDataset{ + // Granularity: to.Ptr(armcostmanagement.ReportGranularityTypeDaily), + // Aggregation: map[string]*armcostmanagement.ReportConfigAggregation{ + // "totalCost": &armcostmanagement.ReportConfigAggregation{ + // Name: to.Ptr("PreTaxCost"), + // Function: to.Ptr(armcostmanagement.FunctionTypeSum), + // }, + // }, + // Grouping: []*armcostmanagement.ReportConfigGrouping{ + // }, + // Sorting: []*armcostmanagement.ReportConfigSorting{ + // { + // Direction: to.Ptr(armcostmanagement.ReportConfigSortingTypeAscending), + // Name: to.Ptr("UsageDate"), + // }, + // }, + // }, + // }, + // Chart: to.Ptr(armcostmanagement.ChartTypeGroupedColumn), + // Accumulated: to.Ptr(armcostmanagement.AccumulatedTypeTrue), + // Metric: to.Ptr(armcostmanagement.MetricTypeActualCost), + // Kpis: []*armcostmanagement.KpiProperties{ + // { + // Type: to.Ptr(armcostmanagement.KpiTypeTypeForecast), + // Enabled: to.Ptr(true), + // }, + // { + // Type: to.Ptr(armcostmanagement.KpiTypeTypeBudget), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Consumption/budgets/swaggerDemo"), + // Enabled: to.Ptr(true), + // }, + // }, + // Pivots: []*armcostmanagement.PivotProperties{ + // { + // Type: to.Ptr(armcostmanagement.PivotTypeTypeDimension), + // Name: to.Ptr("ServiceName"), + // }, + // { + // Type: to.Ptr(armcostmanagement.PivotTypeTypeDimension), + // Name: to.Ptr("MeterCategory"), + // }, + // { + // Type: to.Ptr(armcostmanagement.PivotTypeTypeTagKey), + // Name: to.Ptr("swaggerTagKey"), + // }, + // }, + // }, + // }, + // }, + // }, + // } } }