diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/CHANGELOG.md b/sdk/resourcemanager/costmanagement/armcostmanagement/CHANGELOG.md index c2df8a43bf78..9c1f98adc787 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/CHANGELOG.md +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/CHANGELOG.md @@ -1,5 +1,82 @@ # Release History +## 2.1.0 (2023-10-14) +### Features Added + +- New value `OperationStatusTypeComplete` added to enum type `OperationStatusType` +- New enum type `BenefitUtilizationSummaryReportSchema` with values `BenefitUtilizationSummaryReportSchemaAvgUtilizationPercentage`, `BenefitUtilizationSummaryReportSchemaBenefitID`, `BenefitUtilizationSummaryReportSchemaBenefitOrderID`, `BenefitUtilizationSummaryReportSchemaBenefitType`, `BenefitUtilizationSummaryReportSchemaKind`, `BenefitUtilizationSummaryReportSchemaMaxUtilizationPercentage`, `BenefitUtilizationSummaryReportSchemaMinUtilizationPercentage`, `BenefitUtilizationSummaryReportSchemaUsageDate`, `BenefitUtilizationSummaryReportSchemaUtilizedPercentage` +- New enum type `BudgetNotificationOperatorType` with values `BudgetNotificationOperatorTypeEqualTo`, `BudgetNotificationOperatorTypeGreaterThan`, `BudgetNotificationOperatorTypeGreaterThanOrEqualTo`, `BudgetNotificationOperatorTypeLessThan` +- New enum type `BudgetOperatorType` with values `BudgetOperatorTypeIn` +- New enum type `CategoryType` with values `CategoryTypeCost`, `CategoryTypeReservationUtilization` +- New enum type `CostAllocationPolicyType` with values `CostAllocationPolicyTypeFixedProportion` +- New enum type `CostAllocationResourceType` with values `CostAllocationResourceTypeDimension`, `CostAllocationResourceTypeTag` +- New enum type `CultureCode` with values `CultureCodeCsCz`, `CultureCodeDaDk`, `CultureCodeDeDe`, `CultureCodeEnGb`, `CultureCodeEnUs`, `CultureCodeEsEs`, `CultureCodeFrFr`, `CultureCodeHuHu`, `CultureCodeItIt`, `CultureCodeJaJp`, `CultureCodeKoKr`, `CultureCodeNbNo`, `CultureCodeNlNl`, `CultureCodePlPl`, `CultureCodePtBr`, `CultureCodePtPt`, `CultureCodeRuRu`, `CultureCodeSvSe`, `CultureCodeTrTr`, `CultureCodeZhCn`, `CultureCodeZhTw` +- New enum type `Frequency` with values `FrequencyDaily`, `FrequencyMonthly`, `FrequencyWeekly` +- New enum type `Reason` with values `ReasonAlreadyExists`, `ReasonInvalid`, `ReasonValid` +- New enum type `RuleStatus` with values `RuleStatusActive`, `RuleStatusNotActive`, `RuleStatusProcessing` +- New enum type `SettingType` with values `SettingTypeTaginheritance` +- New enum type `SettingsKind` with values `SettingsKindTaginheritance` +- New enum type `SystemAssignedServiceIdentityType` with values `SystemAssignedServiceIdentityTypeNone`, `SystemAssignedServiceIdentityTypeSystemAssigned` +- New enum type `ThresholdType` with values `ThresholdTypeActual`, `ThresholdTypeForecasted` +- New enum type `TimeGrainType` with values `TimeGrainTypeAnnually`, `TimeGrainTypeBillingAnnual`, `TimeGrainTypeBillingMonth`, `TimeGrainTypeBillingQuarter`, `TimeGrainTypeLast30Days`, `TimeGrainTypeLast7Days`, `TimeGrainTypeMonthly`, `TimeGrainTypeQuarterly` +- New function `NewBudgetsClient(azcore.TokenCredential, *arm.ClientOptions) (*BudgetsClient, error)` +- New function `*BudgetsClient.CreateOrUpdate(context.Context, string, string, Budget, *BudgetsClientCreateOrUpdateOptions) (BudgetsClientCreateOrUpdateResponse, error)` +- New function `*BudgetsClient.Delete(context.Context, string, string, *BudgetsClientDeleteOptions) (BudgetsClientDeleteResponse, error)` +- New function `*BudgetsClient.Get(context.Context, string, string, *BudgetsClientGetOptions) (BudgetsClientGetResponse, error)` +- New function `*BudgetsClient.NewListPager(string, *BudgetsClientListOptions) *runtime.Pager[BudgetsClientListResponse]` +- New function `*ClientFactory.NewBudgetsClient() *BudgetsClient` +- New function `*ClientFactory.NewCostAllocationRulesClient() *CostAllocationRulesClient` +- New function `*ClientFactory.NewGenerateBenefitUtilizationSummariesReportClient() *GenerateBenefitUtilizationSummariesReportClient` +- New function `*ClientFactory.NewSettingsClient() *SettingsClient` +- New function `NewCostAllocationRulesClient(azcore.TokenCredential, *arm.ClientOptions) (*CostAllocationRulesClient, error)` +- New function `*CostAllocationRulesClient.CheckNameAvailability(context.Context, string, CostAllocationRuleCheckNameAvailabilityRequest, *CostAllocationRulesClientCheckNameAvailabilityOptions) (CostAllocationRulesClientCheckNameAvailabilityResponse, error)` +- New function `*CostAllocationRulesClient.CreateOrUpdate(context.Context, string, string, CostAllocationRuleDefinition, *CostAllocationRulesClientCreateOrUpdateOptions) (CostAllocationRulesClientCreateOrUpdateResponse, error)` +- New function `*CostAllocationRulesClient.Delete(context.Context, string, string, *CostAllocationRulesClientDeleteOptions) (CostAllocationRulesClientDeleteResponse, error)` +- New function `*CostAllocationRulesClient.Get(context.Context, string, string, *CostAllocationRulesClientGetOptions) (CostAllocationRulesClientGetResponse, error)` +- New function `*CostAllocationRulesClient.NewListPager(string, *CostAllocationRulesClientListOptions) *runtime.Pager[CostAllocationRulesClientListResponse]` +- New function `NewGenerateBenefitUtilizationSummariesReportClient(azcore.TokenCredential, *arm.ClientOptions) (*GenerateBenefitUtilizationSummariesReportClient, error)` +- New function `*GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByBillingAccount(context.Context, string, BenefitUtilizationSummariesRequest, *GenerateBenefitUtilizationSummariesReportClientBeginGenerateByBillingAccountOptions) (*runtime.Poller[GenerateBenefitUtilizationSummariesReportClientGenerateByBillingAccountResponse], error)` +- New function `*GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByBillingProfile(context.Context, string, string, BenefitUtilizationSummariesRequest, *GenerateBenefitUtilizationSummariesReportClientBeginGenerateByBillingProfileOptions) (*runtime.Poller[GenerateBenefitUtilizationSummariesReportClientGenerateByBillingProfileResponse], error)` +- New function `*GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByReservationID(context.Context, string, string, BenefitUtilizationSummariesRequest, *GenerateBenefitUtilizationSummariesReportClientBeginGenerateByReservationIDOptions) (*runtime.Poller[GenerateBenefitUtilizationSummariesReportClientGenerateByReservationIDResponse], error)` +- New function `*GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByReservationOrderID(context.Context, string, BenefitUtilizationSummariesRequest, *GenerateBenefitUtilizationSummariesReportClientBeginGenerateByReservationOrderIDOptions) (*runtime.Poller[GenerateBenefitUtilizationSummariesReportClientGenerateByReservationOrderIDResponse], error)` +- New function `*GenerateBenefitUtilizationSummariesReportClient.BeginGenerateBySavingsPlanID(context.Context, string, string, BenefitUtilizationSummariesRequest, *GenerateBenefitUtilizationSummariesReportClientBeginGenerateBySavingsPlanIDOptions) (*runtime.Poller[GenerateBenefitUtilizationSummariesReportClientGenerateBySavingsPlanIDResponse], error)` +- New function `*GenerateBenefitUtilizationSummariesReportClient.BeginGenerateBySavingsPlanOrderID(context.Context, string, BenefitUtilizationSummariesRequest, *GenerateBenefitUtilizationSummariesReportClientBeginGenerateBySavingsPlanOrderIDOptions) (*runtime.Poller[GenerateBenefitUtilizationSummariesReportClientGenerateBySavingsPlanOrderIDResponse], error)` +- New function `*Setting.GetSetting() *Setting` +- New function `NewSettingsClient(azcore.TokenCredential, *arm.ClientOptions) (*SettingsClient, error)` +- New function `*SettingsClient.CreateOrUpdateByScope(context.Context, string, SettingType, SettingClassification, *SettingsClientCreateOrUpdateByScopeOptions) (SettingsClientCreateOrUpdateByScopeResponse, error)` +- New function `*SettingsClient.DeleteByScope(context.Context, string, SettingType, *SettingsClientDeleteByScopeOptions) (SettingsClientDeleteByScopeResponse, error)` +- New function `*SettingsClient.GetByScope(context.Context, string, SettingType, *SettingsClientGetByScopeOptions) (SettingsClientGetByScopeResponse, error)` +- New function `*SettingsClient.List(context.Context, string, *SettingsClientListOptions) (SettingsClientListResponse, error)` +- New function `*TagInheritanceSetting.GetSetting() *Setting` +- New struct `AsyncOperationStatusProperties` +- New struct `BenefitUtilizationSummariesOperationStatus` +- New struct `BenefitUtilizationSummariesRequest` +- New struct `Budget` +- New struct `BudgetComparisonExpression` +- New struct `BudgetFilter` +- New struct `BudgetFilterProperties` +- New struct `BudgetProperties` +- New struct `BudgetTimePeriod` +- New struct `BudgetsListResult` +- New struct `CostAllocationProportion` +- New struct `CostAllocationRuleCheckNameAvailabilityRequest` +- New struct `CostAllocationRuleCheckNameAvailabilityResponse` +- New struct `CostAllocationRuleDefinition` +- New struct `CostAllocationRuleDetails` +- New struct `CostAllocationRuleList` +- New struct `CostAllocationRuleProperties` +- New struct `CurrentSpend` +- New struct `ForecastSpend` +- New struct `Notification` +- New struct `SettingsListResult` +- New struct `SourceCostAllocationResource` +- New struct `SystemAssignedServiceIdentity` +- New struct `TagInheritanceProperties` +- New struct `TagInheritanceSetting` +- New struct `TargetCostAllocationResource` +- New field `Identity`, `Location` in struct `Export` + + ## 2.0.0 (2023-05-26) ### Breaking Changes diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/alerts_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/alerts_client.go index af5e860b7ef1..a20ca0dc8398 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/alerts_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/alerts_client.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armcostmanagement @@ -44,7 +43,7 @@ func NewAlertsClient(credential azcore.TokenCredential, options *arm.ClientOptio // Dismiss - Dismisses the specified alert // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - scope - The scope associated with alerts operations. This includes '/subscriptions/{subscriptionId}/' for subscription // scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for // resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and @@ -59,18 +58,21 @@ func NewAlertsClient(credential azcore.TokenCredential, options *arm.ClientOptio // - parameters - Parameters supplied to the Dismiss Alert operation. // - options - AlertsClientDismissOptions contains the optional parameters for the AlertsClient.Dismiss method. func (client *AlertsClient) Dismiss(ctx context.Context, scope string, alertID string, parameters DismissAlertPayload, options *AlertsClientDismissOptions) (AlertsClientDismissResponse, error) { + var err error req, err := client.dismissCreateRequest(ctx, scope, alertID, parameters, options) if err != nil { return AlertsClientDismissResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return AlertsClientDismissResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return AlertsClientDismissResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AlertsClientDismissResponse{}, err } - return client.dismissHandleResponse(resp) + resp, err := client.dismissHandleResponse(httpResp) + return resp, err } // dismissCreateRequest creates the Dismiss request. @@ -83,10 +85,13 @@ func (client *AlertsClient) dismissCreateRequest(ctx context.Context, scope stri return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, parameters) + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil } // dismissHandleResponse handles the Dismiss response. @@ -101,7 +106,7 @@ func (client *AlertsClient) dismissHandleResponse(resp *http.Response) (AlertsCl // Get - Gets the alert for the scope by alert ID. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - scope - The scope associated with alerts operations. This includes '/subscriptions/{subscriptionId}/' for subscription // scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for // resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and @@ -115,18 +120,21 @@ func (client *AlertsClient) dismissHandleResponse(resp *http.Response) (AlertsCl // - 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) { + var err error req, err := client.getCreateRequest(ctx, scope, alertID, options) if err != nil { return AlertsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return AlertsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return AlertsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AlertsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -139,7 +147,7 @@ func (client *AlertsClient) getCreateRequest(ctx context.Context, scope string, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -157,7 +165,7 @@ func (client *AlertsClient) getHandleResponse(resp *http.Response) (AlertsClient // List - Lists the alerts for scope defined. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - scope - The scope associated with alerts operations. This includes '/subscriptions/{subscriptionId}/' for subscription // scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for // resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and @@ -170,18 +178,21 @@ func (client *AlertsClient) getHandleResponse(resp *http.Response) (AlertsClient // '/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 req, err := client.listCreateRequest(ctx, scope, options) if err != nil { return AlertsClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return AlertsClientListResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return AlertsClientListResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AlertsClientListResponse{}, err } - return client.listHandleResponse(resp) + resp, err := client.listHandleResponse(httpResp) + return resp, err } // listCreateRequest creates the List request. @@ -193,7 +204,7 @@ func (client *AlertsClient) listCreateRequest(ctx context.Context, scope string, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -211,25 +222,28 @@ func (client *AlertsClient) listHandleResponse(resp *http.Response) (AlertsClien // ListExternal - Lists the Alerts for external cloud provider type defined. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - externalCloudProviderType - The external cloud provider type associated with dimension/query operations. This includes // 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account. // - externalCloudProviderID - This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' for // consolidated account used with dimension/query operations. // - options - AlertsClientListExternalOptions contains the optional parameters for the AlertsClient.ListExternal method. func (client *AlertsClient) ListExternal(ctx context.Context, externalCloudProviderType ExternalCloudProviderType, externalCloudProviderID string, options *AlertsClientListExternalOptions) (AlertsClientListExternalResponse, error) { + var err error req, err := client.listExternalCreateRequest(ctx, externalCloudProviderType, externalCloudProviderID, options) if err != nil { return AlertsClientListExternalResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return AlertsClientListExternalResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return AlertsClientListExternalResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return AlertsClientListExternalResponse{}, err } - return client.listExternalHandleResponse(resp) + resp, err := client.listExternalHandleResponse(httpResp) + return resp, err } // listExternalCreateRequest creates the ListExternal request. @@ -248,7 +262,7 @@ func (client *AlertsClient) listExternalCreateRequest(ctx context.Context, exter return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/alerts_client_example_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/alerts_client_example_test.go deleted file mode 100644 index 4d7c45d49bc1..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/alerts_client_example_test.go +++ /dev/null @@ -1,1282 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armcostmanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BillingAccountAlerts.json -func ExampleAlertsClient_List_billingAccountAlerts() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAlertsClient().List(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.AlertsResult = armcostmanagement.AlertsResult{ - // Value: []*armcostmanagement.Alert{ - // { - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.CostManagement/alerts"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/providers/Microsoft.CostManagement/alerts/00000000-0000-0000-0000-000000000000"), - // Properties: &armcostmanagement.AlertProperties{ - // Description: to.Ptr(""), - // CloseTime: to.Ptr("0001-01-01T00:00:00"), - // CostEntityID: to.Ptr("budget1"), - // CreationTime: to.Ptr("2020-04-27T11:07:52.7143901Z"), - // Definition: &armcostmanagement.AlertPropertiesDefinition{ - // Type: to.Ptr(armcostmanagement.AlertTypeBudget), - // Category: to.Ptr(armcostmanagement.AlertCategoryCost), - // Criteria: to.Ptr(armcostmanagement.AlertCriteriaCostThresholdExceeded), - // }, - // ModificationTime: to.Ptr("2020-04-28T11:06:02.8999373Z"), - // Source: to.Ptr(armcostmanagement.AlertSourcePreset), - // Status: to.Ptr(armcostmanagement.AlertStatusActive), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, - // ContactGroups: []*string{ - // }, - // ContactRoles: []*string{ - // }, - // CurrentSpend: to.Ptr[float64](161000.12), - // MeterFilter: []any{ - // }, - // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), - // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), - // ResourceFilter: []any{ - // }, - // ResourceGroupFilter: []any{ - // }, - // TagFilter: map[string]any{ - // }, - // Threshold: to.Ptr[float64](0.8), - // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), - // TriggeredBy: to.Ptr("00000000-0000-0000-0000-000000000000_1_01"), - // Unit: to.Ptr("USD"), - // }, - // }, - // }, - // { - // Name: to.Ptr("11111111-1111-1111-111111111111"), - // Type: to.Ptr("Microsoft.CostManagement/alerts"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/providers/Microsoft.CostManagement/alerts/11111111-1111-1111-111111111111"), - // Properties: &armcostmanagement.AlertProperties{ - // Description: to.Ptr(""), - // CloseTime: to.Ptr("0001-01-01T00:00:00"), - // CostEntityID: to.Ptr("budget1"), - // CreationTime: to.Ptr("2019-06-24T05:51:52.8713179Z"), - // Definition: &armcostmanagement.AlertPropertiesDefinition{ - // Type: to.Ptr(armcostmanagement.AlertTypeBudget), - // Category: to.Ptr(armcostmanagement.AlertCategoryCost), - // Criteria: to.Ptr(armcostmanagement.AlertCriteriaCostThresholdExceeded), - // }, - // ModificationTime: to.Ptr("2019-08-31T17:51:55.1808807Z"), - // Source: to.Ptr(armcostmanagement.AlertSourcePreset), - // Status: to.Ptr(armcostmanagement.AlertStatusActive), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, - // ContactGroups: []*string{ - // }, - // ContactRoles: []*string{ - // }, - // CurrentSpend: to.Ptr[float64](171000.32), - // MeterFilter: []any{ - // }, - // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), - // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), - // ResourceFilter: []any{ - // }, - // ResourceGroupFilter: []any{ - // }, - // TagFilter: map[string]any{ - // }, - // Threshold: to.Ptr[float64](0.8), - // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), - // TriggeredBy: to.Ptr("11111111-1111-1111-111111111111_1_01"), - // Unit: to.Ptr("USD"), - // }, - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BillingProfileAlerts.json -func ExampleAlertsClient_List_billingProfileAlerts() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAlertsClient().List(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.AlertsResult = armcostmanagement.AlertsResult{ - // Value: []*armcostmanagement.Alert{ - // { - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.CostManagement/alerts"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/providers/Microsoft.CostManagement/alerts/00000000-0000-0000-0000-000000000000"), - // Properties: &armcostmanagement.AlertProperties{ - // Description: to.Ptr(""), - // CloseTime: to.Ptr("0001-01-01T00:00:00"), - // CostEntityID: to.Ptr("budget1"), - // CreationTime: to.Ptr("2020-04-27T11:07:52.7143901Z"), - // Definition: &armcostmanagement.AlertPropertiesDefinition{ - // Type: to.Ptr(armcostmanagement.AlertTypeBudget), - // Category: to.Ptr(armcostmanagement.AlertCategoryCost), - // Criteria: to.Ptr(armcostmanagement.AlertCriteriaCostThresholdExceeded), - // }, - // ModificationTime: to.Ptr("2020-04-28T11:06:02.8999373Z"), - // Source: to.Ptr(armcostmanagement.AlertSourcePreset), - // Status: to.Ptr(armcostmanagement.AlertStatusActive), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, - // ContactGroups: []*string{ - // }, - // ContactRoles: []*string{ - // }, - // CurrentSpend: to.Ptr[float64](161000.12), - // MeterFilter: []any{ - // }, - // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), - // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), - // ResourceFilter: []any{ - // }, - // ResourceGroupFilter: []any{ - // }, - // TagFilter: map[string]any{ - // }, - // Threshold: to.Ptr[float64](0.8), - // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), - // TriggeredBy: to.Ptr("00000000-0000-0000-0000-000000000000_1_01"), - // Unit: to.Ptr("USD"), - // }, - // }, - // }, - // { - // Name: to.Ptr("11111111-1111-1111-111111111111"), - // Type: to.Ptr("Microsoft.CostManagement/alerts"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/providers/Microsoft.CostManagement/alerts/11111111-1111-1111-111111111111"), - // Properties: &armcostmanagement.AlertProperties{ - // Description: to.Ptr(""), - // CloseTime: to.Ptr("0001-01-01T00:00:00"), - // CostEntityID: to.Ptr("budget1"), - // CreationTime: to.Ptr("2019-06-24T05:51:52.8713179Z"), - // Definition: &armcostmanagement.AlertPropertiesDefinition{ - // Type: to.Ptr(armcostmanagement.AlertTypeBudget), - // Category: to.Ptr(armcostmanagement.AlertCategoryCost), - // Criteria: to.Ptr(armcostmanagement.AlertCriteriaCostThresholdExceeded), - // }, - // ModificationTime: to.Ptr("2019-08-31T17:51:55.1808807Z"), - // Source: to.Ptr(armcostmanagement.AlertSourcePreset), - // Status: to.Ptr(armcostmanagement.AlertStatusActive), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, - // ContactGroups: []*string{ - // }, - // ContactRoles: []*string{ - // }, - // CurrentSpend: to.Ptr[float64](171000.32), - // MeterFilter: []any{ - // }, - // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), - // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), - // ResourceFilter: []any{ - // }, - // ResourceGroupFilter: []any{ - // }, - // TagFilter: map[string]any{ - // }, - // Threshold: to.Ptr[float64](0.8), - // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), - // TriggeredBy: to.Ptr("11111111-1111-1111-111111111111_1_01"), - // Unit: to.Ptr("USD"), - // }, - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/DepartmentAlerts.json -func ExampleAlertsClient_List_departmentAlerts() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAlertsClient().List(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789/departments/123", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.AlertsResult = armcostmanagement.AlertsResult{ - // Value: []*armcostmanagement.Alert{ - // { - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.CostManagement/alerts"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/departments/123/providers/Microsoft.CostManagement/alerts/00000000-0000-0000-0000-000000000000"), - // Properties: &armcostmanagement.AlertProperties{ - // Description: to.Ptr(""), - // CloseTime: to.Ptr("0001-01-01T00:00:00"), - // CostEntityID: to.Ptr("budget1"), - // CreationTime: to.Ptr("2020-04-27T11:07:52.7143901Z"), - // Definition: &armcostmanagement.AlertPropertiesDefinition{ - // Type: to.Ptr(armcostmanagement.AlertTypeBudget), - // Category: to.Ptr(armcostmanagement.AlertCategoryCost), - // Criteria: to.Ptr(armcostmanagement.AlertCriteriaCostThresholdExceeded), - // }, - // ModificationTime: to.Ptr("2020-04-28T11:06:02.8999373Z"), - // Source: to.Ptr(armcostmanagement.AlertSourcePreset), - // Status: to.Ptr(armcostmanagement.AlertStatusActive), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, - // ContactGroups: []*string{ - // }, - // ContactRoles: []*string{ - // }, - // CurrentSpend: to.Ptr[float64](161000.12), - // MeterFilter: []any{ - // }, - // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), - // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), - // ResourceFilter: []any{ - // }, - // ResourceGroupFilter: []any{ - // }, - // TagFilter: map[string]any{ - // }, - // Threshold: to.Ptr[float64](0.8), - // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), - // TriggeredBy: to.Ptr("00000000-0000-0000-0000-000000000000_1_01"), - // Unit: to.Ptr("USD"), - // }, - // }, - // }, - // { - // Name: to.Ptr("11111111-1111-1111-111111111111"), - // Type: to.Ptr("Microsoft.CostManagement/alerts"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/departments/123/providers/Microsoft.CostManagement/alerts/11111111-1111-1111-111111111111"), - // Properties: &armcostmanagement.AlertProperties{ - // Description: to.Ptr(""), - // CloseTime: to.Ptr("0001-01-01T00:00:00"), - // CostEntityID: to.Ptr("budget1"), - // CreationTime: to.Ptr("2019-06-24T05:51:52.8713179Z"), - // Definition: &armcostmanagement.AlertPropertiesDefinition{ - // Type: to.Ptr(armcostmanagement.AlertTypeBudget), - // Category: to.Ptr(armcostmanagement.AlertCategoryCost), - // Criteria: to.Ptr(armcostmanagement.AlertCriteriaCostThresholdExceeded), - // }, - // ModificationTime: to.Ptr("2019-08-31T17:51:55.1808807Z"), - // Source: to.Ptr(armcostmanagement.AlertSourcePreset), - // Status: to.Ptr(armcostmanagement.AlertStatusActive), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, - // ContactGroups: []*string{ - // }, - // ContactRoles: []*string{ - // }, - // CurrentSpend: to.Ptr[float64](171000.32), - // MeterFilter: []any{ - // }, - // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), - // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), - // ResourceFilter: []any{ - // }, - // ResourceGroupFilter: []any{ - // }, - // TagFilter: map[string]any{ - // }, - // Threshold: to.Ptr[float64](0.8), - // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), - // TriggeredBy: to.Ptr("11111111-1111-1111-111111111111_1_01"), - // Unit: to.Ptr("USD"), - // }, - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/EnrollmentAccountAlerts.json -func ExampleAlertsClient_List_enrollmentAccountAlerts() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAlertsClient().List(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789/enrollmentAccounts/456", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.AlertsResult = armcostmanagement.AlertsResult{ - // Value: []*armcostmanagement.Alert{ - // { - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.CostManagement/alerts"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/enrollmentAccounts/456/providers/Microsoft.CostManagement/alerts/00000000-0000-0000-0000-000000000000"), - // Properties: &armcostmanagement.AlertProperties{ - // Description: to.Ptr(""), - // CloseTime: to.Ptr("0001-01-01T00:00:00"), - // CostEntityID: to.Ptr("budget1"), - // CreationTime: to.Ptr("2020-04-27T11:07:52.7143901Z"), - // Definition: &armcostmanagement.AlertPropertiesDefinition{ - // Type: to.Ptr(armcostmanagement.AlertTypeBudget), - // Category: to.Ptr(armcostmanagement.AlertCategoryCost), - // Criteria: to.Ptr(armcostmanagement.AlertCriteriaCostThresholdExceeded), - // }, - // ModificationTime: to.Ptr("2020-04-28T11:06:02.8999373Z"), - // Source: to.Ptr(armcostmanagement.AlertSourcePreset), - // Status: to.Ptr(armcostmanagement.AlertStatusActive), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, - // ContactGroups: []*string{ - // }, - // ContactRoles: []*string{ - // }, - // CurrentSpend: to.Ptr[float64](161000.12), - // MeterFilter: []any{ - // }, - // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), - // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), - // ResourceFilter: []any{ - // }, - // ResourceGroupFilter: []any{ - // }, - // TagFilter: map[string]any{ - // }, - // Threshold: to.Ptr[float64](0.8), - // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), - // TriggeredBy: to.Ptr("00000000-0000-0000-0000-000000000000_1_01"), - // Unit: to.Ptr("USD"), - // }, - // }, - // }, - // { - // Name: to.Ptr("11111111-1111-1111-111111111111"), - // Type: to.Ptr("Microsoft.CostManagement/alerts"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/enrollmentAccounts/456/providers/Microsoft.CostManagement/alerts/11111111-1111-1111-111111111111"), - // Properties: &armcostmanagement.AlertProperties{ - // Description: to.Ptr(""), - // CloseTime: to.Ptr("0001-01-01T00:00:00"), - // CostEntityID: to.Ptr("budget1"), - // CreationTime: to.Ptr("2019-06-24T05:51:52.8713179Z"), - // Definition: &armcostmanagement.AlertPropertiesDefinition{ - // Type: to.Ptr(armcostmanagement.AlertTypeBudget), - // Category: to.Ptr(armcostmanagement.AlertCategoryCost), - // Criteria: to.Ptr(armcostmanagement.AlertCriteriaCostThresholdExceeded), - // }, - // ModificationTime: to.Ptr("2019-08-31T17:51:55.1808807Z"), - // Source: to.Ptr(armcostmanagement.AlertSourcePreset), - // Status: to.Ptr(armcostmanagement.AlertStatusActive), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, - // ContactGroups: []*string{ - // }, - // ContactRoles: []*string{ - // }, - // CurrentSpend: to.Ptr[float64](171000.32), - // MeterFilter: []any{ - // }, - // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), - // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), - // ResourceFilter: []any{ - // }, - // ResourceGroupFilter: []any{ - // }, - // TagFilter: map[string]any{ - // }, - // Threshold: to.Ptr[float64](0.8), - // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), - // TriggeredBy: to.Ptr("11111111-1111-1111-111111111111_1_01"), - // Unit: to.Ptr("USD"), - // }, - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/InvoiceSectionAlerts.json -func ExampleAlertsClient_List_invoiceSectionAlerts() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAlertsClient().List(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.AlertsResult = armcostmanagement.AlertsResult{ - // Value: []*armcostmanagement.Alert{ - // { - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.CostManagement/alerts"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876/providers/Microsoft.CostManagement/alerts/00000000-0000-0000-0000-000000000000"), - // Properties: &armcostmanagement.AlertProperties{ - // Description: to.Ptr(""), - // CloseTime: to.Ptr("0001-01-01T00:00:00"), - // CostEntityID: to.Ptr("budget1"), - // CreationTime: to.Ptr("2020-04-27T11:07:52.7143901Z"), - // Definition: &armcostmanagement.AlertPropertiesDefinition{ - // Type: to.Ptr(armcostmanagement.AlertTypeBudget), - // Category: to.Ptr(armcostmanagement.AlertCategoryCost), - // Criteria: to.Ptr(armcostmanagement.AlertCriteriaCostThresholdExceeded), - // }, - // ModificationTime: to.Ptr("2020-04-28T11:06:02.8999373Z"), - // Source: to.Ptr(armcostmanagement.AlertSourcePreset), - // Status: to.Ptr(armcostmanagement.AlertStatusActive), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, - // ContactGroups: []*string{ - // }, - // ContactRoles: []*string{ - // }, - // CurrentSpend: to.Ptr[float64](161000.12), - // MeterFilter: []any{ - // }, - // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), - // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), - // ResourceFilter: []any{ - // }, - // ResourceGroupFilter: []any{ - // }, - // TagFilter: map[string]any{ - // }, - // Threshold: to.Ptr[float64](0.8), - // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), - // TriggeredBy: to.Ptr("00000000-0000-0000-0000-000000000000_1_01"), - // Unit: to.Ptr("USD"), - // }, - // }, - // }, - // { - // Name: to.Ptr("11111111-1111-1111-111111111111"), - // Type: to.Ptr("Microsoft.CostManagement/alerts"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876/providers/Microsoft.CostManagement/alerts/11111111-1111-1111-111111111111"), - // Properties: &armcostmanagement.AlertProperties{ - // Description: to.Ptr(""), - // CloseTime: to.Ptr("0001-01-01T00:00:00"), - // CostEntityID: to.Ptr("budget1"), - // CreationTime: to.Ptr("2019-06-24T05:51:52.8713179Z"), - // Definition: &armcostmanagement.AlertPropertiesDefinition{ - // Type: to.Ptr(armcostmanagement.AlertTypeBudget), - // Category: to.Ptr(armcostmanagement.AlertCategoryCost), - // Criteria: to.Ptr(armcostmanagement.AlertCriteriaCostThresholdExceeded), - // }, - // ModificationTime: to.Ptr("2019-08-31T17:51:55.1808807Z"), - // Source: to.Ptr(armcostmanagement.AlertSourcePreset), - // Status: to.Ptr(armcostmanagement.AlertStatusActive), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, - // ContactGroups: []*string{ - // }, - // ContactRoles: []*string{ - // }, - // CurrentSpend: to.Ptr[float64](171000.32), - // MeterFilter: []any{ - // }, - // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), - // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), - // ResourceFilter: []any{ - // }, - // ResourceGroupFilter: []any{ - // }, - // TagFilter: map[string]any{ - // }, - // Threshold: to.Ptr[float64](0.8), - // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), - // TriggeredBy: to.Ptr("11111111-1111-1111-111111111111_1_01"), - // Unit: to.Ptr("USD"), - // }, - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ResourceGroupAlerts.json -func ExampleAlertsClient_List_resourceGroupAlerts() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAlertsClient().List(ctx, "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ScreenSharingTest-peer", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.AlertsResult = armcostmanagement.AlertsResult{ - // Value: []*armcostmanagement.Alert{ - // { - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.CostManagement/alerts"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ScreenSharingTest-peer/providers/Microsoft.CostManagement/alerts/00000000-0000-0000-0000-000000000000"), - // Properties: &armcostmanagement.AlertProperties{ - // Description: to.Ptr(""), - // CloseTime: to.Ptr("0001-01-01T00:00:00"), - // CostEntityID: to.Ptr("budget1"), - // CreationTime: to.Ptr("2020-04-27T11:07:52.7143901Z"), - // Definition: &armcostmanagement.AlertPropertiesDefinition{ - // Type: to.Ptr(armcostmanagement.AlertTypeBudget), - // Category: to.Ptr(armcostmanagement.AlertCategoryCost), - // Criteria: to.Ptr(armcostmanagement.AlertCriteriaCostThresholdExceeded), - // }, - // ModificationTime: to.Ptr("2020-04-28T11:06:02.8999373Z"), - // Source: to.Ptr(armcostmanagement.AlertSourcePreset), - // Status: to.Ptr(armcostmanagement.AlertStatusActive), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, - // ContactGroups: []*string{ - // }, - // ContactRoles: []*string{ - // }, - // CurrentSpend: to.Ptr[float64](161000.12), - // MeterFilter: []any{ - // }, - // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), - // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), - // ResourceFilter: []any{ - // }, - // ResourceGroupFilter: []any{ - // }, - // TagFilter: map[string]any{ - // }, - // Threshold: to.Ptr[float64](0.8), - // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), - // TriggeredBy: to.Ptr("00000000-0000-0000-0000-000000000000_1_01"), - // Unit: to.Ptr("USD"), - // }, - // }, - // }, - // { - // Name: to.Ptr("11111111-1111-1111-111111111111"), - // Type: to.Ptr("Microsoft.CostManagement/alerts"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ScreenSharingTest-peer/providers/Microsoft.CostManagement/alerts/11111111-1111-1111-111111111111"), - // Properties: &armcostmanagement.AlertProperties{ - // Description: to.Ptr(""), - // CloseTime: to.Ptr("0001-01-01T00:00:00"), - // CostEntityID: to.Ptr("budget1"), - // CreationTime: to.Ptr("2019-06-24T05:51:52.8713179Z"), - // Definition: &armcostmanagement.AlertPropertiesDefinition{ - // Type: to.Ptr(armcostmanagement.AlertTypeBudget), - // Category: to.Ptr(armcostmanagement.AlertCategoryCost), - // Criteria: to.Ptr(armcostmanagement.AlertCriteriaCostThresholdExceeded), - // }, - // ModificationTime: to.Ptr("2019-08-31T17:51:55.1808807Z"), - // Source: to.Ptr(armcostmanagement.AlertSourcePreset), - // Status: to.Ptr(armcostmanagement.AlertStatusActive), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, - // ContactGroups: []*string{ - // }, - // ContactRoles: []*string{ - // }, - // CurrentSpend: to.Ptr[float64](171000.32), - // MeterFilter: []any{ - // }, - // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), - // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), - // ResourceFilter: []any{ - // }, - // ResourceGroupFilter: []any{ - // }, - // TagFilter: map[string]any{ - // }, - // Threshold: to.Ptr[float64](0.8), - // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), - // TriggeredBy: to.Ptr("11111111-1111-1111-111111111111_1_01"), - // Unit: to.Ptr("USD"), - // }, - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/SubscriptionAlerts.json -func ExampleAlertsClient_List_subscriptionAlerts() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAlertsClient().List(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.AlertsResult = armcostmanagement.AlertsResult{ - // Value: []*armcostmanagement.Alert{ - // { - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.CostManagement/alerts"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/alerts/00000000-0000-0000-0000-000000000000"), - // Properties: &armcostmanagement.AlertProperties{ - // Description: to.Ptr(""), - // CloseTime: to.Ptr("0001-01-01T00:00:00"), - // CostEntityID: to.Ptr("budget1"), - // CreationTime: to.Ptr("2020-04-27T11:07:52.7143901Z"), - // Definition: &armcostmanagement.AlertPropertiesDefinition{ - // Type: to.Ptr(armcostmanagement.AlertTypeBudget), - // Category: to.Ptr(armcostmanagement.AlertCategoryCost), - // Criteria: to.Ptr(armcostmanagement.AlertCriteriaCostThresholdExceeded), - // }, - // ModificationTime: to.Ptr("2020-04-28T11:06:02.8999373Z"), - // Source: to.Ptr(armcostmanagement.AlertSourcePreset), - // Status: to.Ptr(armcostmanagement.AlertStatusActive), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, - // ContactGroups: []*string{ - // }, - // ContactRoles: []*string{ - // }, - // CurrentSpend: to.Ptr[float64](161000.12), - // MeterFilter: []any{ - // }, - // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), - // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), - // ResourceFilter: []any{ - // }, - // ResourceGroupFilter: []any{ - // }, - // TagFilter: map[string]any{ - // }, - // Threshold: to.Ptr[float64](0.8), - // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), - // TriggeredBy: to.Ptr("00000000-0000-0000-0000-000000000000_1_01"), - // Unit: to.Ptr("USD"), - // }, - // }, - // }, - // { - // Name: to.Ptr("11111111-1111-1111-111111111111"), - // Type: to.Ptr("Microsoft.CostManagement/alerts"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/alerts/11111111-1111-1111-111111111111"), - // Properties: &armcostmanagement.AlertProperties{ - // Description: to.Ptr(""), - // CloseTime: to.Ptr("0001-01-01T00:00:00"), - // CostEntityID: to.Ptr("budget1"), - // CreationTime: to.Ptr("2019-06-24T05:51:52.8713179Z"), - // Definition: &armcostmanagement.AlertPropertiesDefinition{ - // Type: to.Ptr(armcostmanagement.AlertTypeBudget), - // Category: to.Ptr(armcostmanagement.AlertCategoryCost), - // Criteria: to.Ptr(armcostmanagement.AlertCriteriaCostThresholdExceeded), - // }, - // ModificationTime: to.Ptr("2019-08-31T17:51:55.1808807Z"), - // Source: to.Ptr(armcostmanagement.AlertSourcePreset), - // Status: to.Ptr(armcostmanagement.AlertStatusActive), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, - // ContactGroups: []*string{ - // }, - // ContactRoles: []*string{ - // }, - // CurrentSpend: to.Ptr[float64](171000.32), - // MeterFilter: []any{ - // }, - // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), - // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), - // ResourceFilter: []any{ - // }, - // ResourceGroupFilter: []any{ - // }, - // TagFilter: map[string]any{ - // }, - // Threshold: to.Ptr[float64](0.8), - // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), - // TriggeredBy: to.Ptr("11111111-1111-1111-111111111111_1_01"), - // Unit: to.Ptr("USD"), - // }, - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/SingleResourceGroupAlert.json -func ExampleAlertsClient_Get_singleResourceGroupAlerts() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAlertsClient().Get(ctx, "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ScreenSharingTest-peer", "22222222-2222-2222-2222-222222222222", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Alert = armcostmanagement.Alert{ - // Name: to.Ptr("22222222-2222-2222-2222-222222222222"), - // Type: to.Ptr("Microsoft.CostManagement/alerts"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ScreenSharingTest-peer/providers/Microsoft.CostManagement/alerts/22222222-2222-2222-2222-222222222222"), - // Properties: &armcostmanagement.AlertProperties{ - // Description: to.Ptr(""), - // CloseTime: to.Ptr("0001-01-01T00:00:00"), - // CostEntityID: to.Ptr("budget1"), - // CreationTime: to.Ptr("2020-04-27T11:07:52.7143901Z"), - // Definition: &armcostmanagement.AlertPropertiesDefinition{ - // Type: to.Ptr(armcostmanagement.AlertTypeBudget), - // Category: to.Ptr(armcostmanagement.AlertCategoryCost), - // Criteria: to.Ptr(armcostmanagement.AlertCriteriaCostThresholdExceeded), - // }, - // ModificationTime: to.Ptr("2020-04-28T11:06:02.8999373Z"), - // Source: to.Ptr(armcostmanagement.AlertSourcePreset), - // Status: to.Ptr(armcostmanagement.AlertStatusActive), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, - // ContactGroups: []*string{ - // }, - // ContactRoles: []*string{ - // }, - // CurrentSpend: to.Ptr[float64](161000.12), - // MeterFilter: []any{ - // }, - // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), - // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), - // ResourceFilter: []any{ - // }, - // ResourceGroupFilter: []any{ - // }, - // TagFilter: map[string]any{ - // }, - // Threshold: to.Ptr[float64](0.8), - // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), - // TriggeredBy: to.Ptr("22222222-2222-2222-2222-222222222222_1_01"), - // Unit: to.Ptr("USD"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/SingleSubscriptionAlert.json -func ExampleAlertsClient_Get_singleSubscriptionAlerts() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAlertsClient().Get(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", "22222222-2222-2222-2222-222222222222", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Alert = armcostmanagement.Alert{ - // Name: to.Ptr("22222222-2222-2222-2222-222222222222"), - // Type: to.Ptr("Microsoft.CostManagement/alerts"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/alerts/22222222-2222-2222-2222-222222222222"), - // Properties: &armcostmanagement.AlertProperties{ - // Description: to.Ptr(""), - // CloseTime: to.Ptr("0001-01-01T00:00:00"), - // CostEntityID: to.Ptr("budget1"), - // CreationTime: to.Ptr("2020-04-27T11:07:52.7143901Z"), - // Definition: &armcostmanagement.AlertPropertiesDefinition{ - // Type: to.Ptr(armcostmanagement.AlertTypeBudget), - // Category: to.Ptr(armcostmanagement.AlertCategoryCost), - // Criteria: to.Ptr(armcostmanagement.AlertCriteriaCostThresholdExceeded), - // }, - // ModificationTime: to.Ptr("2020-04-28T11:06:02.8999373Z"), - // Source: to.Ptr(armcostmanagement.AlertSourcePreset), - // Status: to.Ptr(armcostmanagement.AlertStatusActive), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, - // ContactGroups: []*string{ - // }, - // ContactRoles: []*string{ - // }, - // CurrentSpend: to.Ptr[float64](161000.12), - // MeterFilter: []any{ - // }, - // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), - // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), - // ResourceFilter: []any{ - // }, - // ResourceGroupFilter: []any{ - // }, - // TagFilter: map[string]any{ - // }, - // Threshold: to.Ptr[float64](0.8), - // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), - // TriggeredBy: to.Ptr("22222222-2222-2222-2222-222222222222_1_01"), - // Unit: to.Ptr("USD"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/DismissResourceGroupAlerts.json -func ExampleAlertsClient_Dismiss_patchResourceGroupAlerts() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAlertsClient().Dismiss(ctx, "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ScreenSharingTest-peer", "22222222-2222-2222-2222-222222222222", armcostmanagement.DismissAlertPayload{ - Properties: &armcostmanagement.AlertProperties{ - Status: to.Ptr(armcostmanagement.AlertStatusDismissed), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Alert = armcostmanagement.Alert{ - // Name: to.Ptr("22222222-2222-2222-2222-222222222222"), - // Type: to.Ptr("Microsoft.CostManagement/alerts"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ScreenSharingTest-peer/providers/Microsoft.CostManagement/alerts/22222222-2222-2222-2222-222222222222"), - // Properties: &armcostmanagement.AlertProperties{ - // Description: to.Ptr(""), - // CloseTime: to.Ptr("0001-01-01T00:00:00"), - // CostEntityID: to.Ptr("budget1"), - // CreationTime: to.Ptr("2020-04-27T11:07:52.7143901Z"), - // Definition: &armcostmanagement.AlertPropertiesDefinition{ - // Type: to.Ptr(armcostmanagement.AlertTypeBudget), - // Category: to.Ptr(armcostmanagement.AlertCategoryCost), - // Criteria: to.Ptr(armcostmanagement.AlertCriteriaCostThresholdExceeded), - // }, - // ModificationTime: to.Ptr("2020-04-28T11:06:02.8999373Z"), - // Source: to.Ptr(armcostmanagement.AlertSourcePreset), - // Status: to.Ptr(armcostmanagement.AlertStatusDismissed), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, - // ContactGroups: []*string{ - // }, - // ContactRoles: []*string{ - // }, - // CurrentSpend: to.Ptr[float64](161000.12), - // MeterFilter: []any{ - // }, - // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), - // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), - // ResourceFilter: []any{ - // }, - // ResourceGroupFilter: []any{ - // }, - // TagFilter: map[string]any{ - // }, - // Threshold: to.Ptr[float64](0.8), - // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), - // TriggeredBy: to.Ptr("22222222-2222-2222-2222-222222222222_1_01"), - // Unit: to.Ptr("USD"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/DismissSubscriptionAlerts.json -func ExampleAlertsClient_Dismiss_patchSubscriptionAlerts() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAlertsClient().Dismiss(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", "22222222-2222-2222-2222-222222222222", armcostmanagement.DismissAlertPayload{ - Properties: &armcostmanagement.AlertProperties{ - Status: to.Ptr(armcostmanagement.AlertStatusDismissed), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Alert = armcostmanagement.Alert{ - // Name: to.Ptr("22222222-2222-2222-2222-222222222222"), - // Type: to.Ptr("Microsoft.CostManagement/alerts"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/alerts/22222222-2222-2222-2222-222222222222"), - // Properties: &armcostmanagement.AlertProperties{ - // Description: to.Ptr(""), - // CloseTime: to.Ptr("0001-01-01T00:00:00"), - // CostEntityID: to.Ptr("budget1"), - // CreationTime: to.Ptr("2020-04-27T11:07:52.7143901Z"), - // Definition: &armcostmanagement.AlertPropertiesDefinition{ - // Type: to.Ptr(armcostmanagement.AlertTypeBudget), - // Category: to.Ptr(armcostmanagement.AlertCategoryCost), - // Criteria: to.Ptr(armcostmanagement.AlertCriteriaCostThresholdExceeded), - // }, - // ModificationTime: to.Ptr("2020-04-28T11:06:02.8999373Z"), - // Source: to.Ptr(armcostmanagement.AlertSourcePreset), - // Status: to.Ptr(armcostmanagement.AlertStatusDismissed), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, - // ContactGroups: []*string{ - // }, - // ContactRoles: []*string{ - // }, - // CurrentSpend: to.Ptr[float64](161000.12), - // MeterFilter: []any{ - // }, - // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), - // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), - // ResourceFilter: []any{ - // }, - // ResourceGroupFilter: []any{ - // }, - // TagFilter: map[string]any{ - // }, - // Threshold: to.Ptr[float64](0.8), - // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), - // TriggeredBy: to.Ptr("22222222-2222-2222-2222-222222222222_1_01"), - // Unit: to.Ptr("USD"), - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExternalBillingAccountAlerts.json -func ExampleAlertsClient_ListExternal_externalBillingAccountAlerts() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAlertsClient().ListExternal(ctx, armcostmanagement.ExternalCloudProviderTypeExternalBillingAccounts, "100", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.AlertsResult = armcostmanagement.AlertsResult{ - // Value: []*armcostmanagement.Alert{ - // { - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.CostManagement/alerts"), - // ID: to.Ptr("providers/Microsoft.CostManagement/externalBillingAccounts/100/providers/Microsoft.CostManagement/alerts/00000000-0000-0000-0000-000000000000"), - // Properties: &armcostmanagement.AlertProperties{ - // Description: to.Ptr(""), - // CloseTime: to.Ptr("0001-01-01T00:00:00"), - // CostEntityID: to.Ptr("budget1"), - // CreationTime: to.Ptr("2020-04-27T11:07:52.7143901Z"), - // Definition: &armcostmanagement.AlertPropertiesDefinition{ - // Type: to.Ptr(armcostmanagement.AlertTypeBudget), - // Category: to.Ptr(armcostmanagement.AlertCategoryCost), - // Criteria: to.Ptr(armcostmanagement.AlertCriteriaCostThresholdExceeded), - // }, - // ModificationTime: to.Ptr("2020-04-28T11:06:02.8999373Z"), - // Source: to.Ptr(armcostmanagement.AlertSourcePreset), - // Status: to.Ptr(armcostmanagement.AlertStatusActive), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, - // ContactGroups: []*string{ - // }, - // ContactRoles: []*string{ - // }, - // CurrentSpend: to.Ptr[float64](161000.12), - // MeterFilter: []any{ - // }, - // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), - // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), - // ResourceFilter: []any{ - // }, - // ResourceGroupFilter: []any{ - // }, - // TagFilter: map[string]any{ - // }, - // Threshold: to.Ptr[float64](0.8), - // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), - // TriggeredBy: to.Ptr("00000000-0000-0000-0000-000000000000_1_01"), - // Unit: to.Ptr("USD"), - // }, - // }, - // }, - // { - // Name: to.Ptr("11111111-1111-1111-111111111111"), - // Type: to.Ptr("Microsoft.CostManagement/alerts"), - // ID: to.Ptr("providers/Microsoft.CostManagement/externalBillingAccounts/100/providers/Microsoft.CostManagement/alerts/11111111-1111-1111-111111111111"), - // Properties: &armcostmanagement.AlertProperties{ - // Description: to.Ptr(""), - // CloseTime: to.Ptr("0001-01-01T00:00:00"), - // CostEntityID: to.Ptr("budget1"), - // CreationTime: to.Ptr("2019-06-24T05:51:52.8713179Z"), - // Definition: &armcostmanagement.AlertPropertiesDefinition{ - // Type: to.Ptr(armcostmanagement.AlertTypeBudget), - // Category: to.Ptr(armcostmanagement.AlertCategoryCost), - // Criteria: to.Ptr(armcostmanagement.AlertCriteriaCostThresholdExceeded), - // }, - // ModificationTime: to.Ptr("2019-08-31T17:51:55.1808807Z"), - // Source: to.Ptr(armcostmanagement.AlertSourcePreset), - // Status: to.Ptr(armcostmanagement.AlertStatusActive), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, - // ContactGroups: []*string{ - // }, - // ContactRoles: []*string{ - // }, - // CurrentSpend: to.Ptr[float64](171000.32), - // MeterFilter: []any{ - // }, - // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), - // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), - // ResourceFilter: []any{ - // }, - // ResourceGroupFilter: []any{ - // }, - // TagFilter: map[string]any{ - // }, - // Threshold: to.Ptr[float64](0.8), - // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), - // TriggeredBy: to.Ptr("11111111-1111-1111-111111111111_1_01"), - // Unit: to.Ptr("USD"), - // }, - // }, - // }}, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExternalSubscriptionAlerts.json -func ExampleAlertsClient_ListExternal_externalSubscriptionAlerts() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewAlertsClient().ListExternal(ctx, armcostmanagement.ExternalCloudProviderTypeExternalSubscriptions, "100", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.AlertsResult = armcostmanagement.AlertsResult{ - // Value: []*armcostmanagement.Alert{ - // { - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.CostManagement/alerts"), - // ID: to.Ptr("providers/Microsoft.CostManagement/externalSubscriptions/100/providers/Microsoft.CostManagement/alerts/00000000-0000-0000-0000-000000000000"), - // Properties: &armcostmanagement.AlertProperties{ - // Description: to.Ptr(""), - // CloseTime: to.Ptr("0001-01-01T00:00:00"), - // CostEntityID: to.Ptr("budget1"), - // CreationTime: to.Ptr("2020-04-27T11:07:52.7143901Z"), - // Definition: &armcostmanagement.AlertPropertiesDefinition{ - // Type: to.Ptr(armcostmanagement.AlertTypeBudget), - // Category: to.Ptr(armcostmanagement.AlertCategoryCost), - // Criteria: to.Ptr(armcostmanagement.AlertCriteriaCostThresholdExceeded), - // }, - // ModificationTime: to.Ptr("2020-04-28T11:06:02.8999373Z"), - // Source: to.Ptr(armcostmanagement.AlertSourcePreset), - // Status: to.Ptr(armcostmanagement.AlertStatusActive), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, - // ContactGroups: []*string{ - // }, - // ContactRoles: []*string{ - // }, - // CurrentSpend: to.Ptr[float64](161000.12), - // MeterFilter: []any{ - // }, - // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), - // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), - // ResourceFilter: []any{ - // }, - // ResourceGroupFilter: []any{ - // }, - // TagFilter: map[string]any{ - // }, - // Threshold: to.Ptr[float64](0.8), - // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), - // TriggeredBy: to.Ptr("00000000-0000-0000-0000-000000000000_1_01"), - // Unit: to.Ptr("USD"), - // }, - // }, - // }, - // { - // Name: to.Ptr("11111111-1111-1111-111111111111"), - // Type: to.Ptr("Microsoft.CostManagement/alerts"), - // ID: to.Ptr("providers/Microsoft.CostManagement/externalSubscriptions/100/providers/Microsoft.CostManagement/alerts/11111111-1111-1111-111111111111"), - // Properties: &armcostmanagement.AlertProperties{ - // Description: to.Ptr(""), - // CloseTime: to.Ptr("0001-01-01T00:00:00"), - // CostEntityID: to.Ptr("budget1"), - // CreationTime: to.Ptr("2019-06-24T05:51:52.8713179Z"), - // Definition: &armcostmanagement.AlertPropertiesDefinition{ - // Type: to.Ptr(armcostmanagement.AlertTypeBudget), - // Category: to.Ptr(armcostmanagement.AlertCategoryCost), - // Criteria: to.Ptr(armcostmanagement.AlertCriteriaCostThresholdExceeded), - // }, - // ModificationTime: to.Ptr("2019-08-31T17:51:55.1808807Z"), - // Source: to.Ptr(armcostmanagement.AlertSourcePreset), - // Status: to.Ptr(armcostmanagement.AlertStatusActive), - // StatusModificationTime: to.Ptr("0001-01-01T00:00:00"), - // Details: &armcostmanagement.AlertPropertiesDetails{ - // Amount: to.Ptr[float64](200000), - // ContactEmails: []*string{ - // to.Ptr("1234@contoso.com")}, - // ContactGroups: []*string{ - // }, - // ContactRoles: []*string{ - // }, - // CurrentSpend: to.Ptr[float64](171000.32), - // MeterFilter: []any{ - // }, - // Operator: to.Ptr(armcostmanagement.AlertOperatorGreaterThan), - // PeriodStartDate: to.Ptr("2020-03-01T00:00:00Z"), - // ResourceFilter: []any{ - // }, - // ResourceGroupFilter: []any{ - // }, - // TagFilter: map[string]any{ - // }, - // Threshold: to.Ptr[float64](0.8), - // TimeGrainType: to.Ptr(armcostmanagement.AlertTimeGrainTypeQuarterly), - // TriggeredBy: to.Ptr("11111111-1111-1111-111111111111_1_01"), - // Unit: to.Ptr("USD"), - // }, - // }, - // }}, - // } -} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/autorest.md b/sdk/resourcemanager/costmanagement/armcostmanagement/autorest.md index 3bebc0b2df2e..9415fa5d7ea0 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/autorest.md +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/autorest.md @@ -5,9 +5,8 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/cost-management/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/cost-management/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 2.0.0 -tag: package-2022-10 +module-version: 2.1.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/benefitrecommendations_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/benefitrecommendations_client.go index 134c20438951..37cc606237e7 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/benefitrecommendations_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/benefitrecommendations_client.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armcostmanagement @@ -41,7 +40,7 @@ func NewBenefitRecommendationsClient(credential azcore.TokenCredential, options // NewListPager - List of recommendations for purchasing savings plan. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - billingScope - The scope associated with benefit recommendation operations. This includes '/subscriptions/{subscriptionId}/' // for subscription scope, // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resource group scope, /providers/Microsoft.Billing/billingAccounts/{billingAccountId}' @@ -96,7 +95,7 @@ func (client *BenefitRecommendationsClient) listCreateRequest(ctx context.Contex if options != nil && options.Expand != nil { reqQP.Set("$expand", *options.Expand) } - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/benefitrecommendations_client_example_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/benefitrecommendations_client_example_test.go deleted file mode 100644 index f74e5e306ff2..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/benefitrecommendations_client_example_test.go +++ /dev/null @@ -1,154 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armcostmanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BenefitRecommendationsByBillingAccount.json -func ExampleBenefitRecommendationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewBenefitRecommendationsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/123456", &armcostmanagement.BenefitRecommendationsClientListOptions{Filter: to.Ptr("properties/lookBackPeriod eq 'Last7Days' AND properties/term eq 'P1Y'"), - Orderby: nil, - Expand: to.Ptr("properties/usage,properties/allRecommendationDetails"), - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.BenefitRecommendationsListResult = armcostmanagement.BenefitRecommendationsListResult{ - // Value: []*armcostmanagement.BenefitRecommendationModel{ - // { - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.CostManagement/benefitRecommendations"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/benefitRecommendations/00000000-0000-0000-0000-000000000000"), - // Kind: to.Ptr(armcostmanagement.BenefitKindSavingsPlan), - // Properties: &armcostmanagement.SharedScopeBenefitRecommendationProperties{ - // AllRecommendationDetails: &armcostmanagement.AllSavingsList{ - // Value: []*armcostmanagement.AllSavingsBenefitDetails{ - // { - // AverageUtilizationPercentage: to.Ptr[float64](99.33), - // BenefitCost: to.Ptr[float64](52.002), - // CommitmentAmount: to.Ptr[float64](0.164), - // CoveragePercentage: to.Ptr[float64](54.609), - // OverageCost: to.Ptr[float64](144.841), - // SavingsAmount: to.Ptr[float64](21.424), - // SavingsPercentage: to.Ptr[float64](9.815), - // TotalCost: to.Ptr[float64](196.843), - // WastageCost: to.Ptr[float64](0.035), - // }, - // { - // AverageUtilizationPercentage: to.Ptr[float64](81.474), - // BenefitCost: to.Ptr[float64](83.754), - // CommitmentAmount: to.Ptr[float64](0.161), - // CoveragePercentage: to.Ptr[float64](56.748), - // OverageCost: to.Ptr[float64](120.389), - // SavingsAmount: to.Ptr[float64](14.124), - // SavingsPercentage: to.Ptr[float64](6.47), - // TotalCost: to.Ptr[float64](204.143), - // WastageCost: to.Ptr[float64](0.1), - // }}, - // }, - // ArmSKUName: to.Ptr("Compute_Savings_Plan"), - // CommitmentGranularity: to.Ptr(armcostmanagement.GrainHourly), - // CostWithoutBenefit: to.Ptr[float64](218.267), - // CurrencyCode: to.Ptr("USD"), - // FirstConsumptionDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-18T00:00: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{ - // 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 38a82e04a573..e3bcd70f7268 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/benefitutilizationsummaries_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/benefitutilizationsummaries_client.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armcostmanagement @@ -44,7 +43,7 @@ func NewBenefitUtilizationSummariesClient(credential azcore.TokenCredential, opt // NewListByBillingAccountIDPager - Lists savings plan utilization summaries for the enterprise agreement scope. Supported // at grain values: 'Daily' and 'Monthly'. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - billingAccountID - Billing account ID // - options - BenefitUtilizationSummariesClientListByBillingAccountIDOptions contains the optional parameters for the BenefitUtilizationSummariesClient.NewListByBillingAccountIDPager // method. @@ -88,7 +87,7 @@ func (client *BenefitUtilizationSummariesClient) listByBillingAccountIDCreateReq return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") if options != nil && options.GrainParameter != nil { reqQP.Set("grainParameter", string(*options.GrainParameter)) } @@ -112,7 +111,7 @@ func (client *BenefitUtilizationSummariesClient) listByBillingAccountIDHandleRes // NewListByBillingProfileIDPager - Lists savings plan utilization summaries for billing profile. Supported at grain values: // 'Daily' and 'Monthly'. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - billingAccountID - Billing account ID // - billingProfileID - Billing profile ID. // - options - BenefitUtilizationSummariesClientListByBillingProfileIDOptions contains the optional parameters for the BenefitUtilizationSummariesClient.NewListByBillingProfileIDPager @@ -161,7 +160,7 @@ func (client *BenefitUtilizationSummariesClient) listByBillingProfileIDCreateReq return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") if options != nil && options.GrainParameter != nil { reqQP.Set("grainParameter", string(*options.GrainParameter)) } @@ -184,7 +183,7 @@ func (client *BenefitUtilizationSummariesClient) listByBillingProfileIDHandleRes // NewListBySavingsPlanIDPager - Lists the savings plan utilization summaries for daily or monthly grain. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - savingsPlanOrderID - Savings plan order ID. // - savingsPlanID - Savings plan ID. // - options - BenefitUtilizationSummariesClientListBySavingsPlanIDOptions contains the optional parameters for the BenefitUtilizationSummariesClient.NewListBySavingsPlanIDPager @@ -233,7 +232,7 @@ func (client *BenefitUtilizationSummariesClient) listBySavingsPlanIDCreateReques return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } @@ -256,7 +255,7 @@ func (client *BenefitUtilizationSummariesClient) listBySavingsPlanIDHandleRespon // NewListBySavingsPlanOrderPager - Lists the savings plan utilization summaries for daily or monthly grain. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - savingsPlanOrderID - Savings plan order ID. // - options - BenefitUtilizationSummariesClientListBySavingsPlanOrderOptions contains the optional parameters for the BenefitUtilizationSummariesClient.NewListBySavingsPlanOrderPager // method. @@ -300,7 +299,7 @@ func (client *BenefitUtilizationSummariesClient) listBySavingsPlanOrderCreateReq return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/benefitutilizationsummaries_client_example_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/benefitutilizationsummaries_client_example_test.go deleted file mode 100644 index 60383b83bfe9..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/benefitutilizationsummaries_client_example_test.go +++ /dev/null @@ -1,235 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armcostmanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BenefitUtilizationSummaries/SavingsPlan-BillingAccount.json -func ExampleBenefitUtilizationSummariesClient_NewListByBillingAccountIDPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewBenefitUtilizationSummariesClient().NewListByBillingAccountIDPager("12345", &armcostmanagement.BenefitUtilizationSummariesClientListByBillingAccountIDOptions{GrainParameter: nil, - Filter: to.Ptr("properties/usageDate ge 2022-10-15 and properties/usageDate le 2022-10-18"), - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.BenefitUtilizationSummariesListResult = armcostmanagement.BenefitUtilizationSummariesListResult{ - // Value: []armcostmanagement.BenefitUtilizationSummaryClassification{ - // &armcostmanagement.SavingsPlanUtilizationSummary{ - // Name: to.Ptr("66cccc66-6ccc-6c66-666c-66cc6c6c66c6_222d22dd-d2d2-2dd2-222d-2dd2222ddddd_20211116"), - // Type: to.Ptr("Microsoft.CostManagement/benefitUtilizationSummaries"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/12345/providers/Microsoft.CostManagement/benefitUtilizationSummaries/66cccc66-6ccc-6c66-666c-66cc6c6c66c6_222d22dd-d2d2-2dd2-222d-2dd2222ddddd_20211116"), - // Kind: to.Ptr(armcostmanagement.BenefitKindSavingsPlan), - // Properties: &armcostmanagement.SavingsPlanUtilizationSummaryProperties{ - // ArmSKUName: to.Ptr("Compute_Savings_Plan"), - // BenefitID: to.Ptr("/providers/Microsoft.BillingBenefits/savingsPlanOrders/66cccc66-6ccc-6c66-666c-66cc6c6c66c6/savingsPlans/222d22dd-d2d2-2dd2-222d-2dd2222ddddd"), - // BenefitOrderID: to.Ptr("/providers/Microsoft.BillingBenefits/savingsPlanOrders/66cccc66-6ccc-6c66-666c-66cc6c6c66c6"), - // BenefitType: to.Ptr(armcostmanagement.BenefitKindSavingsPlan), - // UsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-16T00:00:00Z"); return t}()), - // AvgUtilizationPercentage: to.Ptr[float64](90), - // MaxUtilizationPercentage: to.Ptr[float64](100), - // MinUtilizationPercentage: to.Ptr[float64](80), - // }, - // }, - // &armcostmanagement.SavingsPlanUtilizationSummary{ - // Name: to.Ptr("88cccc88-8ccc-8c88-888c-88cc8c8c88c8_444d44dd-d4d4-4dd4-444d-4dd4444ddddd_20211117"), - // Type: to.Ptr("Microsoft.CostManagement/benefitUtilizationSummaries"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/12345/providers/Microsoft.CostManagement/benefitUtilizationSummaries/88cccc88-8ccc-8c88-888c-88cc8c8c88c8_444d44dd-d4d4-4dd4-444d-4dd4444ddddd_20211117"), - // Kind: to.Ptr(armcostmanagement.BenefitKindSavingsPlan), - // Properties: &armcostmanagement.SavingsPlanUtilizationSummaryProperties{ - // ArmSKUName: to.Ptr("Compute_Savings_Plan"), - // BenefitID: to.Ptr("/providers/Microsoft.BillingBenefits/savingsPlanOrders/88cccc88-8ccc-8c88-888c-88cc8c8c88c8/savingsPlans/444d44dd-d4d4-4dd4-444d-4dd4444ddddd"), - // BenefitOrderID: to.Ptr("/providers/Microsoft.BillingBenefits/savingsPlanOrders/88cccc88-8ccc-8c88-888c-88cc8c8c88c8"), - // BenefitType: to.Ptr(armcostmanagement.BenefitKindSavingsPlan), - // UsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T00:00:00Z"); return t}()), - // AvgUtilizationPercentage: to.Ptr[float64](60), - // MaxUtilizationPercentage: to.Ptr[float64](70), - // MinUtilizationPercentage: to.Ptr[float64](50), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BenefitUtilizationSummaries/SavingsPlan-BillingProfile.json -func ExampleBenefitUtilizationSummariesClient_NewListByBillingProfileIDPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewBenefitUtilizationSummariesClient().NewListByBillingProfileIDPager("c0a00000-0e04-5ee3-000e-f0c6e00000ec:c0a00000-0e04-5ee3-000e-f0c6e00000ec", "200e5e90-000e-4960-8dcd-8d00a02db000", &armcostmanagement.BenefitUtilizationSummariesClientListByBillingProfileIDOptions{GrainParameter: nil, - Filter: to.Ptr("properties/usageDate ge 2022-10-15 and properties/usageDate le 2022-10-18"), - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.BenefitUtilizationSummariesListResult = armcostmanagement.BenefitUtilizationSummariesListResult{ - // Value: []armcostmanagement.BenefitUtilizationSummaryClassification{ - // &armcostmanagement.SavingsPlanUtilizationSummary{ - // Name: to.Ptr("66cccc66-6ccc-6c66-666c-66cc6c6c66c6_222d22dd-d2d2-2dd2-222d-2dd2222ddddd_20211116"), - // Type: to.Ptr("Microsoft.CostManagement/benefitUtilizationSummaries"), - // ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/c0a00000-0e04-5ee3-000e-f0c6e00000ec:c0a00000-0e04-5ee3-000e-f0c6e00000ec/billingProfiles/200e5e90-000e-4960-8dcd-8d00a02db000/providers/Microsoft.CostManagement/benefitUtilizationSummaries/66cccc66-6ccc-6c66-666c-66cc6c6c66c6_222d22dd-d2d2-2dd2-222d-2dd2222ddddd_20211116"), - // Kind: to.Ptr(armcostmanagement.BenefitKindSavingsPlan), - // Properties: &armcostmanagement.SavingsPlanUtilizationSummaryProperties{ - // ArmSKUName: to.Ptr("Compute_Savings_Plan"), - // BenefitID: to.Ptr("/providers/Microsoft.BillingBenefits/savingsPlanOrders/66cccc66-6ccc-6c66-666c-66cc6c6c66c6/savingsPlans/222d22dd-d2d2-2dd2-222d-2dd2222ddddd"), - // BenefitOrderID: to.Ptr("/providers/Microsoft.BillingBenefits/savingsPlanOrders/66cccc66-6ccc-6c66-666c-66cc6c6c66c6"), - // BenefitType: to.Ptr(armcostmanagement.BenefitKindSavingsPlan), - // UsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-16T00:00:00Z"); return t}()), - // AvgUtilizationPercentage: to.Ptr[float64](90), - // MaxUtilizationPercentage: to.Ptr[float64](100), - // MinUtilizationPercentage: to.Ptr[float64](80), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BenefitUtilizationSummaries/SavingsPlan-SavingsPlanOrderId-Daily.json -func ExampleBenefitUtilizationSummariesClient_NewListBySavingsPlanOrderPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewBenefitUtilizationSummariesClient().NewListBySavingsPlanOrderPager("66cccc66-6ccc-6c66-666c-66cc6c6c66c6", &armcostmanagement.BenefitUtilizationSummariesClientListBySavingsPlanOrderOptions{Filter: nil, - GrainParameter: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.BenefitUtilizationSummariesListResult = armcostmanagement.BenefitUtilizationSummariesListResult{ - // Value: []armcostmanagement.BenefitUtilizationSummaryClassification{ - // &armcostmanagement.SavingsPlanUtilizationSummary{ - // Name: to.Ptr("66cccc66-6ccc-6c66-666c-66cc6c6c66c6_222d22dd-d2d2-2dd2-222d-2dd2222ddddd_20211116"), - // Type: to.Ptr("Microsoft.CostManagement/benefitUtilizationSummaries"), - // ID: to.Ptr("/providers/Microsoft.BillingBenefits/savingsPlanOrders/66cccc66-6ccc-6c66-666c-66cc6c6c66c6/providers/Microsoft.CostManagement/benefitUtilizationSummaries/66cccc66-6ccc-6c66-666c-66cc6c6c66c6_222d22dd-d2d2-2dd2-222d-2dd2222ddddd_20211116"), - // Kind: to.Ptr(armcostmanagement.BenefitKindSavingsPlan), - // Properties: &armcostmanagement.SavingsPlanUtilizationSummaryProperties{ - // ArmSKUName: to.Ptr("Compute_Savings_Plan"), - // BenefitID: to.Ptr("/providers/Microsoft.BillingBenefits/savingsPlanOrders/66cccc66-6ccc-6c66-666c-66cc6c6c66c6/savingsPlans/222d22dd-d2d2-2dd2-222d-2dd2222ddddd"), - // BenefitOrderID: to.Ptr("/providers/Microsoft.BillingBenefits/savingsPlanOrders/66cccc66-6ccc-6c66-666c-66cc6c6c66c6"), - // BenefitType: to.Ptr(armcostmanagement.BenefitKindSavingsPlan), - // UsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-16T00:00:00Z"); return t}()), - // AvgUtilizationPercentage: to.Ptr[float64](90), - // MaxUtilizationPercentage: to.Ptr[float64](100), - // MinUtilizationPercentage: to.Ptr[float64](80), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BenefitUtilizationSummaries/SavingsPlan-SavingsPlanId-Monthly.json -func ExampleBenefitUtilizationSummariesClient_NewListBySavingsPlanIDPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewBenefitUtilizationSummariesClient().NewListBySavingsPlanIDPager("66cccc66-6ccc-6c66-666c-66cc6c6c66c6", "222d22dd-d2d2-2dd2-222d-2dd2222ddddd", &armcostmanagement.BenefitUtilizationSummariesClientListBySavingsPlanIDOptions{Filter: nil, - GrainParameter: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.BenefitUtilizationSummariesListResult = armcostmanagement.BenefitUtilizationSummariesListResult{ - // Value: []armcostmanagement.BenefitUtilizationSummaryClassification{ - // &armcostmanagement.SavingsPlanUtilizationSummary{ - // Name: to.Ptr("66cccc66-6ccc-6c66-666c-66cc6c6c66c6_222d22dd-d2d2-2dd2-222d-2dd2222ddddd_202111"), - // Type: to.Ptr("Microsoft.CostManagement/benefitUtilizationSummaries"), - // ID: to.Ptr("/providers/Microsoft.BillingBenefits/savingsPlanOrders/66cccc66-6ccc-6c66-666c-66cc6c6c66c6/savingsPlans/222d22dd-d2d2-2dd2-222d-2dd2222ddddd/providers/Microsoft.CostManagement/benefitUtilizationSummaries/66cccc66-6ccc-6c66-666c-66cc6c6c66c6_222d22dd-d2d2-2dd2-222d-2dd2222ddddd_202111"), - // Kind: to.Ptr(armcostmanagement.BenefitKindSavingsPlan), - // Properties: &armcostmanagement.SavingsPlanUtilizationSummaryProperties{ - // ArmSKUName: to.Ptr("Compute_Savings_Plan"), - // BenefitID: to.Ptr("/providers/Microsoft.BillingBenefits/savingsPlanOrders/66cccc66-6ccc-6c66-666c-66cc6c6c66c6/savingsPlans/222d22dd-d2d2-2dd2-222d-2dd2222ddddd"), - // BenefitOrderID: to.Ptr("/providers/Microsoft.BillingBenefits/savingsPlanOrders/66cccc66-6ccc-6c66-666c-66cc6c6c66c6"), - // BenefitType: to.Ptr(armcostmanagement.BenefitKindSavingsPlan), - // UsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-16T00:00:00Z"); return t}()), - // AvgUtilizationPercentage: to.Ptr[float64](90), - // MaxUtilizationPercentage: to.Ptr[float64](100), - // MinUtilizationPercentage: to.Ptr[float64](80), - // }, - // }, - // &armcostmanagement.SavingsPlanUtilizationSummary{ - // Name: to.Ptr("66cccc66-6ccc-6c66-666c-66cc6c6c66c6_222d22dd-d2d2-2dd2-222d-2dd2222ddddd_202112"), - // Type: to.Ptr("Microsoft.CostManagement/benefitUtilizationSummaries"), - // ID: to.Ptr("/providers/Microsoft.BillingBenefits/savingsPlanOrders/66cccc66-6ccc-6c66-666c-66cc6c6c66c6/savingsPlans/222d22dd-d2d2-2dd2-222d-2dd2222ddddd/providers/Microsoft.CostManagement/benefitUtilizationSummaries/66cccc66-6ccc-6c66-666c-66cc6c6c66c6_222d22dd-d2d2-2dd2-222d-2dd2222ddddd_202112"), - // Kind: to.Ptr(armcostmanagement.BenefitKindSavingsPlan), - // Properties: &armcostmanagement.SavingsPlanUtilizationSummaryProperties{ - // ArmSKUName: to.Ptr("Compute_Savings_Plan"), - // BenefitID: to.Ptr("/providers/Microsoft.BillingBenefits/savingsPlanOrders/66cccc66-6ccc-6c66-666c-66cc6c6c66c6/savingsPlans/222d22dd-d2d2-2dd2-222d-2dd2222ddddd"), - // BenefitOrderID: to.Ptr("/providers/Microsoft.BillingBenefits/savingsPlanOrders/66cccc66-6ccc-6c66-666c-66cc6c6c66c6"), - // BenefitType: to.Ptr(armcostmanagement.BenefitKindSavingsPlan), - // UsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-10-17T00:00:00Z"); 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..50faf03b6604 --- /dev/null +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/budgets_client.go @@ -0,0 +1,436 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armcostmanagement + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// BudgetsClient contains the methods for the Budgets group. +// Don't use this type directly, use NewBudgetsClient() instead. +type BudgetsClient struct { + internal *arm.Client +} + +// NewBudgetsClient creates a new instance of BudgetsClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewBudgetsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*BudgetsClient, error) { + cl, err := arm.NewClient(moduleName+".BudgetsClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &BudgetsClient{ + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - The operation to create or update a budget. You can optionally provide an eTag if desired as a form of +// concurrency control. To obtain the latest eTag for a given budget, perform a get operation prior +// to your put operation. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-08-01 +// +// - scope - The scope associated with budget operations. +// Supported scopes for CategoryType: Cost +// Azure RBAC Scopes: +// +// - '/subscriptions/{subscriptionId}/' for subscription scope +// +// - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope +// +// - '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope +// +// EA (Enterprise Agreement) Scopes: +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount +// scope +// +// MCA (Modern Customer Agreement) Scopes: +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile +// scope +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' +// for invoiceSection scope +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' for customer scope (CSP only) +// +// Supported scopes for CategoryType: ReservationUtilization +// +// EA (Enterprise Agreement) Scopes: +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account Scope +// +// MCA (Modern Customer Agreement) Scopes: +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile +// scope (non-CSP only) +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' for customer scope (CSP only) +// +// - budgetName - Budget Name. +// +// - parameters - Parameters supplied to the Create Budget operation. +// +// - options - BudgetsClientCreateOrUpdateOptions contains the optional parameters for the BudgetsClient.CreateOrUpdate method. +func (client *BudgetsClient) CreateOrUpdate(ctx context.Context, scope string, budgetName string, parameters Budget, options *BudgetsClientCreateOrUpdateOptions) (BudgetsClientCreateOrUpdateResponse, error) { + var err error + req, err := client.createOrUpdateCreateRequest(ctx, scope, budgetName, parameters, options) + if err != nil { + return BudgetsClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return BudgetsClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return BudgetsClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *BudgetsClient) createOrUpdateCreateRequest(ctx context.Context, scope string, budgetName string, parameters Budget, options *BudgetsClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/{scope}/providers/Microsoft.CostManagement/budgets/{budgetName}" + urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) + if budgetName == "" { + return nil, errors.New("parameter budgetName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{budgetName}", url.PathEscape(budgetName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-08-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *BudgetsClient) createOrUpdateHandleResponse(resp *http.Response) (BudgetsClientCreateOrUpdateResponse, error) { + result := BudgetsClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Budget); err != nil { + return BudgetsClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - The operation to delete a budget. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-08-01 +// +// - scope - The scope associated with budget operations. +// Supported scopes for CategoryType: Cost +// Azure RBAC Scopes: +// +// - '/subscriptions/{subscriptionId}/' for subscription scope +// +// - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope +// +// - '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope +// +// EA (Enterprise Agreement) Scopes: +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount +// scope +// +// MCA (Modern Customer Agreement) Scopes: +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile +// scope +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' +// for invoiceSection scope +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' for customer scope (CSP only) +// +// Supported scopes for CategoryType: ReservationUtilization +// +// EA (Enterprise Agreement) Scopes: +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account Scope +// +// MCA (Modern Customer Agreement) Scopes: +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile +// scope (non-CSP only) +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' for customer scope (CSP only) +// +// - budgetName - Budget Name. +// +// - options - BudgetsClientDeleteOptions contains the optional parameters for the BudgetsClient.Delete method. +func (client *BudgetsClient) Delete(ctx context.Context, scope string, budgetName string, options *BudgetsClientDeleteOptions) (BudgetsClientDeleteResponse, error) { + var err error + req, err := client.deleteCreateRequest(ctx, scope, budgetName, options) + if err != nil { + return BudgetsClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return BudgetsClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return BudgetsClientDeleteResponse{}, err + } + return BudgetsClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *BudgetsClient) deleteCreateRequest(ctx context.Context, scope string, budgetName string, options *BudgetsClientDeleteOptions) (*policy.Request, error) { + urlPath := "/{scope}/providers/Microsoft.CostManagement/budgets/{budgetName}" + urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) + if budgetName == "" { + return nil, errors.New("parameter budgetName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{budgetName}", url.PathEscape(budgetName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-08-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets the budget for the scope by budget name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-08-01 +// +// - scope - The scope associated with budget operations. +// Supported scopes for CategoryType: Cost +// Azure RBAC Scopes: +// +// - '/subscriptions/{subscriptionId}/' for subscription scope +// +// - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope +// +// - '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope +// +// EA (Enterprise Agreement) Scopes: +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount +// scope +// +// MCA (Modern Customer Agreement) Scopes: +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile +// scope +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' +// for invoiceSection scope +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' for customer scope (CSP only) +// +// Supported scopes for CategoryType: ReservationUtilization +// +// EA (Enterprise Agreement) Scopes: +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account Scope +// +// MCA (Modern Customer Agreement) Scopes: +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile +// scope (non-CSP only) +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' for customer scope (CSP only) +// +// - budgetName - Budget Name. +// +// - options - BudgetsClientGetOptions contains the optional parameters for the BudgetsClient.Get method. +func (client *BudgetsClient) Get(ctx context.Context, scope string, budgetName string, options *BudgetsClientGetOptions) (BudgetsClientGetResponse, error) { + var err error + req, err := client.getCreateRequest(ctx, scope, budgetName, options) + if err != nil { + return BudgetsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return BudgetsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return BudgetsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *BudgetsClient) getCreateRequest(ctx context.Context, scope string, budgetName string, options *BudgetsClientGetOptions) (*policy.Request, error) { + urlPath := "/{scope}/providers/Microsoft.CostManagement/budgets/{budgetName}" + urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) + if budgetName == "" { + return nil, errors.New("parameter budgetName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{budgetName}", url.PathEscape(budgetName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-08-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *BudgetsClient) getHandleResponse(resp *http.Response) (BudgetsClientGetResponse, error) { + result := BudgetsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Budget); err != nil { + return BudgetsClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Lists all budgets for the defined scope. +// +// Generated from API version 2023-08-01 +// +// - scope - The scope associated with budget operations. +// Supported scopes for CategoryType: Cost +// Azure RBAC Scopes: +// +// - '/subscriptions/{subscriptionId}/' for subscription scope +// +// - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope +// +// - '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope +// +// EA (Enterprise Agreement) Scopes: +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount +// scope +// +// MCA (Modern Customer Agreement) Scopes: +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile +// scope +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' +// for invoiceSection scope +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' for customer scope (CSP only) +// +// Supported scopes for CategoryType: ReservationUtilization +// +// EA (Enterprise Agreement) Scopes: +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account Scope +// +// MCA (Modern Customer Agreement) Scopes: +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile +// scope (non-CSP only) +// +// - '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' for customer scope (CSP only) +// +// - options - BudgetsClientListOptions contains the optional parameters for the BudgetsClient.NewListPager method. +func (client *BudgetsClient) NewListPager(scope string, options *BudgetsClientListOptions) *runtime.Pager[BudgetsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[BudgetsClientListResponse]{ + More: func(page BudgetsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *BudgetsClientListResponse) (BudgetsClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, scope, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return BudgetsClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return BudgetsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return BudgetsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *BudgetsClient) listCreateRequest(ctx context.Context, scope string, options *BudgetsClientListOptions) (*policy.Request, error) { + urlPath := "/{scope}/providers/Microsoft.CostManagement/budgets" + urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-08-01") + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *BudgetsClient) listHandleResponse(resp *http.Response) (BudgetsClientListResponse, error) { + result := BudgetsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.BudgetsListResult); err != nil { + return BudgetsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/client_factory.go b/sdk/resourcemanager/costmanagement/armcostmanagement/client_factory.go index f5fd008f8165..e754ecef85cc 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/client_factory.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/client_factory.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armcostmanagement @@ -36,23 +35,28 @@ func NewClientFactory(credential azcore.TokenCredential, options *arm.ClientOpti }, nil } -func (c *ClientFactory) NewOperationsClient() *OperationsClient { - subClient, _ := NewOperationsClient(c.credential, c.options) +func (c *ClientFactory) NewAlertsClient() *AlertsClient { + subClient, _ := NewAlertsClient(c.credential, c.options) return subClient } -func (c *ClientFactory) NewViewsClient() *ViewsClient { - subClient, _ := NewViewsClient(c.credential, c.options) +func (c *ClientFactory) NewBenefitRecommendationsClient() *BenefitRecommendationsClient { + subClient, _ := NewBenefitRecommendationsClient(c.credential, c.options) return subClient } -func (c *ClientFactory) NewAlertsClient() *AlertsClient { - subClient, _ := NewAlertsClient(c.credential, c.options) +func (c *ClientFactory) NewBenefitUtilizationSummariesClient() *BenefitUtilizationSummariesClient { + subClient, _ := NewBenefitUtilizationSummariesClient(c.credential, c.options) return subClient } -func (c *ClientFactory) NewForecastClient() *ForecastClient { - subClient, _ := NewForecastClient(c.credential, c.options) +func (c *ClientFactory) NewBudgetsClient() *BudgetsClient { + subClient, _ := NewBudgetsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewCostAllocationRulesClient() *CostAllocationRulesClient { + subClient, _ := NewCostAllocationRulesClient(c.credential, c.options) return subClient } @@ -61,18 +65,18 @@ func (c *ClientFactory) NewDimensionsClient() *DimensionsClient { return subClient } -func (c *ClientFactory) NewQueryClient() *QueryClient { - subClient, _ := NewQueryClient(c.credential, c.options) +func (c *ClientFactory) NewExportsClient() *ExportsClient { + subClient, _ := NewExportsClient(c.credential, c.options) return subClient } -func (c *ClientFactory) NewGenerateReservationDetailsReportClient() *GenerateReservationDetailsReportClient { - subClient, _ := NewGenerateReservationDetailsReportClient(c.credential, c.options) +func (c *ClientFactory) NewForecastClient() *ForecastClient { + subClient, _ := NewForecastClient(c.credential, c.options) return subClient } -func (c *ClientFactory) NewExportsClient() *ExportsClient { - subClient, _ := NewExportsClient(c.credential, c.options) +func (c *ClientFactory) NewGenerateBenefitUtilizationSummariesReportClient() *GenerateBenefitUtilizationSummariesReportClient { + subClient, _ := NewGenerateBenefitUtilizationSummariesReportClient(c.credential, c.options) return subClient } @@ -96,22 +100,37 @@ func (c *ClientFactory) NewGenerateDetailedCostReportOperationStatusClient() *Ge return subClient } +func (c *ClientFactory) NewGenerateReservationDetailsReportClient() *GenerateReservationDetailsReportClient { + subClient, _ := NewGenerateReservationDetailsReportClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} + func (c *ClientFactory) NewPriceSheetClient() *PriceSheetClient { subClient, _ := NewPriceSheetClient(c.credential, c.options) return subClient } +func (c *ClientFactory) NewQueryClient() *QueryClient { + subClient, _ := NewQueryClient(c.credential, c.options) + return subClient +} + func (c *ClientFactory) NewScheduledActionsClient() *ScheduledActionsClient { subClient, _ := NewScheduledActionsClient(c.credential, c.options) return subClient } -func (c *ClientFactory) NewBenefitRecommendationsClient() *BenefitRecommendationsClient { - subClient, _ := NewBenefitRecommendationsClient(c.credential, c.options) +func (c *ClientFactory) NewSettingsClient() *SettingsClient { + subClient, _ := NewSettingsClient(c.credential, c.options) return subClient } -func (c *ClientFactory) NewBenefitUtilizationSummariesClient() *BenefitUtilizationSummariesClient { - subClient, _ := NewBenefitUtilizationSummariesClient(c.credential, c.options) +func (c *ClientFactory) NewViewsClient() *ViewsClient { + subClient, _ := NewViewsClient(c.credential, c.options) return subClient } diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/constants.go b/sdk/resourcemanager/costmanagement/armcostmanagement/constants.go index 7321602a0d9c..66424b576de3 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/constants.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/constants.go @@ -3,15 +3,14 @@ // 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. +// 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. -// DO NOT EDIT. package armcostmanagement const ( moduleName = "armcostmanagement" - moduleVersion = "v2.0.0" + moduleVersion = "v2.1.0" ) // AccumulatedType - Show costs accumulated over time. @@ -239,6 +238,116 @@ func PossibleBenefitKindValues() []BenefitKind { } } +// BenefitUtilizationSummaryReportSchema - The CSV file from the reportUrl and secondaryReportUrl blob link will consist of +// the following columns of benefit utilization data. UtilizedPercentage will be 0 for savings plans reports and non data +// bricks reservations. Utilization percentages will be 0 for data bricks reservations. +type BenefitUtilizationSummaryReportSchema string + +const ( + BenefitUtilizationSummaryReportSchemaAvgUtilizationPercentage BenefitUtilizationSummaryReportSchema = "AvgUtilizationPercentage" + BenefitUtilizationSummaryReportSchemaBenefitID BenefitUtilizationSummaryReportSchema = "BenefitId" + BenefitUtilizationSummaryReportSchemaBenefitOrderID BenefitUtilizationSummaryReportSchema = "BenefitOrderId" + BenefitUtilizationSummaryReportSchemaBenefitType BenefitUtilizationSummaryReportSchema = "BenefitType" + BenefitUtilizationSummaryReportSchemaKind BenefitUtilizationSummaryReportSchema = "Kind" + BenefitUtilizationSummaryReportSchemaMaxUtilizationPercentage BenefitUtilizationSummaryReportSchema = "MaxUtilizationPercentage" + BenefitUtilizationSummaryReportSchemaMinUtilizationPercentage BenefitUtilizationSummaryReportSchema = "MinUtilizationPercentage" + BenefitUtilizationSummaryReportSchemaUsageDate BenefitUtilizationSummaryReportSchema = "UsageDate" + BenefitUtilizationSummaryReportSchemaUtilizedPercentage BenefitUtilizationSummaryReportSchema = "UtilizedPercentage" +) + +// PossibleBenefitUtilizationSummaryReportSchemaValues returns the possible values for the BenefitUtilizationSummaryReportSchema const type. +func PossibleBenefitUtilizationSummaryReportSchemaValues() []BenefitUtilizationSummaryReportSchema { + return []BenefitUtilizationSummaryReportSchema{ + BenefitUtilizationSummaryReportSchemaAvgUtilizationPercentage, + BenefitUtilizationSummaryReportSchemaBenefitID, + BenefitUtilizationSummaryReportSchemaBenefitOrderID, + BenefitUtilizationSummaryReportSchemaBenefitType, + BenefitUtilizationSummaryReportSchemaKind, + BenefitUtilizationSummaryReportSchemaMaxUtilizationPercentage, + BenefitUtilizationSummaryReportSchemaMinUtilizationPercentage, + BenefitUtilizationSummaryReportSchemaUsageDate, + BenefitUtilizationSummaryReportSchemaUtilizedPercentage, + } +} + +// BudgetNotificationOperatorType - The comparison operator. +// Supported for CategoryType(s): Cost, ReservationUtilization. +// Supported operators for CategoryType: Cost +// * GreaterThan +// +// * GreaterThanOrEqualTo +// +// Supported operators for CategoryType: ReservationUtilization +// +// * LessThan +type BudgetNotificationOperatorType string + +const ( + // BudgetNotificationOperatorTypeEqualTo - Notification will be triggered if the evaluated cost is the same as threshold value. + // Note: It’s not recommended to use this OperatorType as there’s low chance of cost being exactly the same as threshold value, + // leading to missing of your alert. This OperatorType will be deprecated in future. + // Supported for CategoryType(s): Cost. + BudgetNotificationOperatorTypeEqualTo BudgetNotificationOperatorType = "EqualTo" + // BudgetNotificationOperatorTypeGreaterThan - Notification will be triggered if the evaluated cost is greater than the threshold + // value. Note: This is the recommended OperatorType while configuring Budget Alert. + // Supported for CategoryType(s): Cost. + BudgetNotificationOperatorTypeGreaterThan BudgetNotificationOperatorType = "GreaterThan" + // BudgetNotificationOperatorTypeGreaterThanOrEqualTo - Notification will be triggered if the evaluated cost is greater than + // or equal to the threshold value. + // Supported for CategoryType(s): Cost. + BudgetNotificationOperatorTypeGreaterThanOrEqualTo BudgetNotificationOperatorType = "GreaterThanOrEqualTo" + // BudgetNotificationOperatorTypeLessThan - Notification will be triggered if any Reservations in the scope of the Reservation + // Utilization Alert Rule have a utilization less than the threshold percentage. + // Supported for CategoryType(s): ReservationUtilization. + BudgetNotificationOperatorTypeLessThan BudgetNotificationOperatorType = "LessThan" +) + +// PossibleBudgetNotificationOperatorTypeValues returns the possible values for the BudgetNotificationOperatorType const type. +func PossibleBudgetNotificationOperatorTypeValues() []BudgetNotificationOperatorType { + return []BudgetNotificationOperatorType{ + BudgetNotificationOperatorTypeEqualTo, + BudgetNotificationOperatorTypeGreaterThan, + BudgetNotificationOperatorTypeGreaterThanOrEqualTo, + BudgetNotificationOperatorTypeLessThan, + } +} + +// BudgetOperatorType - The operator to use for comparison. +type BudgetOperatorType string + +const ( + BudgetOperatorTypeIn BudgetOperatorType = "In" +) + +// PossibleBudgetOperatorTypeValues returns the possible values for the BudgetOperatorType const type. +func PossibleBudgetOperatorTypeValues() []BudgetOperatorType { + return []BudgetOperatorType{ + BudgetOperatorTypeIn, + } +} + +// CategoryType - The category of the budget. +// * 'Cost' defines a Budget. +// * 'ReservationUtilization' defines a Reservation Utilization Alert Rule. +type CategoryType string + +const ( + // CategoryTypeCost - A Budget that evaluates monetary cost of Azure resources against an amount, and alerts based on a configured + // notification threshold. + CategoryTypeCost CategoryType = "Cost" + // CategoryTypeReservationUtilization - An Alert Rule that evaluates the utilization percentage of Azure Reservations, and + // alerts based on a configured notification threshold. + CategoryTypeReservationUtilization CategoryType = "ReservationUtilization" +) + +// PossibleCategoryTypeValues returns the possible values for the CategoryType const type. +func PossibleCategoryTypeValues() []CategoryType { + return []CategoryType{ + CategoryTypeCost, + CategoryTypeReservationUtilization, + } +} + // ChartType - Chart type of the main view in Cost Analysis. Required. type ChartType string @@ -277,6 +386,40 @@ func PossibleCheckNameAvailabilityReasonValues() []CheckNameAvailabilityReason { } } +// CostAllocationPolicyType - Method to use for allocating cost. FixedProportion indicates that cost will be split based on +// specified percentage values. +type CostAllocationPolicyType string + +const ( + CostAllocationPolicyTypeFixedProportion CostAllocationPolicyType = "FixedProportion" +) + +// PossibleCostAllocationPolicyTypeValues returns the possible values for the CostAllocationPolicyType const type. +func PossibleCostAllocationPolicyTypeValues() []CostAllocationPolicyType { + return []CostAllocationPolicyType{ + CostAllocationPolicyTypeFixedProportion, + } +} + +// CostAllocationResourceType - Category of resource to use for allocation. +type CostAllocationResourceType string + +const ( + // CostAllocationResourceTypeDimension - Indicates an Azure dimension such as a subscription id or resource group name is + // being used for allocation. + CostAllocationResourceTypeDimension CostAllocationResourceType = "Dimension" + // CostAllocationResourceTypeTag - Allocates cost based on Azure Tag key value pairs. + CostAllocationResourceTypeTag CostAllocationResourceType = "Tag" +) + +// PossibleCostAllocationResourceTypeValues returns the possible values for the CostAllocationResourceType const type. +func PossibleCostAllocationResourceTypeValues() []CostAllocationResourceType { + return []CostAllocationResourceType{ + CostAllocationResourceTypeDimension, + CostAllocationResourceTypeTag, + } +} + // CostDetailsDataFormat - The data format of the report type CostDetailsDataFormat string @@ -351,6 +494,61 @@ func PossibleCreatedByTypeValues() []CreatedByType { } } +// CultureCode - Language in which the recipient will receive the notification, +// Supported for CategoryType(s): Cost, ReservationUtilization. +type CultureCode string + +const ( + CultureCodeCsCz CultureCode = "cs-cz" + CultureCodeDaDk CultureCode = "da-dk" + CultureCodeDeDe CultureCode = "de-de" + CultureCodeEnGb CultureCode = "en-gb" + CultureCodeEnUs CultureCode = "en-us" + CultureCodeEsEs CultureCode = "es-es" + CultureCodeFrFr CultureCode = "fr-fr" + CultureCodeHuHu CultureCode = "hu-hu" + CultureCodeItIt CultureCode = "it-it" + CultureCodeJaJp CultureCode = "ja-jp" + CultureCodeKoKr CultureCode = "ko-kr" + CultureCodeNbNo CultureCode = "nb-no" + CultureCodeNlNl CultureCode = "nl-nl" + CultureCodePlPl CultureCode = "pl-pl" + CultureCodePtBr CultureCode = "pt-br" + CultureCodePtPt CultureCode = "pt-pt" + CultureCodeRuRu CultureCode = "ru-ru" + CultureCodeSvSe CultureCode = "sv-se" + CultureCodeTrTr CultureCode = "tr-tr" + CultureCodeZhCn CultureCode = "zh-cn" + CultureCodeZhTw CultureCode = "zh-tw" +) + +// PossibleCultureCodeValues returns the possible values for the CultureCode const type. +func PossibleCultureCodeValues() []CultureCode { + return []CultureCode{ + CultureCodeCsCz, + CultureCodeDaDk, + CultureCodeDeDe, + CultureCodeEnGb, + CultureCodeEnUs, + CultureCodeEsEs, + CultureCodeFrFr, + CultureCodeHuHu, + CultureCodeItIt, + CultureCodeJaJp, + CultureCodeKoKr, + CultureCodeNbNo, + CultureCodeNlNl, + CultureCodePlPl, + CultureCodePtBr, + CultureCodePtPt, + CultureCodeRuRu, + CultureCodeSvSe, + CultureCodeTrTr, + CultureCodeZhCn, + CultureCodeZhTw, + } +} + // DaysOfWeek - Days of Week. type DaysOfWeek string @@ -419,7 +617,8 @@ func PossibleExecutionTypeValues() []ExecutionType { } } -// ExportType - The type of the query. +// ExportType - The type of the export. Note that 'Usage' is equivalent to 'ActualCost' and is applicable to exports that +// do not yet provide data for charges or amortization for service reservations. type ExportType string const ( @@ -526,6 +725,31 @@ func PossibleFormatTypeValues() []FormatType { } } +// Frequency - Frequency of a notification. Represents how long the notification will be silent after triggering an alert +// for a threshold breach. If not specified, the frequency will be set by default based on the +// timeGrain (Weekly when timeGrain: Last7Days, Monthly when timeGrain: Last30Days). +// Supported for CategoryType(s): ReservationUtilization. +type Frequency string + +const ( + // FrequencyDaily - After the threshold breaches and an Alert is fired, no further alerts will be sent until the next calendar + // day. + FrequencyDaily Frequency = "Daily" + // FrequencyMonthly - After the threshold breaches and an Alert is fired, no further alerts will be sent for 30 calendar days. + FrequencyMonthly Frequency = "Monthly" + // FrequencyWeekly - After the threshold breaches and an Alert is fired, no further alerts will be sent for 7 calendar days. + FrequencyWeekly Frequency = "Weekly" +) + +// PossibleFrequencyValues returns the possible values for the Frequency const type. +func PossibleFrequencyValues() []Frequency { + return []Frequency{ + FrequencyDaily, + FrequencyMonthly, + FrequencyWeekly, + } +} + // FunctionName - The name of the column to aggregate. type FunctionName string @@ -617,7 +841,7 @@ func PossibleGrainParameterValues() []GrainParameter { } } -// GranularityType - The granularity of rows in the forecast. +// GranularityType - The granularity of rows in the export. Currently only 'Daily' is supported. type GranularityType string const ( @@ -686,10 +910,11 @@ func PossibleMetricTypeValues() []MetricType { } } -// OperationStatusType - The status of the long running operation. +// OperationStatusType - Enum representing the status of an async operation. type OperationStatusType string const ( + OperationStatusTypeComplete OperationStatusType = "Complete" OperationStatusTypeCompleted OperationStatusType = "Completed" OperationStatusTypeFailed OperationStatusType = "Failed" OperationStatusTypeRunning OperationStatusType = "Running" @@ -698,6 +923,7 @@ const ( // PossibleOperationStatusTypeValues returns the possible values for the OperationStatusType const type. func PossibleOperationStatusTypeValues() []OperationStatusType { return []OperationStatusType{ + OperationStatusTypeComplete, OperationStatusTypeCompleted, OperationStatusTypeFailed, OperationStatusTypeRunning, @@ -787,6 +1013,24 @@ func PossibleQueryOperatorTypeValues() []QueryOperatorType { } } +// Reason - The reason this name is not available. +type Reason string + +const ( + ReasonAlreadyExists Reason = "AlreadyExists" + ReasonInvalid Reason = "Invalid" + ReasonValid Reason = "Valid" +) + +// PossibleReasonValues returns the possible values for the Reason const type. +func PossibleReasonValues() []Reason { + return []Reason{ + ReasonAlreadyExists, + ReasonInvalid, + ReasonValid, + } +} + // RecurrenceType - The schedule recurrence. type RecurrenceType string @@ -936,6 +1180,28 @@ func PossibleReservationReportSchemaValues() []ReservationReportSchema { } } +// RuleStatus - Current status of the rule. +type RuleStatus string + +const ( + // RuleStatusActive - Rule is saved and impacting cost allocation. + RuleStatusActive RuleStatus = "Active" + // RuleStatusNotActive - Rule is saved but not used to allocate costs. + RuleStatusNotActive RuleStatus = "NotActive" + // RuleStatusProcessing - Rule is saved and cost allocation is being updated. Readonly value that cannot be submitted in a + // put request. + RuleStatusProcessing RuleStatus = "Processing" +) + +// PossibleRuleStatusValues returns the possible values for the RuleStatus const type. +func PossibleRuleStatusValues() []RuleStatus { + return []RuleStatus{ + RuleStatusActive, + RuleStatusNotActive, + RuleStatusProcessing, + } +} + // ScheduleFrequency - Frequency of the schedule. type ScheduleFrequency string @@ -1015,6 +1281,35 @@ func PossibleScopeValues() []Scope { } } +type SettingType string + +const ( + // SettingTypeTaginheritance - This setting applies, all the resource group and subscription tags to usage data of child resources. + // Inherited tags will be seen within 24 hours for the current month's usage data. + SettingTypeTaginheritance SettingType = "taginheritance" +) + +// PossibleSettingTypeValues returns the possible values for the SettingType const type. +func PossibleSettingTypeValues() []SettingType { + return []SettingType{ + SettingTypeTaginheritance, + } +} + +// SettingsKind - Specifies the kind of settings. +type SettingsKind string + +const ( + SettingsKindTaginheritance SettingsKind = "taginheritance" +) + +// PossibleSettingsKindValues returns the possible values for the SettingsKind const type. +func PossibleSettingsKindValues() []SettingsKind { + return []SettingsKind{ + SettingsKindTaginheritance, + } +} + // StatusType - The status of the export's schedule. If 'Inactive', the export's schedule is paused. type StatusType string @@ -1031,6 +1326,22 @@ func PossibleStatusTypeValues() []StatusType { } } +// SystemAssignedServiceIdentityType - Type of managed service identity (either system assigned, or none). +type SystemAssignedServiceIdentityType string + +const ( + SystemAssignedServiceIdentityTypeNone SystemAssignedServiceIdentityType = "None" + SystemAssignedServiceIdentityTypeSystemAssigned SystemAssignedServiceIdentityType = "SystemAssigned" +) + +// PossibleSystemAssignedServiceIdentityTypeValues returns the possible values for the SystemAssignedServiceIdentityType const type. +func PossibleSystemAssignedServiceIdentityTypeValues() []SystemAssignedServiceIdentityType { + return []SystemAssignedServiceIdentityType{ + SystemAssignedServiceIdentityTypeNone, + SystemAssignedServiceIdentityTypeSystemAssigned, + } +} + // Term - Grain which corresponds to value. type Term string @@ -1049,7 +1360,96 @@ func PossibleTermValues() []Term { } } -// TimeframeType - The time frame for pulling data for the query. If custom, then a specific time period must be provided. +// ThresholdType - The type of threshold. +// Supported for CategoryType(s): Cost. +type ThresholdType string + +const ( + // ThresholdTypeActual - Actual costs budget alerts notify when the actual accrued cost exceeds the allocated budget. + ThresholdTypeActual ThresholdType = "Actual" + // ThresholdTypeForecasted - Forecasted costs budget alerts provide advanced notification that your spending trends are likely + // to exceed your allocated budget, as it relies on forecasted cost predictions. + ThresholdTypeForecasted ThresholdType = "Forecasted" +) + +// PossibleThresholdTypeValues returns the possible values for the ThresholdType const type. +func PossibleThresholdTypeValues() []ThresholdType { + return []ThresholdType{ + ThresholdTypeActual, + ThresholdTypeForecasted, + } +} + +// TimeGrainType - The time covered by a budget. Tracking of the amount will be reset based on the time grain. +// Supported for CategoryType(s): Cost, ReservationUtilization. +// Supported timeGrainTypes for CategoryType: Cost +// * Monthly +// +// * Quarterly +// +// * Annually +// +// * BillingMonth* +// +// * BillingQuarter* +// +// * BillingAnnual* +// +// *only supported for Web Direct customers. +// +// Supported timeGrainTypes for CategoryType: ReservationUtilization +// +// * Last7Days +// +// * Last30Days +// +// Required for CategoryType(s): Cost, ReservationUtilization. +type TimeGrainType string + +const ( + // TimeGrainTypeAnnually - The budget will track costs in the current calendar year against the amount. + // Supported for CategoryType: Cost only. + TimeGrainTypeAnnually TimeGrainType = "Annually" + // TimeGrainTypeBillingAnnual - The budget will track costs in the current billing year against the amount. + // Supported for CategoryType: Cost and Web Direct customers only. + TimeGrainTypeBillingAnnual TimeGrainType = "BillingAnnual" + // TimeGrainTypeBillingMonth - The budget will track costs in the current billing month against the amount. + // Supported for CategoryType: Cost and Web Direct customers only. + TimeGrainTypeBillingMonth TimeGrainType = "BillingMonth" + // TimeGrainTypeBillingQuarter - The budget will track costs in the current billing quarter against the amount. + // Supported for CategoryType: Cost and Web Direct customers only. + TimeGrainTypeBillingQuarter TimeGrainType = "BillingQuarter" + // TimeGrainTypeLast30Days - The Reservation Utilization Alert Rule will evaluate reservations based on their 30-Day utilization + // percentage. + // Supported for CategoryType: ReservationUtilization only. + TimeGrainTypeLast30Days TimeGrainType = "Last30Days" + // TimeGrainTypeLast7Days - The Reservation Utilization Alert Rule will evaluate reservations based on their 7-Day utilization + // percentage. + // Supported for CategoryType: ReservationUtilization only. + TimeGrainTypeLast7Days TimeGrainType = "Last7Days" + // TimeGrainTypeMonthly - The budget will track costs in the current calendar month against the amount. + // Supported for CategoryType: Cost only. + TimeGrainTypeMonthly TimeGrainType = "Monthly" + // TimeGrainTypeQuarterly - The budget will track costs in the current calendar quarter against the amount. + // Supported for CategoryType: Cost only. + TimeGrainTypeQuarterly TimeGrainType = "Quarterly" +) + +// PossibleTimeGrainTypeValues returns the possible values for the TimeGrainType const type. +func PossibleTimeGrainTypeValues() []TimeGrainType { + return []TimeGrainType{ + TimeGrainTypeAnnually, + TimeGrainTypeBillingAnnual, + TimeGrainTypeBillingMonth, + TimeGrainTypeBillingQuarter, + TimeGrainTypeLast30Days, + TimeGrainTypeLast7Days, + TimeGrainTypeMonthly, + TimeGrainTypeQuarterly, + } +} + +// TimeframeType - The time frame for pulling data for the export. If custom, then a specific time period must be provided. type TimeframeType string const ( diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/costallocationrules_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/costallocationrules_client.go new file mode 100644 index 000000000000..9f1e3c26d5c0 --- /dev/null +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/costallocationrules_client.go @@ -0,0 +1,326 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armcostmanagement + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// CostAllocationRulesClient contains the methods for the CostAllocationRules group. +// Don't use this type directly, use NewCostAllocationRulesClient() instead. +type CostAllocationRulesClient struct { + internal *arm.Client +} + +// NewCostAllocationRulesClient creates a new instance of CostAllocationRulesClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewCostAllocationRulesClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*CostAllocationRulesClient, error) { + cl, err := arm.NewClient(moduleName+".CostAllocationRulesClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &CostAllocationRulesClient{ + internal: cl, + } + return client, nil +} + +// CheckNameAvailability - Checks availability and correctness of a name for a cost allocation rule +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-08-01 +// - billingAccountID - BillingAccount ID +// - costAllocationRuleCheckNameAvailabilityRequest - Cost allocation rule to be created or updated +// - options - CostAllocationRulesClientCheckNameAvailabilityOptions contains the optional parameters for the CostAllocationRulesClient.CheckNameAvailability +// method. +func (client *CostAllocationRulesClient) CheckNameAvailability(ctx context.Context, billingAccountID string, costAllocationRuleCheckNameAvailabilityRequest CostAllocationRuleCheckNameAvailabilityRequest, options *CostAllocationRulesClientCheckNameAvailabilityOptions) (CostAllocationRulesClientCheckNameAvailabilityResponse, error) { + var err error + req, err := client.checkNameAvailabilityCreateRequest(ctx, billingAccountID, costAllocationRuleCheckNameAvailabilityRequest, options) + if err != nil { + return CostAllocationRulesClientCheckNameAvailabilityResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return CostAllocationRulesClientCheckNameAvailabilityResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return CostAllocationRulesClientCheckNameAvailabilityResponse{}, err + } + resp, err := client.checkNameAvailabilityHandleResponse(httpResp) + return resp, err +} + +// checkNameAvailabilityCreateRequest creates the CheckNameAvailability request. +func (client *CostAllocationRulesClient) checkNameAvailabilityCreateRequest(ctx context.Context, billingAccountID string, costAllocationRuleCheckNameAvailabilityRequest CostAllocationRuleCheckNameAvailabilityRequest, options *CostAllocationRulesClientCheckNameAvailabilityOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.CostManagement/costAllocationRules/checkNameAvailability" + if billingAccountID == "" { + return nil, errors.New("parameter billingAccountID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountId}", url.PathEscape(billingAccountID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-08-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, costAllocationRuleCheckNameAvailabilityRequest); err != nil { + return nil, err + } + return req, nil +} + +// checkNameAvailabilityHandleResponse handles the CheckNameAvailability response. +func (client *CostAllocationRulesClient) checkNameAvailabilityHandleResponse(resp *http.Response) (CostAllocationRulesClientCheckNameAvailabilityResponse, error) { + result := CostAllocationRulesClientCheckNameAvailabilityResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CostAllocationRuleCheckNameAvailabilityResponse); err != nil { + return CostAllocationRulesClientCheckNameAvailabilityResponse{}, err + } + return result, nil +} + +// CreateOrUpdate - Create/Update a rule to allocate cost between different resources within a billing account or enterprise +// enrollment. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-08-01 +// - billingAccountID - BillingAccount ID +// - ruleName - Cost allocation rule name. The name cannot include spaces or any non alphanumeric characters other than '_' +// and '-'. The max length is 260 characters. +// - costAllocationRule - Cost allocation rule to be created or updated +// - options - CostAllocationRulesClientCreateOrUpdateOptions contains the optional parameters for the CostAllocationRulesClient.CreateOrUpdate +// method. +func (client *CostAllocationRulesClient) CreateOrUpdate(ctx context.Context, billingAccountID string, ruleName string, costAllocationRule CostAllocationRuleDefinition, options *CostAllocationRulesClientCreateOrUpdateOptions) (CostAllocationRulesClientCreateOrUpdateResponse, error) { + var err error + req, err := client.createOrUpdateCreateRequest(ctx, billingAccountID, ruleName, costAllocationRule, options) + if err != nil { + return CostAllocationRulesClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return CostAllocationRulesClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return CostAllocationRulesClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *CostAllocationRulesClient) createOrUpdateCreateRequest(ctx context.Context, billingAccountID string, ruleName string, costAllocationRule CostAllocationRuleDefinition, options *CostAllocationRulesClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.CostManagement/costAllocationRules/{ruleName}" + if billingAccountID == "" { + return nil, errors.New("parameter billingAccountID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountId}", url.PathEscape(billingAccountID)) + if ruleName == "" { + return nil, errors.New("parameter ruleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{ruleName}", url.PathEscape(ruleName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-08-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, costAllocationRule); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *CostAllocationRulesClient) createOrUpdateHandleResponse(resp *http.Response) (CostAllocationRulesClientCreateOrUpdateResponse, error) { + result := CostAllocationRulesClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CostAllocationRuleDefinition); err != nil { + return CostAllocationRulesClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Delete cost allocation rule for billing account or enterprise enrollment. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-08-01 +// - billingAccountID - BillingAccount ID +// - ruleName - Cost allocation rule name. The name cannot include spaces or any non alphanumeric characters other than '_' +// and '-'. The max length is 260 characters. +// - options - CostAllocationRulesClientDeleteOptions contains the optional parameters for the CostAllocationRulesClient.Delete +// method. +func (client *CostAllocationRulesClient) Delete(ctx context.Context, billingAccountID string, ruleName string, options *CostAllocationRulesClientDeleteOptions) (CostAllocationRulesClientDeleteResponse, error) { + var err error + req, err := client.deleteCreateRequest(ctx, billingAccountID, ruleName, options) + if err != nil { + return CostAllocationRulesClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return CostAllocationRulesClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return CostAllocationRulesClientDeleteResponse{}, err + } + return CostAllocationRulesClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *CostAllocationRulesClient) deleteCreateRequest(ctx context.Context, billingAccountID string, ruleName string, options *CostAllocationRulesClientDeleteOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.CostManagement/costAllocationRules/{ruleName}" + if billingAccountID == "" { + return nil, errors.New("parameter billingAccountID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountId}", url.PathEscape(billingAccountID)) + if ruleName == "" { + return nil, errors.New("parameter ruleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{ruleName}", url.PathEscape(ruleName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-08-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get a cost allocation rule by rule name and billing account or enterprise enrollment. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-08-01 +// - billingAccountID - BillingAccount ID +// - ruleName - Cost allocation rule name. The name cannot include spaces or any non alphanumeric characters other than '_' +// and '-'. The max length is 260 characters. +// - options - CostAllocationRulesClientGetOptions contains the optional parameters for the CostAllocationRulesClient.Get method. +func (client *CostAllocationRulesClient) Get(ctx context.Context, billingAccountID string, ruleName string, options *CostAllocationRulesClientGetOptions) (CostAllocationRulesClientGetResponse, error) { + var err error + req, err := client.getCreateRequest(ctx, billingAccountID, ruleName, options) + if err != nil { + return CostAllocationRulesClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return CostAllocationRulesClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return CostAllocationRulesClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *CostAllocationRulesClient) getCreateRequest(ctx context.Context, billingAccountID string, ruleName string, options *CostAllocationRulesClientGetOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.CostManagement/costAllocationRules/{ruleName}" + if billingAccountID == "" { + return nil, errors.New("parameter billingAccountID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountId}", url.PathEscape(billingAccountID)) + if ruleName == "" { + return nil, errors.New("parameter ruleName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{ruleName}", url.PathEscape(ruleName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-08-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *CostAllocationRulesClient) getHandleResponse(resp *http.Response) (CostAllocationRulesClientGetResponse, error) { + result := CostAllocationRulesClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CostAllocationRuleDefinition); err != nil { + return CostAllocationRulesClientGetResponse{}, err + } + return result, nil +} + +// NewListPager - Get the list of all cost allocation rules for a billing account or enterprise enrollment. +// +// Generated from API version 2023-08-01 +// - billingAccountID - BillingAccount ID +// - options - CostAllocationRulesClientListOptions contains the optional parameters for the CostAllocationRulesClient.NewListPager +// method. +func (client *CostAllocationRulesClient) NewListPager(billingAccountID string, options *CostAllocationRulesClientListOptions) *runtime.Pager[CostAllocationRulesClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[CostAllocationRulesClientListResponse]{ + More: func(page CostAllocationRulesClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *CostAllocationRulesClientListResponse) (CostAllocationRulesClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, billingAccountID, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return CostAllocationRulesClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return CostAllocationRulesClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return CostAllocationRulesClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *CostAllocationRulesClient) listCreateRequest(ctx context.Context, billingAccountID string, options *CostAllocationRulesClientListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.CostManagement/costAllocationRules" + if billingAccountID == "" { + return nil, errors.New("parameter billingAccountID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountId}", url.PathEscape(billingAccountID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-08-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *CostAllocationRulesClient) listHandleResponse(resp *http.Response) (CostAllocationRulesClientListResponse, error) { + result := CostAllocationRulesClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CostAllocationRuleList); err != nil { + return CostAllocationRulesClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/dimensions_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/dimensions_client.go index f23b4810665d..386026709f66 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/dimensions_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/dimensions_client.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armcostmanagement @@ -44,7 +43,7 @@ func NewDimensionsClient(credential azcore.TokenCredential, options *arm.ClientO // NewByExternalCloudProviderTypePager - Lists the dimensions by the external cloud provider type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - externalCloudProviderType - The external cloud provider type associated with dimension/query operations. This includes // 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account. // - externalCloudProviderID - This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' for @@ -89,7 +88,7 @@ func (client *DimensionsClient) byExternalCloudProviderTypeCreateRequest(ctx con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } @@ -118,7 +117,7 @@ func (client *DimensionsClient) byExternalCloudProviderTypeHandleResponse(resp * // NewListPager - Lists the dimensions by the defined scope. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - scope - The scope associated with dimension operations. This includes '/subscriptions/{subscriptionId}/' for subscription // scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for // resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, @@ -161,7 +160,7 @@ func (client *DimensionsClient) listCreateRequest(ctx context.Context, scope str return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/dimensions_client_example_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/dimensions_client_example_test.go deleted file mode 100644 index 6f134368a257..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/dimensions_client_example_test.go +++ /dev/null @@ -1,1822 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armcostmanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BillingAccountDimensionsList.json -func ExampleDimensionsClient_NewListPager_billingAccountDimensionsListLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/100", &armcostmanagement.DimensionsClientListOptions{Filter: nil, - Expand: nil, - Skiptoken: nil, - Top: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceGroup_2018-05-01_2018-05-31"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/100/providers/microsoft.CostManagement/dimensions_ResourceGroup_2018-05-01_2018-05-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource group"), - // Category: to.Ptr("ResourceGroup"), - // Data: []*string{ - // to.Ptr("thoroetrg01"), - // to.Ptr("default-notificationhubs-westus"), - // to.Ptr("jedikeyvaultrg"), - // to.Ptr("contosocodeflow8d4a"), - // to.Ptr("noobaa")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](377), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-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"), - // 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}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCABillingAccountDimensionsList.json -func ExampleDimensionsClient_NewListPager_billingAccountDimensionsListMca() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345:6789", &armcostmanagement.DimensionsClientListOptions{Filter: nil, - Expand: nil, - Skiptoken: nil, - Top: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceGroup_2019-10-01_2019-10-31"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/providers/microsoft.CostManagement/dimensions_ResourceGroup_2019-10-01_2019-10-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource group"), - // Category: to.Ptr("ResourceGroup"), - // Data: []*string{ - // }, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](377), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-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/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}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BillingAccountDimensionsListExpandAndTop.json -func ExampleDimensionsClient_NewListPager_billingAccountDimensionsListExpandAndTopLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/100", &armcostmanagement.DimensionsClientListOptions{Filter: nil, - Expand: to.Ptr("properties/data"), - Skiptoken: nil, - Top: to.Ptr[int32](5), - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceGroup_2018-05-01_2018-05-31_5"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/100/providers/microsoft.CostManagement/dimensions_ResourceGroup_2018-05-01_2018-05-31_5"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource group"), - // Category: to.Ptr("ResourceGroup"), - // Data: []*string{ - // to.Ptr("thoroetrg01"), - // to.Ptr("default-notificationhubs-westus"), - // to.Ptr("jedikeyvaultrg"), - // to.Ptr("contosocodeflow8d4a"), - // to.Ptr("noobaa")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](377), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-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"), - // 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/MCABillingAccountDimensionsListExpandAndTop.json -func ExampleDimensionsClient_NewListPager_billingAccountDimensionsListExpandAndTopMca() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345:6789", &armcostmanagement.DimensionsClientListOptions{Filter: nil, - Expand: to.Ptr("properties/data"), - Skiptoken: nil, - Top: to.Ptr[int32](5), - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceGroup_2019-10-01_2019-10-31"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/providers/microsoft.CostManagement/dimensions_ResourceGroup_2019-10-01_2019-10-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource group"), - // Category: to.Ptr("ResourceGroup"), - // Data: []*string{ - // to.Ptr("thoroetrg01"), - // to.Ptr("default-notificationhubs-westus"), - // to.Ptr("jedikeyvaultrg"), - // to.Ptr("contosocodeflow8d4a"), - // to.Ptr("noobaa")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](377), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-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/providers/microsoft.CostManagement/dimensions_ResourceType_2019-10-01_2019-10-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource type"), - // Category: to.Ptr("ResourceType"), - // Data: []*string{ - // to.Ptr("microsoft.automation/automationaccounts"), - // to.Ptr("microsoft.databricks/workspaces"), - // to.Ptr("microsoft.dbformysql/servers"), - // to.Ptr("microsoft.containerregistry/registries"), - // to.Ptr("microsoft.search/searchservices")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](37), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-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/BillingAccountDimensionsListWithFilter.json -func ExampleDimensionsClient_NewListPager_billingAccountDimensionsListWithFilterLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/100", &armcostmanagement.DimensionsClientListOptions{Filter: to.Ptr("properties/category eq 'resourceId'"), - Expand: to.Ptr("properties/data"), - Skiptoken: nil, - Top: to.Ptr[int32](5), - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceId_2018-05-01_2018-05-31_5"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/100/providers/microsoft.CostManagement/dimensions_ResourceId_2018-05-01_2018-05-31_5"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource Id"), - // Category: to.Ptr("ResourceId"), - // Data: []*string{ - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/system.orlando/providers/microsoft.storage/storageaccounts/urphealthaccount"), - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/system.orlando/providers/microsoft.storage/storageaccounts/srphytenaccount"), - // to.Ptr("/subscriptions/67e24f6b-1ec2-4c90-993a-dc2d25b00b6c/resourcegroups/defaultresourcegroup-eus/providers/microsoft.operationalinsights/workspaces/defaultworkspace-67e24f6b-1ec2-4c90-993a-dc2d25b00b6c-eus"), - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg-sql-ha/providers/microsoft.compute/virtualmachines/sql-4qqp1"), - // to.Ptr("/subscriptions/a98d6dc5-eb8f-46cf-8938-f1fb08f03706/resourcegroups/databricks-rg-testwsp-xijmsdubneexm/providers/microsoft.compute/disks/488cdb42bf74474a98075415be3f806c-containerrootvolume")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](1409), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-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() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345:6789", &armcostmanagement.DimensionsClientListOptions{Filter: to.Ptr("properties/category eq 'resourceId'"), - Expand: to.Ptr("properties/data"), - Skiptoken: nil, - Top: to.Ptr[int32](5), - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceId_2019-10-01_2019-10-31"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/providers/microsoft.CostManagement/dimensions_ResourceId_2019-10-01_2019-10-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource Id"), - // Category: to.Ptr("ResourceId"), - // Data: []*string{ - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/system.orlando/providers/microsoft.storage/storageaccounts/urphealthaccount"), - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/system.orlando/providers/microsoft.storage/storageaccounts/srphytenaccount"), - // to.Ptr("/subscriptions/67e24f6b-1ec2-4c90-993a-dc2d25b00b6c/resourcegroups/defaultresourcegroup-eus/providers/microsoft.operationalinsights/workspaces/defaultworkspace-67e24f6b-1ec2-4c90-993a-dc2d25b00b6c-eus"), - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg-sql-ha/providers/microsoft.compute/virtualmachines/sql-4qqp1"), - // to.Ptr("/subscriptions/a98d6dc5-eb8f-46cf-8938-f1fb08f03706/resourcegroups/databricks-rg-testwsp-xijmsdubneexm/providers/microsoft.compute/disks/488cdb42bf74474a98075415be3f806c-containerrootvolume")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](1409), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-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/MCABillingProfileDimensionsList.json -func ExampleDimensionsClient_NewListPager_billingProfileDimensionsListMca() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579", &armcostmanagement.DimensionsClientListOptions{Filter: nil, - Expand: nil, - Skiptoken: nil, - Top: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceGroup_2019-10-01_2019-10-31"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/providers/microsoft.CostManagement/dimensions_ResourceGroup_2019-10-01_2019-10-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource group"), - // Category: to.Ptr("ResourceGroup"), - // Data: []*string{ - // }, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](377), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-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/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}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCABillingProfileDimensionsListExpandAndTop.json -func ExampleDimensionsClient_NewListPager_billingProfileDimensionsListExpandAndTopMca() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579", &armcostmanagement.DimensionsClientListOptions{Filter: nil, - Expand: to.Ptr("properties/data"), - Skiptoken: nil, - Top: to.Ptr[int32](5), - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceGroup_2019-10-01_2019-10-31"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/providers/microsoft.CostManagement/dimensions_ResourceGroup_2019-10-01_2019-10-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource group"), - // Category: to.Ptr("ResourceGroup"), - // Data: []*string{ - // to.Ptr("thoroetrg01"), - // to.Ptr("default-notificationhubs-westus"), - // to.Ptr("jedikeyvaultrg"), - // to.Ptr("contosocodeflow8d4a"), - // to.Ptr("noobaa")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](377), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-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/providers/microsoft.CostManagement/dimensions_ResourceType_2019-10-01_2019-10-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource type"), - // Category: to.Ptr("ResourceType"), - // Data: []*string{ - // to.Ptr("microsoft.automation/automationaccounts"), - // to.Ptr("microsoft.databricks/workspaces"), - // to.Ptr("microsoft.dbformysql/servers"), - // to.Ptr("microsoft.containerregistry/registries"), - // to.Ptr("microsoft.search/searchservices")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](37), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-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/MCABillingProfileDimensionsListWithFilter.json -func ExampleDimensionsClient_NewListPager_billingProfileDimensionsListWithFilterMca() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579", &armcostmanagement.DimensionsClientListOptions{Filter: to.Ptr("properties/category eq 'resourceId'"), - Expand: to.Ptr("properties/data"), - Skiptoken: nil, - Top: to.Ptr[int32](5), - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceId_2019-10-01_2019-10-31"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/providers/microsoft.CostManagement/dimensions_ResourceId_2019-10-01_2019-10-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource Id"), - // Category: to.Ptr("ResourceId"), - // Data: []*string{ - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/system.orlando/providers/microsoft.storage/storageaccounts/urphealthaccount"), - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/system.orlando/providers/microsoft.storage/storageaccounts/srphytenaccount"), - // to.Ptr("/subscriptions/67e24f6b-1ec2-4c90-993a-dc2d25b00b6c/resourcegroups/defaultresourcegroup-eus/providers/microsoft.operationalinsights/workspaces/defaultworkspace-67e24f6b-1ec2-4c90-993a-dc2d25b00b6c-eus"), - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg-sql-ha/providers/microsoft.compute/virtualmachines/sql-4qqp1"), - // to.Ptr("/subscriptions/a98d6dc5-eb8f-46cf-8938-f1fb08f03706/resourcegroups/databricks-rg-testwsp-xijmsdubneexm/providers/microsoft.compute/disks/488cdb42bf74474a98075415be3f806c-containerrootvolume")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](1409), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-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/MCACustomerDimensionsList.json -func ExampleDimensionsClient_NewListPager_customerDimensionsListMca() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678", &armcostmanagement.DimensionsClientListOptions{Filter: nil, - Expand: nil, - Skiptoken: nil, - Top: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceGroup_2019-10-01_2019-10-31"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678/providers/microsoft.CostManagement/dimensions_ResourceGroup_2019-10-01_2019-10-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource group"), - // Category: to.Ptr("ResourceGroup"), - // Data: []*string{ - // }, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](377), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-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"), - // 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}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCACustomerDimensionsListExpandAndTop.json -func ExampleDimensionsClient_NewListPager_customerDimensionsListExpandAndTopMca() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678", &armcostmanagement.DimensionsClientListOptions{Filter: nil, - Expand: to.Ptr("properties/data"), - Skiptoken: nil, - Top: to.Ptr[int32](5), - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceGroup_2019-10-01_2019-10-31"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678/providers/microsoft.CostManagement/dimensions_ResourceGroup_2019-10-01_2019-10-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource group"), - // Category: to.Ptr("ResourceGroup"), - // Data: []*string{ - // to.Ptr("thoroetrg01"), - // to.Ptr("default-notificationhubs-westus"), - // to.Ptr("jedikeyvaultrg"), - // to.Ptr("contosocodeflow8d4a"), - // to.Ptr("noobaa")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](377), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-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"), - // 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-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() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678", &armcostmanagement.DimensionsClientListOptions{Filter: to.Ptr("properties/category eq 'resourceId'"), - Expand: to.Ptr("properties/data"), - Skiptoken: nil, - Top: to.Ptr[int32](5), - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceId_2019-10-01_2019-10-31"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678/providers/microsoft.CostManagement/dimensions_ResourceId_2019-10-01_2019-10-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource Id"), - // Category: to.Ptr("ResourceId"), - // Data: []*string{ - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/system.orlando/providers/microsoft.storage/storageaccounts/urphealthaccount"), - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/system.orlando/providers/microsoft.storage/storageaccounts/srphytenaccount"), - // to.Ptr("/subscriptions/67e24f6b-1ec2-4c90-993a-dc2d25b00b6c/resourcegroups/defaultresourcegroup-eus/providers/microsoft.operationalinsights/workspaces/defaultworkspace-67e24f6b-1ec2-4c90-993a-dc2d25b00b6c-eus"), - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg-sql-ha/providers/microsoft.compute/virtualmachines/sql-4qqp1"), - // to.Ptr("/subscriptions/a98d6dc5-eb8f-46cf-8938-f1fb08f03706/resourcegroups/databricks-rg-testwsp-xijmsdubneexm/providers/microsoft.compute/disks/488cdb42bf74474a98075415be3f806c-containerrootvolume")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](1409), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-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() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/100/departments/123", &armcostmanagement.DimensionsClientListOptions{Filter: nil, - Expand: nil, - Skiptoken: nil, - Top: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceGroup_2018-05-01_2018-05-31"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/100/departments/123/providers/microsoft.CostManagement/dimensions_ResourceGroup_2018-05-01_2018-05-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource group"), - // Category: to.Ptr("ResourceGroup"), - // Data: []*string{ - // to.Ptr("thoroetrg01"), - // to.Ptr("default-notificationhubs-westus"), - // to.Ptr("jedikeyvaultrg"), - // to.Ptr("contosocodeflow8d4a"), - // to.Ptr("noobaa")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](377), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-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"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/100/departments/123/providers/microsoft.CostManagement/dimensions_ResourceType_2018-05-01_2018-05-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource type"), - // Category: to.Ptr("ResourceType"), - // Data: []*string{ - // to.Ptr("thoroetrg01"), - // to.Ptr("default-notificationhubs-westus"), - // to.Ptr("jedikeyvaultrg"), - // to.Ptr("contosocodeflow8d4a"), - // to.Ptr("noobaa")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](37), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-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/DepartmentDimensionsListExpandAndTop.json -func ExampleDimensionsClient_NewListPager_departmentDimensionsListExpandAndTopLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/100/departments/123", &armcostmanagement.DimensionsClientListOptions{Filter: nil, - Expand: to.Ptr("properties/data"), - Skiptoken: nil, - Top: to.Ptr[int32](5), - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceGroup_2018-05-01_2018-05-31_5"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/100/departments/123/providers/microsoft.CostManagement/dimensions_ResourceGroup_2018-05-01_2018-05-31_5"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource group"), - // Category: to.Ptr("ResourceGroup"), - // Data: []*string{ - // to.Ptr("thoroetrg01"), - // to.Ptr("default-notificationhubs-westus"), - // to.Ptr("jedikeyvaultrg"), - // to.Ptr("contosocodeflow8d4a"), - // to.Ptr("noobaa")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](377), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-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/DepartmentDimensionsListWithFilter.json -func ExampleDimensionsClient_NewListPager_departmentDimensionsListWithFilterLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/100/departments/123", &armcostmanagement.DimensionsClientListOptions{Filter: to.Ptr("properties/category eq 'resourceId'"), - Expand: to.Ptr("properties/data"), - Skiptoken: nil, - Top: to.Ptr[int32](5), - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceId_2018-05-01_2018-05-31_5"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/100/departments/123/providers/microsoft.CostManagement/dimensions_ResourceId_2018-05-01_2018-05-31_5"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource Id"), - // Category: to.Ptr("ResourceId"), - // Data: []*string{ - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/system.orlando/providers/microsoft.storage/storageaccounts/urphealthaccount"), - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/system.orlando/providers/microsoft.storage/storageaccounts/srphytenaccount"), - // to.Ptr("/subscriptions/67e24f6b-1ec2-4c90-993a-dc2d25b00b6c/resourcegroups/defaultresourcegroup-eus/providers/microsoft.operationalinsights/workspaces/defaultworkspace-67e24f6b-1ec2-4c90-993a-dc2d25b00b6c-eus"), - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg-sql-ha/providers/microsoft.compute/virtualmachines/sql-4qqp1"), - // to.Ptr("/subscriptions/a98d6dc5-eb8f-46cf-8938-f1fb08f03706/resourcegroups/databricks-rg-testwsp-xijmsdubneexm/providers/microsoft.compute/disks/488cdb42bf74474a98075415be3f806c-containerrootvolume")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](1409), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-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/EnrollmentAccountDimensionsList.json -func ExampleDimensionsClient_NewListPager_enrollmentAccountDimensionsListLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456", &armcostmanagement.DimensionsClientListOptions{Filter: nil, - Expand: nil, - Skiptoken: nil, - Top: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceGroup_2018-05-01_2018-05-31"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456/providers/microsoft.CostManagement/dimensions_ResourceGroup_2018-05-01_2018-05-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource group"), - // Category: to.Ptr("ResourceGroup"), - // Data: []*string{ - // }, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](377), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-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"), - // 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}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/EnrollmentAccountDimensionsListExpandAndTop.json -func ExampleDimensionsClient_NewListPager_enrollmentAccountDimensionsListExpandAndTopLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456", &armcostmanagement.DimensionsClientListOptions{Filter: nil, - Expand: to.Ptr("properties/data"), - Skiptoken: nil, - Top: to.Ptr[int32](5), - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceGroup_2018-05-01_2018-05-31_5"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456/providers/microsoft.CostManagement/dimensions_ResourceGroup_2018-05-01_2018-05-31_5"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource group"), - // Category: to.Ptr("ResourceGroup"), - // Data: []*string{ - // to.Ptr("thoroetrg01"), - // to.Ptr("default-notificationhubs-westus"), - // to.Ptr("jedikeyvaultrg"), - // to.Ptr("contosocodeflow8d4a"), - // to.Ptr("noobaa")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](377), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-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/enrollmentAccounts/456/providers/microsoft.CostManagement/dimensions_ResourceType_2018-05-01_2018-05-31_5"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource type"), - // Category: to.Ptr("ResourceType"), - // Data: []*string{ - // to.Ptr("microsoft.automation/automationaccounts"), - // to.Ptr("microsoft.databricks/workspaces"), - // to.Ptr("microsoft.dbformysql/servers"), - // to.Ptr("microsoft.containerregistry/registries"), - // to.Ptr("microsoft.search/searchservices")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](37), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-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/EnrollmentAccountDimensionsListWithFilter.json -func ExampleDimensionsClient_NewListPager_enrollmentAccountDimensionsListWithFilterLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456", &armcostmanagement.DimensionsClientListOptions{Filter: to.Ptr("properties/category eq 'resourceId'"), - Expand: to.Ptr("properties/data"), - Skiptoken: nil, - Top: to.Ptr[int32](5), - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceId_2018-05-01_2018-05-31_5"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456/providers/microsoft.CostManagement/dimensions_ResourceId_2018-05-01_2018-05-31_5"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource Id"), - // Category: to.Ptr("ResourceId"), - // Data: []*string{ - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/system.orlando/providers/microsoft.storage/storageaccounts/urphealthaccount"), - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/system.orlando/providers/microsoft.storage/storageaccounts/srphytenaccount"), - // to.Ptr("/subscriptions/67e24f6b-1ec2-4c90-993a-dc2d25b00b6c/resourcegroups/defaultresourcegroup-eus/providers/microsoft.operationalinsights/workspaces/defaultworkspace-67e24f6b-1ec2-4c90-993a-dc2d25b00b6c-eus"), - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg-sql-ha/providers/microsoft.compute/virtualmachines/sql-4qqp1"), - // to.Ptr("/subscriptions/a98d6dc5-eb8f-46cf-8938-f1fb08f03706/resourcegroups/databricks-rg-testwsp-xijmsdubneexm/providers/microsoft.compute/disks/488cdb42bf74474a98075415be3f806c-containerrootvolume")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](1409), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-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/MCAInvoiceSectionDimensionsList.json -func ExampleDimensionsClient_NewListPager_invoiceSectionDimensionsListMca() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876", &armcostmanagement.DimensionsClientListOptions{Filter: nil, - Expand: nil, - Skiptoken: nil, - Top: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceGroup_2019-10-01_2019-10-31"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876/providers/microsoft.CostManagement/dimensions_ResourceGroup_2019-10-01_2019-10-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource group"), - // Category: to.Ptr("ResourceGroup"), - // Data: []*string{ - // }, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](377), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-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"), - // 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}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCAInvoiceSectionDimensionsListExpandAndTop.json -func ExampleDimensionsClient_NewListPager_invoiceSectionDimensionsListExpandAndTopMca() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876", &armcostmanagement.DimensionsClientListOptions{Filter: nil, - Expand: to.Ptr("properties/data"), - Skiptoken: nil, - Top: to.Ptr[int32](5), - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceGroup_2019-10-01_2019-10-31"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876/providers/microsoft.CostManagement/dimensions_ResourceGroup_2019-10-01_2019-10-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource group"), - // Category: to.Ptr("ResourceGroup"), - // Data: []*string{ - // to.Ptr("thoroetrg01"), - // to.Ptr("default-notificationhubs-westus"), - // to.Ptr("jedikeyvaultrg"), - // to.Ptr("contosocodeflow8d4a"), - // to.Ptr("noobaa")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](377), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-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"), - // 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-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 -func ExampleDimensionsClient_NewListPager_invoiceSectionDimensionsListWithFilterMca() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876", &armcostmanagement.DimensionsClientListOptions{Filter: to.Ptr("properties/category eq 'resourceId'"), - Expand: to.Ptr("properties/data"), - Skiptoken: nil, - Top: to.Ptr[int32](5), - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceId_2019-10-01_2019-10-31"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876/providers/microsoft.CostManagement/dimensions_ResourceId_2019-10-01_2019-10-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource Id"), - // Category: to.Ptr("ResourceId"), - // Data: []*string{ - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/system.orlando/providers/microsoft.storage/storageaccounts/urphealthaccount"), - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/system.orlando/providers/microsoft.storage/storageaccounts/srphytenaccount"), - // to.Ptr("/subscriptions/67e24f6b-1ec2-4c90-993a-dc2d25b00b6c/resourcegroups/defaultresourcegroup-eus/providers/microsoft.operationalinsights/workspaces/defaultworkspace-67e24f6b-1ec2-4c90-993a-dc2d25b00b6c-eus"), - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg-sql-ha/providers/microsoft.compute/virtualmachines/sql-4qqp1"), - // to.Ptr("/subscriptions/a98d6dc5-eb8f-46cf-8938-f1fb08f03706/resourcegroups/databricks-rg-testwsp-xijmsdubneexm/providers/microsoft.compute/disks/488cdb42bf74474a98075415be3f806c-containerrootvolume")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](1409), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-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 -func ExampleDimensionsClient_NewListPager_managementGroupDimensionsListLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Management/managementGroups/MyMgId", &armcostmanagement.DimensionsClientListOptions{Filter: nil, - Expand: nil, - Skiptoken: nil, - Top: nil, - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceGroup_2018-05-01_2018-05-31"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Management/managementGroups/MyMgId/providers/microsoft.CostManagement/dimensions_ResourceGroup_2018-05-01_2018-05-31"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource group"), - // Category: to.Ptr("ResourceGroup"), - // Data: []*string{ - // }, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](377), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-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"), - // 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}()), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ManagementGroupDimensionsListExpandAndTop.json -func ExampleDimensionsClient_NewListPager_managementGroupDimensionsListExpandAndTopLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Management/managementGroups/MyMgId", &armcostmanagement.DimensionsClientListOptions{Filter: nil, - Expand: to.Ptr("properties/data"), - Skiptoken: nil, - Top: to.Ptr[int32](5), - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceGroup_2018-05-01_2018-05-31_5"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Management/managementGroups/MyMgId/providers/microsoft.CostManagement/dimensions_ResourceGroup_2018-05-01_2018-05-31_5"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource group"), - // Category: to.Ptr("ResourceGroup"), - // Data: []*string{ - // to.Ptr("thoroetrg01"), - // to.Ptr("default-notificationhubs-westus"), - // to.Ptr("jedikeyvaultrg"), - // to.Ptr("contosocodeflow8d4a"), - // to.Ptr("noobaa")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](377), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-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"), - // 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/ManagementGroupDimensionsListWithFilter.json -func ExampleDimensionsClient_NewListPager_managementGroupDimensionsListWithFilterLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("providers/Microsoft.Management/managementGroups/MyMgId", &armcostmanagement.DimensionsClientListOptions{Filter: to.Ptr("properties/category eq 'resourceId'"), - Expand: to.Ptr("properties/data"), - Skiptoken: nil, - Top: to.Ptr[int32](5), - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceId_2018-05-01_2018-05-31_5"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("providers/Microsoft.Management/managementGroups/MyMgId/providers/microsoft.CostManagement/dimensions_ResourceId_2018-05-01_2018-05-31_5"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource Id"), - // Category: to.Ptr("ResourceId"), - // Data: []*string{ - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/system.orlando/providers/microsoft.storage/storageaccounts/urphealthaccount"), - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/system.orlando/providers/microsoft.storage/storageaccounts/srphytenaccount"), - // to.Ptr("/subscriptions/67e24f6b-1ec2-4c90-993a-dc2d25b00b6c/resourcegroups/defaultresourcegroup-eus/providers/microsoft.operationalinsights/workspaces/defaultworkspace-67e24f6b-1ec2-4c90-993a-dc2d25b00b6c-eus"), - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg-sql-ha/providers/microsoft.compute/virtualmachines/sql-4qqp1"), - // to.Ptr("/subscriptions/a98d6dc5-eb8f-46cf-8938-f1fb08f03706/resourcegroups/databricks-rg-testwsp-xijmsdubneexm/providers/microsoft.compute/disks/488cdb42bf74474a98075415be3f806c-containerrootvolume")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](1409), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-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 -func ExampleDimensionsClient_NewListPager_resourceGroupDimensionsListLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/system.orlando", &armcostmanagement.DimensionsClientListOptions{Filter: nil, - Expand: to.Ptr("properties/data"), - Skiptoken: nil, - Top: to.Ptr[int32](5), - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceType_2018-05-01_2018-05-31_5"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/system.orlando/providers/microsoft.CostManagement/dimensions_ResourceType_2018-05-01_2018-05-31_5"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource type"), - // Category: to.Ptr("ResourceType"), - // Data: []*string{ - // to.Ptr("microsoft.storage/storageaccounts")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](1), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-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"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource Id"), - // Category: to.Ptr("ResourceId"), - // Data: []*string{ - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/system.orlando/providers/microsoft.storage/storageaccounts/authprod"), - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/system.orlando/providers/microsoft.storage/storageaccounts/systemevents"), - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/system.orlando/providers/microsoft.storage/storageaccounts/armadminprod"), - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/system.orlando/providers/microsoft.storage/storageaccounts/srphytenaccount"), - // to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/system.orlando/providers/microsoft.storage/storageaccounts/publicsystemportal")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](27), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-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 -func ExampleDimensionsClient_NewListPager_subscriptionDimensionsListLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewDimensionsClient().NewListPager("subscriptions/00000000-0000-0000-0000-000000000000", &armcostmanagement.DimensionsClientListOptions{Filter: nil, - Expand: to.Ptr("properties/data"), - Skiptoken: nil, - Top: to.Ptr[int32](5), - }) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.DimensionsListResult = armcostmanagement.DimensionsListResult{ - // Value: []*armcostmanagement.Dimension{ - // { - // Name: to.Ptr("dimensions_ResourceGroup_2018-05-01_2018-05-31_5"), - // Type: to.Ptr("microsoft.CostManagement/dimensions"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/dimensions_ResourceGroup_2018-05-01_2018-05-31_5"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource group"), - // Category: to.Ptr("ResourceGroup"), - // Data: []*string{ - // to.Ptr("dcrg"), - // to.Ptr("rg"), - // to.Ptr("offlinegalleryrg"), - // to.Ptr("system.orlando.adminkeyvault"), - // to.Ptr("system.orlando.keyvault")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](68), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-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"), - // Properties: &armcostmanagement.DimensionProperties{ - // Description: to.Ptr("Resource type"), - // Category: to.Ptr("ResourceType"), - // Data: []*string{ - // to.Ptr("microsoft.storage/storageaccounts"), - // to.Ptr("microsoft.web.admin/role"), - // to.Ptr("microsoft.sql/servers"), - // to.Ptr("microsoft.compute/virtualmachines")}, - // FilterEnabled: to.Ptr(true), - // GroupingEnabled: to.Ptr(true), - // Total: to.Ptr[int32](4), - // UsageEnd: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-05-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/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: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/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: 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: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}()), - // }, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/exports_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/exports_client.go index e38930a7f4c2..a13d390bb5ef 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/exports_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/exports_client.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armcostmanagement @@ -46,7 +45,7 @@ func NewExportsClient(credential azcore.TokenCredential, options *arm.ClientOpti // require eTag. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - scope - The scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for subscription // scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for // resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and @@ -61,18 +60,21 @@ func NewExportsClient(credential azcore.TokenCredential, options *arm.ClientOpti // - parameters - Parameters supplied to the CreateOrUpdate Export operation. // - options - ExportsClientCreateOrUpdateOptions contains the optional parameters for the ExportsClient.CreateOrUpdate method. func (client *ExportsClient) CreateOrUpdate(ctx context.Context, scope string, exportName string, parameters Export, options *ExportsClientCreateOrUpdateOptions) (ExportsClientCreateOrUpdateResponse, error) { + var err error req, err := client.createOrUpdateCreateRequest(ctx, scope, exportName, parameters, options) if err != nil { return ExportsClientCreateOrUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ExportsClientCreateOrUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return ExportsClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return ExportsClientCreateOrUpdateResponse{}, err } - return client.createOrUpdateHandleResponse(resp) + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err } // createOrUpdateCreateRequest creates the CreateOrUpdate request. @@ -88,10 +90,13 @@ func (client *ExportsClient) createOrUpdateCreateRequest(ctx context.Context, sc return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, parameters) + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil } // createOrUpdateHandleResponse handles the CreateOrUpdate response. @@ -106,7 +111,7 @@ func (client *ExportsClient) createOrUpdateHandleResponse(resp *http.Response) ( // Delete - The operation to delete a export. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - scope - The scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for subscription // scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for // resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and @@ -120,16 +125,18 @@ func (client *ExportsClient) createOrUpdateHandleResponse(resp *http.Response) ( // - 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) { + var err error req, err := client.deleteCreateRequest(ctx, scope, exportName, options) if err != nil { return ExportsClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ExportsClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ExportsClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ExportsClientDeleteResponse{}, err } return ExportsClientDeleteResponse{}, nil } @@ -147,7 +154,7 @@ func (client *ExportsClient) deleteCreateRequest(ctx context.Context, scope stri return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -156,7 +163,7 @@ func (client *ExportsClient) deleteCreateRequest(ctx context.Context, scope stri // Execute - The operation to run an export. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - scope - The scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for subscription // scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for // resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and @@ -170,16 +177,18 @@ func (client *ExportsClient) deleteCreateRequest(ctx context.Context, scope stri // - 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) { + var err error req, err := client.executeCreateRequest(ctx, scope, exportName, options) if err != nil { return ExportsClientExecuteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ExportsClientExecuteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ExportsClientExecuteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ExportsClientExecuteResponse{}, err } return ExportsClientExecuteResponse{}, nil } @@ -197,7 +206,7 @@ func (client *ExportsClient) executeCreateRequest(ctx context.Context, scope str return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -206,7 +215,7 @@ func (client *ExportsClient) executeCreateRequest(ctx context.Context, scope str // Get - The operation to get the export for the defined scope by export name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - scope - The scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for subscription // scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for // resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and @@ -220,18 +229,21 @@ func (client *ExportsClient) executeCreateRequest(ctx context.Context, scope str // - 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) { + var err error req, err := client.getCreateRequest(ctx, scope, exportName, options) if err != nil { return ExportsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ExportsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ExportsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ExportsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -247,7 +259,7 @@ func (client *ExportsClient) getCreateRequest(ctx context.Context, scope string, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") if options != nil && options.Expand != nil { reqQP.Set("$expand", *options.Expand) } @@ -268,7 +280,7 @@ func (client *ExportsClient) getHandleResponse(resp *http.Response) (ExportsClie // GetExecutionHistory - The operation to get the run history of an export for the defined scope and export name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - scope - The scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for subscription // scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for // resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and @@ -283,18 +295,21 @@ func (client *ExportsClient) getHandleResponse(resp *http.Response) (ExportsClie // - options - ExportsClientGetExecutionHistoryOptions contains the optional parameters for the ExportsClient.GetExecutionHistory // method. func (client *ExportsClient) GetExecutionHistory(ctx context.Context, scope string, exportName string, options *ExportsClientGetExecutionHistoryOptions) (ExportsClientGetExecutionHistoryResponse, error) { + var err error req, err := client.getExecutionHistoryCreateRequest(ctx, scope, exportName, options) if err != nil { return ExportsClientGetExecutionHistoryResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ExportsClientGetExecutionHistoryResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ExportsClientGetExecutionHistoryResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ExportsClientGetExecutionHistoryResponse{}, err } - return client.getExecutionHistoryHandleResponse(resp) + resp, err := client.getExecutionHistoryHandleResponse(httpResp) + return resp, err } // getExecutionHistoryCreateRequest creates the GetExecutionHistory request. @@ -310,7 +325,7 @@ func (client *ExportsClient) getExecutionHistoryCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -328,7 +343,7 @@ func (client *ExportsClient) getExecutionHistoryHandleResponse(resp *http.Respon // List - The operation to list all exports at the given scope. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - scope - The scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for subscription // scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for // resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and @@ -341,18 +356,21 @@ func (client *ExportsClient) getExecutionHistoryHandleResponse(resp *http.Respon // '/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 req, err := client.listCreateRequest(ctx, scope, options) if err != nil { return ExportsClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ExportsClientListResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ExportsClientListResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ExportsClientListResponse{}, err } - return client.listHandleResponse(resp) + resp, err := client.listHandleResponse(httpResp) + return resp, err } // listCreateRequest creates the List request. @@ -364,7 +382,7 @@ func (client *ExportsClient) listCreateRequest(ctx context.Context, scope string return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") if options != nil && options.Expand != nil { reqQP.Set("$expand", *options.Expand) } diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/exports_client_example_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/exports_client_example_test.go deleted file mode 100644 index 793b9cd2adc3..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/exports_client_example_test.go +++ /dev/null @@ -1,2301 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armcostmanagement_test - -import ( - "context" - "log" - - "time" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportsGetByBillingAccount.json -func ExampleExportsClient_List_exportsGetByBillingAccount() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExportsClient().List(ctx, "providers/Microsoft.Billing/billingAccounts/123456", &armcostmanagement.ExportsClientListOptions{Expand: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ExportListResult = armcostmanagement.ExportListResult{ - // Value: []*armcostmanagement.Export{ - // { - // Name: to.Ptr("TestExport1"), - // Type: to.Ptr("Microsoft.CostManagement/exports"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.CostManagement/exports/TestExport1"), - // Properties: &armcostmanagement.ExportProperties{ - // Format: to.Ptr(armcostmanagement.FormatTypeCSV), - // Definition: &armcostmanagement.ExportDefinition{ - // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - // DataSet: &armcostmanagement.ExportDataset{ - // Configuration: &armcostmanagement.ExportDatasetConfiguration{ - // Columns: []*string{ - // to.Ptr("Date"), - // to.Ptr("MeterId"), - // to.Ptr("ResourceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("Quantity")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // TimePeriod: &armcostmanagement.ExportTimePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-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"), - // }, - // }, - // }, - // }, - // { - // 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:00Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00: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/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:00Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-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"), - // }, - // }, - // }, - // }, - // { - // 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:00Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00: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/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:00Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-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"), - // }, - // }, - // }, - // }, - // { - // 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:00Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00: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/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:00Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-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"), - // }, - // }, - // }, - // }, - // { - // 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:00Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00: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/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:00Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-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"), - // }, - // }, - // }, - // }, - // { - // 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:00Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00: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/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:00Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-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"), - // }, - // }, - // }, - // }, - // { - // 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:00Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00: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/ExportGetByBillingAccount.json -func ExampleExportsClient_Get_exportGetByBillingAccount() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExportsClient().Get(ctx, "providers/Microsoft.Billing/billingAccounts/123456", "TestExport", &armcostmanagement.ExportsClientGetOptions{Expand: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Export = armcostmanagement.Export{ - // Name: to.Ptr("TestExport"), - // Type: to.Ptr("Microsoft.CostManagement/exports"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/{billingAccount-Id}/providers/Microsoft.CostManagement/exports/TestExport"), - // Properties: &armcostmanagement.ExportProperties{ - // Format: to.Ptr(armcostmanagement.FormatTypeCSV), - // Definition: &armcostmanagement.ExportDefinition{ - // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - // DataSet: &armcostmanagement.ExportDataset{ - // Configuration: &armcostmanagement.ExportDatasetConfiguration{ - // Columns: []*string{ - // to.Ptr("Date"), - // to.Ptr("MeterId"), - // to.Ptr("ResourceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("Quantity")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // TimePeriod: &armcostmanagement.ExportTimePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T00:00: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"), - // }, - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportGetByDepartment.json -func ExampleExportsClient_Get_exportGetByDepartment() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExportsClient().Get(ctx, "providers/Microsoft.Billing/billingAccounts/12/departments/1234", "TestExport", &armcostmanagement.ExportsClientGetOptions{Expand: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Export = armcostmanagement.Export{ - // Name: to.Ptr("TestExport"), - // Type: to.Ptr("Microsoft.CostManagement/exports"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12/departments/1234/providers/Microsoft.CostManagement/exports/TestExport"), - // Properties: &armcostmanagement.ExportProperties{ - // Format: to.Ptr(armcostmanagement.FormatTypeCSV), - // Definition: &armcostmanagement.ExportDefinition{ - // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - // DataSet: &armcostmanagement.ExportDataset{ - // Configuration: &armcostmanagement.ExportDatasetConfiguration{ - // Columns: []*string{ - // to.Ptr("Date"), - // to.Ptr("MeterId"), - // to.Ptr("ResourceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("Quantity")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // TimePeriod: &armcostmanagement.ExportTimePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00: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"), - // }, - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportGetByEnrollmentAccount.json -func ExampleExportsClient_Get_exportGetByEnrollmentAccount() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExportsClient().Get(ctx, "providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456", "TestExport", &armcostmanagement.ExportsClientGetOptions{Expand: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Export = armcostmanagement.Export{ - // Name: to.Ptr("TestExport"), - // Type: to.Ptr("Microsoft.CostManagement/exports"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456/providers/Microsoft.CostManagement/exports/TestExport"), - // Properties: &armcostmanagement.ExportProperties{ - // Format: to.Ptr(armcostmanagement.FormatTypeCSV), - // Definition: &armcostmanagement.ExportDefinition{ - // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - // DataSet: &armcostmanagement.ExportDataset{ - // Configuration: &armcostmanagement.ExportDatasetConfiguration{ - // Columns: []*string{ - // to.Ptr("Date"), - // to.Ptr("MeterId"), - // to.Ptr("ResourceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("Quantity")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // TimePeriod: &armcostmanagement.ExportTimePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-01T00:00:00Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-10-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"), - // }, - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportGetByManagementGroup.json -func ExampleExportsClient_Get_exportGetByManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExportsClient().Get(ctx, "providers/Microsoft.Management/managementGroups/TestMG", "TestExport", &armcostmanagement.ExportsClientGetOptions{Expand: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Export = armcostmanagement.Export{ - // Name: to.Ptr("TestExport"), - // Type: to.Ptr("Microsoft.CostManagement/exports"), - // ID: to.Ptr("providers/Microsoft.Management/managementGroups/TestMG/providers/Microsoft.CostManagement/exports/TestExport"), - // Properties: &armcostmanagement.ExportProperties{ - // Format: to.Ptr(armcostmanagement.FormatTypeCSV), - // Definition: &armcostmanagement.ExportDefinition{ - // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - // DataSet: &armcostmanagement.ExportDataset{ - // Configuration: &armcostmanagement.ExportDatasetConfiguration{ - // Columns: []*string{ - // to.Ptr("UsageDate"), - // to.Ptr("MeterId"), - // to.Ptr("InstanceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("UsageQuantity")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // TimePeriod: &armcostmanagement.ExportTimePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-09-01T00:00:00Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-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"), - // }, - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportGetByResourceGroup.json -func ExampleExportsClient_Get_exportGetByResourceGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExportsClient().Get(ctx, "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG", "TestExport", &armcostmanagement.ExportsClientGetOptions{Expand: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Export = armcostmanagement.Export{ - // Name: to.Ptr("TestExport"), - // Type: to.Ptr("Microsoft.CostManagement/exports"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.CostManagement/exports/TestExport"), - // Properties: &armcostmanagement.ExportProperties{ - // Format: to.Ptr(armcostmanagement.FormatTypeCSV), - // Definition: &armcostmanagement.ExportDefinition{ - // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - // DataSet: &armcostmanagement.ExportDataset{ - // Configuration: &armcostmanagement.ExportDatasetConfiguration{ - // Columns: []*string{ - // to.Ptr("Date"), - // to.Ptr("MeterId"), - // to.Ptr("ResourceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("Quantity")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // TimePeriod: &armcostmanagement.ExportTimePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00: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"), - // }, - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportGetBySubscription.json -func ExampleExportsClient_Get_exportGetBySubscription() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExportsClient().Get(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", "TestExport", &armcostmanagement.ExportsClientGetOptions{Expand: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.Export = armcostmanagement.Export{ - // Name: to.Ptr("TestExport"), - // Type: to.Ptr("Microsoft.CostManagement/exports"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/exports/TestExport"), - // Properties: &armcostmanagement.ExportProperties{ - // Format: to.Ptr(armcostmanagement.FormatTypeCSV), - // Definition: &armcostmanagement.ExportDefinition{ - // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - // DataSet: &armcostmanagement.ExportDataset{ - // Configuration: &armcostmanagement.ExportDatasetConfiguration{ - // Columns: []*string{ - // to.Ptr("Date"), - // to.Ptr("MeterId"), - // to.Ptr("ResourceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("Quantity")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // TimePeriod: &armcostmanagement.ExportTimePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-06-01T00:00:00Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-07-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"), - // }, - // }, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportCreateOrUpdateByBillingAccount.json -func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateByBillingAccount() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExportsClient().CreateOrUpdate(ctx, "providers/Microsoft.Billing/billingAccounts/123456", "TestExport", armcostmanagement.Export{ - Properties: &armcostmanagement.ExportProperties{ - Format: to.Ptr(armcostmanagement.FormatTypeCSV), - Definition: &armcostmanagement.ExportDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - DataSet: &armcostmanagement.ExportDataset{ - Configuration: &armcostmanagement.ExportDatasetConfiguration{ - Columns: []*string{ - to.Ptr("Date"), - to.Ptr("MeterId"), - to.Ptr("ResourceId"), - to.Ptr("ResourceLocation"), - to.Ptr("Quantity")}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - }, - DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - Destination: &armcostmanagement.ExportDeliveryDestination{ - Container: to.Ptr("exports"), - ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - RootFolderPath: to.Ptr("ad-hoc"), - }, - }, - Schedule: &armcostmanagement.ExportSchedule{ - Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeWeekly), - RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{ - From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t }()), - To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00: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/123456/providers/Microsoft.CostManagement/exports/TestExport"), - // Properties: &armcostmanagement.ExportProperties{ - // Format: to.Ptr(armcostmanagement.FormatTypeCSV), - // Definition: &armcostmanagement.ExportDefinition{ - // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - // DataSet: &armcostmanagement.ExportDataset{ - // Configuration: &armcostmanagement.ExportDatasetConfiguration{ - // Columns: []*string{ - // to.Ptr("Date"), - // to.Ptr("MeterId"), - // to.Ptr("ResourceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("Quantity")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - // }, - // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - // Destination: &armcostmanagement.ExportDeliveryDestination{ - // Container: to.Ptr("exports"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - // RootFolderPath: to.Ptr("ad-hoc"), - // }, - // }, - // Schedule: &armcostmanagement.ExportSchedule{ - // Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeWeekly), - // RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00: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 -func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateByDepartment() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExportsClient().CreateOrUpdate(ctx, "providers/Microsoft.Billing/billingAccounts/12/departments/1234", "TestExport", armcostmanagement.Export{ - Properties: &armcostmanagement.ExportProperties{ - Format: to.Ptr(armcostmanagement.FormatTypeCSV), - Definition: &armcostmanagement.ExportDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - DataSet: &armcostmanagement.ExportDataset{ - Configuration: &armcostmanagement.ExportDatasetConfiguration{ - Columns: []*string{ - to.Ptr("Date"), - to.Ptr("MeterId"), - to.Ptr("ResourceId"), - to.Ptr("ResourceLocation"), - to.Ptr("Quantity")}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - }, - DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - Destination: &armcostmanagement.ExportDeliveryDestination{ - Container: to.Ptr("exports"), - ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - RootFolderPath: to.Ptr("ad-hoc"), - }, - }, - Schedule: &armcostmanagement.ExportSchedule{ - Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeWeekly), - RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{ - From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t }()), - To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00: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/12/departments/1234/providers/Microsoft.CostManagement/exports/TestExport"), - // Properties: &armcostmanagement.ExportProperties{ - // Format: to.Ptr(armcostmanagement.FormatTypeCSV), - // Definition: &armcostmanagement.ExportDefinition{ - // Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - // DataSet: &armcostmanagement.ExportDataset{ - // Configuration: &armcostmanagement.ExportDatasetConfiguration{ - // Columns: []*string{ - // to.Ptr("Date"), - // to.Ptr("MeterId"), - // to.Ptr("ResourceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("Quantity")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - // }, - // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - // Destination: &armcostmanagement.ExportDeliveryDestination{ - // Container: to.Ptr("exports"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - // RootFolderPath: to.Ptr("ad-hoc"), - // }, - // }, - // Schedule: &armcostmanagement.ExportSchedule{ - // Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeWeekly), - // RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00: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 -func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateByEnrollmentAccount() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExportsClient().CreateOrUpdate(ctx, "providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456", "TestExport", armcostmanagement.Export{ - Properties: &armcostmanagement.ExportProperties{ - Format: to.Ptr(armcostmanagement.FormatTypeCSV), - Definition: &armcostmanagement.ExportDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - DataSet: &armcostmanagement.ExportDataset{ - Configuration: &armcostmanagement.ExportDatasetConfiguration{ - Columns: []*string{ - to.Ptr("Date"), - to.Ptr("MeterId"), - to.Ptr("ResourceId"), - to.Ptr("ResourceLocation"), - to.Ptr("Quantity")}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - }, - DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - Destination: &armcostmanagement.ExportDeliveryDestination{ - Container: to.Ptr("exports"), - ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - RootFolderPath: to.Ptr("ad-hoc"), - }, - }, - Schedule: &armcostmanagement.ExportSchedule{ - Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeWeekly), - RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{ - From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t }()), - To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00: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")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - // }, - // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - // Destination: &armcostmanagement.ExportDeliveryDestination{ - // Container: to.Ptr("exports"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - // RootFolderPath: to.Ptr("ad-hoc"), - // }, - // }, - // Schedule: &armcostmanagement.ExportSchedule{ - // Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeWeekly), - // RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00: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 -func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateByManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExportsClient().CreateOrUpdate(ctx, "providers/Microsoft.Management/managementGroups/TestMG", "TestExport", armcostmanagement.Export{ - Properties: &armcostmanagement.ExportProperties{ - Format: to.Ptr(armcostmanagement.FormatTypeCSV), - Definition: &armcostmanagement.ExportDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - DataSet: &armcostmanagement.ExportDataset{ - Configuration: &armcostmanagement.ExportDatasetConfiguration{ - Columns: []*string{ - to.Ptr("Date"), - to.Ptr("MeterId"), - to.Ptr("ResourceId"), - to.Ptr("ResourceLocation"), - to.Ptr("Quantity")}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - }, - DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - Destination: &armcostmanagement.ExportDeliveryDestination{ - Container: to.Ptr("exports"), - ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - RootFolderPath: to.Ptr("ad-hoc"), - }, - }, - Schedule: &armcostmanagement.ExportSchedule{ - Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeWeekly), - RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{ - From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t }()), - To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00: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("Date"), - // to.Ptr("MeterId"), - // to.Ptr("ResourceId"), - // to.Ptr("ResourceLocation"), - // to.Ptr("Quantity")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - // }, - // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - // Destination: &armcostmanagement.ExportDeliveryDestination{ - // Container: to.Ptr("exports"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - // RootFolderPath: to.Ptr("ad-hoc"), - // }, - // }, - // Schedule: &armcostmanagement.ExportSchedule{ - // Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeWeekly), - // RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00: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 -func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateByResourceGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExportsClient().CreateOrUpdate(ctx, "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG", "TestExport", armcostmanagement.Export{ - Properties: &armcostmanagement.ExportProperties{ - Format: to.Ptr(armcostmanagement.FormatTypeCSV), - Definition: &armcostmanagement.ExportDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - DataSet: &armcostmanagement.ExportDataset{ - Configuration: &armcostmanagement.ExportDatasetConfiguration{ - Columns: []*string{ - to.Ptr("Date"), - to.Ptr("MeterId"), - to.Ptr("ResourceId"), - to.Ptr("ResourceLocation"), - to.Ptr("Quantity")}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - }, - DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - Destination: &armcostmanagement.ExportDeliveryDestination{ - Container: to.Ptr("exports"), - ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - RootFolderPath: to.Ptr("ad-hoc"), - }, - }, - Schedule: &armcostmanagement.ExportSchedule{ - Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeWeekly), - RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{ - From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t }()), - To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00: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")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - // }, - // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - // Destination: &armcostmanagement.ExportDeliveryDestination{ - // Container: to.Ptr("exports"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - // RootFolderPath: to.Ptr("ad-hoc"), - // }, - // }, - // Schedule: &armcostmanagement.ExportSchedule{ - // Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeWeekly), - // RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00: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 -func ExampleExportsClient_CreateOrUpdate_exportCreateOrUpdateBySubscription() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExportsClient().CreateOrUpdate(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", "TestExport", armcostmanagement.Export{ - Properties: &armcostmanagement.ExportProperties{ - Format: to.Ptr(armcostmanagement.FormatTypeCSV), - Definition: &armcostmanagement.ExportDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeActualCost), - DataSet: &armcostmanagement.ExportDataset{ - Configuration: &armcostmanagement.ExportDatasetConfiguration{ - Columns: []*string{ - to.Ptr("Date"), - to.Ptr("MeterId"), - to.Ptr("ResourceId"), - to.Ptr("ResourceLocation"), - to.Ptr("Quantity")}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - }, - DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - Destination: &armcostmanagement.ExportDeliveryDestination{ - Container: to.Ptr("exports"), - ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - RootFolderPath: to.Ptr("ad-hoc"), - }, - }, - Schedule: &armcostmanagement.ExportSchedule{ - Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeWeekly), - RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{ - From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t }()), - To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00: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")}, - // }, - // Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - // }, - // Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - // }, - // DeliveryInfo: &armcostmanagement.ExportDeliveryInfo{ - // Destination: &armcostmanagement.ExportDeliveryDestination{ - // Container: to.Ptr("exports"), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - // RootFolderPath: to.Ptr("ad-hoc"), - // }, - // }, - // Schedule: &armcostmanagement.ExportSchedule{ - // Recurrence: to.Ptr(armcostmanagement.RecurrenceTypeWeekly), - // RecurrencePeriod: &armcostmanagement.ExportRecurrencePeriod{ - // From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T00:00:00Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-31T00: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 -func ExampleExportsClient_Delete_exportDeleteByBillingAccount() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewExportsClient().Delete(ctx, "providers/Microsoft.Billing/billingAccounts/123456", "TestExport", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportDeleteByDepartment.json -func ExampleExportsClient_Delete_exportDeleteByDepartment() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewExportsClient().Delete(ctx, "providers/Microsoft.Billing/billingAccounts/12/departments/1234", "TestExport", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportDeleteByEnrollmentAccount.json -func ExampleExportsClient_Delete_exportDeleteByEnrollmentAccount() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewExportsClient().Delete(ctx, "providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456", "TestExport", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportDeleteByManagementGroup.json -func ExampleExportsClient_Delete_exportDeleteByManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewExportsClient().Delete(ctx, "providers/Microsoft.Management/managementGroups/TestMG", "TestExport", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportDeleteByResourceGroup.json -func ExampleExportsClient_Delete_exportDeleteByResourceGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewExportsClient().Delete(ctx, "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG", "TestExport", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportDeleteBySubscription.json -func ExampleExportsClient_Delete_exportDeleteBySubscription() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewExportsClient().Delete(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", "TestExport", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportRunByBillingAccount.json -func ExampleExportsClient_Execute_exportRunByBillingAccount() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewExportsClient().Execute(ctx, "providers/Microsoft.Billing/billingAccounts/123456", "TestExport", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportRunByDepartment.json -func ExampleExportsClient_Execute_exportRunByDepartment() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewExportsClient().Execute(ctx, "providers/Microsoft.Billing/billingAccounts/12/departments/1234", "TestExport", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportRunByEnrollmentAccount.json -func ExampleExportsClient_Execute_exportRunByEnrollmentAccount() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewExportsClient().Execute(ctx, "providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456", "TestExport", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportRunByManagementGroup.json -func ExampleExportsClient_Execute_exportRunByManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewExportsClient().Execute(ctx, "providers/Microsoft.Management/managementGroups/TestMG", "TestExport", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportRunByResourceGroup.json -func ExampleExportsClient_Execute_exportRunByResourceGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewExportsClient().Execute(ctx, "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG", "TestExport", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportRunBySubscription.json -func ExampleExportsClient_Execute_exportRunBySubscription() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewExportsClient().Execute(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", "TestExport", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExportRunHistoryGetByBillingAccount.json -func ExampleExportsClient_GetExecutionHistory_exportRunHistoryGetByBillingAccount() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExportsClient().GetExecutionHistory(ctx, "providers/Microsoft.Billing/billingAccounts/123456", "TestExport", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ExportExecutionListResult = armcostmanagement.ExportExecutionListResult{ - // Value: []*armcostmanagement.ExportRun{ - // { - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/{billingAccount-id}/providers/Microsoft.CostManagement/exports/JohnDoeSchedule/Run/1e25d58a-a3b0-4916-9542-6e04a89bc100"), - // Properties: &armcostmanagement.ExportRunProperties{ - // ExecutionType: to.Ptr(armcostmanagement.ExecutionTypeOnDemand), - // FileName: to.Ptr("ScheduledTestsForJohnDoe/JohnDoeSchedule/20180729-20180804/JohnDoeSchedule_1e25d58a-a3b0-4916-9542-6e04a89bc100.csv"), - // ProcessingEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:28.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), - // 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:00Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-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("ScheduledTestsForJohnDoe"), - // }, - // }, - // }, - // Status: to.Ptr(armcostmanagement.ExecutionStatusCompleted), - // SubmittedBy: to.Ptr("john.doe@gmail.com"), - // SubmittedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:15.6016681Z"); return t}()), - // }, - // }, - // { - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/{billingAccount-id}/providers/Microsoft.CostManagement/exports/JohnDoeSchedule/Run/11ac6811-dca3-46ad-b326-4704cf0c58ef"), - // Properties: &armcostmanagement.ExportRunProperties{ - // ExecutionType: to.Ptr(armcostmanagement.ExecutionTypeScheduled), - // FileName: to.Ptr("ScheduledTestsForJohnDoe/JohnDoeSchedule/20180729-20180804/JohnDoeSchedule_11ac6811-dca3-46ad-b326-4704cf0c58ef.csv"), - // ProcessingEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T09:04:19.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), - // 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:00Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-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("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.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 -func ExampleExportsClient_GetExecutionHistory_exportRunHistoryGetByDepartment() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExportsClient().GetExecutionHistory(ctx, "providers/Microsoft.Billing/billingAccounts/12/departments/1234", "TestExport", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ExportExecutionListResult = armcostmanagement.ExportExecutionListResult{ - // Value: []*armcostmanagement.ExportRun{ - // { - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12/departments/1234/providers/Microsoft.CostManagement/exports/JohnDoeSchedule/Run/1e25d58a-a3b0-4916-9542-6e04a89bc100"), - // Properties: &armcostmanagement.ExportRunProperties{ - // ExecutionType: to.Ptr(armcostmanagement.ExecutionTypeOnDemand), - // FileName: to.Ptr("ScheduledTestsForJohnDoe/JohnDoeSchedule/20180729-20180804/JohnDoeSchedule_1e25d58a-a3b0-4916-9542-6e04a89bc100.csv"), - // ProcessingEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:28.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), - // 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:00Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-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("ScheduledTestsForJohnDoe"), - // }, - // }, - // }, - // Status: to.Ptr(armcostmanagement.ExecutionStatusCompleted), - // SubmittedBy: to.Ptr("john.doe@gmail.com"), - // SubmittedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:15.6016681Z"); return t}()), - // }, - // }, - // { - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12/departments/1234/providers/Microsoft.CostManagement/exports/JohnDoeSchedule/Run/11ac6811-dca3-46ad-b326-4704cf0c58ef"), - // Properties: &armcostmanagement.ExportRunProperties{ - // ExecutionType: to.Ptr(armcostmanagement.ExecutionTypeScheduled), - // FileName: to.Ptr("ScheduledTestsForJohnDoe/JohnDoeSchedule/20180729-20180804/JohnDoeSchedule_11ac6811-dca3-46ad-b326-4704cf0c58ef.csv"), - // ProcessingEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T09:04:19.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), - // 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:00Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-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("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.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 -func ExampleExportsClient_GetExecutionHistory_exportRunHistoryGetByEnrollmentAccount() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExportsClient().GetExecutionHistory(ctx, "providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456", "TestExport", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ExportExecutionListResult = armcostmanagement.ExportExecutionListResult{ - // Value: []*armcostmanagement.ExportRun{ - // { - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456/providers/Microsoft.CostManagement/exports/JohnDoeSchedule/Run/1e25d58a-a3b0-4916-9542-6e04a89bc100"), - // Properties: &armcostmanagement.ExportRunProperties{ - // ExecutionType: to.Ptr(armcostmanagement.ExecutionTypeOnDemand), - // FileName: to.Ptr("ScheduledTestsForJohnDoe/JohnDoeSchedule/20180729-20180804/JohnDoeSchedule_1e25d58a-a3b0-4916-9542-6e04a89bc100.csv"), - // ProcessingEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:28.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), - // 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:00Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-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("ScheduledTestsForJohnDoe"), - // }, - // }, - // }, - // Status: to.Ptr(armcostmanagement.ExecutionStatusCompleted), - // SubmittedBy: to.Ptr("john.doe@gmail.com"), - // SubmittedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:15.6016681Z"); return t}()), - // }, - // }, - // { - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456/providers/Microsoft.CostManagement/exports/JohnDoeSchedule/Run/11ac6811-dca3-46ad-b326-4704cf0c58ef"), - // Properties: &armcostmanagement.ExportRunProperties{ - // ExecutionType: to.Ptr(armcostmanagement.ExecutionTypeScheduled), - // FileName: to.Ptr("ScheduledTestsForJohnDoe/JohnDoeSchedule/20180729-20180804/JohnDoeSchedule_11ac6811-dca3-46ad-b326-4704cf0c58ef.csv"), - // ProcessingEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T09:04:19.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), - // 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:00Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-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("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.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 -func ExampleExportsClient_GetExecutionHistory_exportRunHistoryGetByManagementGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExportsClient().GetExecutionHistory(ctx, "providers/Microsoft.Management/managementGroups/TestMG", "TestExport", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ExportExecutionListResult = armcostmanagement.ExportExecutionListResult{ - // Value: []*armcostmanagement.ExportRun{ - // { - // ID: to.Ptr("providers/Microsoft.Management/managementGroups/TestMG/providers/Microsoft.CostManagement/exports/TestExport/Run/1e25d58a-a3b0-4916-9542-6e04a89bc100"), - // Properties: &armcostmanagement.ExportRunProperties{ - // ExecutionType: to.Ptr(armcostmanagement.ExecutionTypeOnDemand), - // FileName: to.Ptr("ScheduledForTestExport/TestExportSchedule/20180729-20180804/TestExportSchedule_1e25d58a-a3b0-4916-9542-6e04a89bc100.csv"), - // ProcessingEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:28.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), - // 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:00Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-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("ScheduledTestsForJohnDoe"), - // }, - // }, - // }, - // Status: to.Ptr(armcostmanagement.ExecutionStatusCompleted), - // SubmittedBy: to.Ptr("john.doe@gmail.com"), - // SubmittedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:15.6016681Z"); return t}()), - // }, - // }, - // { - // ID: to.Ptr("providers/Microsoft.Management/managementGroups/TestMG/providers/Microsoft.CostManagement/exports/TestExport/Run/11ac6811-dca3-46ad-b326-4704cf0c58ef"), - // Properties: &armcostmanagement.ExportRunProperties{ - // ExecutionType: to.Ptr(armcostmanagement.ExecutionTypeScheduled), - // FileName: to.Ptr("ScheduledForTestExport/TestExportSchedule/20180729-20180804/TestExportSchedule_11ac6811-dca3-46ad-b326-4704cf0c58ef.csv"), - // ProcessingEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T09:04:19.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), - // 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:00Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-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("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.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 -func ExampleExportsClient_GetExecutionHistory_exportRunHistoryGetByResourceGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExportsClient().GetExecutionHistory(ctx, "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG", "TestExport", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ExportExecutionListResult = armcostmanagement.ExportExecutionListResult{ - // Value: []*armcostmanagement.ExportRun{ - // { - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.CostManagement/exports/JohnDoeSchedule/Run/1e25d58a-a3b0-4916-9542-6e04a89bc100"), - // Properties: &armcostmanagement.ExportRunProperties{ - // ExecutionType: to.Ptr(armcostmanagement.ExecutionTypeOnDemand), - // FileName: to.Ptr("ScheduledTestsForJohnDoe/JohnDoeSchedule/20180729-20180804/JohnDoeSchedule_1e25d58a-a3b0-4916-9542-6e04a89bc100.csv"), - // ProcessingEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:28.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), - // 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:00Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-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("ScheduledTestsForJohnDoe"), - // }, - // }, - // }, - // Status: to.Ptr(armcostmanagement.ExecutionStatusCompleted), - // SubmittedBy: to.Ptr("john.doe@gmail.com"), - // SubmittedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:15.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"), - // Properties: &armcostmanagement.ExportRunProperties{ - // ExecutionType: to.Ptr(armcostmanagement.ExecutionTypeScheduled), - // FileName: to.Ptr("ScheduledTestsForJohnDoe/JohnDoeSchedule/20180729-20180804/JohnDoeSchedule_11ac6811-dca3-46ad-b326-4704cf0c58ef.csv"), - // ProcessingEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T09:04:19.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), - // 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:00Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-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("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.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 -func ExampleExportsClient_GetExecutionHistory_exportRunHistoryGetBySubscription() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewExportsClient().GetExecutionHistory(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", "TestExport", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ExportExecutionListResult = armcostmanagement.ExportExecutionListResult{ - // Value: []*armcostmanagement.ExportRun{ - // { - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/exports/JohnDoeSchedule/Run/1e25d58a-a3b0-4916-9542-6e04a89bc100"), - // Properties: &armcostmanagement.ExportRunProperties{ - // ExecutionType: to.Ptr(armcostmanagement.ExecutionTypeOnDemand), - // FileName: to.Ptr("ScheduledTestsForJohnDoe/JohnDoeSchedule/20180729-20180804/JohnDoeSchedule_1e25d58a-a3b0-4916-9542-6e04a89bc100.csv"), - // ProcessingEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:28.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), - // 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:00Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-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("ScheduledTestsForJohnDoe"), - // }, - // }, - // }, - // Status: to.Ptr(armcostmanagement.ExecutionStatusCompleted), - // SubmittedBy: to.Ptr("john.doe@gmail.com"), - // SubmittedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T07:52:15.6016681Z"); return t}()), - // }, - // }, - // { - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/exports/JohnDoeSchedule/Run/11ac6811-dca3-46ad-b326-4704cf0c58ef"), - // Properties: &armcostmanagement.ExportRunProperties{ - // ExecutionType: to.Ptr(armcostmanagement.ExecutionTypeScheduled), - // FileName: to.Ptr("ScheduledTestsForJohnDoe/JohnDoeSchedule/20180729-20180804/JohnDoeSchedule_11ac6811-dca3-46ad-b326-4704cf0c58ef.csv"), - // ProcessingEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-03T09:04:19.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), - // 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:00Z"); return t}()), - // To: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-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("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.5710244Z"); return t}()), - // }, - // }}, - // } -} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/forecast_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/forecast_client.go index 91d73d2b4c75..931d71cce0da 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/forecast_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/forecast_client.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armcostmanagement @@ -44,7 +43,7 @@ func NewForecastClient(credential azcore.TokenCredential, options *arm.ClientOpt // ExternalCloudProviderUsage - Lists the forecast charges for external cloud provider type defined. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - externalCloudProviderType - The external cloud provider type associated with dimension/query operations. This includes // 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account. // - externalCloudProviderID - This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' for @@ -53,18 +52,21 @@ func NewForecastClient(credential azcore.TokenCredential, options *arm.ClientOpt // - 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) { + var err error req, err := client.externalCloudProviderUsageCreateRequest(ctx, externalCloudProviderType, externalCloudProviderID, parameters, options) if err != nil { return ForecastClientExternalCloudProviderUsageResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ForecastClientExternalCloudProviderUsageResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ForecastClientExternalCloudProviderUsageResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ForecastClientExternalCloudProviderUsageResponse{}, err } - return client.externalCloudProviderUsageHandleResponse(resp) + resp, err := client.externalCloudProviderUsageHandleResponse(httpResp) + return resp, err } // externalCloudProviderUsageCreateRequest creates the ExternalCloudProviderUsage request. @@ -86,10 +88,13 @@ func (client *ForecastClient) externalCloudProviderUsageCreateRequest(ctx contex if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, parameters) + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil } // externalCloudProviderUsageHandleResponse handles the ExternalCloudProviderUsage response. @@ -104,7 +109,7 @@ func (client *ForecastClient) externalCloudProviderUsageHandleResponse(resp *htt // Usage - Lists the forecast charges for scope defined. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - scope - The scope associated with forecast operations. This includes '/subscriptions/{subscriptionId}/' for subscription // scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for // resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and @@ -118,18 +123,21 @@ func (client *ForecastClient) externalCloudProviderUsageHandleResponse(resp *htt // - 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) { + var err error req, err := client.usageCreateRequest(ctx, scope, parameters, options) if err != nil { return ForecastClientUsageResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ForecastClientUsageResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { - return ForecastClientUsageResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return ForecastClientUsageResponse{}, err } - return client.usageHandleResponse(resp) + resp, err := client.usageHandleResponse(httpResp) + return resp, err } // usageCreateRequest creates the Usage request. @@ -144,10 +152,13 @@ func (client *ForecastClient) usageCreateRequest(ctx context.Context, scope stri if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, parameters) + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil } // usageHandleResponse handles the Usage response. diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/forecast_client_example_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/forecast_client_example_test.go deleted file mode 100644 index 3ed44d8b0584..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/forecast_client_example_test.go +++ /dev/null @@ -1,1010 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armcostmanagement_test - -import ( - "context" - "log" - - "time" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BillingAccountForecast.json -func ExampleForecastClient_Usage_billingAccountForecast() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewForecastClient().Usage(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789", armcostmanagement.ForecastDefinition{ - Type: to.Ptr(armcostmanagement.ForecastTypeUsage), - Dataset: &armcostmanagement.ForecastDataset{ - Aggregation: map[string]*armcostmanagement.ForecastAggregation{ - "totalCost": { - Name: to.Ptr(armcostmanagement.FunctionNameCost), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), - }, - }, - Filter: &armcostmanagement.ForecastFilter{ - And: []*armcostmanagement.ForecastFilter{ - { - Or: []*armcostmanagement.ForecastFilter{ - { - Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("East US"), - to.Ptr("West Europe")}, - }, - }, - { - Tags: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("UAT"), - to.Ptr("Prod")}, - }, - }}, - }, - { - Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("API")}, - }, - }}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - IncludeActualCost: to.Ptr(false), - IncludeFreshPartialCost: to.Ptr(false), - TimePeriod: &armcostmanagement.ForecastTimePeriod{ - From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T00:00:00+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}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ForecastResult = armcostmanagement.ForecastResult{ - // Name: to.Ptr("ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Type: to.Ptr("Microsoft.CostManagement/query"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/providers/Microsoft.CostManagement/query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Properties: &armcostmanagement.ForecastProperties{ - // Columns: []*armcostmanagement.ForecastColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("UsageDate"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("CostStatus"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(2.10333307059661), - // float64(20180331), - // "Forecast", - // "USD"}, - // []any{ - // float64(218.68795741935486), - // float64(20180331), - // "Forecast", - // "USD"}, - // []any{ - // float64(0.14384913581657052), - // float64(20180401), - // "Forecast", - // "USD"}, - // []any{ - // float64(0.009865586851323632), - // float64(20180429), - // "Forecast", - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BillingProfileForecast.json -func ExampleForecastClient_Usage_billingProfileForecast() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewForecastClient().Usage(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579", armcostmanagement.ForecastDefinition{ - Type: to.Ptr(armcostmanagement.ForecastTypeUsage), - Dataset: &armcostmanagement.ForecastDataset{ - Aggregation: map[string]*armcostmanagement.ForecastAggregation{ - "totalCost": { - Name: to.Ptr(armcostmanagement.FunctionNameCost), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), - }, - }, - Filter: &armcostmanagement.ForecastFilter{ - And: []*armcostmanagement.ForecastFilter{ - { - Or: []*armcostmanagement.ForecastFilter{ - { - Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("East US"), - to.Ptr("West Europe")}, - }, - }, - { - Tags: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("UAT"), - to.Ptr("Prod")}, - }, - }}, - }, - { - Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("API")}, - }, - }}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - IncludeActualCost: to.Ptr(false), - IncludeFreshPartialCost: to.Ptr(false), - TimePeriod: &armcostmanagement.ForecastTimePeriod{ - From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T00:00:00+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}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ForecastResult = armcostmanagement.ForecastResult{ - // Name: to.Ptr("ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Type: to.Ptr("Microsoft.CostManagement/query"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/providers/Microsoft.CostManagement/query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Properties: &armcostmanagement.ForecastProperties{ - // Columns: []*armcostmanagement.ForecastColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("UsageDate"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("CostStatus"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(2.10333307059661), - // float64(20180331), - // "Forecast", - // "USD"}, - // []any{ - // float64(218.68795741935486), - // float64(20180331), - // "Forecast", - // "USD"}, - // []any{ - // float64(0.14384913581657052), - // float64(20180401), - // "Forecast", - // "USD"}, - // []any{ - // float64(0.009865586851323632), - // float64(20180429), - // "Forecast", - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/DepartmentForecast.json -func ExampleForecastClient_Usage_departmentForecast() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewForecastClient().Usage(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789/departments/123", armcostmanagement.ForecastDefinition{ - Type: to.Ptr(armcostmanagement.ForecastTypeUsage), - Dataset: &armcostmanagement.ForecastDataset{ - Aggregation: map[string]*armcostmanagement.ForecastAggregation{ - "totalCost": { - Name: to.Ptr(armcostmanagement.FunctionNameCost), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), - }, - }, - Filter: &armcostmanagement.ForecastFilter{ - And: []*armcostmanagement.ForecastFilter{ - { - Or: []*armcostmanagement.ForecastFilter{ - { - Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("East US"), - to.Ptr("West Europe")}, - }, - }, - { - Tags: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("UAT"), - to.Ptr("Prod")}, - }, - }}, - }, - { - Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("API")}, - }, - }}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - IncludeActualCost: to.Ptr(false), - IncludeFreshPartialCost: to.Ptr(false), - TimePeriod: &armcostmanagement.ForecastTimePeriod{ - From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T00:00:00+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}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ForecastResult = armcostmanagement.ForecastResult{ - // Name: to.Ptr("ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Type: to.Ptr("Microsoft.CostManagement/query"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/departments/123/providers/Microsoft.CostManagement/query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Properties: &armcostmanagement.ForecastProperties{ - // Columns: []*armcostmanagement.ForecastColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("UsageDate"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("CostStatus"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(2.10333307059661), - // float64(20180331), - // "Forecast", - // "USD"}, - // []any{ - // float64(218.68795741935486), - // float64(20180331), - // "Forecast", - // "USD"}, - // []any{ - // float64(0.14384913581657052), - // float64(20180401), - // "Forecast", - // "USD"}, - // []any{ - // float64(0.009865586851323632), - // float64(20180429), - // "Forecast", - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/EnrollmentAccountForecast.json -func ExampleForecastClient_Usage_enrollmentAccountForecast() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewForecastClient().Usage(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789/enrollmentAccounts/456", armcostmanagement.ForecastDefinition{ - Type: to.Ptr(armcostmanagement.ForecastTypeUsage), - Dataset: &armcostmanagement.ForecastDataset{ - Aggregation: map[string]*armcostmanagement.ForecastAggregation{ - "totalCost": { - Name: to.Ptr(armcostmanagement.FunctionNameCost), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), - }, - }, - Filter: &armcostmanagement.ForecastFilter{ - And: []*armcostmanagement.ForecastFilter{ - { - Or: []*armcostmanagement.ForecastFilter{ - { - Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("East US"), - to.Ptr("West Europe")}, - }, - }, - { - Tags: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("UAT"), - to.Ptr("Prod")}, - }, - }}, - }, - { - Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("API")}, - }, - }}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - IncludeActualCost: to.Ptr(false), - IncludeFreshPartialCost: to.Ptr(false), - TimePeriod: &armcostmanagement.ForecastTimePeriod{ - From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T00:00:00+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}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ForecastResult = armcostmanagement.ForecastResult{ - // Name: to.Ptr("ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Type: to.Ptr("Microsoft.CostManagement/query"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/enrollmentAccounts/456/providers/Microsoft.CostManagement/query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Properties: &armcostmanagement.ForecastProperties{ - // Columns: []*armcostmanagement.ForecastColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("UsageDate"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("CostStatus"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(2.10333307059661), - // float64(20180331), - // "Forecast", - // "USD"}, - // []any{ - // float64(218.68795741935486), - // float64(20180331), - // "Forecast", - // "USD"}, - // []any{ - // float64(0.14384913581657052), - // float64(20180401), - // "Forecast", - // "USD"}, - // []any{ - // float64(0.009865586851323632), - // float64(20180429), - // "Forecast", - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/InvoiceSectionForecast.json -func ExampleForecastClient_Usage_invoiceSectionForecast() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewForecastClient().Usage(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876", armcostmanagement.ForecastDefinition{ - Type: to.Ptr(armcostmanagement.ForecastTypeUsage), - Dataset: &armcostmanagement.ForecastDataset{ - Aggregation: map[string]*armcostmanagement.ForecastAggregation{ - "totalCost": { - Name: to.Ptr(armcostmanagement.FunctionNameCost), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), - }, - }, - Filter: &armcostmanagement.ForecastFilter{ - And: []*armcostmanagement.ForecastFilter{ - { - Or: []*armcostmanagement.ForecastFilter{ - { - Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("East US"), - to.Ptr("West Europe")}, - }, - }, - { - Tags: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("UAT"), - to.Ptr("Prod")}, - }, - }}, - }, - { - Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("API")}, - }, - }}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - IncludeActualCost: to.Ptr(false), - IncludeFreshPartialCost: to.Ptr(false), - TimePeriod: &armcostmanagement.ForecastTimePeriod{ - From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T00:00:00+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}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ForecastResult = armcostmanagement.ForecastResult{ - // Name: to.Ptr("ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Type: to.Ptr("Microsoft.CostManagement/query"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876/providers/Microsoft.CostManagement/query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Properties: &armcostmanagement.ForecastProperties{ - // Columns: []*armcostmanagement.ForecastColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("UsageDate"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("CostStatus"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(2.10333307059661), - // float64(20180331), - // "Forecast", - // "USD"}, - // []any{ - // float64(218.68795741935486), - // float64(20180331), - // "Forecast", - // "USD"}, - // []any{ - // float64(0.14384913581657052), - // float64(20180401), - // "Forecast", - // "USD"}, - // []any{ - // float64(0.009865586851323632), - // float64(20180429), - // "Forecast", - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ResourceGroupForecast.json -func ExampleForecastClient_Usage_resourceGroupForecast() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewForecastClient().Usage(ctx, "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ScreenSharingTest-peer", armcostmanagement.ForecastDefinition{ - Type: to.Ptr(armcostmanagement.ForecastTypeUsage), - Dataset: &armcostmanagement.ForecastDataset{ - Aggregation: map[string]*armcostmanagement.ForecastAggregation{ - "totalCost": { - Name: to.Ptr(armcostmanagement.FunctionNameCost), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), - }, - }, - Filter: &armcostmanagement.ForecastFilter{ - And: []*armcostmanagement.ForecastFilter{ - { - Or: []*armcostmanagement.ForecastFilter{ - { - Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("East US"), - to.Ptr("West Europe")}, - }, - }, - { - Tags: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("UAT"), - to.Ptr("Prod")}, - }, - }}, - }, - { - Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("API")}, - }, - }}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - IncludeActualCost: to.Ptr(false), - IncludeFreshPartialCost: to.Ptr(false), - TimePeriod: &armcostmanagement.ForecastTimePeriod{ - From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T00:00:00+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}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ForecastResult = armcostmanagement.ForecastResult{ - // Name: to.Ptr("55312978-ba1b-415c-9304-cfd9c43c0481"), - // Type: to.Ptr("Microsoft.CostManagement/query"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ScreenSharingTest-peer/providers/Microsoft.CostManagement/query/00000000-0000-0000-0000-000000000000"), - // Properties: &armcostmanagement.ForecastProperties{ - // Columns: []*armcostmanagement.ForecastColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("UsageDate"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("CostStatus"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(2.10333307059661), - // float64(20180331), - // "Forecast", - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/SubscriptionForecast.json -func ExampleForecastClient_Usage_subscriptionForecast() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewForecastClient().Usage(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", armcostmanagement.ForecastDefinition{ - Type: to.Ptr(armcostmanagement.ForecastTypeUsage), - Dataset: &armcostmanagement.ForecastDataset{ - Aggregation: map[string]*armcostmanagement.ForecastAggregation{ - "totalCost": { - Name: to.Ptr(armcostmanagement.FunctionNameCost), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), - }, - }, - Filter: &armcostmanagement.ForecastFilter{ - And: []*armcostmanagement.ForecastFilter{ - { - Or: []*armcostmanagement.ForecastFilter{ - { - Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("East US"), - to.Ptr("West Europe")}, - }, - }, - { - Tags: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("UAT"), - to.Ptr("Prod")}, - }, - }}, - }, - { - Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("API")}, - }, - }}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - IncludeActualCost: to.Ptr(false), - IncludeFreshPartialCost: to.Ptr(false), - TimePeriod: &armcostmanagement.ForecastTimePeriod{ - From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T00:00:00+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}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ForecastResult = armcostmanagement.ForecastResult{ - // Name: to.Ptr("55312978-ba1b-415c-9304-cfd9c43c0481"), - // Type: to.Ptr("Microsoft.CostManagement/query"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/query/00000000-0000-0000-0000-000000000000"), - // Properties: &armcostmanagement.ForecastProperties{ - // Columns: []*armcostmanagement.ForecastColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("UsageDate"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("CostStatus"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(2.10333307059661), - // float64(20180331), - // "Forecast", - // "USD"}, - // []any{ - // float64(218.68795741935486), - // float64(20180331), - // "Forecast", - // "USD"}, - // []any{ - // float64(0.14384913581657052), - // float64(20180401), - // "Forecast", - // "USD"}, - // []any{ - // float64(0.009865586851323632), - // float64(20180429), - // "Forecast", - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExternalBillingAccountForecast.json -func ExampleForecastClient_ExternalCloudProviderUsage_externalBillingAccountForecast() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewForecastClient().ExternalCloudProviderUsage(ctx, armcostmanagement.ExternalCloudProviderTypeExternalBillingAccounts, "100", armcostmanagement.ForecastDefinition{ - Type: to.Ptr(armcostmanagement.ForecastTypeUsage), - Dataset: &armcostmanagement.ForecastDataset{ - Aggregation: map[string]*armcostmanagement.ForecastAggregation{ - "totalCost": { - Name: to.Ptr(armcostmanagement.FunctionNameCost), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), - }, - }, - Filter: &armcostmanagement.ForecastFilter{ - And: []*armcostmanagement.ForecastFilter{ - { - Or: []*armcostmanagement.ForecastFilter{ - { - Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("East US"), - to.Ptr("West Europe")}, - }, - }, - { - Tags: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("UAT"), - to.Ptr("Prod")}, - }, - }}, - }, - { - Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("API")}, - }, - }}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - TimePeriod: &armcostmanagement.ForecastTimePeriod{ - From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T00:00:00+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}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ForecastResult = armcostmanagement.ForecastResult{ - // Name: to.Ptr("6dc7b06a-d90a-4df5-b655-ce6cf1c0814d"), - // Type: to.Ptr("Microsoft.CostManagement/query"), - // ID: to.Ptr("providers/Microsoft.CostManagement/externalBillingAccounts/100/query/6dc7b06a-d90a-4df5-b655-ce6cf1c0814d"), - // Properties: &armcostmanagement.ForecastProperties{ - // Columns: []*armcostmanagement.ForecastColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("CostStatus"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(0), - // "Forecast", - // "USD"}, - // []any{ - // float64(30.2572751438), - // "Forecast", - // "USD"}, - // []any{ - // float64(0.07675760200000002), - // "Forecast", - // "USD"}, - // []any{ - // float64(50.43096419040001), - // "Forecast", - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExternalSubscriptionForecast.json -func ExampleForecastClient_ExternalCloudProviderUsage_externalSubscriptionForecast() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewForecastClient().ExternalCloudProviderUsage(ctx, armcostmanagement.ExternalCloudProviderTypeExternalSubscriptions, "100", armcostmanagement.ForecastDefinition{ - Type: to.Ptr(armcostmanagement.ForecastTypeUsage), - Dataset: &armcostmanagement.ForecastDataset{ - Aggregation: map[string]*armcostmanagement.ForecastAggregation{ - "totalCost": { - Name: to.Ptr(armcostmanagement.FunctionNameCost), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), - }, - }, - Filter: &armcostmanagement.ForecastFilter{ - And: []*armcostmanagement.ForecastFilter{ - { - Or: []*armcostmanagement.ForecastFilter{ - { - Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("East US"), - to.Ptr("West Europe")}, - }, - }, - { - Tags: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("UAT"), - to.Ptr("Prod")}, - }, - }}, - }, - { - Dimensions: &armcostmanagement.ForecastComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.ForecastOperatorTypeIn), - Values: []*string{ - to.Ptr("API")}, - }, - }}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - TimePeriod: &armcostmanagement.ForecastTimePeriod{ - From: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-01T00:00:00+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}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ForecastResult = armcostmanagement.ForecastResult{ - // Name: to.Ptr("d99477af-7510-40ee-aca2-e59bdca0d10d"), - // Type: to.Ptr("Microsoft.CostManagement/query"), - // ID: to.Ptr("providers/Microsoft.CostManagement/externalSubscriptions/100/query/d99477af-7510-40ee-aca2-e59bdca0d10d"), - // Properties: &armcostmanagement.ForecastProperties{ - // Columns: []*armcostmanagement.ForecastColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("UsageDate"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("CostStatus"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // }, - // }, - // } -} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/generatebenefitutilizationsummariesreport_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/generatebenefitutilizationsummariesreport_client.go new file mode 100644 index 000000000000..6dfb9507b5b9 --- /dev/null +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/generatebenefitutilizationsummariesreport_client.go @@ -0,0 +1,454 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armcostmanagement + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// GenerateBenefitUtilizationSummariesReportClient contains the methods for the GenerateBenefitUtilizationSummariesReport group. +// Don't use this type directly, use NewGenerateBenefitUtilizationSummariesReportClient() instead. +type GenerateBenefitUtilizationSummariesReportClient struct { + internal *arm.Client +} + +// NewGenerateBenefitUtilizationSummariesReportClient creates a new instance of GenerateBenefitUtilizationSummariesReportClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewGenerateBenefitUtilizationSummariesReportClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*GenerateBenefitUtilizationSummariesReportClient, error) { + cl, err := arm.NewClient(moduleName+".GenerateBenefitUtilizationSummariesReportClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &GenerateBenefitUtilizationSummariesReportClient{ + internal: cl, + } + return client, nil +} + +// BeginGenerateByBillingAccount - Triggers generation of a benefit utilization summaries report for the provided billing +// account. This API supports only enrollment accounts. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-08-01 +// - billingAccountID - Billing account ID +// - benefitUtilizationSummariesRequest - Async Benefit Utilization Summary report to be created. +// - options - GenerateBenefitUtilizationSummariesReportClientBeginGenerateByBillingAccountOptions contains the optional parameters +// for the GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByBillingAccount method. +func (client *GenerateBenefitUtilizationSummariesReportClient) BeginGenerateByBillingAccount(ctx context.Context, billingAccountID string, benefitUtilizationSummariesRequest BenefitUtilizationSummariesRequest, options *GenerateBenefitUtilizationSummariesReportClientBeginGenerateByBillingAccountOptions) (*runtime.Poller[GenerateBenefitUtilizationSummariesReportClientGenerateByBillingAccountResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.generateByBillingAccount(ctx, billingAccountID, benefitUtilizationSummariesRequest, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[GenerateBenefitUtilizationSummariesReportClientGenerateByBillingAccountResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[GenerateBenefitUtilizationSummariesReportClientGenerateByBillingAccountResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// GenerateByBillingAccount - Triggers generation of a benefit utilization summaries report for the provided billing account. +// This API supports only enrollment accounts. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-08-01 +func (client *GenerateBenefitUtilizationSummariesReportClient) generateByBillingAccount(ctx context.Context, billingAccountID string, benefitUtilizationSummariesRequest BenefitUtilizationSummariesRequest, options *GenerateBenefitUtilizationSummariesReportClientBeginGenerateByBillingAccountOptions) (*http.Response, error) { + var err error + req, err := client.generateByBillingAccountCreateRequest(ctx, billingAccountID, benefitUtilizationSummariesRequest, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// generateByBillingAccountCreateRequest creates the GenerateByBillingAccount request. +func (client *GenerateBenefitUtilizationSummariesReportClient) generateByBillingAccountCreateRequest(ctx context.Context, billingAccountID string, benefitUtilizationSummariesRequest BenefitUtilizationSummariesRequest, options *GenerateBenefitUtilizationSummariesReportClientBeginGenerateByBillingAccountOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.CostManagement/generateBenefitUtilizationSummariesReport" + if billingAccountID == "" { + return nil, errors.New("parameter billingAccountID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountId}", url.PathEscape(billingAccountID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-08-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, benefitUtilizationSummariesRequest); err != nil { + return nil, err + } + return req, nil +} + +// BeginGenerateByBillingProfile - Triggers generation of a benefit utilization summaries report for the provided billing +// account and billing profile. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-08-01 +// - billingAccountID - Billing account ID +// - billingProfileID - Billing profile ID. +// - benefitUtilizationSummariesRequest - Async Benefit Utilization Summary report to be created. +// - options - GenerateBenefitUtilizationSummariesReportClientBeginGenerateByBillingProfileOptions contains the optional parameters +// for the GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByBillingProfile method. +func (client *GenerateBenefitUtilizationSummariesReportClient) BeginGenerateByBillingProfile(ctx context.Context, billingAccountID string, billingProfileID string, benefitUtilizationSummariesRequest BenefitUtilizationSummariesRequest, options *GenerateBenefitUtilizationSummariesReportClientBeginGenerateByBillingProfileOptions) (*runtime.Poller[GenerateBenefitUtilizationSummariesReportClientGenerateByBillingProfileResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.generateByBillingProfile(ctx, billingAccountID, billingProfileID, benefitUtilizationSummariesRequest, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[GenerateBenefitUtilizationSummariesReportClientGenerateByBillingProfileResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[GenerateBenefitUtilizationSummariesReportClientGenerateByBillingProfileResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// GenerateByBillingProfile - Triggers generation of a benefit utilization summaries report for the provided billing account +// and billing profile. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-08-01 +func (client *GenerateBenefitUtilizationSummariesReportClient) generateByBillingProfile(ctx context.Context, billingAccountID string, billingProfileID string, benefitUtilizationSummariesRequest BenefitUtilizationSummariesRequest, options *GenerateBenefitUtilizationSummariesReportClientBeginGenerateByBillingProfileOptions) (*http.Response, error) { + var err error + req, err := client.generateByBillingProfileCreateRequest(ctx, billingAccountID, billingProfileID, benefitUtilizationSummariesRequest, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// generateByBillingProfileCreateRequest creates the GenerateByBillingProfile request. +func (client *GenerateBenefitUtilizationSummariesReportClient) generateByBillingProfileCreateRequest(ctx context.Context, billingAccountID string, billingProfileID string, benefitUtilizationSummariesRequest BenefitUtilizationSummariesRequest, options *GenerateBenefitUtilizationSummariesReportClientBeginGenerateByBillingProfileOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/providers/Microsoft.CostManagement/generateBenefitUtilizationSummariesReport" + if billingAccountID == "" { + return nil, errors.New("parameter billingAccountID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingAccountId}", url.PathEscape(billingAccountID)) + if billingProfileID == "" { + return nil, errors.New("parameter billingProfileID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{billingProfileId}", url.PathEscape(billingProfileID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-08-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, benefitUtilizationSummariesRequest); err != nil { + return nil, err + } + return req, nil +} + +// BeginGenerateByReservationID - Triggers generation of a benefit utilization summaries report for the provided reservation. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-08-01 +// - reservationOrderID - Reservation Order ID +// - reservationID - Reservation ID +// - benefitUtilizationSummariesRequest - Async Benefit Utilization Summary report to be created. +// - options - GenerateBenefitUtilizationSummariesReportClientBeginGenerateByReservationIDOptions contains the optional parameters +// for the GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByReservationID method. +func (client *GenerateBenefitUtilizationSummariesReportClient) BeginGenerateByReservationID(ctx context.Context, reservationOrderID string, reservationID string, benefitUtilizationSummariesRequest BenefitUtilizationSummariesRequest, options *GenerateBenefitUtilizationSummariesReportClientBeginGenerateByReservationIDOptions) (*runtime.Poller[GenerateBenefitUtilizationSummariesReportClientGenerateByReservationIDResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.generateByReservationID(ctx, reservationOrderID, reservationID, benefitUtilizationSummariesRequest, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[GenerateBenefitUtilizationSummariesReportClientGenerateByReservationIDResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[GenerateBenefitUtilizationSummariesReportClientGenerateByReservationIDResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// GenerateByReservationID - Triggers generation of a benefit utilization summaries report for the provided reservation. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-08-01 +func (client *GenerateBenefitUtilizationSummariesReportClient) generateByReservationID(ctx context.Context, reservationOrderID string, reservationID string, benefitUtilizationSummariesRequest BenefitUtilizationSummariesRequest, options *GenerateBenefitUtilizationSummariesReportClientBeginGenerateByReservationIDOptions) (*http.Response, error) { + var err error + req, err := client.generateByReservationIDCreateRequest(ctx, reservationOrderID, reservationID, benefitUtilizationSummariesRequest, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// generateByReservationIDCreateRequest creates the GenerateByReservationID request. +func (client *GenerateBenefitUtilizationSummariesReportClient) generateByReservationIDCreateRequest(ctx context.Context, reservationOrderID string, reservationID string, benefitUtilizationSummariesRequest BenefitUtilizationSummariesRequest, options *GenerateBenefitUtilizationSummariesReportClientBeginGenerateByReservationIDOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/reservations/{reservationId}/providers/Microsoft.CostManagement/generateBenefitUtilizationSummariesReport" + if reservationOrderID == "" { + return nil, errors.New("parameter reservationOrderID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reservationOrderId}", url.PathEscape(reservationOrderID)) + if reservationID == "" { + return nil, errors.New("parameter reservationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reservationId}", url.PathEscape(reservationID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-08-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, benefitUtilizationSummariesRequest); err != nil { + return nil, err + } + return req, nil +} + +// BeginGenerateByReservationOrderID - Triggers generation of a benefit utilization summaries report for the provided reservation +// order. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-08-01 +// - reservationOrderID - Reservation Order ID +// - benefitUtilizationSummariesRequest - Async Benefit Utilization Summary report to be created. +// - options - GenerateBenefitUtilizationSummariesReportClientBeginGenerateByReservationOrderIDOptions contains the optional +// parameters for the GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByReservationOrderID method. +func (client *GenerateBenefitUtilizationSummariesReportClient) BeginGenerateByReservationOrderID(ctx context.Context, reservationOrderID string, benefitUtilizationSummariesRequest BenefitUtilizationSummariesRequest, options *GenerateBenefitUtilizationSummariesReportClientBeginGenerateByReservationOrderIDOptions) (*runtime.Poller[GenerateBenefitUtilizationSummariesReportClientGenerateByReservationOrderIDResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.generateByReservationOrderID(ctx, reservationOrderID, benefitUtilizationSummariesRequest, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[GenerateBenefitUtilizationSummariesReportClientGenerateByReservationOrderIDResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[GenerateBenefitUtilizationSummariesReportClientGenerateByReservationOrderIDResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// GenerateByReservationOrderID - Triggers generation of a benefit utilization summaries report for the provided reservation +// order. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-08-01 +func (client *GenerateBenefitUtilizationSummariesReportClient) generateByReservationOrderID(ctx context.Context, reservationOrderID string, benefitUtilizationSummariesRequest BenefitUtilizationSummariesRequest, options *GenerateBenefitUtilizationSummariesReportClientBeginGenerateByReservationOrderIDOptions) (*http.Response, error) { + var err error + req, err := client.generateByReservationOrderIDCreateRequest(ctx, reservationOrderID, benefitUtilizationSummariesRequest, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// generateByReservationOrderIDCreateRequest creates the GenerateByReservationOrderID request. +func (client *GenerateBenefitUtilizationSummariesReportClient) generateByReservationOrderIDCreateRequest(ctx context.Context, reservationOrderID string, benefitUtilizationSummariesRequest BenefitUtilizationSummariesRequest, options *GenerateBenefitUtilizationSummariesReportClientBeginGenerateByReservationOrderIDOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.Capacity/reservationorders/{reservationOrderId}/providers/Microsoft.CostManagement/generateBenefitUtilizationSummariesReport" + if reservationOrderID == "" { + return nil, errors.New("parameter reservationOrderID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{reservationOrderId}", url.PathEscape(reservationOrderID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-08-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, benefitUtilizationSummariesRequest); err != nil { + return nil, err + } + return req, nil +} + +// BeginGenerateBySavingsPlanID - Triggers generation of a benefit utilization summaries report for the provided savings plan. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-08-01 +// - savingsPlanOrderID - Savings plan order ID. +// - savingsPlanID - Savings plan ID. +// - benefitUtilizationSummariesRequest - Async Benefit Utilization Summary report to be created. +// - options - GenerateBenefitUtilizationSummariesReportClientBeginGenerateBySavingsPlanIDOptions contains the optional parameters +// for the GenerateBenefitUtilizationSummariesReportClient.BeginGenerateBySavingsPlanID method. +func (client *GenerateBenefitUtilizationSummariesReportClient) BeginGenerateBySavingsPlanID(ctx context.Context, savingsPlanOrderID string, savingsPlanID string, benefitUtilizationSummariesRequest BenefitUtilizationSummariesRequest, options *GenerateBenefitUtilizationSummariesReportClientBeginGenerateBySavingsPlanIDOptions) (*runtime.Poller[GenerateBenefitUtilizationSummariesReportClientGenerateBySavingsPlanIDResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.generateBySavingsPlanID(ctx, savingsPlanOrderID, savingsPlanID, benefitUtilizationSummariesRequest, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[GenerateBenefitUtilizationSummariesReportClientGenerateBySavingsPlanIDResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[GenerateBenefitUtilizationSummariesReportClientGenerateBySavingsPlanIDResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// GenerateBySavingsPlanID - Triggers generation of a benefit utilization summaries report for the provided savings plan. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-08-01 +func (client *GenerateBenefitUtilizationSummariesReportClient) generateBySavingsPlanID(ctx context.Context, savingsPlanOrderID string, savingsPlanID string, benefitUtilizationSummariesRequest BenefitUtilizationSummariesRequest, options *GenerateBenefitUtilizationSummariesReportClientBeginGenerateBySavingsPlanIDOptions) (*http.Response, error) { + var err error + req, err := client.generateBySavingsPlanIDCreateRequest(ctx, savingsPlanOrderID, savingsPlanID, benefitUtilizationSummariesRequest, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// generateBySavingsPlanIDCreateRequest creates the GenerateBySavingsPlanID request. +func (client *GenerateBenefitUtilizationSummariesReportClient) generateBySavingsPlanIDCreateRequest(ctx context.Context, savingsPlanOrderID string, savingsPlanID string, benefitUtilizationSummariesRequest BenefitUtilizationSummariesRequest, options *GenerateBenefitUtilizationSummariesReportClientBeginGenerateBySavingsPlanIDOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.BillingBenefits/savingsPlanOrders/{savingsPlanOrderId}/savingsPlans/{savingsPlanId}/providers/Microsoft.CostManagement/generateBenefitUtilizationSummariesReport" + if savingsPlanOrderID == "" { + return nil, errors.New("parameter savingsPlanOrderID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{savingsPlanOrderId}", url.PathEscape(savingsPlanOrderID)) + if savingsPlanID == "" { + return nil, errors.New("parameter savingsPlanID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{savingsPlanId}", url.PathEscape(savingsPlanID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-08-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, benefitUtilizationSummariesRequest); err != nil { + return nil, err + } + return req, nil +} + +// BeginGenerateBySavingsPlanOrderID - Triggers generation of a benefit utilization summaries report for the provided savings +// plan order. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-08-01 +// - savingsPlanOrderID - Savings plan order ID. +// - benefitUtilizationSummariesRequest - Async Benefit Utilization Summary report to be created. +// - options - GenerateBenefitUtilizationSummariesReportClientBeginGenerateBySavingsPlanOrderIDOptions contains the optional +// parameters for the GenerateBenefitUtilizationSummariesReportClient.BeginGenerateBySavingsPlanOrderID method. +func (client *GenerateBenefitUtilizationSummariesReportClient) BeginGenerateBySavingsPlanOrderID(ctx context.Context, savingsPlanOrderID string, benefitUtilizationSummariesRequest BenefitUtilizationSummariesRequest, options *GenerateBenefitUtilizationSummariesReportClientBeginGenerateBySavingsPlanOrderIDOptions) (*runtime.Poller[GenerateBenefitUtilizationSummariesReportClientGenerateBySavingsPlanOrderIDResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.generateBySavingsPlanOrderID(ctx, savingsPlanOrderID, benefitUtilizationSummariesRequest, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[GenerateBenefitUtilizationSummariesReportClientGenerateBySavingsPlanOrderIDResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[GenerateBenefitUtilizationSummariesReportClientGenerateBySavingsPlanOrderIDResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// GenerateBySavingsPlanOrderID - Triggers generation of a benefit utilization summaries report for the provided savings plan +// order. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-08-01 +func (client *GenerateBenefitUtilizationSummariesReportClient) generateBySavingsPlanOrderID(ctx context.Context, savingsPlanOrderID string, benefitUtilizationSummariesRequest BenefitUtilizationSummariesRequest, options *GenerateBenefitUtilizationSummariesReportClientBeginGenerateBySavingsPlanOrderIDOptions) (*http.Response, error) { + var err error + req, err := client.generateBySavingsPlanOrderIDCreateRequest(ctx, savingsPlanOrderID, benefitUtilizationSummariesRequest, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// generateBySavingsPlanOrderIDCreateRequest creates the GenerateBySavingsPlanOrderID request. +func (client *GenerateBenefitUtilizationSummariesReportClient) generateBySavingsPlanOrderIDCreateRequest(ctx context.Context, savingsPlanOrderID string, benefitUtilizationSummariesRequest BenefitUtilizationSummariesRequest, options *GenerateBenefitUtilizationSummariesReportClientBeginGenerateBySavingsPlanOrderIDOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.BillingBenefits/savingsPlanOrders/{savingsPlanOrderId}/providers/Microsoft.CostManagement/generateBenefitUtilizationSummariesReport" + if savingsPlanOrderID == "" { + return nil, errors.New("parameter savingsPlanOrderID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{savingsPlanOrderId}", url.PathEscape(savingsPlanOrderID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-08-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, benefitUtilizationSummariesRequest); err != nil { + return nil, err + } + return req, nil +} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/generatecostdetailsreport_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/generatecostdetailsreport_client.go index 5e79fec9be5d..328cc57b2bfe 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/generatecostdetailsreport_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/generatecostdetailsreport_client.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armcostmanagement @@ -54,9 +53,9 @@ func NewGenerateCostDetailsReportClient(credential azcore.TokenCredential, optio // in files ,see https://learn.microsoft.com/en-us/azure/cost-management-billing/automate/understand-usage-details-fields // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 -// - scope - The ARM Resource ID for subscription, resource group, billing account, or other billing scopes. For details, see -// https://aka.ms/costmgmt/scopes. +// Generated from API version 2023-08-01 +// - scope - The ARM Resource ID for subscription, billing account, or other billing scopes.Currently Resource Group and Management +// Group are not supported. For details, see https://aka.ms/costmgmt/scopes. // - parameters - Parameters supplied to the Create cost details operation. // - options - GenerateCostDetailsReportClientBeginCreateOperationOptions contains the optional parameters for the GenerateCostDetailsReportClient.BeginCreateOperation // method. @@ -66,9 +65,10 @@ func (client *GenerateCostDetailsReportClient) BeginCreateOperation(ctx context. if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[GenerateCostDetailsReportClientCreateOperationResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[GenerateCostDetailsReportClientCreateOperationResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[GenerateCostDetailsReportClientCreateOperationResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -87,20 +87,22 @@ func (client *GenerateCostDetailsReportClient) BeginCreateOperation(ctx context. // in files ,see https://learn.microsoft.com/en-us/azure/cost-management-billing/automate/understand-usage-details-fields // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 func (client *GenerateCostDetailsReportClient) createOperation(ctx context.Context, scope string, parameters GenerateCostDetailsReportRequestDefinition, options *GenerateCostDetailsReportClientBeginCreateOperationOptions) (*http.Response, error) { + var err error req, err := client.createOperationCreateRequest(ctx, scope, parameters, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // createOperationCreateRequest creates the CreateOperation request. @@ -112,19 +114,22 @@ func (client *GenerateCostDetailsReportClient) createOperationCreateRequest(ctx return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, parameters) + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil } // BeginGetOperationResults - Get the result of the specified operation. This link is provided in the CostDetails creation // request response Location header. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 -// - scope - The ARM Resource ID for subscription, resource group, billing account, or other billing scopes. For details, see -// https://aka.ms/costmgmt/scopes. +// Generated from API version 2023-08-01 +// - scope - The ARM Resource ID for subscription, billing account, or other billing scopes.Currently Resource Group and Management +// Group are not supported. For details, see https://aka.ms/costmgmt/scopes. // - operationID - The target operation Id. // - options - GenerateCostDetailsReportClientBeginGetOperationResultsOptions contains the optional parameters for the GenerateCostDetailsReportClient.BeginGetOperationResults // method. @@ -134,9 +139,10 @@ func (client *GenerateCostDetailsReportClient) BeginGetOperationResults(ctx cont if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[GenerateCostDetailsReportClientGetOperationResultsResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[GenerateCostDetailsReportClientGetOperationResultsResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[GenerateCostDetailsReportClientGetOperationResultsResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -146,20 +152,22 @@ func (client *GenerateCostDetailsReportClient) BeginGetOperationResults(ctx cont // response Location header. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 func (client *GenerateCostDetailsReportClient) getOperationResults(ctx context.Context, scope string, operationID string, options *GenerateCostDetailsReportClientBeginGetOperationResultsOptions) (*http.Response, error) { + var err error req, err := client.getOperationResultsCreateRequest(ctx, scope, operationID, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // getOperationResultsCreateRequest creates the GetOperationResults request. @@ -175,7 +183,7 @@ func (client *GenerateCostDetailsReportClient) getOperationResultsCreateRequest( return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/generatecostdetailsreport_client_example_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/generatecostdetailsreport_client_example_test.go deleted file mode 100644 index 5057b18332f2..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/generatecostdetailsreport_client_example_test.go +++ /dev/null @@ -1,459 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armcostmanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateCostDetailsReportByBillingAccountEnterpriseAgreementCustomerAndBillingPeriod.json -func ExampleGenerateCostDetailsReportClient_BeginCreateOperation_generateCostDetailsReportByBillingAccountEnterpriseAgreementCustomerAndBillingPeriod() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewGenerateCostDetailsReportClient().BeginCreateOperation(ctx, "providers/Microsoft.Billing/billingAccounts/12345", armcostmanagement.GenerateCostDetailsReportRequestDefinition{ - BillingPeriod: to.Ptr("202205"), - Metric: to.Ptr(armcostmanagement.CostDetailsMetricTypeActualCostCostDetailsMetricType), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.CostDetailsOperationResults = armcostmanagement.CostDetailsOperationResults{ - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345/providers/Microsoft.CostManagement/costDetailsOperationResults/00000000-0000-0000-0000-000000000000"), - // Manifest: &armcostmanagement.ReportManifest{ - // BlobCount: to.Ptr[int32](1), - // Blobs: []*armcostmanagement.BlobInfo{ - // { - // BlobLink: to.Ptr("https://ccmreportstorageeastus.blob.core.windows.net/armreports/00000/00000000-0000-0000-0000-000000000000?sv=2020-05-31&sr=b&sig=abcd"), - // ByteCount: to.Ptr[int64](32741), - // }}, - // ByteCount: to.Ptr[int64](32741), - // CompressData: to.Ptr(false), - // DataFormat: to.Ptr(armcostmanagement.CostDetailsDataFormatCSVCostDetailsDataFormat), - // ManifestVersion: to.Ptr("2022-10-01"), - // RequestContext: &armcostmanagement.RequestContext{ - // RequestBody: &armcostmanagement.GenerateCostDetailsReportRequestDefinition{ - // BillingPeriod: to.Ptr("202205"), - // Metric: to.Ptr(armcostmanagement.CostDetailsMetricTypeActualCostCostDetailsMetricType), - // }, - // RequestScope: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345"), - // }, - // }, - // Status: to.Ptr(armcostmanagement.CostDetailsStatusTypeCompletedCostDetailsStatusType), - // ValidTill: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-05-10T08:08:46.1973252Z"); return t}()), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateCostDetailsReportByBillingProfileAndInvoiceId.json -func ExampleGenerateCostDetailsReportClient_BeginCreateOperation_generateCostDetailsReportByBillingProfileAndInvoiceId() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewGenerateCostDetailsReportClient().BeginCreateOperation(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579", armcostmanagement.GenerateCostDetailsReportRequestDefinition{ - InvoiceID: to.Ptr("M1234567"), - Metric: to.Ptr(armcostmanagement.CostDetailsMetricTypeActualCostCostDetailsMetricType), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.CostDetailsOperationResults = armcostmanagement.CostDetailsOperationResults{ - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/providers/Microsoft.CostManagement/costDetailsOperationResults/00000000-0000-0000-0000-000000000000"), - // Manifest: &armcostmanagement.ReportManifest{ - // BlobCount: to.Ptr[int32](1), - // Blobs: []*armcostmanagement.BlobInfo{ - // { - // BlobLink: to.Ptr("https://ccmreportstorageeastus.blob.core.windows.net/armreports/00000/00000000-0000-0000-0000-000000000000?sv=2020-05-31&sr=b&sig=abcd"), - // ByteCount: to.Ptr[int64](32741), - // }}, - // ByteCount: to.Ptr[int64](32741), - // CompressData: to.Ptr(false), - // DataFormat: to.Ptr(armcostmanagement.CostDetailsDataFormatCSVCostDetailsDataFormat), - // ManifestVersion: to.Ptr("2022-10-01"), - // RequestContext: &armcostmanagement.RequestContext{ - // RequestBody: &armcostmanagement.GenerateCostDetailsReportRequestDefinition{ - // BillingPeriod: to.Ptr("202205"), - // Metric: to.Ptr(armcostmanagement.CostDetailsMetricTypeActualCostCostDetailsMetricType), - // }, - // RequestScope: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579"), - // }, - // }, - // Status: to.Ptr(armcostmanagement.CostDetailsStatusTypeCompletedCostDetailsStatusType), - // ValidTill: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-05-10T08:08:46.1973252Z"); return t}()), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateCostDetailsReportByBillingProfileAndInvoiceIdAndCustomerId.json -func ExampleGenerateCostDetailsReportClient_BeginCreateOperation_generateCostDetailsReportByBillingProfileAndInvoiceIdAndCustomerId() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewGenerateCostDetailsReportClient().BeginCreateOperation(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789/customers/13579", armcostmanagement.GenerateCostDetailsReportRequestDefinition{ - InvoiceID: to.Ptr("M1234567"), - Metric: to.Ptr(armcostmanagement.CostDetailsMetricTypeActualCostCostDetailsMetricType), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.CostDetailsOperationResults = armcostmanagement.CostDetailsOperationResults{ - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/customers/13579/providers/Microsoft.CostManagement/costDetailsOperationResults/00000000-0000-0000-0000-000000000000"), - // Manifest: &armcostmanagement.ReportManifest{ - // BlobCount: to.Ptr[int32](1), - // Blobs: []*armcostmanagement.BlobInfo{ - // { - // BlobLink: to.Ptr("https://ccmreportstorageeastus.blob.core.windows.net/armreports/00000/00000000-0000-0000-0000-000000000000?sv=2020-05-31&sr=b&sig=abcd"), - // ByteCount: to.Ptr[int64](32741), - // }}, - // ByteCount: to.Ptr[int64](32741), - // CompressData: to.Ptr(false), - // DataFormat: to.Ptr(armcostmanagement.CostDetailsDataFormatCSVCostDetailsDataFormat), - // ManifestVersion: to.Ptr("2022-10-01"), - // RequestContext: &armcostmanagement.RequestContext{ - // RequestBody: &armcostmanagement.GenerateCostDetailsReportRequestDefinition{ - // BillingPeriod: to.Ptr("202205"), - // Metric: to.Ptr(armcostmanagement.CostDetailsMetricTypeActualCostCostDetailsMetricType), - // }, - // RequestScope: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/customers/13579"), - // }, - // }, - // Status: to.Ptr(armcostmanagement.CostDetailsStatusTypeCompletedCostDetailsStatusType), - // ValidTill: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-05-10T08:08:46.1973252Z"); return t}()), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateCostDetailsReportByCustomerAndTimePeriod.json -func ExampleGenerateCostDetailsReportClient_BeginCreateOperation_generateCostDetailsReportByCustomerAndTimePeriod() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewGenerateCostDetailsReportClient().BeginCreateOperation(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789/customers/13579", armcostmanagement.GenerateCostDetailsReportRequestDefinition{ - Metric: to.Ptr(armcostmanagement.CostDetailsMetricTypeActualCostCostDetailsMetricType), - TimePeriod: &armcostmanagement.CostDetailsTimePeriod{ - End: to.Ptr("2020-03-15"), - Start: to.Ptr("2020-03-01"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.CostDetailsOperationResults = armcostmanagement.CostDetailsOperationResults{ - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/customers/13579/providers/Microsoft.CostManagement/costDetailsOperationResults/00000000-0000-0000-0000-000000000000"), - // Manifest: &armcostmanagement.ReportManifest{ - // BlobCount: to.Ptr[int32](1), - // Blobs: []*armcostmanagement.BlobInfo{ - // { - // BlobLink: to.Ptr("https://ccmreportstorageeastus.blob.core.windows.net/armreports/00000/00000000-0000-0000-0000-000000000000?sv=2020-05-31&sr=b&sig=abcd"), - // ByteCount: to.Ptr[int64](32741), - // }}, - // ByteCount: to.Ptr[int64](32741), - // CompressData: to.Ptr(false), - // DataFormat: to.Ptr(armcostmanagement.CostDetailsDataFormatCSVCostDetailsDataFormat), - // ManifestVersion: to.Ptr("2022-10-01"), - // RequestContext: &armcostmanagement.RequestContext{ - // RequestBody: &armcostmanagement.GenerateCostDetailsReportRequestDefinition{ - // Metric: to.Ptr(armcostmanagement.CostDetailsMetricTypeActualCostCostDetailsMetricType), - // TimePeriod: &armcostmanagement.CostDetailsTimePeriod{ - // End: to.Ptr("2020-03-15"), - // Start: to.Ptr("2020-03-01"), - // }, - // }, - // RequestScope: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/customers/13579"), - // }, - // }, - // Status: to.Ptr(armcostmanagement.CostDetailsStatusTypeCompletedCostDetailsStatusType), - // ValidTill: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-05-10T08:08:46.1973252Z"); return t}()), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateCostDetailsReportByDepartmentsAndTimePeriod.json -func ExampleGenerateCostDetailsReportClient_BeginCreateOperation_generateCostDetailsReportByDepartmentsAndTimePeriod() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewGenerateCostDetailsReportClient().BeginCreateOperation(ctx, "providers/Microsoft.Billing/departments/12345", armcostmanagement.GenerateCostDetailsReportRequestDefinition{ - Metric: to.Ptr(armcostmanagement.CostDetailsMetricTypeActualCostCostDetailsMetricType), - TimePeriod: &armcostmanagement.CostDetailsTimePeriod{ - End: to.Ptr("2020-03-15"), - Start: to.Ptr("2020-03-01"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.CostDetailsOperationResults = armcostmanagement.CostDetailsOperationResults{ - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ID: to.Ptr("providers/Microsoft.Billing/departments/12345/providers/Microsoft.CostManagement/costDetailsOperationResults/00000000-0000-0000-0000-000000000000"), - // Manifest: &armcostmanagement.ReportManifest{ - // BlobCount: to.Ptr[int32](1), - // Blobs: []*armcostmanagement.BlobInfo{ - // { - // BlobLink: to.Ptr("https://ccmreportstorageeastus.blob.core.windows.net/armreports/00000/00000000-0000-0000-0000-000000000000?sv=2020-05-31&sr=b&sig=abcd"), - // ByteCount: to.Ptr[int64](32741), - // }}, - // ByteCount: to.Ptr[int64](32741), - // CompressData: to.Ptr(false), - // DataFormat: to.Ptr(armcostmanagement.CostDetailsDataFormatCSVCostDetailsDataFormat), - // ManifestVersion: to.Ptr("2022-10-01"), - // RequestContext: &armcostmanagement.RequestContext{ - // RequestBody: &armcostmanagement.GenerateCostDetailsReportRequestDefinition{ - // Metric: to.Ptr(armcostmanagement.CostDetailsMetricTypeActualCostCostDetailsMetricType), - // TimePeriod: &armcostmanagement.CostDetailsTimePeriod{ - // End: to.Ptr("2020-03-15"), - // Start: to.Ptr("2020-03-01"), - // }, - // }, - // RequestScope: to.Ptr("providers/Microsoft.Billing/departments/12345"), - // }, - // }, - // Status: to.Ptr(armcostmanagement.CostDetailsStatusTypeCompletedCostDetailsStatusType), - // ValidTill: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-05-10T08:08:46.1973252Z"); return t}()), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateCostDetailsReportByEnrollmentAccountsAndTimePeriod.json -func ExampleGenerateCostDetailsReportClient_BeginCreateOperation_generateCostDetailsReportByEnrollmentAccountsAndTimePeriod() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewGenerateCostDetailsReportClient().BeginCreateOperation(ctx, "providers/Microsoft.Billing/enrollmentAccounts/1234", armcostmanagement.GenerateCostDetailsReportRequestDefinition{ - Metric: to.Ptr(armcostmanagement.CostDetailsMetricTypeActualCostCostDetailsMetricType), - TimePeriod: &armcostmanagement.CostDetailsTimePeriod{ - End: to.Ptr("2020-03-15"), - Start: to.Ptr("2020-03-01"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.CostDetailsOperationResults = armcostmanagement.CostDetailsOperationResults{ - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ID: to.Ptr("providers/Microsoft.Billing/enrollmentAccounts/1234/providers/Microsoft.CostManagement/costDetailsOperationResults/00000000-0000-0000-0000-000000000000"), - // Manifest: &armcostmanagement.ReportManifest{ - // BlobCount: to.Ptr[int32](1), - // Blobs: []*armcostmanagement.BlobInfo{ - // { - // BlobLink: to.Ptr("https://ccmreportstorageeastus.blob.core.windows.net/armreports/00000/00000000-0000-0000-0000-000000000000?sv=2020-05-31&sr=b&sig=abcd"), - // ByteCount: to.Ptr[int64](32741), - // }}, - // ByteCount: to.Ptr[int64](32741), - // CompressData: to.Ptr(false), - // DataFormat: to.Ptr(armcostmanagement.CostDetailsDataFormatCSVCostDetailsDataFormat), - // ManifestVersion: to.Ptr("2022-10-01"), - // RequestContext: &armcostmanagement.RequestContext{ - // RequestBody: &armcostmanagement.GenerateCostDetailsReportRequestDefinition{ - // Metric: to.Ptr(armcostmanagement.CostDetailsMetricTypeActualCostCostDetailsMetricType), - // TimePeriod: &armcostmanagement.CostDetailsTimePeriod{ - // End: to.Ptr("2020-03-15"), - // Start: to.Ptr("2020-03-01"), - // }, - // }, - // RequestScope: to.Ptr("providers/Microsoft.Billing/enrollmentAccounts/1234"), - // }, - // }, - // Status: to.Ptr(armcostmanagement.CostDetailsStatusTypeCompletedCostDetailsStatusType), - // ValidTill: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-05-10T08:08:46.1973252Z"); return t}()), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateCostDetailsReportBySubscriptionAndTimePeriod.json -func ExampleGenerateCostDetailsReportClient_BeginCreateOperation_generateCostDetailsReportBySubscriptionAndTimePeriod() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewGenerateCostDetailsReportClient().BeginCreateOperation(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", armcostmanagement.GenerateCostDetailsReportRequestDefinition{ - Metric: to.Ptr(armcostmanagement.CostDetailsMetricTypeActualCostCostDetailsMetricType), - TimePeriod: &armcostmanagement.CostDetailsTimePeriod{ - End: to.Ptr("2020-03-15"), - Start: to.Ptr("2020-03-01"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.CostDetailsOperationResults = armcostmanagement.CostDetailsOperationResults{ - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/costDetailsOperationResults/00000000-0000-0000-0000-000000000000"), - // Manifest: &armcostmanagement.ReportManifest{ - // BlobCount: to.Ptr[int32](1), - // Blobs: []*armcostmanagement.BlobInfo{ - // { - // BlobLink: to.Ptr("https://ccmreportstorageeastus.blob.core.windows.net/armreports/00000/00000000-0000-0000-0000-000000000000?sv=2020-05-31&sr=b&sig=abcd"), - // ByteCount: to.Ptr[int64](32741), - // }}, - // ByteCount: to.Ptr[int64](32741), - // CompressData: to.Ptr(false), - // DataFormat: to.Ptr(armcostmanagement.CostDetailsDataFormatCSVCostDetailsDataFormat), - // ManifestVersion: to.Ptr("2022-10-01"), - // RequestContext: &armcostmanagement.RequestContext{ - // RequestBody: &armcostmanagement.GenerateCostDetailsReportRequestDefinition{ - // Metric: to.Ptr(armcostmanagement.CostDetailsMetricTypeActualCostCostDetailsMetricType), - // TimePeriod: &armcostmanagement.CostDetailsTimePeriod{ - // End: to.Ptr("2020-03-15"), - // Start: to.Ptr("2020-03-01"), - // }, - // }, - // RequestScope: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000"), - // }, - // }, - // Status: to.Ptr(armcostmanagement.CostDetailsStatusTypeCompletedCostDetailsStatusType), - // ValidTill: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-05-10T08:08:46.1973252Z"); return t}()), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/CostDetailsOperationResultsBySubscriptionScope.json -func ExampleGenerateCostDetailsReportClient_BeginGetOperationResults() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewGenerateCostDetailsReportClient().BeginGetOperationResults(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", "00000000-0000-0000-0000-000000000000", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.CostDetailsOperationResults = armcostmanagement.CostDetailsOperationResults{ - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/costDetailsOperationResults/00000000-0000-0000-0000-000000000000"), - // Manifest: &armcostmanagement.ReportManifest{ - // BlobCount: to.Ptr[int32](1), - // Blobs: []*armcostmanagement.BlobInfo{ - // { - // BlobLink: to.Ptr("https://ccmreportstorageeastus.blob.core.windows.net/armreports/00000/00000000-0000-0000-0000-000000000000?sv=2020-05-31&sr=b&sig=abcd"), - // ByteCount: to.Ptr[int64](32741), - // }}, - // ByteCount: to.Ptr[int64](32741), - // CompressData: to.Ptr(false), - // DataFormat: to.Ptr(armcostmanagement.CostDetailsDataFormatCSVCostDetailsDataFormat), - // ManifestVersion: to.Ptr("2022-10-01"), - // RequestContext: &armcostmanagement.RequestContext{ - // RequestBody: &armcostmanagement.GenerateCostDetailsReportRequestDefinition{ - // Metric: to.Ptr(armcostmanagement.CostDetailsMetricTypeActualCostCostDetailsMetricType), - // TimePeriod: &armcostmanagement.CostDetailsTimePeriod{ - // End: to.Ptr("2020-03-15"), - // Start: to.Ptr("2020-03-01"), - // }, - // }, - // RequestScope: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000"), - // }, - // }, - // Status: to.Ptr(armcostmanagement.CostDetailsStatusTypeCompletedCostDetailsStatusType), - // ValidTill: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-05-10T08:08:46.1973252Z"); return t}()), - // } -} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreport_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreport_client.go index 4b7a9891d8c4..979ab770f8dd 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreport_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreport_client.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armcostmanagement @@ -46,7 +45,7 @@ func NewGenerateDetailedCostReportClient(credential azcore.TokenCredential, opti // cost report is being stored. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - scope - The ARM Resource ID for subscription, resource group, billing account, or other billing scopes. For details, see // https://aka.ms/costmgmt/scopes. // - parameters - Parameters supplied to the Create detailed cost report operation. @@ -58,9 +57,10 @@ func (client *GenerateDetailedCostReportClient) BeginCreateOperation(ctx context if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[GenerateDetailedCostReportClientCreateOperationResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[GenerateDetailedCostReportClientCreateOperationResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[GenerateDetailedCostReportClientCreateOperationResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -73,20 +73,22 @@ func (client *GenerateDetailedCostReportClient) BeginCreateOperation(ctx context // cost report is being stored. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 func (client *GenerateDetailedCostReportClient) createOperation(ctx context.Context, scope string, parameters GenerateDetailedCostReportDefinition, options *GenerateDetailedCostReportClientBeginCreateOperationOptions) (*http.Response, error) { + var err error req, err := client.createOperationCreateRequest(ctx, scope, parameters, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // createOperationCreateRequest creates the CreateOperation request. @@ -98,8 +100,11 @@ func (client *GenerateDetailedCostReportClient) createOperationCreateRequest(ctx return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, parameters) + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil } diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreport_client_example_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreport_client_example_test.go deleted file mode 100644 index 76466f5c3fe6..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreport_client_example_test.go +++ /dev/null @@ -1,206 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armcostmanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateDetailedCostReportByBillingAccountLegacyAndBillingPeriod.json -func ExampleGenerateDetailedCostReportClient_BeginCreateOperation_generateDetailedCostReportByBillingAccountLegacyAndBillingPeriod() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewGenerateDetailedCostReportClient().BeginCreateOperation(ctx, "providers/Microsoft.Billing/billingAccounts/12345", armcostmanagement.GenerateDetailedCostReportDefinition{ - BillingPeriod: to.Ptr("202008"), - Metric: to.Ptr(armcostmanagement.GenerateDetailedCostReportMetricTypeActualCost), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.GenerateDetailedCostReportOperationResult = armcostmanagement.GenerateDetailedCostReportOperationResult{ - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.Consumption/operationResult"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/operationResults/00000000-0000-0000-0000-000000000000"), - // Properties: &armcostmanagement.DownloadURL{ - // DownloadURL: to.Ptr("https://ccmreportstorageeastus.blob.core.windows.net/armreports/20201207/00000000-0000-0000-0000-000000000000?sv=2020-05-31&sr=b&sig=abcd"), - // ValidTill: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-08T05:55:59.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 -func ExampleGenerateDetailedCostReportClient_BeginCreateOperation_generateDetailedCostReportByBillingProfileAndInvoiceId() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewGenerateDetailedCostReportClient().BeginCreateOperation(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579", armcostmanagement.GenerateDetailedCostReportDefinition{ - InvoiceID: to.Ptr("M1234567"), - Metric: to.Ptr(armcostmanagement.GenerateDetailedCostReportMetricTypeActualCost), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.GenerateDetailedCostReportOperationResult = armcostmanagement.GenerateDetailedCostReportOperationResult{ - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.Consumption/operationResult"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/operationResults/00000000-0000-0000-0000-000000000000"), - // Properties: &armcostmanagement.DownloadURL{ - // DownloadURL: to.Ptr("https://ccmreportstorageeastus.blob.core.windows.net/armreports/20201207/00000000-0000-0000-0000-000000000000?sv=2020-05-31&sr=b&sig=abcd"), - // ValidTill: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-08T05:55:59.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 -func ExampleGenerateDetailedCostReportClient_BeginCreateOperation_generateDetailedCostReportByBillingProfileAndInvoiceIdAndCustomerId() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewGenerateDetailedCostReportClient().BeginCreateOperation(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579", armcostmanagement.GenerateDetailedCostReportDefinition{ - CustomerID: to.Ptr("456789"), - InvoiceID: to.Ptr("M1234567"), - Metric: to.Ptr(armcostmanagement.GenerateDetailedCostReportMetricTypeActualCost), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.GenerateDetailedCostReportOperationResult = armcostmanagement.GenerateDetailedCostReportOperationResult{ - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.Consumption/operationResult"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/operationResults/00000000-0000-0000-0000-000000000000"), - // Properties: &armcostmanagement.DownloadURL{ - // DownloadURL: to.Ptr("https://ccmreportstorageeastus.blob.core.windows.net/armreports/20201207/00000000-0000-0000-0000-000000000000?sv=2020-05-31&sr=b&sig=abcd"), - // ValidTill: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-08T05:55:59.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 -func ExampleGenerateDetailedCostReportClient_BeginCreateOperation_generateDetailedCostReportByCustomerAndTimePeriod() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewGenerateDetailedCostReportClient().BeginCreateOperation(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789/customers/13579", armcostmanagement.GenerateDetailedCostReportDefinition{ - Metric: to.Ptr(armcostmanagement.GenerateDetailedCostReportMetricTypeActualCost), - TimePeriod: &armcostmanagement.GenerateDetailedCostReportTimePeriod{ - End: to.Ptr("2020-03-15"), - Start: to.Ptr("2020-03-01"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.GenerateDetailedCostReportOperationResult = armcostmanagement.GenerateDetailedCostReportOperationResult{ - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.Consumption/operationResult"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/operationResults/00000000-0000-0000-0000-000000000000"), - // Properties: &armcostmanagement.DownloadURL{ - // DownloadURL: to.Ptr("https://ccmreportstorageeastus.blob.core.windows.net/armreports/20201207/00000000-0000-0000-0000-000000000000?sv=2020-05-31&sr=b&sig=abcd"), - // ValidTill: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-08T05:55:59.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 -func ExampleGenerateDetailedCostReportClient_BeginCreateOperation_generateDetailedCostReportBySubscriptionAndTimePeriod() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewGenerateDetailedCostReportClient().BeginCreateOperation(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", armcostmanagement.GenerateDetailedCostReportDefinition{ - Metric: to.Ptr(armcostmanagement.GenerateDetailedCostReportMetricTypeActualCost), - TimePeriod: &armcostmanagement.GenerateDetailedCostReportTimePeriod{ - End: to.Ptr("2020-03-15"), - Start: to.Ptr("2020-03-01"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.GenerateDetailedCostReportOperationResult = armcostmanagement.GenerateDetailedCostReportOperationResult{ - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.Consumption/operationResult"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/operationResults/00000000-0000-0000-0000-000000000000"), - // Properties: &armcostmanagement.DownloadURL{ - // DownloadURL: to.Ptr("https://ccmreportstorageeastus.blob.core.windows.net/armreports/20201207/00000000-0000-0000-0000-000000000000?sv=2020-05-31&sr=b&sig=abcd"), - // ValidTill: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-08T05:55:59.4394737Z"); return t}()), - // }, - // } -} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationresults_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationresults_client.go index 562e1c03274f..156044cdf2c4 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationresults_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationresults_client.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armcostmanagement @@ -45,7 +44,7 @@ func NewGenerateDetailedCostReportOperationResultsClient(credential azcore.Token // of the initial request. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - operationID - The target operation Id. // - scope - The ARM Resource ID for subscription, resource group, billing account, or other billing scopes. For details, see // https://aka.ms/costmgmt/scopes. @@ -57,7 +56,8 @@ func (client *GenerateDetailedCostReportOperationResultsClient) BeginGet(ctx con if err != nil { return nil, err } - return runtime.NewPoller[GenerateDetailedCostReportOperationResultsClientGetResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller[GenerateDetailedCostReportOperationResultsClientGetResponse](resp, client.internal.Pipeline(), nil) + return poller, err } else { return runtime.NewPollerFromResumeToken[GenerateDetailedCostReportOperationResultsClientGetResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -67,20 +67,22 @@ func (client *GenerateDetailedCostReportOperationResultsClient) BeginGet(ctx con // initial request. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 func (client *GenerateDetailedCostReportOperationResultsClient) get(ctx context.Context, operationID string, scope string, options *GenerateDetailedCostReportOperationResultsClientBeginGetOptions) (*http.Response, error) { + var err error req, err := client.getCreateRequest(ctx, operationID, scope, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // getCreateRequest creates the Get request. @@ -96,7 +98,7 @@ func (client *GenerateDetailedCostReportOperationResultsClient) getCreateRequest return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationresults_client_example_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationresults_client_example_test.go deleted file mode 100644 index da700a0c89ba..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationresults_client_example_test.go +++ /dev/null @@ -1,51 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armcostmanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateDetailedCostReportOperationResultsBySubscriptionScope.json -func ExampleGenerateDetailedCostReportOperationResultsClient_BeginGet() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewGenerateDetailedCostReportOperationResultsClient().BeginGet(ctx, "00000000-0000-0000-0000-000000000000", "subscriptions/00000000-0000-0000-0000-000000000000", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.GenerateDetailedCostReportOperationResult = armcostmanagement.GenerateDetailedCostReportOperationResult{ - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.Consumption/operationResult"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/operationResults/00000000-0000-0000-0000-000000000000"), - // Properties: &armcostmanagement.DownloadURL{ - // DownloadURL: to.Ptr("https://ccmreportstorageeastus.blob.core.windows.net/armreports/20201207/00000000-0000-0000-0000-000000000000?sv=2020-05-31&sr=b&sig=abcd"), - // ValidTill: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-08T05:55:59.4394737Z"); return t}()), - // }, - // } -} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationstatus_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationstatus_client.go index aea1459156be..c3359faf9322 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationstatus_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationstatus_client.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armcostmanagement @@ -45,25 +44,28 @@ func NewGenerateDetailedCostReportOperationStatusClient(credential azcore.TokenC // response header. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - operationID - The target operation Id. // - scope - The ARM Resource ID for subscription, resource group, billing account, or other billing scopes. For details, see // https://aka.ms/costmgmt/scopes. // - 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) { + var err error req, err := client.getCreateRequest(ctx, operationID, scope, options) if err != nil { return GenerateDetailedCostReportOperationStatusClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return GenerateDetailedCostReportOperationStatusClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return GenerateDetailedCostReportOperationStatusClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return GenerateDetailedCostReportOperationStatusClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -79,7 +81,7 @@ func (client *GenerateDetailedCostReportOperationStatusClient) getCreateRequest( return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationstatus_client_example_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationstatus_client_example_test.go deleted file mode 100644 index 5254b62595c2..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationstatus_client_example_test.go +++ /dev/null @@ -1,52 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armcostmanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateDetailedCostReportOperationStatusBySubscriptionScope.json -func ExampleGenerateDetailedCostReportOperationStatusClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewGenerateDetailedCostReportOperationStatusClient().Get(ctx, "00000000-0000-0000-0000-000000000000", "subscriptions/00000000-0000-0000-0000-000000000000", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.GenerateDetailedCostReportOperationStatuses = armcostmanagement.GenerateDetailedCostReportOperationStatuses{ - // Name: to.Ptr("00000000-0000-0000-0000-000000000000"), - // Type: to.Ptr("Microsoft.Consumption/operationStatus"), - // Error: &armcostmanagement.ErrorDetails{ - // Code: to.Ptr("0"), - // }, - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/operationStatus/00000000-0000-0000-0000-000000000000"), - // Properties: &armcostmanagement.DownloadURL{ - // DownloadURL: to.Ptr("https://ccmreportstorageeastus.blob.core.windows.net/armreports/20201207/00000000-0000-0000-0000-000000000000?sv=2020-05-31&sr=b&sig=abcd"), - // ValidTill: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-12-08T05:55:59.4394737Z"); return t}()), - // }, - // Status: &armcostmanagement.Status{ - // }, - // } -} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/generatereservationdetailsreport_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/generatereservationdetailsreport_client.go index b61a4091d116..d803fcb97506 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/generatereservationdetailsreport_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/generatereservationdetailsreport_client.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armcostmanagement @@ -46,7 +45,7 @@ func NewGenerateReservationDetailsReportClient(credential azcore.TokenCredential // on the roles see, https://docs.microsoft.com/en-us/azure/cost-management-billing/manage/understand-ea-roles#usage-and-costs-access-by-role // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - billingAccountID - Enrollment ID (Legacy BillingAccount ID) // - startDate - Start Date // - endDate - End Date @@ -58,9 +57,10 @@ func (client *GenerateReservationDetailsReportClient) BeginByBillingAccountID(ct if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[GenerateReservationDetailsReportClientByBillingAccountIDResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[GenerateReservationDetailsReportClientByBillingAccountIDResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[GenerateReservationDetailsReportClientByBillingAccountIDResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -71,20 +71,22 @@ func (client *GenerateReservationDetailsReportClient) BeginByBillingAccountID(ct // on the roles see, https://docs.microsoft.com/en-us/azure/cost-management-billing/manage/understand-ea-roles#usage-and-costs-access-by-role // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 func (client *GenerateReservationDetailsReportClient) byBillingAccountID(ctx context.Context, billingAccountID string, startDate string, endDate string, options *GenerateReservationDetailsReportClientBeginByBillingAccountIDOptions) (*http.Response, error) { + var err error req, err := client.byBillingAccountIDCreateRequest(ctx, billingAccountID, startDate, endDate, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // byBillingAccountIDCreateRequest creates the ByBillingAccountID request. @@ -101,7 +103,7 @@ func (client *GenerateReservationDetailsReportClient) byBillingAccountIDCreateRe reqQP := req.Raw().URL.Query() reqQP.Set("startDate", startDate) reqQP.Set("endDate", endDate) - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -112,7 +114,7 @@ func (client *GenerateReservationDetailsReportClient) byBillingAccountIDCreateRe // details on the roles see, https://docs.microsoft.com/en-us/azure/cost-management-billing/reservations/reservation-utilization#view-utilization-in-the-azure-portal-with-azure-rbac-access // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - billingAccountID - Billing account ID // - billingProfileID - Billing profile ID. // - startDate - Start Date @@ -125,9 +127,10 @@ func (client *GenerateReservationDetailsReportClient) BeginByBillingProfileID(ct if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[GenerateReservationDetailsReportClientByBillingProfileIDResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[GenerateReservationDetailsReportClientByBillingProfileIDResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[GenerateReservationDetailsReportClientByBillingProfileIDResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -138,20 +141,22 @@ func (client *GenerateReservationDetailsReportClient) BeginByBillingProfileID(ct // details on the roles see, https://docs.microsoft.com/en-us/azure/cost-management-billing/reservations/reservation-utilization#view-utilization-in-the-azure-portal-with-azure-rbac-access // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 func (client *GenerateReservationDetailsReportClient) byBillingProfileID(ctx context.Context, billingAccountID string, billingProfileID string, startDate string, endDate string, options *GenerateReservationDetailsReportClientBeginByBillingProfileIDOptions) (*http.Response, error) { + var err error req, err := client.byBillingProfileIDCreateRequest(ctx, billingAccountID, billingProfileID, startDate, endDate, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // byBillingProfileIDCreateRequest creates the ByBillingProfileID request. @@ -172,7 +177,7 @@ func (client *GenerateReservationDetailsReportClient) byBillingProfileIDCreateRe reqQP := req.Raw().URL.Query() reqQP.Set("startDate", startDate) reqQP.Set("endDate", endDate) - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/generatereservationdetailsreport_client_example_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/generatereservationdetailsreport_client_example_test.go deleted file mode 100644 index 50160771bad5..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/generatereservationdetailsreport_client_example_test.go +++ /dev/null @@ -1,80 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armcostmanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateReservationDetailsReportByBillingAccount.json -func ExampleGenerateReservationDetailsReportClient_BeginByBillingAccountID() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewGenerateReservationDetailsReportClient().BeginByBillingAccountID(ctx, "9845612", "2020-01-01", "2020-01-30", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.OperationStatus = armcostmanagement.OperationStatus{ - // Properties: &armcostmanagement.ReportURL{ - // ReportURL: to.Ptr(armcostmanagement.ReservationReportSchema("https://storage.blob.core.windows.net/details/20200911/00000000-0000-0000-0000-000000000000?sv=2016-05-31&sr=b&sig=jep8HT2aphfUkyERRZa5LRfd9RPzjXbzB%2F9TNiQ")), - // ValidUntil: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-09-12T02:56:55.5021869Z"); return t}()), - // }, - // Status: to.Ptr(armcostmanagement.OperationStatusTypeCompleted), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/GenerateReservationDetailsReportByBillingProfile.json -func ExampleGenerateReservationDetailsReportClient_BeginByBillingProfileID() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewGenerateReservationDetailsReportClient().BeginByBillingProfileID(ctx, "00000000-0000-0000-0000-000000000000", "CZSFR-SDFXC-DSDF", "2020-01-01", "2020-01-30", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.OperationStatus = armcostmanagement.OperationStatus{ - // Properties: &armcostmanagement.ReportURL{ - // ReportURL: to.Ptr(armcostmanagement.ReservationReportSchema("https://storage.blob.core.windows.net/details/20200911/00000000-0000-0000-0000-000000000000?sv=2016-05-31&sr=b&sig=jep8HT2aphfUkyERRZa5LRfd9RPzjXbzB%2F9TNiQ")), - // ValidUntil: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-09-12T02:56:55.5021869Z"); return t}()), - // }, - // Status: to.Ptr(armcostmanagement.OperationStatusTypeCompleted), - // } -} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/go.mod b/sdk/resourcemanager/costmanagement/armcostmanagement/go.mod index 6fd8cad2b783..e9d05ab358b7 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/go.mod +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/go.mod @@ -2,20 +2,12 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armc go 1.18 -require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1 require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0 // indirect - github.com/golang-jwt/jwt/v4 v4.5.0 // indirect - github.com/google/uuid v1.3.0 // indirect - github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect - golang.org/x/crypto v0.7.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect golang.org/x/net v0.8.0 // indirect - golang.org/x/sys v0.6.0 // indirect golang.org/x/text v0.8.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/go.sum b/sdk/resourcemanager/costmanagement/armcostmanagement/go.sum index 21718b486698..727ce838bdc8 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/go.sum +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/go.sum @@ -1,31 +1,15 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.0 h1:8kDqDngH+DmVBiCtIjCFTGa7MBnsIOkF9IccInFEbjk= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.0/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0 h1:vcYCAze6p19qBW7MhZybIsqD8sMV8js0NyQM8JDnVtg= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0/go.mod h1:OQeznEEkTZ9OrhHJoDD8ZDq51FHgXjqtP9z6bEwBq9U= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1 h1:SEy2xmstIphdPwNBUi7uhvjyjhVKISfwjfOJmuy7kg4= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 h1:sXr+ck84g/ZlZUOZiNELInmMgOsuGwdjjVkEIde0OtY= github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0/go.mod h1:okt5dMMTOFjX/aovMlrjvvXoPMBVSPzk9185BT0+eZM= -github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0 h1:OBhqkivkhkMqLPymWEppkm7vgPQY2XsHoEkaMQ0AdZY= -github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= -github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= -github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= -github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= -golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/interfaces.go b/sdk/resourcemanager/costmanagement/armcostmanagement/interfaces.go new file mode 100644 index 000000000000..5b4d0247d521 --- /dev/null +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/interfaces.go @@ -0,0 +1,36 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armcostmanagement + +// BenefitRecommendationPropertiesClassification provides polymorphic access to related types. +// Call the interface's GetBenefitRecommendationProperties() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *BenefitRecommendationProperties, *SharedScopeBenefitRecommendationProperties, *SingleScopeBenefitRecommendationProperties +type BenefitRecommendationPropertiesClassification interface { + // GetBenefitRecommendationProperties returns the BenefitRecommendationProperties content of the underlying type. + GetBenefitRecommendationProperties() *BenefitRecommendationProperties +} + +// BenefitUtilizationSummaryClassification provides polymorphic access to related types. +// Call the interface's GetBenefitUtilizationSummary() method to access the common type. +// Use a type switch to determine the concrete type. The possible types are: +// - *BenefitUtilizationSummary, *IncludedQuantityUtilizationSummary, *SavingsPlanUtilizationSummary +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 56511a7e1771..05269cf2cb71 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/models.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/models.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armcostmanagement @@ -147,26 +146,6 @@ type AlertPropertiesDetails struct { Unit *string } -// AlertsClientDismissOptions contains the optional parameters for the AlertsClient.Dismiss method. -type AlertsClientDismissOptions struct { - // placeholder for future optional parameters -} - -// AlertsClientGetOptions contains the optional parameters for the AlertsClient.Get method. -type AlertsClientGetOptions struct { - // placeholder for future optional parameters -} - -// AlertsClientListExternalOptions contains the optional parameters for the AlertsClient.ListExternal method. -type AlertsClientListExternalOptions struct { - // placeholder for future optional parameters -} - -// AlertsClientListOptions contains the optional parameters for the AlertsClient.List method. -type AlertsClientListOptions struct { - // placeholder for future optional parameters -} - // AlertsResult - Result of alerts. type AlertsResult struct { // READ-ONLY; URL to get the next set of alerts results if there are any. @@ -218,6 +197,19 @@ type AllSavingsList struct { Value []*AllSavingsBenefitDetails } +// AsyncOperationStatusProperties - Object representing the report url and valid until date of the async report generated. +type AsyncOperationStatusProperties struct { + // Sas url to the async benefit utilization summaries report. Will be empty if the report is in Running or Failed state. + ReportURL *BenefitUtilizationSummaryReportSchema + + // Sas url to async benefit utilization summaries report in secondary storage in case of primary outage. Will be empty if + // the report is in Running or Failed state. + SecondaryReportURL *BenefitUtilizationSummaryReportSchema + + // The date that the sas url provided in reportUrl expires. + ValidUntil *time.Time +} + // BenefitRecommendationModel - benefit plan recommendation details. type BenefitRecommendationModel struct { // Reservation or SavingsPlan. @@ -236,15 +228,6 @@ type BenefitRecommendationModel struct { Type *string } -// BenefitRecommendationPropertiesClassification provides polymorphic access to related types. -// Call the interface's GetBenefitRecommendationProperties() method to access the common type. -// Use a type switch to determine the concrete type. The possible types are: -// - *BenefitRecommendationProperties, *SharedScopeBenefitRecommendationProperties, *SingleScopeBenefitRecommendationProperties -type BenefitRecommendationPropertiesClassification interface { - // GetBenefitRecommendationProperties returns the BenefitRecommendationProperties content of the underlying type. - GetBenefitRecommendationProperties() *BenefitRecommendationProperties -} - // BenefitRecommendationProperties - The properties of the benefit recommendations. type BenefitRecommendationProperties struct { // REQUIRED; Benefit scope. For example, Single or Shared. @@ -292,21 +275,6 @@ func (b *BenefitRecommendationProperties) GetBenefitRecommendationProperties() * return b } -// BenefitRecommendationsClientListOptions contains the optional parameters for the BenefitRecommendationsClient.NewListPager -// method. -type BenefitRecommendationsClientListOptions struct { - // May be used to expand the properties by: properties/usage, properties/allRecommendationDetails - 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 - Filter *string - // May be used to order the recommendations by: properties/armSkuName. For the savings plan, the results are in order by default. - // There is no need to use this clause. - Orderby *string -} - // BenefitRecommendationsListResult - Result of listing benefit recommendations. type BenefitRecommendationsListResult struct { // READ-ONLY; The link (URL) to the next page of results. @@ -316,42 +284,6 @@ type BenefitRecommendationsListResult struct { Value []*BenefitRecommendationModel } -// BenefitUtilizationSummariesClientListByBillingAccountIDOptions contains the optional parameters for the BenefitUtilizationSummariesClient.NewListByBillingAccountIDPager -// method. -type BenefitUtilizationSummariesClientListByBillingAccountIDOptions struct { - // Supports filtering by properties/benefitId, properties/benefitOrderId and properties/usageDate. - Filter *string - // Grain. - GrainParameter *GrainParameter -} - -// BenefitUtilizationSummariesClientListByBillingProfileIDOptions contains the optional parameters for the BenefitUtilizationSummariesClient.NewListByBillingProfileIDPager -// method. -type BenefitUtilizationSummariesClientListByBillingProfileIDOptions struct { - // Supports filtering by properties/benefitId, properties/benefitOrderId and properties/usageDate. - Filter *string - // Grain. - GrainParameter *GrainParameter -} - -// BenefitUtilizationSummariesClientListBySavingsPlanIDOptions contains the optional parameters for the BenefitUtilizationSummariesClient.NewListBySavingsPlanIDPager -// method. -type BenefitUtilizationSummariesClientListBySavingsPlanIDOptions struct { - // Supports filtering by properties/usageDate. - Filter *string - // Grain. - GrainParameter *GrainParameter -} - -// BenefitUtilizationSummariesClientListBySavingsPlanOrderOptions contains the optional parameters for the BenefitUtilizationSummariesClient.NewListBySavingsPlanOrderPager -// method. -type BenefitUtilizationSummariesClientListBySavingsPlanOrderOptions struct { - // Supports filtering by properties/usageDate. - Filter *string - // Grain. - GrainParameter *GrainParameter -} - // BenefitUtilizationSummariesListResult - List of benefit utilization summaries. type BenefitUtilizationSummariesListResult struct { // READ-ONLY; The link (URL) to the next page of results. @@ -361,13 +293,50 @@ type BenefitUtilizationSummariesListResult struct { Value []BenefitUtilizationSummaryClassification } -// BenefitUtilizationSummaryClassification provides polymorphic access to related types. -// Call the interface's GetBenefitUtilizationSummary() method to access the common type. -// Use a type switch to determine the concrete type. The possible types are: -// - *BenefitUtilizationSummary, *IncludedQuantityUtilizationSummary, *SavingsPlanUtilizationSummary -type BenefitUtilizationSummaryClassification interface { - // GetBenefitUtilizationSummary returns the BenefitUtilizationSummary content of the underlying type. - GetBenefitUtilizationSummary() *BenefitUtilizationSummary +// 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. @@ -399,6 +368,173 @@ type BlobInfo struct { ByteCount *int64 } +// Budget - A budget resource. +type Budget struct { + // eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating + // the latest version or not. + ETag *string + + // The properties of the budget. + Properties *BudgetProperties + + // READ-ONLY; Resource Id. + ID *string + + // READ-ONLY; Resource name. + Name *string + + // READ-ONLY; Resource type. + Type *string +} + +// BudgetComparisonExpression - The comparison expression to be used in the budgets. +type BudgetComparisonExpression struct { + // REQUIRED; The name of the column to use in comparison. + Name *string + + // REQUIRED; The operator to use for comparison. + Operator *BudgetOperatorType + + // REQUIRED; Array of values to use for comparison + Values []*string +} + +// BudgetFilter - May be used to filter budgets by user-specified dimensions and/or tags. +// Supported for CategoryType(s): Cost, ReservationUtilization. +type BudgetFilter struct { + // The logical "AND" expression. Must have at least 2 items. + // Supported for CategoryType(s): Cost. + And []*BudgetFilterProperties + + // Has comparison expression for a dimension. + // Supported for CategoryType(s): Cost, ReservationUtilization. + // Supported dimension names for CategoryType: ReservationUtilization + // * ReservationId + // * ReservedResourceType + Dimensions *BudgetComparisonExpression + + // Has comparison expression for a tag. + // Supported for CategoryType(s): Cost. + Tags *BudgetComparisonExpression +} + +// BudgetFilterProperties - The Dimensions or Tags to filter a budget by. +// Supported for CategoryType(s): Cost, ReservationUtilization. +type BudgetFilterProperties struct { + // Has comparison expression for a dimension. + // Supported for CategoryType(s): Cost, ReservationUtilization. + // Supported dimension names for CategoryType: ReservationUtilization + // * ReservationId + // * ReservedResourceType + Dimensions *BudgetComparisonExpression + + // Has comparison expression for a tag. + // Supported for CategoryType(s): Cost. + Tags *BudgetComparisonExpression +} + +// BudgetProperties - The properties of the budget. +type BudgetProperties struct { + // REQUIRED; The category of the budget. + // * 'Cost' defines a Budget. + // * 'ReservationUtilization' defines a Reservation Utilization Alert Rule. + Category *CategoryType + + // REQUIRED; The time covered by a budget. Tracking of the amount will be reset based on the time grain. + // Supported for CategoryType(s): Cost, ReservationUtilization. + // Supported timeGrainTypes for CategoryType: Cost + // * Monthly + // + // + // * Quarterly + // + // + // * Annually + // + // + // * BillingMonth* + // + // + // * BillingQuarter* + // + // + // * BillingAnnual* + // + // *only supported for Web Direct customers. + // + // Supported timeGrainTypes for CategoryType: ReservationUtilization + // + // + // * Last7Days + // + // + // * Last30Days + // + // Required for CategoryType(s): Cost, ReservationUtilization. + TimeGrain *TimeGrainType + + // REQUIRED; The time period that defines the active period of the budget. The budget will evaluate data on or after the startDate + // and will expire on the endDate. + // Supported for CategoryType(s): Cost, ReservationUtilization. + // Required for CategoryType(s): Cost, ReservationUtilization. + TimePeriod *BudgetTimePeriod + + // The total amount of cost to track with the budget. + // Supported for CategoryType(s): Cost. + // Required for CategoryType(s): Cost. + Amount *float32 + + // May be used to filter budgets by user-specified dimensions and/or tags. + // Supported for CategoryType(s): Cost, ReservationUtilization. + Filter *BudgetFilter + + // Dictionary of notifications associated with the budget. + // Supported for CategoryType(s): Cost, ReservationUtilization. + // * Constraints for CategoryType: Cost - Budget can have up to 5 notifications with thresholdType: Actual and 5 notifications + // with thresholdType: Forecasted. + // * Constraints for CategoryType: ReservationUtilization - Only one notification allowed. thresholdType is not applicable. + Notifications map[string]*Notification + + // READ-ONLY; The current amount of cost which is being tracked for a budget. + // Supported for CategoryType(s): Cost. + CurrentSpend *CurrentSpend + + // READ-ONLY; The forecasted cost which is being tracked for a budget. + // Supported for CategoryType(s): Cost. + ForecastSpend *ForecastSpend +} + +// BudgetTimePeriod - The time period that defines the active period of the budget. The budget will evaluate data on or after +// the startDate and will expire on the endDate. +// Supported for CategoryType(s): Cost, ReservationUtilization. +// Required for CategoryType(s): Cost, ReservationUtilization. +type BudgetTimePeriod struct { + // REQUIRED; The start date for the budget. + // * Constraints for CategoryType: Cost - Must be first of the month and should be less than the end date. Budget start date + // must be on or after June 1, 2017. Future start date should not be more than + // twelve months. Past start date should be selected within the timegrain period. + // + // + // * Constraints for CategoryType: ReservationUtilization - Must be on or after the current date and less than the end date. + StartDate *time.Time + + // The end date for the budget. + // * Constraints for CategoryType: Cost - No constraints. If not provided, we default this to 10 years from the start date. + // + // + // * Constraints for CategoryType: ReservationUtilization - End date cannot be more than 3 years after the start date. + EndDate *time.Time +} + +// BudgetsListResult - Result of listing budgets. It contains a list of available budgets in the scope provided. +type BudgetsListResult struct { + // READ-ONLY; The link (url) to the next page of results. It's null for now, added for future use. + NextLink *string + + // READ-ONLY; The list of budgets. + Value []*Budget +} + // CheckNameAvailabilityRequest - The check availability request body. type CheckNameAvailabilityRequest struct { // The name of the resource for which availability needs to be checked. @@ -443,6 +579,89 @@ type CommonExportProperties struct { NextRunTimeEstimate *time.Time } +// CostAllocationProportion - Target resources and allocation +type CostAllocationProportion struct { + // REQUIRED; Target resource for cost allocation + Name *string + + // REQUIRED; Percentage of source cost to allocate to this resource. This value can be specified to two decimal places and + // the total percentage of all resources in this rule must sum to 100.00. + Percentage *float32 +} + +// CostAllocationRuleCheckNameAvailabilityRequest - The cost allocation rule check name availability request +type CostAllocationRuleCheckNameAvailabilityRequest struct { + // Rule name + Name *string + + // Resource type. This is expected to be Microsoft.CostManagement/costAllocationRules + Type *string +} + +// CostAllocationRuleCheckNameAvailabilityResponse - The cost allocation rule check name availability response +type CostAllocationRuleCheckNameAvailabilityResponse struct { + // Error message if the name is not available + Message *string + + // Whether this rule name is available + NameAvailable *bool + + // The reason this name is not available + Reason *Reason +} + +// CostAllocationRuleDefinition - The cost allocation rule model definition +type CostAllocationRuleDefinition struct { + // Cost allocation rule properties + Properties *CostAllocationRuleProperties + + // READ-ONLY; Azure Resource Manager Id for the rule. This is a read ony value. + ID *string + + // READ-ONLY; Name of the rule. This is a read only value. + Name *string + + // READ-ONLY; Resource type of the rule. This is a read only value of Microsoft.CostManagement/CostAllocationRule. + Type *string +} + +// CostAllocationRuleDetails - Resource details of the cost allocation rule +type CostAllocationRuleDetails struct { + // Source resources for cost allocation. At this time, this list can contain no more than one element. + SourceResources []*SourceCostAllocationResource + + // Target resources for cost allocation. At this time, this list can contain no more than one element. + TargetResources []*TargetCostAllocationResource +} + +// CostAllocationRuleList - Result of listing cost allocation rules. It contains a list of available rules in the billing +// account or enterprise enrollment provided. +type CostAllocationRuleList struct { + // The list of cost allocation rules. + Value []*CostAllocationRuleDefinition + + // READ-ONLY; URL to get the next set of rule list results if there are any. + NextLink *string +} + +// CostAllocationRuleProperties - The properties of a cost allocation rule +type CostAllocationRuleProperties struct { + // REQUIRED; Resource information for the cost allocation rule + Details *CostAllocationRuleDetails + + // REQUIRED; Status of the rule + Status *RuleStatus + + // Description of a cost allocation rule. + Description *string + + // READ-ONLY; Time at which the rule was created. Rules that change cost for the same resource are applied in order of creation. + CreatedDate *time.Time + + // READ-ONLY; Time at which the rule was last updated. + UpdatedDate *time.Time +} + // CostDetailsOperationResults - The result of the long running operation for cost details Api. type CostDetailsOperationResults struct { // The details of the error. @@ -477,6 +696,16 @@ type CostDetailsTimePeriod struct { Start *string } +// CurrentSpend - The current amount of cost which is being tracked for a budget. +// Supported for CategoryType(s): Cost. +type CurrentSpend struct { + // READ-ONLY; The total amount of cost which is being tracked by the budget. + Amount *float32 + + // READ-ONLY; The unit of measure for the budget amount. + Unit *string +} + // Dimension - List of Dimension. type Dimension struct { // Dimension properties. @@ -534,37 +763,6 @@ type DimensionProperties struct { UsageStart *time.Time } -// DimensionsClientByExternalCloudProviderTypeOptions contains the optional parameters for the DimensionsClient.NewByExternalCloudProviderTypePager -// method. -type DimensionsClientByExternalCloudProviderTypeOptions struct { - // May be used to expand the properties/data within a dimension category. By default, data is not included when listing dimensions. - Expand *string - // May be used to filter dimensions by properties/category, properties/usageStart, properties/usageEnd. Supported operators - // are 'eq','lt', 'gt', 'le', 'ge'. - 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. - Skiptoken *string - // May be used to limit the number of results to the most recent N dimension data. - Top *int32 -} - -// DimensionsClientListOptions contains the optional parameters for the DimensionsClient.NewListPager method. -type DimensionsClientListOptions struct { - // May be used to expand the properties/data within a dimension category. By default, data is not included when listing dimensions. - Expand *string - // May be used to filter dimensions by properties/category, properties/usageStart, properties/usageEnd. Supported operators - // are 'eq','lt', 'gt', 'le', 'ge'. - 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. - Skiptoken *string - // May be used to limit the number of results to the most recent N dimension data. - Top *int32 -} - // DimensionsListResult - Result of listing dimensions. It contains a list of available dimensions. type DimensionsListResult struct { // READ-ONLY; The list of dimensions. @@ -604,6 +802,12 @@ type Export struct { // the latest version or not. ETag *string + // The managed identity associated with Export + Identity *SystemAssignedServiceIdentity + + // The location of the Export's managed identity. Only required when utilizing managed identity. + Location *string + // The properties of the export. Properties *ExportProperties @@ -812,40 +1016,6 @@ type ExportTimePeriod struct { To *time.Time } -// ExportsClientCreateOrUpdateOptions contains the optional parameters for the ExportsClient.CreateOrUpdate method. -type ExportsClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// ExportsClientDeleteOptions contains the optional parameters for the ExportsClient.Delete method. -type ExportsClientDeleteOptions struct { - // placeholder for future optional parameters -} - -// ExportsClientExecuteOptions contains the optional parameters for the ExportsClient.Execute method. -type ExportsClientExecuteOptions struct { - // placeholder for future optional parameters -} - -// ExportsClientGetExecutionHistoryOptions contains the optional parameters for the ExportsClient.GetExecutionHistory method. -type ExportsClientGetExecutionHistoryOptions struct { - // placeholder for future optional parameters -} - -// ExportsClientGetOptions contains the optional parameters for the ExportsClient.Get method. -type ExportsClientGetOptions struct { - // May be used to expand the properties within an export. Currently only 'runHistory' is supported and will return information - // for the last 10 runs of the export. - Expand *string -} - -// ExportsClientListOptions contains the optional parameters for the ExportsClient.List 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. - Expand *string -} - // FileDestination - Destination of the view data. This is optional. Currently only CSV format is supported. type FileDestination struct { // Destination of the view data. Currently only CSV format is supported. @@ -861,23 +1031,6 @@ type ForecastAggregation struct { Name *FunctionName } -// ForecastClientExternalCloudProviderUsageOptions contains the optional parameters for the ForecastClient.ExternalCloudProviderUsage -// 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'. - 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'. - Filter *string -} - // ForecastColumn - Forecast column properties type ForecastColumn struct { // The name of column. @@ -998,6 +1151,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. @@ -1007,20 +1171,6 @@ type ForecastTimePeriod struct { To *time.Time } -// GenerateCostDetailsReportClientBeginCreateOperationOptions contains the optional parameters for the GenerateCostDetailsReportClient.BeginCreateOperation -// method. -type GenerateCostDetailsReportClientBeginCreateOperationOptions struct { - // Resumes the LRO 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. - ResumeToken string -} - // 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 @@ -1046,13 +1196,6 @@ type GenerateCostDetailsReportRequestDefinition struct { TimePeriod *CostDetailsTimePeriod } -// GenerateDetailedCostReportClientBeginCreateOperationOptions contains the optional parameters for the GenerateDetailedCostReportClient.BeginCreateOperation -// method. -type GenerateDetailedCostReportClientBeginCreateOperationOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - // 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 @@ -1090,19 +1233,6 @@ type GenerateDetailedCostReportOperationResult struct { Type *string } -// GenerateDetailedCostReportOperationResultsClientBeginGetOptions contains the optional parameters for the GenerateDetailedCostReportOperationResultsClient.BeginGet -// method. -type GenerateDetailedCostReportOperationResultsClientBeginGetOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// GenerateDetailedCostReportOperationStatusClientGetOptions contains the optional parameters for the GenerateDetailedCostReportOperationStatusClient.Get -// method. -type GenerateDetailedCostReportOperationStatusClientGetOptions struct { - // placeholder for future optional parameters -} - // GenerateDetailedCostReportOperationStatuses - The status of the long running operation for cost detailed report. type GenerateDetailedCostReportOperationStatuses struct { // The endTime of the operation. @@ -1139,20 +1269,6 @@ type GenerateDetailedCostReportTimePeriod struct { Start *string } -// GenerateReservationDetailsReportClientBeginByBillingAccountIDOptions contains the optional parameters for the GenerateReservationDetailsReportClient.BeginByBillingAccountID -// method. -type GenerateReservationDetailsReportClientBeginByBillingAccountIDOptions struct { - // Resumes the LRO 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. - ResumeToken string -} - // IncludedQuantityUtilizationSummary - Included Quantity utilization summary resource. type IncludedQuantityUtilizationSummary struct { // REQUIRED; Supported values: 'SavingsPlan'. @@ -1174,8 +1290,8 @@ type IncludedQuantityUtilizationSummary struct { // GetBenefitUtilizationSummary implements the BenefitUtilizationSummaryClassification interface for type IncludedQuantityUtilizationSummary. func (i *IncludedQuantityUtilizationSummary) GetBenefitUtilizationSummary() *BenefitUtilizationSummary { return &BenefitUtilizationSummary{ - Kind: i.Kind, ID: i.ID, + Kind: i.Kind, Name: i.Name, Type: i.Type, } @@ -1215,6 +1331,64 @@ type KpiProperties struct { Type *KpiType } +// Notification - The notification associated with a budget. +// Supported for CategoryType(s): Cost, ReservationUtilization. +type Notification struct { + // REQUIRED; Email addresses to send the notification to when the threshold is breached. Must have at least one contact email + // or contact group specified at the Subscription or Resource Group scopes. All other + // scopes must have at least one contact email specified. + // Supported for CategoryType(s): Cost, ReservationUtilization. + ContactEmails []*string + + // REQUIRED; The notification is enabled or not. + // Supported for CategoryType(s): Cost, ReservationUtilization. + Enabled *bool + + // REQUIRED; The comparison operator. + // Supported for CategoryType(s): Cost, ReservationUtilization. + // Supported operators for CategoryType: Cost + // * GreaterThan + // + // + // * GreaterThanOrEqualTo + // + // Supported operators for CategoryType: ReservationUtilization + // + // + // * LessThan + Operator *BudgetNotificationOperatorType + + // REQUIRED; Threshold value associated with a notification. It is always percent with a maximum of 2 decimal places. + // Supported for CategoryType(s): Cost, ReservationUtilization. + // CategoryType: Cost - Must be between 0 and 1000. Notification is sent when the cost exceeded the threshold. + // CategoryType: ReservationUtilization - Must be between 0 and 100. Notification is sent when a reservation has a utilization + // percentage below the threshold. + Threshold *float32 + + // Subscription or Resource Group scopes only. Action groups to send the notification to when the threshold is exceeded. Must + // be provided as a fully qualified Azure resource id. + // Supported for CategoryType(s): Cost. + ContactGroups []*string + + // Subscription or Resource Group scopes only. Contact roles to send the notification to when the threshold is breached. + // Supported for CategoryType(s): Cost. + ContactRoles []*string + + // Frequency of a notification. Represents how long the notification will be silent after triggering an alert for a threshold + // breach. If not specified, the frequency will be set by default based on the + // timeGrain (Weekly when timeGrain: Last7Days, Monthly when timeGrain: Last30Days). + // Supported for CategoryType(s): ReservationUtilization. + Frequency *Frequency + + // Language in which the recipient will receive the notification, + // Supported for CategoryType(s): Cost, ReservationUtilization. + Locale *CultureCode + + // The type of threshold. + // Supported for CategoryType(s): Cost. + ThresholdType *ThresholdType +} + // NotificationProperties - The properties of the scheduled action notification. type NotificationProperties struct { // REQUIRED; Subject of the email. Length is limited to 70 characters. @@ -1294,11 +1468,6 @@ type OperationStatus struct { Status *OperationStatusType } -// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. -type OperationsClientListOptions struct { - // placeholder for future optional parameters -} - // PivotProperties - Each pivot must contain a 'type' and 'name'. type PivotProperties struct { // Data field to show in view. @@ -1308,19 +1477,6 @@ type PivotProperties struct { Type *PivotType } -// PriceSheetClientBeginDownloadByBillingProfileOptions contains the optional parameters for the PriceSheetClient.BeginDownloadByBillingProfile -// method. -type PriceSheetClientBeginDownloadByBillingProfileOptions struct { - // Resumes the LRO 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. - ResumeToken string -} - // QueryAggregation - The aggregation expression to be used in the query. type QueryAggregation struct { // REQUIRED; The name of the aggregation function to use. @@ -1330,17 +1486,6 @@ type QueryAggregation struct { Name *string } -// QueryClientUsageByExternalCloudProviderTypeOptions contains the optional parameters for the QueryClient.UsageByExternalCloudProviderType -// method. -type QueryClientUsageByExternalCloudProviderTypeOptions struct { - // placeholder for future optional parameters -} - -// QueryClientUsageOptions contains the optional parameters for the QueryClient.Usage method. -type QueryClientUsageOptions struct { - // placeholder for future optional parameters -} - // QueryColumn properties type QueryColumn struct { // The name of column. @@ -1664,8 +1809,8 @@ type SavingsPlanUtilizationSummary struct { // GetBenefitUtilizationSummary implements the BenefitUtilizationSummaryClassification interface for type SavingsPlanUtilizationSummary. func (s *SavingsPlanUtilizationSummary) GetBenefitUtilizationSummary() *BenefitUtilizationSummary { return &BenefitUtilizationSummary{ - Kind: s.Kind, ID: s.ID, + Kind: s.Kind, Name: s.Name, Type: s.Type, } @@ -1680,7 +1825,7 @@ type SavingsPlanUtilizationSummaryProperties struct { ArmSKUName *string // READ-ONLY; This is the average hourly utilization for each date range that corresponds to given grain (Daily, Monthly). - // Suppose the API call is for usageDate > 2022-10-01 and usageDate < 2022-10-31 at a daily + // Suppose the API call is for usageDate > 2023-08-01 and usageDate < 2022-10-31 at a daily // granularity. There will be one record per benefit id for each day. For a single day, the avgUtilizationPercentage value // will be equal to the average of the set of values where the set contains 24 // utilization percentage entries one for each hour in a specific day. @@ -1693,7 +1838,7 @@ type SavingsPlanUtilizationSummaryProperties struct { BenefitOrderID *string // READ-ONLY; This is the maximum hourly utilization for each date range that corresponds to given grain (Daily, Monthly). - // Suppose the API call is for usageDate > 2022-10-01 and usageDate < 2022-10-31 at a daily + // Suppose the API call is for usageDate > 2023-08-01 and usageDate < 2022-10-31 at a daily // granularity. There will be one record per benefit id for each day. For a single day, the maxUtilizationPercentage value // will be equal to the largest in the set of values where the set contains 24 // utilization percentage entries one for each hour in a specific day. If on the day 2022-10-18, the largest utilization percentage @@ -1702,7 +1847,7 @@ type SavingsPlanUtilizationSummaryProperties struct { MaxUtilizationPercentage *float64 // READ-ONLY; This is the minimum hourly utilization for each date range that corresponds to given grain (Daily, Monthly). - // Suppose the API call is for usageDate > 2022-10-01 and usageDate < 2022-10-31 at a daily + // Suppose the API call is for usageDate > 2023-08-01 and usageDate < 2022-10-31 at a daily // granularity. There will be one record per benefit id for each day. For a single day, the minUtilizationPercentage value // will be equal to the smallest in the set of values where the set contains 24 // utilization percentage entries one for each hour in a specific day. If on the day 2022-10-18, the lowest utilization percentage @@ -1800,11 +1945,13 @@ type ScheduledActionProperties struct { // Email address of the point of contact that should get the unsubscribe requests and notification emails. NotificationEmail *string - // Cost Management scope like 'subscriptions/{subscriptionId}' for subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' - // for resourceGroup scope, - // 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' - // for Department - // scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount + // For private scheduled action(Create or Update), scope will be empty. + // For shared scheduled action(Create or Update By Scope), Cost Management scope can be 'subscriptions/{subscriptionId}' for + // subscription scope, + // 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' + // for Billing Account scope, + // 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope, + // 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount // scope, // 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for BillingProfile // scope, @@ -1816,76 +1963,28 @@ type ScheduledActionProperties struct { Scope *string } -// ScheduledActionsClientCheckNameAvailabilityByScopeOptions contains the optional parameters for the ScheduledActionsClient.CheckNameAvailabilityByScope -// method. -type ScheduledActionsClientCheckNameAvailabilityByScopeOptions struct { - // placeholder for future optional parameters -} +// Setting definition. +type Setting struct { + // REQUIRED; Specifies the kind of settings. + Kind *SettingsKind -// ScheduledActionsClientCheckNameAvailabilityOptions contains the optional parameters for the ScheduledActionsClient.CheckNameAvailability -// method. -type ScheduledActionsClientCheckNameAvailabilityOptions struct { - // placeholder for future optional parameters -} - -// ScheduledActionsClientCreateOrUpdateByScopeOptions contains the optional parameters for the ScheduledActionsClient.CreateOrUpdateByScope -// method. -type ScheduledActionsClientCreateOrUpdateByScopeOptions struct { - // ETag of the Entity. Not required when creating an entity. Optional when updating an entity and can be specified to achieve - // optimistic concurrency. - IfMatch *string -} - -// ScheduledActionsClientCreateOrUpdateOptions contains the optional parameters for the ScheduledActionsClient.CreateOrUpdate -// method. -type ScheduledActionsClientCreateOrUpdateOptions struct { - // ETag of the Entity. Not required when creating an entity. Optional when updating an entity and can be specified to achieve - // optimistic concurrency. - IfMatch *string -} - -// ScheduledActionsClientDeleteByScopeOptions contains the optional parameters for the ScheduledActionsClient.DeleteByScope -// method. -type ScheduledActionsClientDeleteByScopeOptions struct { - // placeholder for future optional parameters -} - -// ScheduledActionsClientDeleteOptions contains the optional parameters for the ScheduledActionsClient.Delete method. -type ScheduledActionsClientDeleteOptions struct { - // placeholder for future optional parameters -} - -// ScheduledActionsClientGetByScopeOptions contains the optional parameters for the ScheduledActionsClient.GetByScope method. -type ScheduledActionsClientGetByScopeOptions struct { - // placeholder for future optional parameters -} - -// ScheduledActionsClientGetOptions contains the optional parameters for the ScheduledActionsClient.Get method. -type ScheduledActionsClientGetOptions struct { - // placeholder for future optional parameters -} + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string -// ScheduledActionsClientListByScopeOptions contains the optional parameters for the ScheduledActionsClient.NewListByScopePager -// method. -type ScheduledActionsClientListByScopeOptions struct { - // May be used to filter scheduled actions by properties/viewId. Supported operator is 'eq'. - Filter *string -} + // READ-ONLY; The name of the resource + Name *string -// ScheduledActionsClientListOptions contains the optional parameters for the ScheduledActionsClient.NewListPager method. -type ScheduledActionsClientListOptions struct { - // May be used to filter scheduled actions by properties/viewId. Supported operator is 'eq'. - Filter *string + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string } -// ScheduledActionsClientRunByScopeOptions contains the optional parameters for the ScheduledActionsClient.RunByScope method. -type ScheduledActionsClientRunByScopeOptions struct { - // placeholder for future optional parameters -} +// GetSetting implements the SettingClassification interface for type Setting. +func (s *Setting) GetSetting() *Setting { return s } -// ScheduledActionsClientRunOptions contains the optional parameters for the ScheduledActionsClient.Run method. -type ScheduledActionsClientRunOptions struct { - // placeholder for future optional parameters +// 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'. @@ -1933,19 +2032,19 @@ type SharedScopeBenefitRecommendationProperties struct { // GetBenefitRecommendationProperties implements the BenefitRecommendationPropertiesClassification interface for type SharedScopeBenefitRecommendationProperties. func (s *SharedScopeBenefitRecommendationProperties) GetBenefitRecommendationProperties() *BenefitRecommendationProperties { return &BenefitRecommendationProperties{ - FirstConsumptionDate: s.FirstConsumptionDate, - LastConsumptionDate: s.LastConsumptionDate, - LookBackPeriod: s.LookBackPeriod, - TotalHours: s.TotalHours, - Usage: s.Usage, + AllRecommendationDetails: s.AllRecommendationDetails, ArmSKUName: s.ArmSKUName, - Term: s.Term, CommitmentGranularity: s.CommitmentGranularity, - CurrencyCode: s.CurrencyCode, CostWithoutBenefit: s.CostWithoutBenefit, + CurrencyCode: s.CurrencyCode, + FirstConsumptionDate: s.FirstConsumptionDate, + LastConsumptionDate: s.LastConsumptionDate, + LookBackPeriod: s.LookBackPeriod, RecommendationDetails: s.RecommendationDetails, - AllRecommendationDetails: s.AllRecommendationDetails, Scope: s.Scope, + Term: s.Term, + TotalHours: s.TotalHours, + Usage: s.Usage, } } @@ -2002,28 +2101,54 @@ type SingleScopeBenefitRecommendationProperties struct { // GetBenefitRecommendationProperties implements the BenefitRecommendationPropertiesClassification interface for type SingleScopeBenefitRecommendationProperties. func (s *SingleScopeBenefitRecommendationProperties) GetBenefitRecommendationProperties() *BenefitRecommendationProperties { return &BenefitRecommendationProperties{ - FirstConsumptionDate: s.FirstConsumptionDate, - LastConsumptionDate: s.LastConsumptionDate, - LookBackPeriod: s.LookBackPeriod, - TotalHours: s.TotalHours, - Usage: s.Usage, + AllRecommendationDetails: s.AllRecommendationDetails, ArmSKUName: s.ArmSKUName, - Term: s.Term, CommitmentGranularity: s.CommitmentGranularity, - CurrencyCode: s.CurrencyCode, CostWithoutBenefit: s.CostWithoutBenefit, + CurrencyCode: s.CurrencyCode, + FirstConsumptionDate: s.FirstConsumptionDate, + LastConsumptionDate: s.LastConsumptionDate, + LookBackPeriod: s.LookBackPeriod, RecommendationDetails: s.RecommendationDetails, - AllRecommendationDetails: s.AllRecommendationDetails, Scope: s.Scope, + Term: s.Term, + TotalHours: s.TotalHours, + Usage: s.Usage, } } +// SourceCostAllocationResource - Source resources for cost allocation +type SourceCostAllocationResource struct { + // REQUIRED; If resource type is dimension, this must be either ResourceGroupName or SubscriptionId. If resource type is tag, + // this must be a valid Azure tag + Name *string + + // REQUIRED; Type of resources contained in this cost allocation rule + ResourceType *CostAllocationResourceType + + // REQUIRED; Source Resources for cost allocation. This list cannot contain more than 25 values. + Values []*string +} + // Status - The status of the long running operation. type Status struct { // The status of the long running operation. Status *ReportOperationStatusType } +// SystemAssignedServiceIdentity - Managed service identity (either system assigned, or none) +type SystemAssignedServiceIdentity struct { + // REQUIRED; Type of managed service identity (either system assigned, or none). + Type *SystemAssignedServiceIdentityType + + // READ-ONLY; The service principal ID of the system assigned identity. This property will only be provided for a system assigned + // identity. + PrincipalID *string + + // READ-ONLY; The tenant ID of the system assigned identity. This property will only be provided for a system assigned identity. + TenantID *string +} + // SystemData - Metadata pertaining to creation and last modification of the resource. type SystemData struct { // The timestamp of resource creation (UTC). @@ -2045,6 +2170,58 @@ type SystemData struct { LastModifiedByType *CreatedByType } +// TagInheritanceProperties - The properties of the tag inheritance setting. +type TagInheritanceProperties struct { + // REQUIRED; When resource has the same tag as subscription or resource group and this property is set to true - the subscription + // or resource group tag will be applied. If subscription and resource group tags are + // also the same, subscription tag will be applied. + PreferContainerTags *bool +} + +// TagInheritanceSetting - Tag Inheritance Setting definition. +type TagInheritanceSetting struct { + // REQUIRED; Specifies the kind of settings. + Kind *SettingsKind + + // The properties of the tag inheritance setting. + Properties *TagInheritanceProperties + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// GetSetting implements the SettingClassification interface for type TagInheritanceSetting. +func (t *TagInheritanceSetting) GetSetting() *Setting { + return &Setting{ + ID: t.ID, + Kind: t.Kind, + Name: t.Name, + Type: t.Type, + } +} + +// TargetCostAllocationResource - Target resources for cost allocation. +type TargetCostAllocationResource struct { + // REQUIRED; If resource type is dimension, this must be either ResourceGroupName or SubscriptionId. If resource type is tag, + // this must be a valid Azure tag + Name *string + + // REQUIRED; Method of cost allocation for the rule + PolicyType *CostAllocationPolicyType + + // REQUIRED; Type of resources contained in this cost allocation rule + ResourceType *CostAllocationResourceType + + // REQUIRED; Target resources for cost allocation. This list cannot contain more than 25 values. + Values []*CostAllocationProportion +} + // View - States and configurations of Cost Analysis. type View struct { // eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating @@ -2081,6 +2258,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 @@ -2090,6 +2270,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 @@ -2116,50 +2299,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 -} - -// ViewsClientCreateOrUpdateByScopeOptions contains the optional parameters for the ViewsClient.CreateOrUpdateByScope method. -type ViewsClientCreateOrUpdateByScopeOptions struct { - // placeholder for future optional parameters -} - -// ViewsClientCreateOrUpdateOptions contains the optional parameters for the ViewsClient.CreateOrUpdate method. -type ViewsClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// ViewsClientDeleteByScopeOptions contains the optional parameters for the ViewsClient.DeleteByScope method. -type ViewsClientDeleteByScopeOptions struct { - // placeholder for future optional parameters -} - -// ViewsClientDeleteOptions contains the optional parameters for the ViewsClient.Delete method. -type ViewsClientDeleteOptions struct { - // placeholder for future optional parameters -} - -// ViewsClientGetByScopeOptions contains the optional parameters for the ViewsClient.GetByScope method. -type ViewsClientGetByScopeOptions struct { - // placeholder for future optional parameters -} - -// ViewsClientGetOptions contains the optional parameters for the ViewsClient.Get method. -type ViewsClientGetOptions struct { - // placeholder for future optional parameters -} - -// ViewsClientListByScopeOptions contains the optional parameters for the ViewsClient.NewListByScopePager method. -type ViewsClientListByScopeOptions struct { - // placeholder for future optional parameters -} - -// ViewsClientListOptions contains the optional parameters for the ViewsClient.NewListPager method. -type ViewsClientListOptions struct { - // placeholder for future optional parameters } diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/models_serde.go b/sdk/resourcemanager/costmanagement/armcostmanagement/models_serde.go index 54906dccbe1e..f6cb0a8ab975 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/models_serde.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/models_serde.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armcostmanagement @@ -393,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) + populateTimeRFC3339(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 = unpopulateTimeRFC3339(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) @@ -573,6 +607,96 @@ func (b *BenefitUtilizationSummariesListResult) UnmarshalJSON(data []byte) error return nil } +// MarshalJSON implements the json.Marshaller interface for type BenefitUtilizationSummariesOperationStatus. +func (b BenefitUtilizationSummariesOperationStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "input", b.Input) + populate(objectMap, "properties", b.Properties) + populate(objectMap, "status", b.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BenefitUtilizationSummariesOperationStatus. +func (b *BenefitUtilizationSummariesOperationStatus) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "input": + err = unpopulate(val, "Input", &b.Input) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &b.Properties) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &b.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BenefitUtilizationSummariesRequest. +func (b BenefitUtilizationSummariesRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "benefitId", b.BenefitID) + populate(objectMap, "benefitOrderId", b.BenefitOrderID) + populate(objectMap, "billingAccountId", b.BillingAccountID) + populate(objectMap, "billingProfileId", b.BillingProfileID) + populateTimeRFC3339(objectMap, "endDate", b.EndDate) + populate(objectMap, "grain", b.Grain) + populate(objectMap, "kind", b.Kind) + populateTimeRFC3339(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 = unpopulateTimeRFC3339(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 = unpopulateTimeRFC3339(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) @@ -643,6 +767,267 @@ 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, "type", b.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Budget. +func (b *Budget) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "eTag": + err = unpopulate(val, "ETag", &b.ETag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &b.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &b.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &b.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &b.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BudgetComparisonExpression. +func (b BudgetComparisonExpression) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", b.Name) + populate(objectMap, "operator", b.Operator) + populate(objectMap, "values", b.Values) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BudgetComparisonExpression. +func (b *BudgetComparisonExpression) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &b.Name) + delete(rawMsg, key) + case "operator": + err = unpopulate(val, "Operator", &b.Operator) + delete(rawMsg, key) + case "values": + err = unpopulate(val, "Values", &b.Values) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BudgetFilter. +func (b BudgetFilter) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "and", b.And) + populate(objectMap, "dimensions", b.Dimensions) + populate(objectMap, "tags", b.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BudgetFilter. +func (b *BudgetFilter) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "and": + err = unpopulate(val, "And", &b.And) + delete(rawMsg, key) + case "dimensions": + err = unpopulate(val, "Dimensions", &b.Dimensions) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &b.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BudgetFilterProperties. +func (b BudgetFilterProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "dimensions", b.Dimensions) + populate(objectMap, "tags", b.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BudgetFilterProperties. +func (b *BudgetFilterProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "dimensions": + err = unpopulate(val, "Dimensions", &b.Dimensions) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &b.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BudgetProperties. +func (b BudgetProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "amount", b.Amount) + populate(objectMap, "category", b.Category) + populate(objectMap, "currentSpend", b.CurrentSpend) + populate(objectMap, "filter", b.Filter) + populate(objectMap, "forecastSpend", b.ForecastSpend) + populate(objectMap, "notifications", b.Notifications) + populate(objectMap, "timeGrain", b.TimeGrain) + populate(objectMap, "timePeriod", b.TimePeriod) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BudgetProperties. +func (b *BudgetProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "amount": + err = unpopulate(val, "Amount", &b.Amount) + delete(rawMsg, key) + case "category": + err = unpopulate(val, "Category", &b.Category) + delete(rawMsg, key) + case "currentSpend": + err = unpopulate(val, "CurrentSpend", &b.CurrentSpend) + delete(rawMsg, key) + case "filter": + err = unpopulate(val, "Filter", &b.Filter) + delete(rawMsg, key) + case "forecastSpend": + err = unpopulate(val, "ForecastSpend", &b.ForecastSpend) + delete(rawMsg, key) + case "notifications": + err = unpopulate(val, "Notifications", &b.Notifications) + delete(rawMsg, key) + case "timeGrain": + err = unpopulate(val, "TimeGrain", &b.TimeGrain) + delete(rawMsg, key) + case "timePeriod": + err = unpopulate(val, "TimePeriod", &b.TimePeriod) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BudgetTimePeriod. +func (b BudgetTimePeriod) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateTimeRFC3339(objectMap, "endDate", b.EndDate) + populateTimeRFC3339(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 = unpopulateTimeRFC3339(val, "EndDate", &b.EndDate) + delete(rawMsg, key) + case "startDate": + err = unpopulateTimeRFC3339(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) @@ -756,6 +1141,247 @@ func (c *CommonExportProperties) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type CostAllocationProportion. +func (c CostAllocationProportion) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", c.Name) + populate(objectMap, "percentage", c.Percentage) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CostAllocationProportion. +func (c *CostAllocationProportion) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "percentage": + err = unpopulate(val, "Percentage", &c.Percentage) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CostAllocationRuleCheckNameAvailabilityRequest. +func (c CostAllocationRuleCheckNameAvailabilityRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", c.Name) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CostAllocationRuleCheckNameAvailabilityRequest. +func (c *CostAllocationRuleCheckNameAvailabilityRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CostAllocationRuleCheckNameAvailabilityResponse. +func (c CostAllocationRuleCheckNameAvailabilityResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "message", c.Message) + populate(objectMap, "nameAvailable", c.NameAvailable) + populate(objectMap, "reason", c.Reason) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CostAllocationRuleCheckNameAvailabilityResponse. +func (c *CostAllocationRuleCheckNameAvailabilityResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "message": + err = unpopulate(val, "Message", &c.Message) + delete(rawMsg, key) + case "nameAvailable": + err = unpopulate(val, "NameAvailable", &c.NameAvailable) + delete(rawMsg, key) + case "reason": + err = unpopulate(val, "Reason", &c.Reason) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CostAllocationRuleDefinition. +func (c CostAllocationRuleDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", c.ID) + populate(objectMap, "name", c.Name) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CostAllocationRuleDefinition. +func (c *CostAllocationRuleDefinition) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &c.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &c.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type 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) + populateTimeRFC3339(objectMap, "createdDate", c.CreatedDate) + populate(objectMap, "description", c.Description) + populate(objectMap, "details", c.Details) + populate(objectMap, "status", c.Status) + populateTimeRFC3339(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 = unpopulateTimeRFC3339(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 = unpopulateTimeRFC3339(val, "UpdatedDate", &c.UpdatedDate) + 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 CostDetailsOperationResults. func (c CostDetailsOperationResults) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -796,8 +1422,39 @@ func (c *CostDetailsOperationResults) UnmarshalJSON(data []byte) error { case "type": err = unpopulate(val, "Type", &c.Type) delete(rawMsg, key) - case "validTill": - err = unpopulateTimeRFC3339(val, "ValidTill", &c.ValidTill) + case "validTill": + err = unpopulateTimeRFC3339(val, "ValidTill", &c.ValidTill) + 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 CostDetailsTimePeriod. +func (c CostDetailsTimePeriod) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "end", c.End) + populate(objectMap, "start", c.Start) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CostDetailsTimePeriod. +func (c *CostDetailsTimePeriod) 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 "end": + err = unpopulate(val, "End", &c.End) + delete(rawMsg, key) + case "start": + err = unpopulate(val, "Start", &c.Start) delete(rawMsg, key) } if err != nil { @@ -807,16 +1464,16 @@ func (c *CostDetailsOperationResults) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type CostDetailsTimePeriod. -func (c CostDetailsTimePeriod) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type CurrentSpend. +func (c CurrentSpend) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "end", c.End) - populate(objectMap, "start", c.Start) + populate(objectMap, "amount", c.Amount) + populate(objectMap, "unit", c.Unit) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type CostDetailsTimePeriod. -func (c *CostDetailsTimePeriod) UnmarshalJSON(data []byte) error { +// 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) @@ -824,11 +1481,11 @@ func (c *CostDetailsTimePeriod) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "end": - err = unpopulate(val, "End", &c.End) + case "amount": + err = unpopulate(val, "Amount", &c.Amount) delete(rawMsg, key) - case "start": - err = unpopulate(val, "Start", &c.Start) + case "unit": + err = unpopulate(val, "Unit", &c.Unit) delete(rawMsg, key) } if err != nil { @@ -1077,6 +1734,8 @@ func (e Export) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "eTag", e.ETag) populate(objectMap, "id", e.ID) + populate(objectMap, "identity", e.Identity) + populate(objectMap, "location", e.Location) populate(objectMap, "name", e.Name) populate(objectMap, "properties", e.Properties) populate(objectMap, "type", e.Type) @@ -1098,6 +1757,12 @@ func (e *Export) UnmarshalJSON(data []byte) error { case "id": err = unpopulate(val, "ID", &e.ID) delete(rawMsg, key) + case "identity": + err = unpopulate(val, "Identity", &e.Identity) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &e.Location) + delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &e.Name) delete(rawMsg, key) @@ -1952,6 +2617,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) @@ -2315,6 +3011,65 @@ func (k *KpiProperties) UnmarshalJSON(data []byte) error { 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) + } + for key, val := range rawMsg { + var err error + switch key { + case "contactEmails": + err = unpopulate(val, "ContactEmails", &n.ContactEmails) + delete(rawMsg, key) + case "contactGroups": + err = unpopulate(val, "ContactGroups", &n.ContactGroups) + delete(rawMsg, key) + case "contactRoles": + err = unpopulate(val, "ContactRoles", &n.ContactRoles) + delete(rawMsg, key) + case "enabled": + err = unpopulate(val, "Enabled", &n.Enabled) + delete(rawMsg, key) + 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 { + return fmt.Errorf("unmarshalling type %T: %v", n, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type NotificationProperties. func (n NotificationProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -3679,6 +4434,72 @@ func (s *ScheduledActionProperties) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type Setting. +func (s Setting) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", s.ID) + objectMap["kind"] = s.Kind + populate(objectMap, "name", s.Name) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Setting. +func (s *Setting) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &s.Kind) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &s.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SettingsListResult. +func (s SettingsListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SettingsListResult. +func (s *SettingsListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "value": + s.Value, err = unmarshalSettingClassificationArray(val) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type SharedScopeBenefitRecommendationProperties. func (s SharedScopeBenefitRecommendationProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -3837,6 +4658,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) @@ -3864,6 +4720,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) @@ -3911,6 +4802,115 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { return nil } +// MarshalJSON implements the json.Marshaller interface for type TagInheritanceProperties. +func (t TagInheritanceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "preferContainerTags", t.PreferContainerTags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TagInheritanceProperties. +func (t *TagInheritanceProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "preferContainerTags": + err = unpopulate(val, "PreferContainerTags", &t.PreferContainerTags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TagInheritanceSetting. +func (t TagInheritanceSetting) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", t.ID) + objectMap["kind"] = SettingsKindTaginheritance + populate(objectMap, "name", t.Name) + populate(objectMap, "properties", t.Properties) + populate(objectMap, "type", t.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TagInheritanceSetting. +func (t *TagInheritanceSetting) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &t.ID) + delete(rawMsg, key) + case "kind": + err = unpopulate(val, "Kind", &t.Kind) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &t.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &t.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &t.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TargetCostAllocationResource. +func (t TargetCostAllocationResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", t.Name) + populate(objectMap, "policyType", t.PolicyType) + populate(objectMap, "resourceType", t.ResourceType) + populate(objectMap, "values", t.Values) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TargetCostAllocationResource. +func (t *TargetCostAllocationResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &t.Name) + delete(rawMsg, key) + case "policyType": + err = unpopulate(val, "PolicyType", &t.PolicyType) + delete(rawMsg, key) + case "resourceType": + err = unpopulate(val, "ResourceType", &t.ResourceType) + delete(rawMsg, key) + case "values": + err = unpopulate(val, "Values", &t.Values) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + // MarshalJSON implements the json.Marshaller interface for type View. func (v View) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/operations_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/operations_client.go index f5fc82448315..154ab8427728 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/operations_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/operations_client.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armcostmanagement @@ -40,7 +39,7 @@ func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientO // NewListPager - Lists all of the available cost management REST API operations. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ @@ -78,7 +77,7 @@ func (client *OperationsClient) listCreateRequest(ctx context.Context, options * return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/operations_client_example_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/operations_client_example_test.go deleted file mode 100644 index 3d8646009998..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/operations_client_example_test.go +++ /dev/null @@ -1,146 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armcostmanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/OperationList.json -func ExampleOperationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewOperationsClient().NewListPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.OperationListResult = armcostmanagement.OperationListResult{ - // Value: []*armcostmanagement.OperationForCostManagement{ - // { - // Name: to.Ptr("Microsoft.CostManagement/budgets/read"), - // Display: &armcostmanagement.OperationDisplay{ - // Description: to.Ptr("List the budgets by a subscription or a management group."), - // Operation: to.Ptr("List budgets"), - // Provider: to.Ptr("Microsoft.CostManagement"), - // Resource: to.Ptr("Budgets"), - // }, - // ID: to.Ptr("Microsoft.CostManagement/budgets/read"), - // }, - // { - // Name: to.Ptr("Microsoft.CostManagement/query/action"), - // Display: &armcostmanagement.OperationDisplay{ - // Description: to.Ptr("Query usage data by a scope."), - // Operation: to.Ptr("Query usage data"), - // Provider: to.Ptr("Microsoft.CostManagement"), - // Resource: to.Ptr("Query"), - // }, - // ID: to.Ptr("Microsoft.CostManagement/query/action"), - // }, - // { - // Name: to.Ptr("Microsoft.CostManagement/exports/read"), - // Display: &armcostmanagement.OperationDisplay{ - // Description: to.Ptr("List the exports by scope."), - // Operation: to.Ptr("List exports"), - // Provider: to.Ptr("Microsoft.CostManagement"), - // Resource: to.Ptr("Exports"), - // }, - // ID: to.Ptr("Microsoft.CostManagement/exports/read"), - // }, - // { - // Name: to.Ptr("Microsoft.CostManagement/exports/write"), - // Display: &armcostmanagement.OperationDisplay{ - // Description: to.Ptr("Create or update the specified export."), - // Operation: to.Ptr("Create and update export"), - // Provider: to.Ptr("Microsoft.CostManagement"), - // Resource: to.Ptr("Exports"), - // }, - // ID: to.Ptr("Microsoft.CostManagement/exports/write"), - // }, - // { - // Name: to.Ptr("Microsoft.CostManagement/exports/action"), - // Display: &armcostmanagement.OperationDisplay{ - // Description: to.Ptr("Run the specified export."), - // Operation: to.Ptr("Run export"), - // Provider: to.Ptr("Microsoft.CostManagement"), - // Resource: to.Ptr("Exports"), - // }, - // ID: to.Ptr("Microsoft.CostManagement/exports/action"), - // }, - // { - // Name: to.Ptr("Microsoft.CostManagement/exports/run/action"), - // Display: &armcostmanagement.OperationDisplay{ - // Description: to.Ptr("Run exports."), - // Operation: to.Ptr("Run exports"), - // Provider: to.Ptr("Microsoft.CostManagement"), - // Resource: to.Ptr("exports/run"), - // }, - // ID: to.Ptr("Microsoft.CostManagement/exports/run/action"), - // }, - // { - // Name: to.Ptr("Microsoft.CostManagement/alerts/read"), - // Display: &armcostmanagement.OperationDisplay{ - // Description: to.Ptr("List alerts."), - // Operation: to.Ptr("List Alerts"), - // Provider: to.Ptr("Microsoft.CostManagement"), - // Resource: to.Ptr("Alerts"), - // }, - // ID: to.Ptr("Microsoft.CostManagement/alerts/read"), - // }, - // { - // Name: to.Ptr("Microsoft.CostManagement/operations/read"), - // Display: &armcostmanagement.OperationDisplay{ - // Description: to.Ptr("List all supported operations by Microsoft.CostManagement resource provider."), - // Operation: to.Ptr("List supported operations"), - // Provider: to.Ptr("Microsoft.CostManagement"), - // Resource: to.Ptr("Operations"), - // }, - // ID: to.Ptr("Microsoft.CostManagement/operations/read"), - // }, - // { - // Name: to.Ptr("Microsoft.CostManagement/views/action"), - // Display: &armcostmanagement.OperationDisplay{ - // Description: to.Ptr("Create view."), - // Operation: to.Ptr("Create views"), - // Provider: to.Ptr("Microsoft.CostManagement"), - // Resource: to.Ptr("Views"), - // }, - // ID: to.Ptr("Microsoft.CostManagement/views/action"), - // }, - // { - // Name: to.Ptr("Microsoft.CostManagement/views/write"), - // Display: &armcostmanagement.OperationDisplay{ - // Description: to.Ptr("Update view."), - // Operation: to.Ptr("Update views"), - // Provider: to.Ptr("Microsoft.CostManagement"), - // Resource: to.Ptr("Views"), - // }, - // ID: to.Ptr("Microsoft.CostManagement/views/write"), - // }}, - // } - } -} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/options.go b/sdk/resourcemanager/costmanagement/armcostmanagement/options.go new file mode 100644 index 000000000000..25d6860d421f --- /dev/null +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/options.go @@ -0,0 +1,474 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armcostmanagement + +// AlertsClientDismissOptions contains the optional parameters for the AlertsClient.Dismiss method. +type AlertsClientDismissOptions struct { + // placeholder for future optional parameters +} + +// AlertsClientGetOptions contains the optional parameters for the AlertsClient.Get method. +type AlertsClientGetOptions struct { + // placeholder for future optional parameters +} + +// AlertsClientListExternalOptions contains the optional parameters for the AlertsClient.ListExternal method. +type AlertsClientListExternalOptions struct { + // placeholder for future optional parameters +} + +// AlertsClientListOptions contains the optional parameters for the AlertsClient.List method. +type AlertsClientListOptions struct { + // placeholder for future optional parameters +} + +// BenefitRecommendationsClientListOptions contains the optional parameters for the BenefitRecommendationsClient.NewListPager +// method. +type BenefitRecommendationsClientListOptions struct { + // May be used to expand the properties by: properties/usage, properties/allRecommendationDetails + 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 + Filter *string + + // May be used to order the recommendations by: properties/armSkuName. For the savings plan, the results are in order by default. + // There is no need to use this clause. + Orderby *string +} + +// BenefitUtilizationSummariesClientListByBillingAccountIDOptions contains the optional parameters for the BenefitUtilizationSummariesClient.NewListByBillingAccountIDPager +// method. +type BenefitUtilizationSummariesClientListByBillingAccountIDOptions struct { + // Supports filtering by properties/benefitId, properties/benefitOrderId and properties/usageDate. + Filter *string + + // Grain. + GrainParameter *GrainParameter +} + +// BenefitUtilizationSummariesClientListByBillingProfileIDOptions contains the optional parameters for the BenefitUtilizationSummariesClient.NewListByBillingProfileIDPager +// method. +type BenefitUtilizationSummariesClientListByBillingProfileIDOptions struct { + // Supports filtering by properties/benefitId, properties/benefitOrderId and properties/usageDate. + Filter *string + + // Grain. + GrainParameter *GrainParameter +} + +// BenefitUtilizationSummariesClientListBySavingsPlanIDOptions contains the optional parameters for the BenefitUtilizationSummariesClient.NewListBySavingsPlanIDPager +// method. +type BenefitUtilizationSummariesClientListBySavingsPlanIDOptions struct { + // Supports filtering by properties/usageDate. + Filter *string + + // Grain. + GrainParameter *GrainParameter +} + +// BenefitUtilizationSummariesClientListBySavingsPlanOrderOptions contains the optional parameters for the BenefitUtilizationSummariesClient.NewListBySavingsPlanOrderPager +// method. +type BenefitUtilizationSummariesClientListBySavingsPlanOrderOptions struct { + // Supports filtering by properties/usageDate. + Filter *string + + // Grain. + 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 { + // May be used to expand the properties/data within a dimension category. By default, data is not included when listing dimensions. + Expand *string + + // May be used to filter dimensions by properties/category, properties/usageStart, properties/usageEnd. Supported operators + // are 'eq','lt', 'gt', 'le', 'ge'. + 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. + Skiptoken *string + + // May be used to limit the number of results to the most recent N dimension data. + Top *int32 +} + +// DimensionsClientListOptions contains the optional parameters for the DimensionsClient.NewListPager method. +type DimensionsClientListOptions struct { + // May be used to expand the properties/data within a dimension category. By default, data is not included when listing dimensions. + Expand *string + + // May be used to filter dimensions by properties/category, properties/usageStart, properties/usageEnd. Supported operators + // are 'eq','lt', 'gt', 'le', 'ge'. + 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. + Skiptoken *string + + // May be used to limit the number of results to the most recent N dimension data. + Top *int32 +} + +// ExportsClientCreateOrUpdateOptions contains the optional parameters for the ExportsClient.CreateOrUpdate method. +type ExportsClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// ExportsClientDeleteOptions contains the optional parameters for the ExportsClient.Delete method. +type ExportsClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// ExportsClientExecuteOptions contains the optional parameters for the ExportsClient.Execute method. +type ExportsClientExecuteOptions struct { + // placeholder for future optional parameters +} + +// ExportsClientGetExecutionHistoryOptions contains the optional parameters for the ExportsClient.GetExecutionHistory method. +type ExportsClientGetExecutionHistoryOptions struct { + // placeholder for future optional parameters +} + +// ExportsClientGetOptions contains the optional parameters for the ExportsClient.Get method. +type ExportsClientGetOptions struct { + // May be used to expand the properties within an export. Currently only 'runHistory' is supported and will return information + // for the last 10 runs of the export. + Expand *string +} + +// ExportsClientListOptions contains the optional parameters for the ExportsClient.List 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. + Expand *string +} + +// ForecastClientExternalCloudProviderUsageOptions contains the optional parameters for the ForecastClient.ExternalCloudProviderUsage +// 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'. + 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'. + Filter *string +} + +// GenerateBenefitUtilizationSummariesReportClientBeginGenerateByBillingAccountOptions contains the optional parameters for +// the GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByBillingAccount method. +type GenerateBenefitUtilizationSummariesReportClientBeginGenerateByBillingAccountOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// GenerateBenefitUtilizationSummariesReportClientBeginGenerateByBillingProfileOptions contains the optional parameters for +// the GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByBillingProfile method. +type GenerateBenefitUtilizationSummariesReportClientBeginGenerateByBillingProfileOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// GenerateBenefitUtilizationSummariesReportClientBeginGenerateByReservationIDOptions contains the optional parameters for +// the GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByReservationID method. +type GenerateBenefitUtilizationSummariesReportClientBeginGenerateByReservationIDOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// GenerateBenefitUtilizationSummariesReportClientBeginGenerateByReservationOrderIDOptions contains the optional parameters +// for the GenerateBenefitUtilizationSummariesReportClient.BeginGenerateByReservationOrderID method. +type GenerateBenefitUtilizationSummariesReportClientBeginGenerateByReservationOrderIDOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// GenerateBenefitUtilizationSummariesReportClientBeginGenerateBySavingsPlanIDOptions contains the optional parameters for +// the GenerateBenefitUtilizationSummariesReportClient.BeginGenerateBySavingsPlanID method. +type GenerateBenefitUtilizationSummariesReportClientBeginGenerateBySavingsPlanIDOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// GenerateBenefitUtilizationSummariesReportClientBeginGenerateBySavingsPlanOrderIDOptions contains the optional parameters +// for the GenerateBenefitUtilizationSummariesReportClient.BeginGenerateBySavingsPlanOrderID method. +type GenerateBenefitUtilizationSummariesReportClientBeginGenerateBySavingsPlanOrderIDOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// GenerateCostDetailsReportClientBeginCreateOperationOptions contains the optional parameters for the GenerateCostDetailsReportClient.BeginCreateOperation +// method. +type GenerateCostDetailsReportClientBeginCreateOperationOptions struct { + // Resumes the LRO 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. + ResumeToken string +} + +// GenerateDetailedCostReportClientBeginCreateOperationOptions contains the optional parameters for the GenerateDetailedCostReportClient.BeginCreateOperation +// method. +type GenerateDetailedCostReportClientBeginCreateOperationOptions struct { + // Resumes the LRO 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. + ResumeToken string +} + +// GenerateDetailedCostReportOperationStatusClientGetOptions contains the optional parameters for the GenerateDetailedCostReportOperationStatusClient.Get +// method. +type GenerateDetailedCostReportOperationStatusClientGetOptions struct { + // placeholder for future optional parameters +} + +// GenerateReservationDetailsReportClientBeginByBillingAccountIDOptions contains the optional parameters for the GenerateReservationDetailsReportClient.BeginByBillingAccountID +// method. +type GenerateReservationDetailsReportClientBeginByBillingAccountIDOptions struct { + // Resumes the LRO 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. + ResumeToken string +} + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} + +// PriceSheetClientBeginDownloadByBillingProfileOptions contains the optional parameters for the PriceSheetClient.BeginDownloadByBillingProfile +// method. +type PriceSheetClientBeginDownloadByBillingProfileOptions struct { + // Resumes the LRO 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. + ResumeToken string +} + +// QueryClientUsageByExternalCloudProviderTypeOptions contains the optional parameters for the QueryClient.UsageByExternalCloudProviderType +// method. +type QueryClientUsageByExternalCloudProviderTypeOptions struct { + // placeholder for future optional parameters +} + +// QueryClientUsageOptions contains the optional parameters for the QueryClient.Usage method. +type QueryClientUsageOptions struct { + // placeholder for future optional parameters +} + +// ScheduledActionsClientCheckNameAvailabilityByScopeOptions contains the optional parameters for the ScheduledActionsClient.CheckNameAvailabilityByScope +// method. +type ScheduledActionsClientCheckNameAvailabilityByScopeOptions struct { + // placeholder for future optional parameters +} + +// ScheduledActionsClientCheckNameAvailabilityOptions contains the optional parameters for the ScheduledActionsClient.CheckNameAvailability +// method. +type ScheduledActionsClientCheckNameAvailabilityOptions struct { + // placeholder for future optional parameters +} + +// ScheduledActionsClientCreateOrUpdateByScopeOptions contains the optional parameters for the ScheduledActionsClient.CreateOrUpdateByScope +// method. +type ScheduledActionsClientCreateOrUpdateByScopeOptions struct { + // ETag of the Entity. Not required when creating an entity. Optional when updating an entity and can be specified to achieve + // optimistic concurrency. + IfMatch *string +} + +// ScheduledActionsClientCreateOrUpdateOptions contains the optional parameters for the ScheduledActionsClient.CreateOrUpdate +// method. +type ScheduledActionsClientCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity. Optional when updating an entity and can be specified to achieve + // optimistic concurrency. + IfMatch *string +} + +// ScheduledActionsClientDeleteByScopeOptions contains the optional parameters for the ScheduledActionsClient.DeleteByScope +// method. +type ScheduledActionsClientDeleteByScopeOptions struct { + // placeholder for future optional parameters +} + +// ScheduledActionsClientDeleteOptions contains the optional parameters for the ScheduledActionsClient.Delete method. +type ScheduledActionsClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// ScheduledActionsClientGetByScopeOptions contains the optional parameters for the ScheduledActionsClient.GetByScope method. +type ScheduledActionsClientGetByScopeOptions struct { + // placeholder for future optional parameters +} + +// ScheduledActionsClientGetOptions contains the optional parameters for the ScheduledActionsClient.Get method. +type ScheduledActionsClientGetOptions struct { + // placeholder for future optional parameters +} + +// ScheduledActionsClientListByScopeOptions contains the optional parameters for the ScheduledActionsClient.NewListByScopePager +// method. +type ScheduledActionsClientListByScopeOptions struct { + // May be used to filter scheduled actions by properties/viewId. Supported operator is 'eq'. + Filter *string +} + +// ScheduledActionsClientListOptions contains the optional parameters for the ScheduledActionsClient.NewListPager method. +type ScheduledActionsClientListOptions struct { + // May be used to filter scheduled actions by properties/viewId. Supported operator is 'eq'. + Filter *string +} + +// ScheduledActionsClientRunByScopeOptions contains the optional parameters for the ScheduledActionsClient.RunByScope method. +type ScheduledActionsClientRunByScopeOptions struct { + // placeholder for future optional parameters +} + +// ScheduledActionsClientRunOptions contains the optional parameters for the ScheduledActionsClient.Run method. +type ScheduledActionsClientRunOptions struct { + // placeholder for future optional parameters +} + +// SettingsClientCreateOrUpdateByScopeOptions contains the optional parameters for the SettingsClient.CreateOrUpdateByScope +// method. +type SettingsClientCreateOrUpdateByScopeOptions struct { + // placeholder for future optional parameters +} + +// SettingsClientDeleteByScopeOptions contains the optional parameters for the SettingsClient.DeleteByScope method. +type SettingsClientDeleteByScopeOptions struct { + // placeholder for future optional parameters +} + +// SettingsClientGetByScopeOptions contains the optional parameters for the SettingsClient.GetByScope method. +type SettingsClientGetByScopeOptions struct { + // placeholder for future optional parameters +} + +// SettingsClientListOptions contains the optional parameters for the SettingsClient.List method. +type SettingsClientListOptions struct { + // placeholder for future optional parameters +} + +// ViewsClientCreateOrUpdateByScopeOptions contains the optional parameters for the ViewsClient.CreateOrUpdateByScope method. +type ViewsClientCreateOrUpdateByScopeOptions struct { + // placeholder for future optional parameters +} + +// ViewsClientCreateOrUpdateOptions contains the optional parameters for the ViewsClient.CreateOrUpdate method. +type ViewsClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// ViewsClientDeleteByScopeOptions contains the optional parameters for the ViewsClient.DeleteByScope method. +type ViewsClientDeleteByScopeOptions struct { + // placeholder for future optional parameters +} + +// ViewsClientDeleteOptions contains the optional parameters for the ViewsClient.Delete method. +type ViewsClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// ViewsClientGetByScopeOptions contains the optional parameters for the ViewsClient.GetByScope method. +type ViewsClientGetByScopeOptions struct { + // placeholder for future optional parameters +} + +// ViewsClientGetOptions contains the optional parameters for the ViewsClient.Get method. +type ViewsClientGetOptions struct { + // placeholder for future optional parameters +} + +// ViewsClientListByScopeOptions contains the optional parameters for the ViewsClient.NewListByScopePager method. +type ViewsClientListByScopeOptions struct { + // placeholder for future optional parameters +} + +// ViewsClientListOptions contains the optional parameters for the ViewsClient.NewListPager method. +type ViewsClientListOptions 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 e0e6de74ae32..bbd1b96caf3f 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/polymorphic_helpers.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/polymorphic_helpers.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armcostmanagement @@ -28,7 +27,10 @@ func unmarshalBenefitRecommendationPropertiesClassification(rawMsg json.RawMessa default: b = &BenefitRecommendationProperties{} } - return b, json.Unmarshal(rawMsg, b) + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil } func unmarshalBenefitUtilizationSummaryClassification(rawMsg json.RawMessage) (BenefitUtilizationSummaryClassification, error) { @@ -48,7 +50,10 @@ func unmarshalBenefitUtilizationSummaryClassification(rawMsg json.RawMessage) (B default: b = &BenefitUtilizationSummary{} } - return b, json.Unmarshal(rawMsg, b) + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil } func unmarshalBenefitUtilizationSummaryClassificationArray(rawMsg json.RawMessage) ([]BenefitUtilizationSummaryClassification, error) { @@ -69,3 +74,43 @@ func unmarshalBenefitUtilizationSummaryClassificationArray(rawMsg json.RawMessag } return fArray, nil } + +func unmarshalSettingClassification(rawMsg json.RawMessage) (SettingClassification, error) { + if rawMsg == nil { + 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 { + 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 2e657b17644a..a63ab4f311f9 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/pricesheet_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/pricesheet_client.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armcostmanagement @@ -45,7 +44,7 @@ func NewPriceSheetClient(credential azcore.TokenCredential, options *arm.ClientO // agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - billingAccountName - The ID that uniquely identifies a billing account. // - billingProfileName - The ID that uniquely identifies a billing profile. // - invoiceName - The ID that uniquely identifies an invoice. @@ -57,9 +56,10 @@ func (client *PriceSheetClient) BeginDownload(ctx context.Context, billingAccoun if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PriceSheetClientDownloadResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PriceSheetClientDownloadResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[PriceSheetClientDownloadResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -69,20 +69,22 @@ func (client *PriceSheetClient) BeginDownload(ctx context.Context, billingAccoun // type Microsoft Partner Agreement or Microsoft Customer Agreement. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 func (client *PriceSheetClient) download(ctx context.Context, billingAccountName string, billingProfileName string, invoiceName string, options *PriceSheetClientBeginDownloadOptions) (*http.Response, error) { + var err error req, err := client.downloadCreateRequest(ctx, billingAccountName, billingProfileName, invoiceName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // downloadCreateRequest creates the Download request. @@ -105,7 +107,7 @@ func (client *PriceSheetClient) downloadCreateRequest(ctx context.Context, billi return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -118,7 +120,7 @@ func (client *PriceSheetClient) downloadCreateRequest(ctx context.Context, billi // max 200k records. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - billingAccountName - The ID that uniquely identifies a billing account. // - billingProfileName - The ID that uniquely identifies a billing profile. // - options - PriceSheetClientBeginDownloadByBillingProfileOptions contains the optional parameters for the PriceSheetClient.BeginDownloadByBillingProfile @@ -129,9 +131,10 @@ func (client *PriceSheetClient) BeginDownloadByBillingProfile(ctx context.Contex if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PriceSheetClientDownloadByBillingProfileResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PriceSheetClientDownloadByBillingProfileResponse]{ FinalStateVia: runtime.FinalStateViaLocation, }) + return poller, err } else { return runtime.NewPollerFromResumeToken[PriceSheetClientDownloadByBillingProfileResponse](options.ResumeToken, client.internal.Pipeline(), nil) } @@ -144,20 +147,22 @@ func (client *PriceSheetClient) BeginDownloadByBillingProfile(ctx context.Contex // max 200k records. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 func (client *PriceSheetClient) downloadByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string, options *PriceSheetClientBeginDownloadByBillingProfileOptions) (*http.Response, error) { + var err error req, err := client.downloadByBillingProfileCreateRequest(ctx, billingAccountName, billingProfileName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // downloadByBillingProfileCreateRequest creates the DownloadByBillingProfile request. @@ -176,7 +181,7 @@ func (client *PriceSheetClient) downloadByBillingProfileCreateRequest(ctx contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/pricesheet_client_example_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/pricesheet_client_example_test.go deleted file mode 100644 index c94a6a2e8cd3..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/pricesheet_client_example_test.go +++ /dev/null @@ -1,74 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armcostmanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/PricesheetDownload.json -func ExamplePriceSheetClient_BeginDownload() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewPriceSheetClient().BeginDownload(ctx, "7c05a543-80ff-571e-9f98-1063b3b53cf2:99ad03ad-2d1b-4889-a452-090ad407d25f_2019-05-31", "2USN-TPCD-BG7-TGB", "T000940677", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.DownloadURL = armcostmanagement.DownloadURL{ - // DownloadURL: to.Ptr("https://myaccount.blob.core.windows.net/?restype=service&comp=properties&sv=2015-04-05&ss=bf&srt=s&st=2015-04-29T22%3A18%3A26Z&se=2015-04-30T02%3A23%3A26Z&sr=b&sp=rw&spr=https&sig=G%2TEST%4B"), - // ExpiryTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-09-30T17:32:28Z"); return t}()), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/PricesheetDownloadByBillingProfile.json -func ExamplePriceSheetClient_BeginDownloadByBillingProfile() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewPriceSheetClient().BeginDownloadByBillingProfile(ctx, "7c05a543-80ff-571e-9f98-1063b3b53cf2:99ad03ad-2d1b-4889-a452-090ad407d25f_2019-05-31", "2USN-TPCD-BG7-TGB", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.DownloadURL = armcostmanagement.DownloadURL{ - // DownloadURL: to.Ptr("https://myaccount.blob.core.windows.net/?restype=service&comp=properties&sv=2015-04-05&ss=bf&srt=s&st=2015-04-29T22%3A18%3A26Z&se=2015-04-30T02%3A23%3A26Z&sr=b&sp=rw&spr=https&sig=G%2TEST%4B"), - // ExpiryTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-07-21T17:32:28Z"); return t}()), - // } -} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/query_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/query_client.go index 847d61a93e09..37c3083b792e 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/query_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/query_client.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armcostmanagement @@ -44,7 +43,7 @@ func NewQueryClient(credential azcore.TokenCredential, options *arm.ClientOption // Usage - Query the usage data for scope defined. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - scope - The scope associated with query and export operations. This includes '/subscriptions/{subscriptionId}/' for subscription // scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for // resourceGroup scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and @@ -58,18 +57,21 @@ func NewQueryClient(credential azcore.TokenCredential, options *arm.ClientOption // - 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) { + var err error req, err := client.usageCreateRequest(ctx, scope, parameters, options) if err != nil { return QueryClientUsageResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return QueryClientUsageResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { - return QueryClientUsageResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return QueryClientUsageResponse{}, err } - return client.usageHandleResponse(resp) + resp, err := client.usageHandleResponse(httpResp) + return resp, err } // usageCreateRequest creates the Usage request. @@ -81,10 +83,13 @@ func (client *QueryClient) usageCreateRequest(ctx context.Context, scope string, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, parameters) + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil } // usageHandleResponse handles the Usage response. @@ -99,7 +104,7 @@ func (client *QueryClient) usageHandleResponse(resp *http.Response) (QueryClient // UsageByExternalCloudProviderType - Query the usage data for external cloud provider type defined. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - externalCloudProviderType - The external cloud provider type associated with dimension/query operations. This includes // 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated account. // - externalCloudProviderID - This can be '{externalSubscriptionId}' for linked account or '{externalBillingAccountId}' for @@ -108,18 +113,21 @@ func (client *QueryClient) usageHandleResponse(resp *http.Response) (QueryClient // - 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) { + var err error req, err := client.usageByExternalCloudProviderTypeCreateRequest(ctx, externalCloudProviderType, externalCloudProviderID, parameters, options) if err != nil { return QueryClientUsageByExternalCloudProviderTypeResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return QueryClientUsageByExternalCloudProviderTypeResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return QueryClientUsageByExternalCloudProviderTypeResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return QueryClientUsageByExternalCloudProviderTypeResponse{}, err } - return client.usageByExternalCloudProviderTypeHandleResponse(resp) + resp, err := client.usageByExternalCloudProviderTypeHandleResponse(httpResp) + return resp, err } // usageByExternalCloudProviderTypeCreateRequest creates the UsageByExternalCloudProviderType request. @@ -138,10 +146,13 @@ func (client *QueryClient) usageByExternalCloudProviderTypeCreateRequest(ctx con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, parameters) + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil } // usageByExternalCloudProviderTypeHandleResponse handles the UsageByExternalCloudProviderType response. diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/query_client_example_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/query_client_example_test.go deleted file mode 100644 index 6d938b0233ce..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/query_client_example_test.go +++ /dev/null @@ -1,1934 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armcostmanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BillingAccountQuery.json -func ExampleQueryClient_Usage_billingAccountQueryLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQueryClient().Usage(ctx, "providers/Microsoft.Billing/billingAccounts/70664866", armcostmanagement.QueryDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeUsage), - Dataset: &armcostmanagement.QueryDataset{ - Filter: &armcostmanagement.QueryFilter{ - And: []*armcostmanagement.QueryFilter{ - { - Or: []*armcostmanagement.QueryFilter{ - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("East US"), - to.Ptr("West Europe")}, - }, - }, - { - Tags: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("UAT"), - to.Ptr("Prod")}, - }, - }}, - }, - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("API")}, - }, - }}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.QueryResult = armcostmanagement.QueryResult{ - // Name: to.Ptr("ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Type: to.Ptr("microsoft.costmanagement/Query"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/70664866/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Properties: &armcostmanagement.QueryProperties{ - // Columns: []*armcostmanagement.QueryColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("ResourceGroup"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("UsageDate"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // float64(20180331), - // "USD"}, - // []any{ - // float64(173.41979241290323), - // "RVIIOT-TRIAL", - // float64(20180331), - // "USD"}, - // []any{ - // float64(20.35941656262545), - // "VSTSHOL-1595322048000", - // float64(20180331), - // "USD"}, - // []any{ - // float64(0.16677720329728665), - // "gs-stms-dev", - // float64(20180331), - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCABillingAccountQuery.json -func ExampleQueryClient_Usage_billingAccountQueryMca() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQueryClient().Usage(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789", armcostmanagement.QueryDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeUsage), - Dataset: &armcostmanagement.QueryDataset{ - Filter: &armcostmanagement.QueryFilter{ - And: []*armcostmanagement.QueryFilter{ - { - Or: []*armcostmanagement.QueryFilter{ - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("East US"), - to.Ptr("West Europe")}, - }, - }, - { - Tags: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("UAT"), - to.Ptr("Prod")}, - }, - }}, - }, - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("API")}, - }, - }}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.QueryResult = armcostmanagement.QueryResult{ - // Name: to.Ptr("ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Type: to.Ptr("microsoft.costmanagement/Query"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Properties: &armcostmanagement.QueryProperties{ - // Columns: []*armcostmanagement.QueryColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("ResourceGroup"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("UsageDate"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // float64(20180331), - // "USD"}, - // []any{ - // float64(173.41979241290323), - // "RVIIOT-TRIAL", - // float64(20180331), - // "USD"}, - // []any{ - // float64(20.35941656262545), - // "VSTSHOL-1595322048000", - // float64(20180331), - // "USD"}, - // []any{ - // float64(0.16677720329728665), - // "gs-stms-dev", - // float64(20180331), - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/BillingAccountQueryGrouping.json -func ExampleQueryClient_Usage_billingAccountQueryGroupingLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQueryClient().Usage(ctx, "providers/Microsoft.Billing/billingAccounts/70664866", armcostmanagement.QueryDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeUsage), - Dataset: &armcostmanagement.QueryDataset{ - Aggregation: map[string]*armcostmanagement.QueryAggregation{ - "totalCost": { - Name: to.Ptr("PreTaxCost"), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), - }, - }, - Granularity: to.Ptr(armcostmanagement.GranularityType("None")), - Grouping: []*armcostmanagement.QueryGrouping{ - { - Name: to.Ptr("ResourceGroup"), - Type: to.Ptr(armcostmanagement.QueryColumnTypeDimension), - }}, - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheLastMonth), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.QueryResult = armcostmanagement.QueryResult{ - // Name: to.Ptr("ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Type: to.Ptr("microsoft.costmanagement/Query"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/70664866/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Properties: &armcostmanagement.QueryProperties{ - // Columns: []*armcostmanagement.QueryColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("ResourceGroup"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // "USD"}, - // []any{ - // float64(173.41979241290323), - // "RVIIOT-TRIAL", - // "USD"}, - // []any{ - // float64(20.35941656262545), - // "VSTSHOL-1595322048000", - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCABillingAccountQueryGrouping.json -func ExampleQueryClient_Usage_billingAccountQueryGroupingMca() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQueryClient().Usage(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789", armcostmanagement.QueryDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeUsage), - Dataset: &armcostmanagement.QueryDataset{ - Aggregation: map[string]*armcostmanagement.QueryAggregation{ - "totalCost": { - Name: to.Ptr("PreTaxCost"), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), - }, - }, - Granularity: to.Ptr(armcostmanagement.GranularityType("None")), - Grouping: []*armcostmanagement.QueryGrouping{ - { - Name: to.Ptr("ResourceGroup"), - Type: to.Ptr(armcostmanagement.QueryColumnTypeDimension), - }}, - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheLastMonth), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.QueryResult = armcostmanagement.QueryResult{ - // Name: to.Ptr("ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Type: to.Ptr("microsoft.costmanagement/Query"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Properties: &armcostmanagement.QueryProperties{ - // Columns: []*armcostmanagement.QueryColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("ResourceGroup"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // "USD"}, - // []any{ - // float64(173.41979241290323), - // "RVIIOT-TRIAL", - // "USD"}, - // []any{ - // float64(20.35941656262545), - // "VSTSHOL-1595322048000", - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCABillingProfileQuery.json -func ExampleQueryClient_Usage_billingProfileQueryMca() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQueryClient().Usage(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579", armcostmanagement.QueryDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeUsage), - Dataset: &armcostmanagement.QueryDataset{ - Filter: &armcostmanagement.QueryFilter{ - And: []*armcostmanagement.QueryFilter{ - { - Or: []*armcostmanagement.QueryFilter{ - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("East US"), - to.Ptr("West Europe")}, - }, - }, - { - Tags: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("UAT"), - to.Ptr("Prod")}, - }, - }}, - }, - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("API")}, - }, - }}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.QueryResult = armcostmanagement.QueryResult{ - // Name: to.Ptr("ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Type: to.Ptr("microsoft.costmanagement/Query"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Properties: &armcostmanagement.QueryProperties{ - // Columns: []*armcostmanagement.QueryColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("ResourceGroup"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("UsageDate"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // float64(20180331), - // "USD"}, - // []any{ - // float64(173.41979241290323), - // "RVIIOT-TRIAL", - // float64(20180331), - // "USD"}, - // []any{ - // float64(20.35941656262545), - // "VSTSHOL-1595322048000", - // float64(20180331), - // "USD"}, - // []any{ - // float64(0.16677720329728665), - // "gs-stms-dev", - // float64(20180331), - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCABillingProfileQueryGrouping.json -func ExampleQueryClient_Usage_billingProfileQueryGroupingMca() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQueryClient().Usage(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579", armcostmanagement.QueryDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeUsage), - Dataset: &armcostmanagement.QueryDataset{ - Aggregation: map[string]*armcostmanagement.QueryAggregation{ - "totalCost": { - Name: to.Ptr("PreTaxCost"), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), - }, - }, - Granularity: to.Ptr(armcostmanagement.GranularityType("None")), - Grouping: []*armcostmanagement.QueryGrouping{ - { - Name: to.Ptr("ResourceGroup"), - Type: to.Ptr(armcostmanagement.QueryColumnTypeDimension), - }}, - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheLastMonth), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.QueryResult = armcostmanagement.QueryResult{ - // Name: to.Ptr("ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Type: to.Ptr("microsoft.costmanagement/Query"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Properties: &armcostmanagement.QueryProperties{ - // Columns: []*armcostmanagement.QueryColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("ResourceGroup"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // "USD"}, - // []any{ - // float64(173.41979241290323), - // "RVIIOT-TRIAL", - // "USD"}, - // []any{ - // float64(20.35941656262545), - // "VSTSHOL-1595322048000", - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCACustomerQuery.json -func ExampleQueryClient_Usage_customerQueryMca() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQueryClient().Usage(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678", armcostmanagement.QueryDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeUsage), - Dataset: &armcostmanagement.QueryDataset{ - Filter: &armcostmanagement.QueryFilter{ - And: []*armcostmanagement.QueryFilter{ - { - Or: []*armcostmanagement.QueryFilter{ - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("East US"), - to.Ptr("West Europe")}, - }, - }, - { - Tags: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("UAT"), - to.Ptr("Prod")}, - }, - }}, - }, - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("API")}, - }, - }}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.QueryResult = armcostmanagement.QueryResult{ - // Name: to.Ptr("ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Type: to.Ptr("microsoft.costmanagement/Query"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Properties: &armcostmanagement.QueryProperties{ - // Columns: []*armcostmanagement.QueryColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("ResourceGroup"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("UsageDate"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // float64(20180331), - // "USD"}, - // []any{ - // float64(173.41979241290323), - // "RVIIOT-TRIAL", - // float64(20180331), - // "USD"}, - // []any{ - // float64(20.35941656262545), - // "VSTSHOL-1595322048000", - // float64(20180331), - // "USD"}, - // []any{ - // float64(0.16677720329728665), - // "gs-stms-dev", - // float64(20180331), - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCACustomerQueryGrouping.json -func ExampleQueryClient_Usage_customerQueryGroupingMca() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQueryClient().Usage(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678", armcostmanagement.QueryDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeUsage), - Dataset: &armcostmanagement.QueryDataset{ - Aggregation: map[string]*armcostmanagement.QueryAggregation{ - "totalCost": { - Name: to.Ptr("PreTaxCost"), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), - }, - }, - Granularity: to.Ptr(armcostmanagement.GranularityType("None")), - Grouping: []*armcostmanagement.QueryGrouping{ - { - Name: to.Ptr("ResourceGroup"), - Type: to.Ptr(armcostmanagement.QueryColumnTypeDimension), - }}, - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheLastMonth), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.QueryResult = armcostmanagement.QueryResult{ - // Name: to.Ptr("ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Type: to.Ptr("microsoft.costmanagement/Query"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/customers/5678/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Properties: &armcostmanagement.QueryProperties{ - // Columns: []*armcostmanagement.QueryColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("ResourceGroup"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // "USD"}, - // []any{ - // float64(173.41979241290323), - // "RVIIOT-TRIAL", - // "USD"}, - // []any{ - // float64(20.35941656262545), - // "VSTSHOL-1595322048000", - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/DepartmentQuery.json -func ExampleQueryClient_Usage_departmentQueryLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQueryClient().Usage(ctx, "providers/Microsoft.Billing/billingAccounts/100/departments/123", armcostmanagement.QueryDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeUsage), - Dataset: &armcostmanagement.QueryDataset{ - Filter: &armcostmanagement.QueryFilter{ - And: []*armcostmanagement.QueryFilter{ - { - Or: []*armcostmanagement.QueryFilter{ - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("East US"), - to.Ptr("West Europe")}, - }, - }, - { - Tags: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("UAT"), - to.Ptr("Prod")}, - }, - }}, - }, - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("API")}, - }, - }}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.QueryResult = armcostmanagement.QueryResult{ - // Name: to.Ptr("ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Type: to.Ptr("microsoft.costmanagement/Query"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/70664866/departments/123/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Properties: &armcostmanagement.QueryProperties{ - // Columns: []*armcostmanagement.QueryColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("ResourceGroup"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("UsageDate"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // float64(20180331), - // "USD"}, - // []any{ - // float64(173.41979241290323), - // "RVIIOT-TRIAL", - // float64(20180331), - // "USD"}, - // []any{ - // float64(20.35941656262545), - // "VSTSHOL-1595322048000", - // float64(20180331), - // "USD"}, - // []any{ - // float64(0.16677720329728665), - // "gs-stms-dev", - // float64(20180331), - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/DepartmentQueryGrouping.json -func ExampleQueryClient_Usage_departmentQueryGroupingLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQueryClient().Usage(ctx, "providers/Microsoft.Billing/billingAccounts/100/departments/123", armcostmanagement.QueryDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeUsage), - Dataset: &armcostmanagement.QueryDataset{ - Aggregation: map[string]*armcostmanagement.QueryAggregation{ - "totalCost": { - Name: to.Ptr("PreTaxCost"), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), - }, - }, - Granularity: to.Ptr(armcostmanagement.GranularityType("None")), - Grouping: []*armcostmanagement.QueryGrouping{ - { - Name: to.Ptr("ResourceGroup"), - Type: to.Ptr(armcostmanagement.QueryColumnTypeDimension), - }}, - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheLastMonth), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.QueryResult = armcostmanagement.QueryResult{ - // Name: to.Ptr("ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Type: to.Ptr("microsoft.costmanagement/Query"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/70664866/departments/123/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Properties: &armcostmanagement.QueryProperties{ - // Columns: []*armcostmanagement.QueryColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("ResourceGroup"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // "USD"}, - // []any{ - // float64(173.41979241290323), - // "RVIIOT-TRIAL", - // "USD"}, - // []any{ - // float64(20.35941656262545), - // "VSTSHOL-1595322048000", - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/EnrollmentAccountQuery.json -func ExampleQueryClient_Usage_enrollmentAccountQueryLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQueryClient().Usage(ctx, "providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456", armcostmanagement.QueryDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeUsage), - Dataset: &armcostmanagement.QueryDataset{ - Filter: &armcostmanagement.QueryFilter{ - And: []*armcostmanagement.QueryFilter{ - { - Or: []*armcostmanagement.QueryFilter{ - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("East US"), - to.Ptr("West Europe")}, - }, - }, - { - Tags: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("UAT"), - to.Ptr("Prod")}, - }, - }}, - }, - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("API")}, - }, - }}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.QueryResult = armcostmanagement.QueryResult{ - // Name: to.Ptr("ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Type: to.Ptr("microsoft.costmanagement/Query"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/70664866/enrollmentAccounts/456/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Properties: &armcostmanagement.QueryProperties{ - // Columns: []*armcostmanagement.QueryColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("ResourceGroup"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("UsageDate"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // float64(20180331), - // "USD"}, - // []any{ - // float64(173.41979241290323), - // "RVIIOT-TRIAL", - // float64(20180331), - // "USD"}, - // []any{ - // float64(20.35941656262545), - // "VSTSHOL-1595322048000", - // float64(20180331), - // "USD"}, - // []any{ - // float64(0.16677720329728665), - // "gs-stms-dev", - // float64(20180331), - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/EnrollmentAccountQueryGrouping.json -func ExampleQueryClient_Usage_enrollmentAccountQueryGroupingLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQueryClient().Usage(ctx, "providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456", armcostmanagement.QueryDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeUsage), - Dataset: &armcostmanagement.QueryDataset{ - Aggregation: map[string]*armcostmanagement.QueryAggregation{ - "totalCost": { - Name: to.Ptr("PreTaxCost"), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), - }, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - Grouping: []*armcostmanagement.QueryGrouping{ - { - Name: to.Ptr("ResourceGroup"), - Type: to.Ptr(armcostmanagement.QueryColumnTypeDimension), - }}, - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheLastMonth), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.QueryResult = armcostmanagement.QueryResult{ - // Name: to.Ptr("ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Type: to.Ptr("microsoft.costmanagement/Query"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/70664866/enrollmentAccounts/456/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Properties: &armcostmanagement.QueryProperties{ - // Columns: []*armcostmanagement.QueryColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("ResourceGroup"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("UsageDate"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // float64(20180331), - // "USD"}, - // []any{ - // float64(173.41979241290323), - // "RVIIOT-TRIAL", - // float64(20180331), - // "USD"}, - // []any{ - // float64(20.35941656262545), - // "VSTSHOL-1595322048000", - // float64(20180331), - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCAInvoiceSectionQuery.json -func ExampleQueryClient_Usage_invoiceSectionQueryMca() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQueryClient().Usage(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876", armcostmanagement.QueryDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeUsage), - Dataset: &armcostmanagement.QueryDataset{ - Filter: &armcostmanagement.QueryFilter{ - And: []*armcostmanagement.QueryFilter{ - { - Or: []*armcostmanagement.QueryFilter{ - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("East US"), - to.Ptr("West Europe")}, - }, - }, - { - Tags: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("UAT"), - to.Ptr("Prod")}, - }, - }}, - }, - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("API")}, - }, - }}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.QueryResult = armcostmanagement.QueryResult{ - // Name: to.Ptr("ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Type: to.Ptr("microsoft.costmanagement/Query"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Properties: &armcostmanagement.QueryProperties{ - // Columns: []*armcostmanagement.QueryColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("ResourceGroup"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("UsageDate"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // float64(20180331), - // "USD"}, - // []any{ - // float64(173.41979241290323), - // "RVIIOT-TRIAL", - // float64(20180331), - // "USD"}, - // []any{ - // float64(20.35941656262545), - // "VSTSHOL-1595322048000", - // float64(20180331), - // "USD"}, - // []any{ - // float64(0.16677720329728665), - // "gs-stms-dev", - // float64(20180331), - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/MCAInvoiceSectionQueryGrouping.json -func ExampleQueryClient_Usage_invoiceSectionQueryGroupingMca() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQueryClient().Usage(ctx, "providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876", armcostmanagement.QueryDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeUsage), - Dataset: &armcostmanagement.QueryDataset{ - Aggregation: map[string]*armcostmanagement.QueryAggregation{ - "totalCost": { - Name: to.Ptr("PreTaxCost"), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), - }, - }, - Granularity: to.Ptr(armcostmanagement.GranularityType("None")), - Grouping: []*armcostmanagement.QueryGrouping{ - { - Name: to.Ptr("ResourceGroup"), - Type: to.Ptr(armcostmanagement.QueryColumnTypeDimension), - }}, - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheLastMonth), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.QueryResult = armcostmanagement.QueryResult{ - // Name: to.Ptr("ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Type: to.Ptr("microsoft.costmanagement/Query"), - // ID: to.Ptr("providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Properties: &armcostmanagement.QueryProperties{ - // Columns: []*armcostmanagement.QueryColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("ResourceGroup"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // "USD"}, - // []any{ - // float64(173.41979241290323), - // "RVIIOT-TRIAL", - // "USD"}, - // []any{ - // float64(20.35941656262545), - // "VSTSHOL-1595322048000", - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ManagementGroupQuery.json -func ExampleQueryClient_Usage_managementGroupQueryLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQueryClient().Usage(ctx, "providers/Microsoft.Management/managementGroups/MyMgId", armcostmanagement.QueryDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeUsage), - Dataset: &armcostmanagement.QueryDataset{ - Filter: &armcostmanagement.QueryFilter{ - And: []*armcostmanagement.QueryFilter{ - { - Or: []*armcostmanagement.QueryFilter{ - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("East US"), - to.Ptr("West Europe")}, - }, - }, - { - Tags: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("UAT"), - to.Ptr("Prod")}, - }, - }}, - }, - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("API")}, - }, - }}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.QueryResult = armcostmanagement.QueryResult{ - // Name: to.Ptr("ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Type: to.Ptr("microsoft.costmanagement/Query"), - // ID: to.Ptr("providers/Microsoft.Management/managementGroups/MyMgId/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Properties: &armcostmanagement.QueryProperties{ - // Columns: []*armcostmanagement.QueryColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("ResourceGroup"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("UsageDate"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // float64(20180331), - // "USD"}, - // []any{ - // float64(173.41979241290323), - // "RVIIOT-TRIAL", - // float64(20180331), - // "USD"}, - // []any{ - // float64(20.35941656262545), - // "VSTSHOL-1595322048000", - // float64(20180331), - // "USD"}, - // []any{ - // float64(0.16677720329728665), - // "gs-stms-dev", - // float64(20180331), - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ManagementGroupQueryGrouping.json -func ExampleQueryClient_Usage_managementGroupQueryGroupingLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQueryClient().Usage(ctx, "providers/Microsoft.Management/managementGroups/MyMgId", armcostmanagement.QueryDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeUsage), - Dataset: &armcostmanagement.QueryDataset{ - Aggregation: map[string]*armcostmanagement.QueryAggregation{ - "totalCost": { - Name: to.Ptr("PreTaxCost"), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), - }, - }, - Granularity: to.Ptr(armcostmanagement.GranularityType("None")), - Grouping: []*armcostmanagement.QueryGrouping{ - { - Name: to.Ptr("ResourceGroup"), - Type: to.Ptr(armcostmanagement.QueryColumnTypeDimension), - }}, - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheLastMonth), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.QueryResult = armcostmanagement.QueryResult{ - // Name: to.Ptr("ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Type: to.Ptr("microsoft.costmanagement/Query"), - // ID: to.Ptr("providers/Microsoft.Management/managementGroups/MyMgId/providers/Microsoft.CostManagement/Query/ad67fd91-c131-4bda-9ba9-7187ecb1cebd"), - // Properties: &armcostmanagement.QueryProperties{ - // Columns: []*armcostmanagement.QueryColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("ResourceGroup"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("UsageDate"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(20.35941656262545), - // "VSTSHOL-1595322048000", - // float64(20180331), - // "USD"}, - // []any{ - // float64(173.41979241290323), - // "RVIIOT-TRIAL", - // float64(20180331), - // "USD"}, - // []any{ - // float64(19.545363672276512), - // "JapanUnifia-Trial", - // float64(20180331), - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ResourceGroupQuery.json -func ExampleQueryClient_Usage_resourceGroupQueryLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQueryClient().Usage(ctx, "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ScreenSharingTest-peer", armcostmanagement.QueryDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeUsage), - Dataset: &armcostmanagement.QueryDataset{ - Filter: &armcostmanagement.QueryFilter{ - And: []*armcostmanagement.QueryFilter{ - { - Or: []*armcostmanagement.QueryFilter{ - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("East US"), - to.Ptr("West Europe")}, - }, - }, - { - Tags: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("UAT"), - to.Ptr("Prod")}, - }, - }}, - }, - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("API")}, - }, - }}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.QueryResult = armcostmanagement.QueryResult{ - // Name: to.Ptr("9af9459d-441d-4055-9ed0-83d4c4a363fb"), - // Type: to.Ptr("microsoft.costmanagement/Query"), - // ID: to.Ptr("subscriptions/55312978-ba1b-415c-9304-c4b9c43c0481/resourcegroups/ScreenSharingTest-peer/providers/Microsoft.CostManagement/Query/9af9459d-441d-4055-9ed0-83d4c4a363fb"), - // Properties: &armcostmanagement.QueryProperties{ - // Columns: []*armcostmanagement.QueryColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("ResourceGroup"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("UsageDate"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(2.10333307059661), - // "ScreenSharingTest-peer", - // float64(20180417), - // "USD"}, - // []any{ - // float64(20.10333307059661), - // "ScreenSharingTest-peer", - // float64(20180418), - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ResourceGroupQueryGrouping.json -func ExampleQueryClient_Usage_resourceGroupQueryGroupingLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQueryClient().Usage(ctx, "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ScreenSharingTest-peer", armcostmanagement.QueryDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeUsage), - Dataset: &armcostmanagement.QueryDataset{ - Aggregation: map[string]*armcostmanagement.QueryAggregation{ - "totalCost": { - Name: to.Ptr("PreTaxCost"), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), - }, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - Grouping: []*armcostmanagement.QueryGrouping{ - { - Name: to.Ptr("ResourceType"), - Type: to.Ptr(armcostmanagement.QueryColumnTypeDimension), - }}, - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheLastMonth), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.QueryResult = armcostmanagement.QueryResult{ - // Name: to.Ptr("9af9459d-441d-4055-9ed0-83d4c4a363fb"), - // Type: to.Ptr("microsoft.costmanagement/Query"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/ScreenSharingTest-peer/providers/Microsoft.CostManagement/Query/9af9459d-441d-4055-9ed0-83d4c4a363fb"), - // Properties: &armcostmanagement.QueryProperties{ - // Columns: []*armcostmanagement.QueryColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("ResourceType"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("UsageDate"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(2.10333307059661), - // "Microsoft.SqlServer", - // float64(20180417), - // "USD"}, - // []any{ - // float64(20.10333307059661), - // "Microsoft.Compute", - // float64(20180418), - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/SubscriptionQuery.json -func ExampleQueryClient_Usage_subscriptionQueryLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQueryClient().Usage(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", armcostmanagement.QueryDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeUsage), - Dataset: &armcostmanagement.QueryDataset{ - Filter: &armcostmanagement.QueryFilter{ - And: []*armcostmanagement.QueryFilter{ - { - Or: []*armcostmanagement.QueryFilter{ - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("East US"), - to.Ptr("West Europe")}, - }, - }, - { - Tags: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("UAT"), - to.Ptr("Prod")}, - }, - }}, - }, - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("API")}, - }, - }}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.QueryResult = armcostmanagement.QueryResult{ - // Name: to.Ptr("55312978-ba1b-415c-9304-cfd9c43c0481"), - // Type: to.Ptr("microsoft.costmanagement/Query"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/Query/00000000-0000-0000-0000-000000000000"), - // Properties: &armcostmanagement.QueryProperties{ - // Columns: []*armcostmanagement.QueryColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("ResourceGroup"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("UsageDate"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(2.10333307059661), - // "ScreenSharingTest-peer", - // float64(20180331), - // "USD"}, - // []any{ - // float64(218.68795741935486), - // "Ict_StratAndPlan_GoldSprova_Prod", - // float64(20180331), - // "USD"}, - // []any{ - // float64(0.14384913581657052), - // "ssbciotelement01", - // float64(20180401), - // "USD"}, - // []any{ - // float64(0.009865586851323632), - // "ict_stratandplan_goldsprova_prod", - // float64(20180429), - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/SubscriptionQueryGrouping.json -func ExampleQueryClient_Usage_subscriptionQueryGroupingLegacy() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQueryClient().Usage(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", armcostmanagement.QueryDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeUsage), - Dataset: &armcostmanagement.QueryDataset{ - Aggregation: map[string]*armcostmanagement.QueryAggregation{ - "totalCost": { - Name: to.Ptr("PreTaxCost"), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), - }, - }, - Granularity: to.Ptr(armcostmanagement.GranularityType("None")), - Grouping: []*armcostmanagement.QueryGrouping{ - { - Name: to.Ptr("ResourceGroup"), - Type: to.Ptr(armcostmanagement.QueryColumnTypeDimension), - }}, - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeTheLastMonth), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.QueryResult = armcostmanagement.QueryResult{ - // Name: to.Ptr("55312978-ba1b-415c-9304-cfd9c43c0481"), - // Type: to.Ptr("microsoft.costmanagement/Query"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/Query/00000000-0000-0000-0000-000000000000"), - // Properties: &armcostmanagement.QueryProperties{ - // Columns: []*armcostmanagement.QueryColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("ResourceGroup"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(0.009865586851323632), - // "Ict_StratAndPlan_GoldSprova_Prod_0", - // "USD"}, - // []any{ - // float64(218.68795741935486), - // "Ict_StratAndPlan_GoldSprova_Prod_1", - // "USD"}, - // []any{ - // float64(2.10333307059661), - // "ScreenSharingTest-peer1", - // "USD"}, - // []any{ - // float64(0.14384913581657052), - // "Ssbciotelement01", - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExternalBillingAccountsQuery.json -func ExampleQueryClient_UsageByExternalCloudProviderType_externalBillingAccountQueryList() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQueryClient().UsageByExternalCloudProviderType(ctx, armcostmanagement.ExternalCloudProviderTypeExternalBillingAccounts, "100", armcostmanagement.QueryDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeUsage), - Dataset: &armcostmanagement.QueryDataset{ - Filter: &armcostmanagement.QueryFilter{ - And: []*armcostmanagement.QueryFilter{ - { - Or: []*armcostmanagement.QueryFilter{ - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("East US"), - to.Ptr("West Europe")}, - }, - }, - { - Tags: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("UAT"), - to.Ptr("Prod")}, - }, - }}, - }, - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("API")}, - }, - }}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.QueryResult = armcostmanagement.QueryResult{ - // Name: to.Ptr("6dc7b06a-d90a-4df5-b655-ce6cf1c0814d"), - // Type: to.Ptr("Microsoft.CostManagement/query"), - // ID: to.Ptr("providers/Microsoft.CostManagement/externalBillingAccounts/100/query/6dc7b06a-d90a-4df5-b655-ce6cf1c0814d"), - // Properties: &armcostmanagement.QueryProperties{ - // Columns: []*armcostmanagement.QueryColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("ServiceName"), - // Type: to.Ptr("String"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // []any{ - // float64(0), - // "abc db", - // "USD"}, - // []any{ - // float64(30.2572751438), - // "abc compute cloud", - // "USD"}, - // []any{ - // float64(0.07675760200000002), - // "abc file system", - // "USD"}, - // []any{ - // float64(50.43096419040001), - // "abc elasticache", - // "USD"}}, - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ExternalSubscriptionsQuery.json -func ExampleQueryClient_UsageByExternalCloudProviderType_externalSubscriptionsQuery() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQueryClient().UsageByExternalCloudProviderType(ctx, armcostmanagement.ExternalCloudProviderTypeExternalSubscriptions, "100", armcostmanagement.QueryDefinition{ - Type: to.Ptr(armcostmanagement.ExportTypeUsage), - Dataset: &armcostmanagement.QueryDataset{ - Filter: &armcostmanagement.QueryFilter{ - And: []*armcostmanagement.QueryFilter{ - { - Or: []*armcostmanagement.QueryFilter{ - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceLocation"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("East US"), - to.Ptr("West Europe")}, - }, - }, - { - Tags: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("Environment"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("UAT"), - to.Ptr("Prod")}, - }, - }}, - }, - { - Dimensions: &armcostmanagement.QueryComparisonExpression{ - Name: to.Ptr("ResourceGroup"), - Operator: to.Ptr(armcostmanagement.QueryOperatorTypeIn), - Values: []*string{ - to.Ptr("API")}, - }, - }}, - }, - Granularity: to.Ptr(armcostmanagement.GranularityTypeDaily), - }, - Timeframe: to.Ptr(armcostmanagement.TimeframeTypeMonthToDate), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.QueryResult = armcostmanagement.QueryResult{ - // Name: to.Ptr("d99477af-7510-40ee-aca2-e59bdca0d10d"), - // Type: to.Ptr("Microsoft.CostManagement/query"), - // ID: to.Ptr("providers/Microsoft.CostManagement/externalSubscriptions/100/query/d99477af-7510-40ee-aca2-e59bdca0d10d"), - // Properties: &armcostmanagement.QueryProperties{ - // Columns: []*armcostmanagement.QueryColumn{ - // { - // Name: to.Ptr("PreTaxCost"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("UsageDate"), - // Type: to.Ptr("Number"), - // }, - // { - // Name: to.Ptr("Currency"), - // Type: to.Ptr("String"), - // }}, - // Rows: [][]any{ - // }, - // }, - // } -} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/response_types.go b/sdk/resourcemanager/costmanagement/armcostmanagement/response_types.go index 0cc64c1e1196..f75f10b38f62 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/response_types.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/response_types.go @@ -3,69 +3,133 @@ // 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. +// 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. -// DO NOT EDIT. package armcostmanagement // AlertsClientDismissResponse contains the response from method AlertsClient.Dismiss. type AlertsClientDismissResponse struct { + // An individual alert. Alert } // AlertsClientGetResponse contains the response from method AlertsClient.Get. type AlertsClientGetResponse struct { + // An individual alert. Alert } // AlertsClientListExternalResponse contains the response from method AlertsClient.ListExternal. type AlertsClientListExternalResponse struct { + // Result of alerts. AlertsResult } // AlertsClientListResponse contains the response from method AlertsClient.List. type AlertsClientListResponse struct { + // Result of alerts. AlertsResult } // BenefitRecommendationsClientListResponse contains the response from method BenefitRecommendationsClient.NewListPager. type BenefitRecommendationsClientListResponse struct { + // Result of listing benefit recommendations. BenefitRecommendationsListResult } // BenefitUtilizationSummariesClientListByBillingAccountIDResponse contains the response from method BenefitUtilizationSummariesClient.NewListByBillingAccountIDPager. type BenefitUtilizationSummariesClientListByBillingAccountIDResponse struct { + // List of benefit utilization summaries. BenefitUtilizationSummariesListResult } // BenefitUtilizationSummariesClientListByBillingProfileIDResponse contains the response from method BenefitUtilizationSummariesClient.NewListByBillingProfileIDPager. type BenefitUtilizationSummariesClientListByBillingProfileIDResponse struct { + // List of benefit utilization summaries. BenefitUtilizationSummariesListResult } // BenefitUtilizationSummariesClientListBySavingsPlanIDResponse contains the response from method BenefitUtilizationSummariesClient.NewListBySavingsPlanIDPager. type BenefitUtilizationSummariesClientListBySavingsPlanIDResponse struct { + // List of benefit utilization summaries. BenefitUtilizationSummariesListResult } // BenefitUtilizationSummariesClientListBySavingsPlanOrderResponse contains the response from method BenefitUtilizationSummariesClient.NewListBySavingsPlanOrderPager. type BenefitUtilizationSummariesClientListBySavingsPlanOrderResponse struct { + // List of benefit utilization summaries. 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. DimensionsListResult } // DimensionsClientListResponse contains the response from method DimensionsClient.NewListPager. type DimensionsClientListResponse struct { + // Result of listing dimensions. It contains a list of available dimensions. DimensionsListResult } // ExportsClientCreateOrUpdateResponse contains the response from method ExportsClient.CreateOrUpdate. type ExportsClientCreateOrUpdateResponse struct { + // An export resource. Export } @@ -81,106 +145,169 @@ type ExportsClientExecuteResponse struct { // ExportsClientGetExecutionHistoryResponse contains the response from method ExportsClient.GetExecutionHistory. type ExportsClientGetExecutionHistoryResponse struct { + // Result of listing the run history of an export. ExportExecutionListResult } // ExportsClientGetResponse contains the response from method ExportsClient.Get. type ExportsClientGetResponse struct { + // An export resource. Export } // ExportsClientListResponse contains the response from method ExportsClient.List. type ExportsClientListResponse struct { + // Result of listing exports. It contains a list of available exports in the scope provided. ExportListResult } // ForecastClientExternalCloudProviderUsageResponse contains the response from method ForecastClient.ExternalCloudProviderUsage. type ForecastClientExternalCloudProviderUsageResponse struct { + // Result of forecast. It contains all columns listed under groupings and aggregation. ForecastResult } // ForecastClientUsageResponse contains the response from method ForecastClient.Usage. type ForecastClientUsageResponse struct { + // Result of forecast. It contains all columns listed under groupings and aggregation. 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. CostDetailsOperationResults } // GenerateCostDetailsReportClientGetOperationResultsResponse contains the response from method GenerateCostDetailsReportClient.BeginGetOperationResults. type GenerateCostDetailsReportClientGetOperationResultsResponse struct { + // The result of the long running operation for cost details Api. CostDetailsOperationResults } // GenerateDetailedCostReportClientCreateOperationResponse contains the response from method GenerateDetailedCostReportClient.BeginCreateOperation. type GenerateDetailedCostReportClientCreateOperationResponse struct { + // The result of the long running operation for cost detailed report. GenerateDetailedCostReportOperationResult } // GenerateDetailedCostReportOperationResultsClientGetResponse contains the response from method GenerateDetailedCostReportOperationResultsClient.BeginGet. type GenerateDetailedCostReportOperationResultsClientGetResponse struct { + // The result of the long running operation for cost detailed report. GenerateDetailedCostReportOperationResult } // GenerateDetailedCostReportOperationStatusClientGetResponse contains the response from method GenerateDetailedCostReportOperationStatusClient.Get. type GenerateDetailedCostReportOperationStatusClientGetResponse struct { + // The status of the long running operation for cost detailed report. GenerateDetailedCostReportOperationStatuses } // GenerateReservationDetailsReportClientByBillingAccountIDResponse contains the response from method GenerateReservationDetailsReportClient.BeginByBillingAccountID. type GenerateReservationDetailsReportClientByBillingAccountIDResponse struct { + // The status of the long running operation. OperationStatus } // GenerateReservationDetailsReportClientByBillingProfileIDResponse contains the response from method GenerateReservationDetailsReportClient.BeginByBillingProfileID. type GenerateReservationDetailsReportClientByBillingProfileIDResponse struct { + // The status of the long running operation. OperationStatus } // OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { + // Result of listing cost management operations. It contains a list of operations and a URL link to get the next set of results. OperationListResult } // PriceSheetClientDownloadByBillingProfileResponse contains the response from method PriceSheetClient.BeginDownloadByBillingProfile. type PriceSheetClientDownloadByBillingProfileResponse struct { + // The URL to download the generated report. DownloadURL } // PriceSheetClientDownloadResponse contains the response from method PriceSheetClient.BeginDownload. type PriceSheetClientDownloadResponse struct { + // The URL to download the generated report. DownloadURL } // QueryClientUsageByExternalCloudProviderTypeResponse contains the response from method QueryClient.UsageByExternalCloudProviderType. type QueryClientUsageByExternalCloudProviderTypeResponse struct { + // Result of query. It contains all columns listed under groupings and aggregation. QueryResult } // QueryClientUsageResponse contains the response from method QueryClient.Usage. type QueryClientUsageResponse struct { + // Result of query. It contains all columns listed under groupings and aggregation. QueryResult } // ScheduledActionsClientCheckNameAvailabilityByScopeResponse contains the response from method ScheduledActionsClient.CheckNameAvailabilityByScope. type ScheduledActionsClientCheckNameAvailabilityByScopeResponse struct { + // The check availability result. CheckNameAvailabilityResponse } // ScheduledActionsClientCheckNameAvailabilityResponse contains the response from method ScheduledActionsClient.CheckNameAvailability. type ScheduledActionsClientCheckNameAvailabilityResponse struct { + // The check availability result. CheckNameAvailabilityResponse } // ScheduledActionsClientCreateOrUpdateByScopeResponse contains the response from method ScheduledActionsClient.CreateOrUpdateByScope. type ScheduledActionsClientCreateOrUpdateByScopeResponse struct { + // Scheduled action definition. ScheduledAction } // ScheduledActionsClientCreateOrUpdateResponse contains the response from method ScheduledActionsClient.CreateOrUpdate. type ScheduledActionsClientCreateOrUpdateResponse struct { + // Scheduled action definition. ScheduledAction } @@ -196,21 +323,25 @@ type ScheduledActionsClientDeleteResponse struct { // ScheduledActionsClientGetByScopeResponse contains the response from method ScheduledActionsClient.GetByScope. type ScheduledActionsClientGetByScopeResponse struct { + // Scheduled action definition. ScheduledAction } // ScheduledActionsClientGetResponse contains the response from method ScheduledActionsClient.Get. type ScheduledActionsClientGetResponse struct { + // Scheduled action definition. ScheduledAction } // ScheduledActionsClientListByScopeResponse contains the response from method ScheduledActionsClient.NewListByScopePager. type ScheduledActionsClientListByScopeResponse struct { + // Scheduled actions list result. It contains a list of scheduled actions. ScheduledActionListResult } // ScheduledActionsClientListResponse contains the response from method ScheduledActionsClient.NewListPager. type ScheduledActionsClientListResponse struct { + // Scheduled actions list result. It contains a list of scheduled actions. ScheduledActionListResult } @@ -224,13 +355,58 @@ type ScheduledActionsClientRunResponse struct { // placeholder for future response values } +// SettingsClientCreateOrUpdateByScopeResponse contains the response from method SettingsClient.CreateOrUpdateByScope. +type SettingsClientCreateOrUpdateByScopeResponse struct { + // Setting definition. + SettingClassification +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SettingsClientCreateOrUpdateByScopeResponse. +func (s *SettingsClientCreateOrUpdateByScopeResponse) UnmarshalJSON(data []byte) error { + res, err := unmarshalSettingClassification(data) + if err != nil { + return err + } + s.SettingClassification = res + return nil +} + +// SettingsClientDeleteByScopeResponse contains the response from method SettingsClient.DeleteByScope. +type SettingsClientDeleteByScopeResponse struct { + // placeholder for future response values +} + +// SettingsClientGetByScopeResponse contains the response from method SettingsClient.GetByScope. +type SettingsClientGetByScopeResponse struct { + // Setting definition. + SettingClassification +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SettingsClientGetByScopeResponse. +func (s *SettingsClientGetByScopeResponse) UnmarshalJSON(data []byte) error { + res, err := unmarshalSettingClassification(data) + if err != nil { + return err + } + s.SettingClassification = res + return nil +} + +// SettingsClientListResponse contains the response from method SettingsClient.List. +type SettingsClientListResponse struct { + // Setting list result. It contains a list of settings. + SettingsListResult +} + // ViewsClientCreateOrUpdateByScopeResponse contains the response from method ViewsClient.CreateOrUpdateByScope. type ViewsClientCreateOrUpdateByScopeResponse struct { + // States and configurations of Cost Analysis. View } // ViewsClientCreateOrUpdateResponse contains the response from method ViewsClient.CreateOrUpdate. type ViewsClientCreateOrUpdateResponse struct { + // States and configurations of Cost Analysis. View } @@ -246,20 +422,24 @@ type ViewsClientDeleteResponse struct { // ViewsClientGetByScopeResponse contains the response from method ViewsClient.GetByScope. type ViewsClientGetByScopeResponse struct { + // States and configurations of Cost Analysis. View } // ViewsClientGetResponse contains the response from method ViewsClient.Get. type ViewsClientGetResponse struct { + // States and configurations of Cost Analysis. View } // ViewsClientListByScopeResponse contains the response from method ViewsClient.NewListByScopePager. type ViewsClientListByScopeResponse struct { + // Result of listing views. It contains a list of available views. ViewListResult } // ViewsClientListResponse contains the response from method ViewsClient.NewListPager. type ViewsClientListResponse struct { + // Result of listing views. It contains a list of available views. ViewListResult } diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/scheduledactions_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/scheduledactions_client.go index 32d6536afca2..ef8804a85bab 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/scheduledactions_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/scheduledactions_client.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armcostmanagement @@ -44,23 +43,26 @@ func NewScheduledActionsClient(credential azcore.TokenCredential, options *arm.C // CheckNameAvailability - Checks availability and correctness of the name for a scheduled action. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - checkNameAvailabilityRequest - Scheduled action to be created or updated. // - options - ScheduledActionsClientCheckNameAvailabilityOptions contains the optional parameters for the ScheduledActionsClient.CheckNameAvailability // method. func (client *ScheduledActionsClient) CheckNameAvailability(ctx context.Context, checkNameAvailabilityRequest CheckNameAvailabilityRequest, options *ScheduledActionsClientCheckNameAvailabilityOptions) (ScheduledActionsClientCheckNameAvailabilityResponse, error) { + var err error req, err := client.checkNameAvailabilityCreateRequest(ctx, checkNameAvailabilityRequest, options) if err != nil { return ScheduledActionsClientCheckNameAvailabilityResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ScheduledActionsClientCheckNameAvailabilityResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ScheduledActionsClientCheckNameAvailabilityResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ScheduledActionsClientCheckNameAvailabilityResponse{}, err } - return client.checkNameAvailabilityHandleResponse(resp) + resp, err := client.checkNameAvailabilityHandleResponse(httpResp) + return resp, err } // checkNameAvailabilityCreateRequest creates the CheckNameAvailability request. @@ -71,10 +73,13 @@ func (client *ScheduledActionsClient) checkNameAvailabilityCreateRequest(ctx con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, checkNameAvailabilityRequest) + if err := runtime.MarshalAsJSON(req, checkNameAvailabilityRequest); err != nil { + return nil, err + } + return req, nil } // checkNameAvailabilityHandleResponse handles the CheckNameAvailability response. @@ -90,7 +95,7 @@ func (client *ScheduledActionsClient) checkNameAvailabilityHandleResponse(resp * // scope. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - scope - The scope associated with scheduled action operations. This includes 'subscriptions/{subscriptionId}' for subscription // scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for // resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, @@ -109,36 +114,39 @@ func (client *ScheduledActionsClient) checkNameAvailabilityHandleResponse(resp * // - options - ScheduledActionsClientCheckNameAvailabilityByScopeOptions contains the optional parameters for the ScheduledActionsClient.CheckNameAvailabilityByScope // method. func (client *ScheduledActionsClient) CheckNameAvailabilityByScope(ctx context.Context, scope string, checkNameAvailabilityRequest CheckNameAvailabilityRequest, options *ScheduledActionsClientCheckNameAvailabilityByScopeOptions) (ScheduledActionsClientCheckNameAvailabilityByScopeResponse, error) { + var err error req, err := client.checkNameAvailabilityByScopeCreateRequest(ctx, scope, checkNameAvailabilityRequest, options) if err != nil { return ScheduledActionsClientCheckNameAvailabilityByScopeResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ScheduledActionsClientCheckNameAvailabilityByScopeResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ScheduledActionsClientCheckNameAvailabilityByScopeResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ScheduledActionsClientCheckNameAvailabilityByScopeResponse{}, err } - return client.checkNameAvailabilityByScopeHandleResponse(resp) + resp, err := client.checkNameAvailabilityByScopeHandleResponse(httpResp) + return resp, err } // checkNameAvailabilityByScopeCreateRequest creates the CheckNameAvailabilityByScope request. func (client *ScheduledActionsClient) checkNameAvailabilityByScopeCreateRequest(ctx context.Context, scope string, checkNameAvailabilityRequest CheckNameAvailabilityRequest, options *ScheduledActionsClientCheckNameAvailabilityByScopeOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.CostManagement/checkNameAvailability" - if scope == "" { - return nil, errors.New("parameter scope cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{scope}", url.PathEscape(scope)) + 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", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, checkNameAvailabilityRequest) + if err := runtime.MarshalAsJSON(req, checkNameAvailabilityRequest); err != nil { + return nil, err + } + return req, nil } // checkNameAvailabilityByScopeHandleResponse handles the CheckNameAvailabilityByScope response. @@ -153,24 +161,27 @@ func (client *ScheduledActionsClient) checkNameAvailabilityByScopeHandleResponse // CreateOrUpdate - Create or update a private scheduled action. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - name - Scheduled action name. // - scheduledAction - Scheduled action to be created or updated. // - options - ScheduledActionsClientCreateOrUpdateOptions contains the optional parameters for the ScheduledActionsClient.CreateOrUpdate // method. func (client *ScheduledActionsClient) CreateOrUpdate(ctx context.Context, name string, scheduledAction ScheduledAction, options *ScheduledActionsClientCreateOrUpdateOptions) (ScheduledActionsClientCreateOrUpdateResponse, error) { + var err error req, err := client.createOrUpdateCreateRequest(ctx, name, scheduledAction, options) if err != nil { return ScheduledActionsClientCreateOrUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ScheduledActionsClientCreateOrUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return ScheduledActionsClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return ScheduledActionsClientCreateOrUpdateResponse{}, err } - return client.createOrUpdateHandleResponse(resp) + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err } // createOrUpdateCreateRequest creates the CreateOrUpdate request. @@ -185,13 +196,16 @@ func (client *ScheduledActionsClient) createOrUpdateCreateRequest(ctx context.Co return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, scheduledAction) + if err := runtime.MarshalAsJSON(req, scheduledAction); err != nil { + return nil, err + } + return req, nil } // createOrUpdateHandleResponse handles the CreateOrUpdate response. @@ -206,7 +220,7 @@ func (client *ScheduledActionsClient) createOrUpdateHandleResponse(resp *http.Re // CreateOrUpdateByScope - Create or update a shared scheduled action within the given scope. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - scope - The scope associated with scheduled action operations. This includes 'subscriptions/{subscriptionId}' for subscription // scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for // resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, @@ -226,27 +240,27 @@ func (client *ScheduledActionsClient) createOrUpdateHandleResponse(resp *http.Re // - options - ScheduledActionsClientCreateOrUpdateByScopeOptions contains the optional parameters for the ScheduledActionsClient.CreateOrUpdateByScope // method. func (client *ScheduledActionsClient) CreateOrUpdateByScope(ctx context.Context, scope string, name string, scheduledAction ScheduledAction, options *ScheduledActionsClientCreateOrUpdateByScopeOptions) (ScheduledActionsClientCreateOrUpdateByScopeResponse, error) { + var err error req, err := client.createOrUpdateByScopeCreateRequest(ctx, scope, name, scheduledAction, options) if err != nil { return ScheduledActionsClientCreateOrUpdateByScopeResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ScheduledActionsClientCreateOrUpdateByScopeResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return ScheduledActionsClientCreateOrUpdateByScopeResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return ScheduledActionsClientCreateOrUpdateByScopeResponse{}, err } - return client.createOrUpdateByScopeHandleResponse(resp) + resp, err := client.createOrUpdateByScopeHandleResponse(httpResp) + return resp, err } // createOrUpdateByScopeCreateRequest creates the CreateOrUpdateByScope request. func (client *ScheduledActionsClient) createOrUpdateByScopeCreateRequest(ctx context.Context, scope string, name string, scheduledAction ScheduledAction, options *ScheduledActionsClientCreateOrUpdateByScopeOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.CostManagement/scheduledActions/{name}" - if scope == "" { - return nil, errors.New("parameter scope cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{scope}", url.PathEscape(scope)) + urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) if name == "" { return nil, errors.New("parameter name cannot be empty") } @@ -256,13 +270,16 @@ func (client *ScheduledActionsClient) createOrUpdateByScopeCreateRequest(ctx con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() if options != nil && options.IfMatch != nil { req.Raw().Header["If-Match"] = []string{*options.IfMatch} } req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, scheduledAction) + if err := runtime.MarshalAsJSON(req, scheduledAction); err != nil { + return nil, err + } + return req, nil } // createOrUpdateByScopeHandleResponse handles the CreateOrUpdateByScope response. @@ -277,20 +294,22 @@ func (client *ScheduledActionsClient) createOrUpdateByScopeHandleResponse(resp * // Delete - Delete a private scheduled action. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - name - Scheduled action name. // - options - ScheduledActionsClientDeleteOptions contains the optional parameters for the ScheduledActionsClient.Delete method. func (client *ScheduledActionsClient) Delete(ctx context.Context, name string, options *ScheduledActionsClientDeleteOptions) (ScheduledActionsClientDeleteResponse, error) { + var err error req, err := client.deleteCreateRequest(ctx, name, options) if err != nil { return ScheduledActionsClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ScheduledActionsClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { - return ScheduledActionsClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return ScheduledActionsClientDeleteResponse{}, err } return ScheduledActionsClientDeleteResponse{}, nil } @@ -307,7 +326,7 @@ func (client *ScheduledActionsClient) deleteCreateRequest(ctx context.Context, n return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -316,7 +335,7 @@ func (client *ScheduledActionsClient) deleteCreateRequest(ctx context.Context, n // DeleteByScope - Delete a scheduled action within the given scope. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - scope - The scope associated with scheduled action operations. This includes 'subscriptions/{subscriptionId}' for subscription // scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for // resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, @@ -335,16 +354,18 @@ func (client *ScheduledActionsClient) deleteCreateRequest(ctx context.Context, n // - options - ScheduledActionsClientDeleteByScopeOptions contains the optional parameters for the ScheduledActionsClient.DeleteByScope // method. func (client *ScheduledActionsClient) DeleteByScope(ctx context.Context, scope string, name string, options *ScheduledActionsClientDeleteByScopeOptions) (ScheduledActionsClientDeleteByScopeResponse, error) { + var err error req, err := client.deleteByScopeCreateRequest(ctx, scope, name, options) if err != nil { return ScheduledActionsClientDeleteByScopeResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ScheduledActionsClientDeleteByScopeResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { - return ScheduledActionsClientDeleteByScopeResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return ScheduledActionsClientDeleteByScopeResponse{}, err } return ScheduledActionsClientDeleteByScopeResponse{}, nil } @@ -352,10 +373,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) { urlPath := "/{scope}/providers/Microsoft.CostManagement/scheduledActions/{name}" - if scope == "" { - return nil, errors.New("parameter scope cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{scope}", url.PathEscape(scope)) + urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) if name == "" { return nil, errors.New("parameter name cannot be empty") } @@ -365,7 +383,7 @@ func (client *ScheduledActionsClient) deleteByScopeCreateRequest(ctx context.Con return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -374,22 +392,25 @@ func (client *ScheduledActionsClient) deleteByScopeCreateRequest(ctx context.Con // Get - Get the private scheduled action by name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - name - Scheduled action name. // - options - ScheduledActionsClientGetOptions contains the optional parameters for the ScheduledActionsClient.Get method. func (client *ScheduledActionsClient) Get(ctx context.Context, name string, options *ScheduledActionsClientGetOptions) (ScheduledActionsClientGetResponse, error) { + var err error req, err := client.getCreateRequest(ctx, name, options) if err != nil { return ScheduledActionsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ScheduledActionsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ScheduledActionsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ScheduledActionsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -404,7 +425,7 @@ func (client *ScheduledActionsClient) getCreateRequest(ctx context.Context, name return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -422,7 +443,7 @@ func (client *ScheduledActionsClient) getHandleResponse(resp *http.Response) (Sc // GetByScope - Get the shared scheduled action from the given scope by name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - scope - The scope associated with scheduled action operations. This includes 'subscriptions/{subscriptionId}' for subscription // scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for // resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, @@ -441,27 +462,27 @@ func (client *ScheduledActionsClient) getHandleResponse(resp *http.Response) (Sc // - options - ScheduledActionsClientGetByScopeOptions contains the optional parameters for the ScheduledActionsClient.GetByScope // method. func (client *ScheduledActionsClient) GetByScope(ctx context.Context, scope string, name string, options *ScheduledActionsClientGetByScopeOptions) (ScheduledActionsClientGetByScopeResponse, error) { + var err error req, err := client.getByScopeCreateRequest(ctx, scope, name, options) if err != nil { return ScheduledActionsClientGetByScopeResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ScheduledActionsClientGetByScopeResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ScheduledActionsClientGetByScopeResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ScheduledActionsClientGetByScopeResponse{}, err } - return client.getByScopeHandleResponse(resp) + resp, err := client.getByScopeHandleResponse(httpResp) + return resp, err } // getByScopeCreateRequest creates the GetByScope request. func (client *ScheduledActionsClient) getByScopeCreateRequest(ctx context.Context, scope string, name string, options *ScheduledActionsClientGetByScopeOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.CostManagement/scheduledActions/{name}" - if scope == "" { - return nil, errors.New("parameter scope cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{scope}", url.PathEscape(scope)) + urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) if name == "" { return nil, errors.New("parameter name cannot be empty") } @@ -471,7 +492,7 @@ func (client *ScheduledActionsClient) getByScopeCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -488,7 +509,7 @@ func (client *ScheduledActionsClient) getByScopeHandleResponse(resp *http.Respon // NewListPager - List all private scheduled actions. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - options - ScheduledActionsClientListOptions contains the optional parameters for the ScheduledActionsClient.NewListPager // method. func (client *ScheduledActionsClient) NewListPager(options *ScheduledActionsClientListOptions) *runtime.Pager[ScheduledActionsClientListResponse] { @@ -527,7 +548,7 @@ func (client *ScheduledActionsClient) listCreateRequest(ctx context.Context, opt return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } @@ -547,7 +568,7 @@ func (client *ScheduledActionsClient) listHandleResponse(resp *http.Response) (S // NewListByScopePager - List all shared scheduled actions within the given scope. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - scope - The scope associated with scheduled action operations. This includes 'subscriptions/{subscriptionId}' for subscription // scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for // resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, @@ -595,16 +616,13 @@ func (client *ScheduledActionsClient) NewListByScopePager(scope string, options // listByScopeCreateRequest creates the ListByScope request. func (client *ScheduledActionsClient) listByScopeCreateRequest(ctx context.Context, scope string, options *ScheduledActionsClientListByScopeOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.CostManagement/scheduledActions" - if scope == "" { - return nil, errors.New("parameter scope cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{scope}", url.PathEscape(scope)) + 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", "2023-08-01") if options != nil && options.Filter != nil { reqQP.Set("$filter", *options.Filter) } @@ -625,20 +643,22 @@ func (client *ScheduledActionsClient) listByScopeHandleResponse(resp *http.Respo // Run - Processes a private scheduled action. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - name - Scheduled action name. // - options - ScheduledActionsClientRunOptions contains the optional parameters for the ScheduledActionsClient.Run method. func (client *ScheduledActionsClient) Run(ctx context.Context, name string, options *ScheduledActionsClientRunOptions) (ScheduledActionsClientRunResponse, error) { + var err error req, err := client.runCreateRequest(ctx, name, options) if err != nil { return ScheduledActionsClientRunResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ScheduledActionsClientRunResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ScheduledActionsClientRunResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ScheduledActionsClientRunResponse{}, err } return ScheduledActionsClientRunResponse{}, nil } @@ -655,7 +675,7 @@ func (client *ScheduledActionsClient) runCreateRequest(ctx context.Context, name return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -664,7 +684,7 @@ func (client *ScheduledActionsClient) runCreateRequest(ctx context.Context, name // RunByScope - Runs a shared scheduled action within the given scope. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - scope - The scope associated with scheduled action operations. This includes 'subscriptions/{subscriptionId}' for subscription // scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for // resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, @@ -683,16 +703,18 @@ func (client *ScheduledActionsClient) runCreateRequest(ctx context.Context, name // - options - ScheduledActionsClientRunByScopeOptions contains the optional parameters for the ScheduledActionsClient.RunByScope // method. func (client *ScheduledActionsClient) RunByScope(ctx context.Context, scope string, name string, options *ScheduledActionsClientRunByScopeOptions) (ScheduledActionsClientRunByScopeResponse, error) { + var err error req, err := client.runByScopeCreateRequest(ctx, scope, name, options) if err != nil { return ScheduledActionsClientRunByScopeResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ScheduledActionsClientRunByScopeResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ScheduledActionsClientRunByScopeResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ScheduledActionsClientRunByScopeResponse{}, err } return ScheduledActionsClientRunByScopeResponse{}, nil } @@ -700,10 +722,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) { urlPath := "/{scope}/providers/Microsoft.CostManagement/scheduledActions/{name}/execute" - if scope == "" { - return nil, errors.New("parameter scope cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{scope}", url.PathEscape(scope)) + urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) if name == "" { return nil, errors.New("parameter name cannot be empty") } @@ -713,7 +732,7 @@ func (client *ScheduledActionsClient) runByScopeCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/scheduledactions_client_example_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/scheduledactions_client_example_test.go deleted file mode 100644 index d847bc44d259..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/scheduledactions_client_example_test.go +++ /dev/null @@ -1,899 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armcostmanagement_test - -import ( - "context" - "log" - - "time" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledActions-list-private.json -func ExampleScheduledActionsClient_NewListPager_privateScheduledActionsList() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewScheduledActionsClient().NewListPager(&armcostmanagement.ScheduledActionsClientListOptions{Filter: nil}) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ScheduledActionListResult = armcostmanagement.ScheduledActionListResult{ - // Value: []*armcostmanagement.ScheduledAction{ - // { - // Name: to.Ptr("monthlyCostByResource"), - // Type: to.Ptr("Microsoft.CostManagement/ScheduledActions"), - // ID: to.Ptr("providers/Microsoft.CostManagement/scheduledActions/monthlyCostByResource"), - // ETag: to.Ptr("\"1d4ff9fe66f1d10\""), - // Kind: to.Ptr(armcostmanagement.ScheduledActionKindEmail), - // SystemData: &armcostmanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.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), - // }, - // 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"), - // }, - // }, - // { - // 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.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), - // }, - // 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"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledActions-listWithFilter-private.json -func ExampleScheduledActionsClient_NewListPager_privateScheduledActionsListFilterByViewId() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewScheduledActionsClient().NewListPager(&armcostmanagement.ScheduledActionsClientListOptions{Filter: to.Ptr("properties/viewId eq '/providers/Microsoft.CostManagement/views/swaggerExample'")}) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ScheduledActionListResult = armcostmanagement.ScheduledActionListResult{ - // Value: []*armcostmanagement.ScheduledAction{ - // { - // Name: to.Ptr("monthlyCostByResource"), - // Type: to.Ptr("Microsoft.CostManagement/ScheduledActions"), - // ID: to.Ptr("providers/Microsoft.CostManagement/scheduledActions/monthlyCostByResource"), - // ETag: to.Ptr("\"1d4ff9fe66f1d10\""), - // Kind: to.Ptr(armcostmanagement.ScheduledActionKindEmail), - // SystemData: &armcostmanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.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), - // }, - // 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"), - // }, - // }, - // { - // 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.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), - // }, - // 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"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledActions-list-shared.json -func ExampleScheduledActionsClient_NewListByScopePager_scheduledActionsListByScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewScheduledActionsClient().NewListByScopePager("subscriptions/00000000-0000-0000-0000-000000000000", &armcostmanagement.ScheduledActionsClientListByScopeOptions{Filter: nil}) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ScheduledActionListResult = armcostmanagement.ScheduledActionListResult{ - // Value: []*armcostmanagement.ScheduledAction{ - // { - // Name: to.Ptr("monthlyCostByResource"), - // Type: to.Ptr("Microsoft.CostManagement/ScheduledActions"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/scheduledActions/monthlyCostByResource"), - // ETag: to.Ptr("\"1d4ff9fe66f1d10\""), - // Kind: to.Ptr(armcostmanagement.ScheduledActionKindEmail), - // SystemData: &armcostmanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.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), - // }, - // 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("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.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), - // }, - // 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("subscriptions/00000000-0000-0000-0000-000000000000"), - // Status: to.Ptr(armcostmanagement.ScheduledActionStatusDisabled), - // ViewID: to.Ptr("/providers/Microsoft.CostManagement/views/swaggerExample"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledActions-listWithFilter-shared.json -func ExampleScheduledActionsClient_NewListByScopePager_scheduledActionsListByScopeFilterByViewId() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewScheduledActionsClient().NewListByScopePager("subscriptions/00000000-0000-0000-0000-000000000000", &armcostmanagement.ScheduledActionsClientListByScopeOptions{Filter: to.Ptr("properties/viewId eq '/providers/Microsoft.CostManagement/views/swaggerExample'")}) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ScheduledActionListResult = armcostmanagement.ScheduledActionListResult{ - // Value: []*armcostmanagement.ScheduledAction{ - // { - // Name: to.Ptr("monthlyCostByResource"), - // Type: to.Ptr("Microsoft.CostManagement/ScheduledActions"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/scheduledActions/monthlyCostByResource"), - // ETag: to.Ptr("\"1d4ff9fe66f1d10\""), - // Kind: to.Ptr(armcostmanagement.ScheduledActionKindEmail), - // SystemData: &armcostmanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.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), - // }, - // 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("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.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), - // }, - // 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("subscriptions/00000000-0000-0000-0000-000000000000"), - // Status: to.Ptr(armcostmanagement.ScheduledActionStatusDisabled), - // ViewID: to.Ptr("/providers/Microsoft.CostManagement/views/swaggerExample"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledAction-createOrUpdate-private.json -func ExampleScheduledActionsClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewScheduledActionsClient().CreateOrUpdate(ctx, "monthlyCostByResource", armcostmanagement.ScheduledAction{ - Kind: to.Ptr(armcostmanagement.ScheduledActionKindEmail), - Properties: &armcostmanagement.ScheduledActionProperties{ - DisplayName: to.Ptr("Monthly Cost By Resource"), - Notification: &armcostmanagement.NotificationProperties{ - Subject: to.Ptr("Cost by resource this month"), - To: []*string{ - to.Ptr("user@gmail.com"), - to.Ptr("team@gmail.com")}, - }, - Schedule: &armcostmanagement.ScheduleProperties{ - DaysOfWeek: []*armcostmanagement.DaysOfWeek{ - to.Ptr(armcostmanagement.DaysOfWeekMonday)}, - EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-19T22:21:51.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.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.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), - // }, - // 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"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledAction-get-private.json -func ExampleScheduledActionsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewScheduledActionsClient().Get(ctx, "monthlyCostByResource", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ScheduledAction = armcostmanagement.ScheduledAction{ - // Name: to.Ptr("monthlyCostByResource"), - // Type: to.Ptr("Microsoft.CostManagement/ScheduledActions"), - // ID: to.Ptr("providers/Microsoft.CostManagement/scheduledActions/monthlyCostByResource"), - // ETag: to.Ptr("\"1d4ff9fe66f1d10\""), - // Kind: to.Ptr(armcostmanagement.ScheduledActionKindEmail), - // SystemData: &armcostmanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.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), - // }, - // 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"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledAction-delete-private.json -func ExampleScheduledActionsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewScheduledActionsClient().Delete(ctx, "monthlyCostByResource", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledAction-insightAlert-createOrUpdate-shared.json -func ExampleScheduledActionsClient_CreateOrUpdateByScope_createOrUpdateInsightAlertScheduledActionByScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewScheduledActionsClient().CreateOrUpdateByScope(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", "dailyAnomalyByResource", armcostmanagement.ScheduledAction{ - Kind: to.Ptr(armcostmanagement.ScheduledActionKindInsightAlert), - Properties: &armcostmanagement.ScheduledActionProperties{ - DisplayName: to.Ptr("Daily anomaly by resource"), - Notification: &armcostmanagement.NotificationProperties{ - Subject: to.Ptr("Cost anomaly detected in the resource"), - To: []*string{ - to.Ptr("user@gmail.com"), - to.Ptr("team@gmail.com")}, - }, - Schedule: &armcostmanagement.ScheduleProperties{ - EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-19T22:21:51.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("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.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), - // }, - // 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.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"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledAction-createOrUpdate-shared.json -func ExampleScheduledActionsClient_CreateOrUpdateByScope_createOrUpdateScheduledActionByScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewScheduledActionsClient().CreateOrUpdateByScope(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", "monthlyCostByResource", armcostmanagement.ScheduledAction{ - Kind: to.Ptr(armcostmanagement.ScheduledActionKindEmail), - Properties: &armcostmanagement.ScheduledActionProperties{ - DisplayName: to.Ptr("Monthly Cost By Resource"), - FileDestination: &armcostmanagement.FileDestination{ - FileFormats: []*armcostmanagement.FileFormat{ - to.Ptr(armcostmanagement.FileFormatCSV)}, - }, - Notification: &armcostmanagement.NotificationProperties{ - Subject: to.Ptr("Cost by resource this month"), - To: []*string{ - to.Ptr("user@gmail.com"), - to.Ptr("team@gmail.com")}, - }, - Schedule: &armcostmanagement.ScheduleProperties{ - DaysOfWeek: []*armcostmanagement.DaysOfWeek{ - to.Ptr(armcostmanagement.DaysOfWeekMonday)}, - EndDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-19T22:21:51.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.ScheduledActionsClientCreateOrUpdateByScopeOptions{IfMatch: to.Ptr("")}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ScheduledAction = armcostmanagement.ScheduledAction{ - // Name: to.Ptr("monthlyCostByResource"), - // Type: to.Ptr("Microsoft.CostManagement/ScheduledActions"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/scheduledActions/monthlyCostByResource"), - // ETag: to.Ptr("\"1d4ff9fe66f1d10\""), - // Kind: to.Ptr(armcostmanagement.ScheduledActionKindEmail), - // SystemData: &armcostmanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.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), - // }, - // 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("subscriptions/00000000-0000-0000-0000-000000000000"), - // Status: to.Ptr(armcostmanagement.ScheduledActionStatusEnabled), - // ViewID: to.Ptr("/providers/Microsoft.CostManagement/views/swaggerExample"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledAction-get-shared.json -func ExampleScheduledActionsClient_GetByScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewScheduledActionsClient().GetByScope(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", "monthlyCostByResource", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ScheduledAction = armcostmanagement.ScheduledAction{ - // Name: to.Ptr("monthlyCostByResource"), - // Type: to.Ptr("Microsoft.CostManagement/ScheduledActions"), - // ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.CostManagement/scheduledActions/monthlyCostByResource"), - // ETag: to.Ptr("\"1d4ff9fe66f1d10\""), - // Kind: to.Ptr(armcostmanagement.ScheduledActionKindEmail), - // SystemData: &armcostmanagement.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-18T22:21:51.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), - // }, - // 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("subscriptions/00000000-0000-0000-0000-000000000000"), - // Status: to.Ptr(armcostmanagement.ScheduledActionStatusEnabled), - // ViewID: to.Ptr("/providers/Microsoft.CostManagement/views/swaggerExample"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledAction-delete-shared.json -func ExampleScheduledActionsClient_DeleteByScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewScheduledActionsClient().DeleteByScope(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", "monthlyCostByResource", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledAction-sendNow-private.json -func ExampleScheduledActionsClient_Run() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewScheduledActionsClient().Run(ctx, "monthlyCostByResource", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/scheduledAction-sendNow-shared.json -func ExampleScheduledActionsClient_RunByScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewScheduledActionsClient().RunByScope(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", "monthlyCostByResource", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/checkNameAvailability-private-scheduledAction.json -func ExampleScheduledActionsClient_CheckNameAvailability() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewScheduledActionsClient().CheckNameAvailability(ctx, armcostmanagement.CheckNameAvailabilityRequest{ - Name: to.Ptr("testName"), - Type: to.Ptr("Microsoft.CostManagement/ScheduledActions"), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.CheckNameAvailabilityResponse = armcostmanagement.CheckNameAvailabilityResponse{ - // Message: to.Ptr("A private scheduled action with name 'testName' is already present. Please specify a differnt name."), - // NameAvailable: to.Ptr(false), - // Reason: to.Ptr(armcostmanagement.CheckNameAvailabilityReasonAlreadyExists), - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/scheduledActions/checkNameAvailability-shared-scheduledAction.json -func ExampleScheduledActionsClient_CheckNameAvailabilityByScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewScheduledActionsClient().CheckNameAvailabilityByScope(ctx, "subscriptions/00000000-0000-0000-0000-000000000000", armcostmanagement.CheckNameAvailabilityRequest{ - Name: to.Ptr("testName"), - Type: to.Ptr("Microsoft.CostManagement/ScheduledActions"), - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.CheckNameAvailabilityResponse = armcostmanagement.CheckNameAvailabilityResponse{ - // NameAvailable: to.Ptr(true), - // } -} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/settings_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/settings_client.go new file mode 100644 index 000000000000..d9a3017a64df --- /dev/null +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/settings_client.go @@ -0,0 +1,255 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armcostmanagement + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// SettingsClient contains the methods for the Settings group. +// Don't use this type directly, use NewSettingsClient() instead. +type SettingsClient struct { + internal *arm.Client +} + +// NewSettingsClient creates a new instance of SettingsClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewSettingsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*SettingsClient, error) { + cl, err := arm.NewClient(moduleName+".SettingsClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &SettingsClient{ + internal: cl, + } + return client, nil +} + +// CreateOrUpdateByScope - Create or update a setting within the given scope. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-08-01 +// - scope - The scope associated with this setting. This includes 'subscriptions/{subscriptionId}' for subscription scope, +// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account +// scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billing +// profile scope. +// - typeParam - Setting type. +// - setting - Setting to be created or updated. +// - options - SettingsClientCreateOrUpdateByScopeOptions contains the optional parameters for the SettingsClient.CreateOrUpdateByScope +// method. +func (client *SettingsClient) CreateOrUpdateByScope(ctx context.Context, scope string, typeParam SettingType, setting SettingClassification, options *SettingsClientCreateOrUpdateByScopeOptions) (SettingsClientCreateOrUpdateByScopeResponse, error) { + var err error + req, err := client.createOrUpdateByScopeCreateRequest(ctx, scope, typeParam, setting, options) + if err != nil { + return SettingsClientCreateOrUpdateByScopeResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SettingsClientCreateOrUpdateByScopeResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return SettingsClientCreateOrUpdateByScopeResponse{}, err + } + resp, err := client.createOrUpdateByScopeHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateByScopeCreateRequest creates the CreateOrUpdateByScope request. +func (client *SettingsClient) createOrUpdateByScopeCreateRequest(ctx context.Context, scope string, typeParam SettingType, setting SettingClassification, options *SettingsClientCreateOrUpdateByScopeOptions) (*policy.Request, error) { + urlPath := "/{scope}/providers/Microsoft.CostManagement/settings/{type}" + urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) + if typeParam == "" { + return nil, errors.New("parameter typeParam cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{type}", url.PathEscape(string(typeParam))) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-08-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, setting); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateByScopeHandleResponse handles the CreateOrUpdateByScope response. +func (client *SettingsClient) createOrUpdateByScopeHandleResponse(resp *http.Response) (SettingsClientCreateOrUpdateByScopeResponse, error) { + result := SettingsClientCreateOrUpdateByScopeResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result); err != nil { + return SettingsClientCreateOrUpdateByScopeResponse{}, err + } + return result, nil +} + +// DeleteByScope - Delete a setting within the given scope. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-08-01 +// - scope - The scope associated with this setting. This includes 'subscriptions/{subscriptionId}' for subscription scope, +// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account +// scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billing +// profile scope. +// - typeParam - Setting type. +// - options - SettingsClientDeleteByScopeOptions contains the optional parameters for the SettingsClient.DeleteByScope method. +func (client *SettingsClient) DeleteByScope(ctx context.Context, scope string, typeParam SettingType, options *SettingsClientDeleteByScopeOptions) (SettingsClientDeleteByScopeResponse, error) { + var err error + req, err := client.deleteByScopeCreateRequest(ctx, scope, typeParam, options) + if err != nil { + return SettingsClientDeleteByScopeResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SettingsClientDeleteByScopeResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return SettingsClientDeleteByScopeResponse{}, err + } + return SettingsClientDeleteByScopeResponse{}, nil +} + +// deleteByScopeCreateRequest creates the DeleteByScope request. +func (client *SettingsClient) deleteByScopeCreateRequest(ctx context.Context, scope string, typeParam SettingType, options *SettingsClientDeleteByScopeOptions) (*policy.Request, error) { + urlPath := "/{scope}/providers/Microsoft.CostManagement/settings/{type}" + urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) + if typeParam == "" { + return nil, errors.New("parameter typeParam cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{type}", url.PathEscape(string(typeParam))) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-08-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// GetByScope - Get the setting from the given scope by name. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-08-01 +// - scope - The scope associated with this setting. This includes 'subscriptions/{subscriptionId}' for subscription scope, +// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account +// scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billing +// profile scope. +// - typeParam - Setting type. +// - options - SettingsClientGetByScopeOptions contains the optional parameters for the SettingsClient.GetByScope method. +func (client *SettingsClient) GetByScope(ctx context.Context, scope string, typeParam SettingType, options *SettingsClientGetByScopeOptions) (SettingsClientGetByScopeResponse, error) { + var err error + req, err := client.getByScopeCreateRequest(ctx, scope, typeParam, options) + if err != nil { + return SettingsClientGetByScopeResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SettingsClientGetByScopeResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SettingsClientGetByScopeResponse{}, err + } + resp, err := client.getByScopeHandleResponse(httpResp) + return resp, err +} + +// getByScopeCreateRequest creates the GetByScope request. +func (client *SettingsClient) getByScopeCreateRequest(ctx context.Context, scope string, typeParam SettingType, options *SettingsClientGetByScopeOptions) (*policy.Request, error) { + urlPath := "/{scope}/providers/Microsoft.CostManagement/settings/{type}" + urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) + if typeParam == "" { + return nil, errors.New("parameter typeParam cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{type}", url.PathEscape(string(typeParam))) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-08-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getByScopeHandleResponse handles the GetByScope response. +func (client *SettingsClient) getByScopeHandleResponse(resp *http.Response) (SettingsClientGetByScopeResponse, error) { + result := SettingsClientGetByScopeResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result); err != nil { + return SettingsClientGetByScopeResponse{}, err + } + return result, nil +} + +// List - List all cost management settings in the requested scope. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-08-01 +// - scope - The scope associated with this setting. This includes 'subscriptions/{subscriptionId}' for subscription scope, +// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account +// scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billing +// profile scope. +// - options - SettingsClientListOptions contains the optional parameters for the SettingsClient.List method. +func (client *SettingsClient) List(ctx context.Context, scope string, options *SettingsClientListOptions) (SettingsClientListResponse, error) { + var err error + req, err := client.listCreateRequest(ctx, scope, options) + if err != nil { + return SettingsClientListResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SettingsClientListResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SettingsClientListResponse{}, err + } + resp, err := client.listHandleResponse(httpResp) + return resp, err +} + +// listCreateRequest creates the List request. +func (client *SettingsClient) listCreateRequest(ctx context.Context, scope string, options *SettingsClientListOptions) (*policy.Request, error) { + urlPath := "/{scope}/providers/Microsoft.CostManagement/settings" + 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", "2023-08-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *SettingsClient) listHandleResponse(resp *http.Response) (SettingsClientListResponse, error) { + result := SettingsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SettingsListResult); err != nil { + return SettingsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/time_rfc3339.go b/sdk/resourcemanager/costmanagement/armcostmanagement/time_rfc3339.go index 91525711655a..c06bb8c7980d 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/time_rfc3339.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/time_rfc3339.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armcostmanagement diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/views_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/views_client.go index 857632927d2e..f6dcf172095b 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/views_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/views_client.go @@ -3,9 +3,8 @@ // 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. +// 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. -// DO NOT EDIT. package armcostmanagement @@ -46,23 +45,26 @@ func NewViewsClient(credential azcore.TokenCredential, options *arm.ClientOption // require eTag. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - viewName - View name // - parameters - Parameters supplied to the CreateOrUpdate View operation. // - options - ViewsClientCreateOrUpdateOptions contains the optional parameters for the ViewsClient.CreateOrUpdate method. func (client *ViewsClient) CreateOrUpdate(ctx context.Context, viewName string, parameters View, options *ViewsClientCreateOrUpdateOptions) (ViewsClientCreateOrUpdateResponse, error) { + var err error req, err := client.createOrUpdateCreateRequest(ctx, viewName, parameters, options) if err != nil { return ViewsClientCreateOrUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ViewsClientCreateOrUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return ViewsClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return ViewsClientCreateOrUpdateResponse{}, err } - return client.createOrUpdateHandleResponse(resp) + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err } // createOrUpdateCreateRequest creates the CreateOrUpdate request. @@ -77,10 +79,13 @@ func (client *ViewsClient) createOrUpdateCreateRequest(ctx context.Context, view return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, parameters) + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil } // createOrUpdateHandleResponse handles the CreateOrUpdate response. @@ -97,7 +102,7 @@ func (client *ViewsClient) createOrUpdateHandleResponse(resp *http.Response) (Vi // require eTag. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - scope - The scope associated with view operations. This includes 'subscriptions/{subscriptionId}' for subscription scope, // 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup // scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' @@ -116,27 +121,27 @@ func (client *ViewsClient) createOrUpdateHandleResponse(resp *http.Response) (Vi // - options - ViewsClientCreateOrUpdateByScopeOptions contains the optional parameters for the ViewsClient.CreateOrUpdateByScope // method. func (client *ViewsClient) CreateOrUpdateByScope(ctx context.Context, scope string, viewName string, parameters View, options *ViewsClientCreateOrUpdateByScopeOptions) (ViewsClientCreateOrUpdateByScopeResponse, error) { + var err error req, err := client.createOrUpdateByScopeCreateRequest(ctx, scope, viewName, parameters, options) if err != nil { return ViewsClientCreateOrUpdateByScopeResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ViewsClientCreateOrUpdateByScopeResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return ViewsClientCreateOrUpdateByScopeResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return ViewsClientCreateOrUpdateByScopeResponse{}, err } - return client.createOrUpdateByScopeHandleResponse(resp) + resp, err := client.createOrUpdateByScopeHandleResponse(httpResp) + return resp, err } // createOrUpdateByScopeCreateRequest creates the CreateOrUpdateByScope request. func (client *ViewsClient) createOrUpdateByScopeCreateRequest(ctx context.Context, scope string, viewName string, parameters View, options *ViewsClientCreateOrUpdateByScopeOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.CostManagement/views/{viewName}" - if scope == "" { - return nil, errors.New("parameter scope cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{scope}", url.PathEscape(scope)) + urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) if viewName == "" { return nil, errors.New("parameter viewName cannot be empty") } @@ -146,10 +151,13 @@ func (client *ViewsClient) createOrUpdateByScopeCreateRequest(ctx context.Contex return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, parameters) + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil } // createOrUpdateByScopeHandleResponse handles the CreateOrUpdateByScope response. @@ -164,20 +172,22 @@ func (client *ViewsClient) createOrUpdateByScopeHandleResponse(resp *http.Respon // Delete - The operation to delete a view. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - viewName - View name // - options - ViewsClientDeleteOptions contains the optional parameters for the ViewsClient.Delete method. func (client *ViewsClient) Delete(ctx context.Context, viewName string, options *ViewsClientDeleteOptions) (ViewsClientDeleteResponse, error) { + var err error req, err := client.deleteCreateRequest(ctx, viewName, options) if err != nil { return ViewsClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ViewsClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { - return ViewsClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return ViewsClientDeleteResponse{}, err } return ViewsClientDeleteResponse{}, nil } @@ -194,7 +204,7 @@ func (client *ViewsClient) deleteCreateRequest(ctx context.Context, viewName str return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -203,7 +213,7 @@ func (client *ViewsClient) deleteCreateRequest(ctx context.Context, viewName str // DeleteByScope - The operation to delete a view. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - scope - The scope associated with view operations. This includes 'subscriptions/{subscriptionId}' for subscription scope, // 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup // scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' @@ -220,16 +230,18 @@ func (client *ViewsClient) deleteCreateRequest(ctx context.Context, viewName str // - 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) { + var err error req, err := client.deleteByScopeCreateRequest(ctx, scope, viewName, options) if err != nil { return ViewsClientDeleteByScopeResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ViewsClientDeleteByScopeResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { - return ViewsClientDeleteByScopeResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return ViewsClientDeleteByScopeResponse{}, err } return ViewsClientDeleteByScopeResponse{}, nil } @@ -237,10 +249,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) { urlPath := "/{scope}/providers/Microsoft.CostManagement/views/{viewName}" - if scope == "" { - return nil, errors.New("parameter scope cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{scope}", url.PathEscape(scope)) + urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) if viewName == "" { return nil, errors.New("parameter viewName cannot be empty") } @@ -250,7 +259,7 @@ func (client *ViewsClient) deleteByScopeCreateRequest(ctx context.Context, scope return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -259,22 +268,25 @@ func (client *ViewsClient) deleteByScopeCreateRequest(ctx context.Context, scope // Get - Gets the view by view name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - viewName - View name // - options - ViewsClientGetOptions contains the optional parameters for the ViewsClient.Get method. func (client *ViewsClient) Get(ctx context.Context, viewName string, options *ViewsClientGetOptions) (ViewsClientGetResponse, error) { + var err error req, err := client.getCreateRequest(ctx, viewName, options) if err != nil { return ViewsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ViewsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ViewsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ViewsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -289,7 +301,7 @@ func (client *ViewsClient) getCreateRequest(ctx context.Context, viewName string return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -307,7 +319,7 @@ func (client *ViewsClient) getHandleResponse(resp *http.Response) (ViewsClientGe // GetByScope - Gets the view for the defined scope by view name. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - scope - The scope associated with view operations. This includes 'subscriptions/{subscriptionId}' for subscription scope, // 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup // scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' @@ -324,27 +336,27 @@ func (client *ViewsClient) getHandleResponse(resp *http.Response) (ViewsClientGe // - 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) { + var err error req, err := client.getByScopeCreateRequest(ctx, scope, viewName, options) if err != nil { return ViewsClientGetByScopeResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ViewsClientGetByScopeResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ViewsClientGetByScopeResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ViewsClientGetByScopeResponse{}, err } - return client.getByScopeHandleResponse(resp) + resp, err := client.getByScopeHandleResponse(httpResp) + return resp, err } // getByScopeCreateRequest creates the GetByScope request. func (client *ViewsClient) getByScopeCreateRequest(ctx context.Context, scope string, viewName string, options *ViewsClientGetByScopeOptions) (*policy.Request, error) { urlPath := "/{scope}/providers/Microsoft.CostManagement/views/{viewName}" - if scope == "" { - return nil, errors.New("parameter scope cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{scope}", url.PathEscape(scope)) + urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) if viewName == "" { return nil, errors.New("parameter viewName cannot be empty") } @@ -354,7 +366,7 @@ func (client *ViewsClient) getByScopeCreateRequest(ctx context.Context, scope st return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -371,7 +383,7 @@ func (client *ViewsClient) getByScopeHandleResponse(resp *http.Response) (ViewsC // NewListPager - Lists all views by tenant and object. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - options - ViewsClientListOptions contains the optional parameters for the ViewsClient.NewListPager method. func (client *ViewsClient) NewListPager(options *ViewsClientListOptions) *runtime.Pager[ViewsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[ViewsClientListResponse]{ @@ -409,7 +421,7 @@ func (client *ViewsClient) listCreateRequest(ctx context.Context, options *Views return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-10-01") + reqQP.Set("api-version", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil @@ -426,7 +438,7 @@ func (client *ViewsClient) listHandleResponse(resp *http.Response) (ViewsClientL // NewListByScopePager - Lists all views at the given scope. // -// Generated from API version 2022-10-01 +// Generated from API version 2023-08-01 // - scope - The scope associated with view operations. This includes 'subscriptions/{subscriptionId}' for subscription scope, // 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup // scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' @@ -472,16 +484,13 @@ 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) { urlPath := "/{scope}/providers/Microsoft.CostManagement/views" - if scope == "" { - return nil, errors.New("parameter scope cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{scope}", url.PathEscape(scope)) + 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", "2023-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/views_client_example_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/views_client_example_test.go deleted file mode 100644 index 1ed213bfd73e..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/views_client_example_test.go +++ /dev/null @@ -1,737 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. - -package armcostmanagement_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement/v2" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/PrivateViewList.json -func ExampleViewsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewViewsClient().NewListPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ViewListResult = armcostmanagement.ViewListResult{ - // Value: []*armcostmanagement.View{ - // { - // Name: to.Ptr("swaggerExample"), - // Type: to.Ptr("Microsoft.CostManagement/Views"), - // ETag: to.Ptr("\"1d4ff9fe66f1d10\""), - // ID: to.Ptr("/providers/Microsoft.CostManagement/views/swaggerExample"), - // Properties: &armcostmanagement.ViewProperties{ - // Accumulated: to.Ptr(armcostmanagement.AccumulatedTypeTrue), - // Chart: to.Ptr(armcostmanagement.ChartTypeTable), - // DisplayName: to.Ptr("swagger Example"), - // Kpis: []*armcostmanagement.KpiProperties{ - // { - // Type: to.Ptr(armcostmanagement.KpiTypeForecast), - // Enabled: to.Ptr(true), - // }, - // { - // Type: to.Ptr(armcostmanagement.KpiTypeBudget), - // Enabled: to.Ptr(true), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Consumption/budgets/swaggerDemo"), - // }}, - // Metric: to.Ptr(armcostmanagement.MetricTypeActualCost), - // Pivots: []*armcostmanagement.PivotProperties{ - // { - // Name: to.Ptr("ServiceName"), - // Type: to.Ptr(armcostmanagement.PivotTypeDimension), - // }, - // { - // Name: to.Ptr("MeterCategory"), - // Type: to.Ptr(armcostmanagement.PivotTypeDimension), - // }, - // { - // Name: to.Ptr("swaggerTagKey"), - // Type: to.Ptr(armcostmanagement.PivotTypeTagKey), - // }}, - // Query: &armcostmanagement.ReportConfigDefinition{ - // Type: to.Ptr(armcostmanagement.ReportTypeUsage), - // DataSet: &armcostmanagement.ReportConfigDataset{ - // Aggregation: map[string]*armcostmanagement.ReportConfigAggregation{ - // "totalCost": &armcostmanagement.ReportConfigAggregation{ - // Name: to.Ptr("PreTaxCost"), - // Function: to.Ptr(armcostmanagement.FunctionTypeSum), - // }, - // }, - // Granularity: to.Ptr(armcostmanagement.ReportGranularityTypeDaily), - // Grouping: []*armcostmanagement.ReportConfigGrouping{ - // }, - // Sorting: []*armcostmanagement.ReportConfigSorting{ - // { - // Name: to.Ptr("UsageDate"), - // Direction: to.Ptr(armcostmanagement.ReportConfigSortingTypeAscending), - // }}, - // }, - // Timeframe: to.Ptr(armcostmanagement.ReportTimeframeTypeMonthToDate), - // }, - // Scope: to.Ptr(""), - // }, - // }, - // { - // Name: to.Ptr("swaggerExample2"), - // Type: to.Ptr("Microsoft.CostManagement/Views"), - // ETag: to.Ptr("\"1d4ffa5a9c2430c\""), - // ID: to.Ptr("/providers/Microsoft.CostManagement/views/swaggerExample2"), - // Properties: &armcostmanagement.ViewProperties{ - // Accumulated: to.Ptr(armcostmanagement.AccumulatedTypeTrue), - // Chart: to.Ptr(armcostmanagement.ChartTypeGroupedColumn), - // DisplayName: to.Ptr("swagger Example 2"), - // Kpis: []*armcostmanagement.KpiProperties{ - // { - // Type: to.Ptr(armcostmanagement.KpiTypeForecast), - // Enabled: to.Ptr(true), - // }, - // { - // Type: to.Ptr(armcostmanagement.KpiTypeBudget), - // Enabled: to.Ptr(true), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Consumption/budgets/swaggerDemo"), - // }}, - // Metric: to.Ptr(armcostmanagement.MetricTypeActualCost), - // Pivots: []*armcostmanagement.PivotProperties{ - // { - // Name: to.Ptr("ServiceName"), - // Type: to.Ptr(armcostmanagement.PivotTypeDimension), - // }, - // { - // Name: to.Ptr("MeterCategory"), - // Type: to.Ptr(armcostmanagement.PivotTypeDimension), - // }, - // { - // Name: to.Ptr("swaggerTagKey"), - // Type: to.Ptr(armcostmanagement.PivotTypeTagKey), - // }}, - // Query: &armcostmanagement.ReportConfigDefinition{ - // Type: to.Ptr(armcostmanagement.ReportTypeUsage), - // DataSet: &armcostmanagement.ReportConfigDataset{ - // Aggregation: map[string]*armcostmanagement.ReportConfigAggregation{ - // "totalCost": &armcostmanagement.ReportConfigAggregation{ - // Name: to.Ptr("PreTaxCost"), - // Function: to.Ptr(armcostmanagement.FunctionTypeSum), - // }, - // }, - // Granularity: to.Ptr(armcostmanagement.ReportGranularityTypeDaily), - // Grouping: []*armcostmanagement.ReportConfigGrouping{ - // }, - // Sorting: []*armcostmanagement.ReportConfigSorting{ - // { - // Name: to.Ptr("UsageDate"), - // Direction: to.Ptr(armcostmanagement.ReportConfigSortingTypeAscending), - // }}, - // }, - // Timeframe: to.Ptr(armcostmanagement.ReportTimeframeType("LastMonthToDate")), - // }, - // Scope: to.Ptr(""), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ViewListByResourceGroup.json -func ExampleViewsClient_NewListByScopePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewViewsClient().NewListByScopePager("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.ViewListResult = armcostmanagement.ViewListResult{ - // Value: []*armcostmanagement.View{ - // { - // Name: to.Ptr("swaggerExample"), - // Type: to.Ptr("Microsoft.CostManagement/Views"), - // ETag: to.Ptr("\"1d4ff9fe66f1d10\""), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.CostManagement/views/swaggerExample"), - // Properties: &armcostmanagement.ViewProperties{ - // Accumulated: to.Ptr(armcostmanagement.AccumulatedTypeTrue), - // Chart: to.Ptr(armcostmanagement.ChartTypeTable), - // DisplayName: to.Ptr("swagger Example"), - // Kpis: []*armcostmanagement.KpiProperties{ - // { - // Type: to.Ptr(armcostmanagement.KpiTypeForecast), - // Enabled: to.Ptr(true), - // }, - // { - // Type: to.Ptr(armcostmanagement.KpiTypeBudget), - // Enabled: to.Ptr(true), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Consumption/budgets/swaggerDemo"), - // }}, - // Metric: to.Ptr(armcostmanagement.MetricTypeActualCost), - // Pivots: []*armcostmanagement.PivotProperties{ - // { - // Name: to.Ptr("ServiceName"), - // Type: to.Ptr(armcostmanagement.PivotTypeDimension), - // }, - // { - // Name: to.Ptr("MeterCategory"), - // Type: to.Ptr(armcostmanagement.PivotTypeDimension), - // }, - // { - // Name: to.Ptr("swaggerTagKey"), - // Type: to.Ptr(armcostmanagement.PivotTypeTagKey), - // }}, - // Query: &armcostmanagement.ReportConfigDefinition{ - // Type: to.Ptr(armcostmanagement.ReportTypeUsage), - // DataSet: &armcostmanagement.ReportConfigDataset{ - // Aggregation: map[string]*armcostmanagement.ReportConfigAggregation{ - // "totalCost": &armcostmanagement.ReportConfigAggregation{ - // Name: to.Ptr("PreTaxCost"), - // Function: to.Ptr(armcostmanagement.FunctionTypeSum), - // }, - // }, - // Granularity: to.Ptr(armcostmanagement.ReportGranularityTypeDaily), - // Grouping: []*armcostmanagement.ReportConfigGrouping{ - // }, - // Sorting: []*armcostmanagement.ReportConfigSorting{ - // { - // Name: to.Ptr("UsageDate"), - // Direction: to.Ptr(armcostmanagement.ReportConfigSortingTypeAscending), - // }}, - // }, - // Timeframe: to.Ptr(armcostmanagement.ReportTimeframeTypeMonthToDate), - // }, - // Scope: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG"), - // }, - // }, - // { - // Name: to.Ptr("swaggerExample2"), - // Type: to.Ptr("Microsoft.CostManagement/Views"), - // ETag: to.Ptr("\"1d4ffa5a9c2430c\""), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.CostManagement/views/swaggerExample2"), - // Properties: &armcostmanagement.ViewProperties{ - // Accumulated: to.Ptr(armcostmanagement.AccumulatedTypeTrue), - // Chart: to.Ptr(armcostmanagement.ChartTypeGroupedColumn), - // DisplayName: to.Ptr("swagger Example 2"), - // Kpis: []*armcostmanagement.KpiProperties{ - // { - // Type: to.Ptr(armcostmanagement.KpiTypeForecast), - // Enabled: to.Ptr(true), - // }, - // { - // Type: to.Ptr(armcostmanagement.KpiTypeBudget), - // Enabled: to.Ptr(true), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Consumption/budgets/swaggerDemo"), - // }}, - // Metric: to.Ptr(armcostmanagement.MetricTypeActualCost), - // Pivots: []*armcostmanagement.PivotProperties{ - // { - // Name: to.Ptr("ServiceName"), - // Type: to.Ptr(armcostmanagement.PivotTypeDimension), - // }, - // { - // Name: to.Ptr("MeterCategory"), - // Type: to.Ptr(armcostmanagement.PivotTypeDimension), - // }, - // { - // Name: to.Ptr("swaggerTagKey"), - // Type: to.Ptr(armcostmanagement.PivotTypeTagKey), - // }}, - // Query: &armcostmanagement.ReportConfigDefinition{ - // Type: to.Ptr(armcostmanagement.ReportTypeUsage), - // DataSet: &armcostmanagement.ReportConfigDataset{ - // Aggregation: map[string]*armcostmanagement.ReportConfigAggregation{ - // "totalCost": &armcostmanagement.ReportConfigAggregation{ - // Name: to.Ptr("PreTaxCost"), - // Function: to.Ptr(armcostmanagement.FunctionTypeSum), - // }, - // }, - // Granularity: to.Ptr(armcostmanagement.ReportGranularityTypeDaily), - // Grouping: []*armcostmanagement.ReportConfigGrouping{ - // }, - // Sorting: []*armcostmanagement.ReportConfigSorting{ - // { - // Name: to.Ptr("UsageDate"), - // Direction: to.Ptr(armcostmanagement.ReportConfigSortingTypeAscending), - // }}, - // }, - // Timeframe: to.Ptr(armcostmanagement.ReportTimeframeType("LastMonthToDate")), - // }, - // Scope: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG"), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/PrivateView.json -func ExampleViewsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewViewsClient().Get(ctx, "swaggerExample", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.View = armcostmanagement.View{ - // Name: to.Ptr("swaggerExample"), - // Type: to.Ptr("Microsoft.CostManagement/Views"), - // ETag: to.Ptr("\"1d4ff9fe66f1d10\""), - // ID: to.Ptr("/providers/Microsoft.CostManagement/views/swaggerExample"), - // Properties: &armcostmanagement.ViewProperties{ - // Accumulated: to.Ptr(armcostmanagement.AccumulatedTypeTrue), - // Chart: to.Ptr(armcostmanagement.ChartTypeTable), - // DisplayName: to.Ptr("swagger Example"), - // Kpis: []*armcostmanagement.KpiProperties{ - // { - // Type: to.Ptr(armcostmanagement.KpiTypeForecast), - // Enabled: to.Ptr(true), - // }, - // { - // Type: to.Ptr(armcostmanagement.KpiTypeBudget), - // Enabled: to.Ptr(true), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Consumption/budgets/swaggerDemo"), - // }}, - // Metric: to.Ptr(armcostmanagement.MetricTypeActualCost), - // Pivots: []*armcostmanagement.PivotProperties{ - // { - // Name: to.Ptr("ServiceName"), - // Type: to.Ptr(armcostmanagement.PivotTypeDimension), - // }, - // { - // Name: to.Ptr("MeterCategory"), - // Type: to.Ptr(armcostmanagement.PivotTypeDimension), - // }, - // { - // Name: to.Ptr("swaggerTagKey"), - // Type: to.Ptr(armcostmanagement.PivotTypeTagKey), - // }}, - // Query: &armcostmanagement.ReportConfigDefinition{ - // Type: to.Ptr(armcostmanagement.ReportTypeUsage), - // DataSet: &armcostmanagement.ReportConfigDataset{ - // Aggregation: map[string]*armcostmanagement.ReportConfigAggregation{ - // "totalCost": &armcostmanagement.ReportConfigAggregation{ - // Name: to.Ptr("PreTaxCost"), - // Function: to.Ptr(armcostmanagement.FunctionTypeSum), - // }, - // }, - // Granularity: to.Ptr(armcostmanagement.ReportGranularityTypeDaily), - // Grouping: []*armcostmanagement.ReportConfigGrouping{ - // }, - // Sorting: []*armcostmanagement.ReportConfigSorting{ - // { - // Name: to.Ptr("UsageDate"), - // Direction: to.Ptr(armcostmanagement.ReportConfigSortingTypeAscending), - // }}, - // }, - // Timeframe: to.Ptr(armcostmanagement.ReportTimeframeTypeMonthToDate), - // }, - // Scope: to.Ptr(""), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/PrivateViewCreateOrUpdate.json -func ExampleViewsClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewViewsClient().CreateOrUpdate(ctx, "swaggerExample", armcostmanagement.View{ - ETag: to.Ptr("\"1d4ff9fe66f1d10\""), - Properties: &armcostmanagement.ViewProperties{ - Accumulated: to.Ptr(armcostmanagement.AccumulatedTypeTrue), - Chart: to.Ptr(armcostmanagement.ChartTypeTable), - DisplayName: to.Ptr("swagger Example"), - Kpis: []*armcostmanagement.KpiProperties{ - { - Type: to.Ptr(armcostmanagement.KpiTypeForecast), - Enabled: to.Ptr(true), - }, - { - Type: to.Ptr(armcostmanagement.KpiTypeBudget), - Enabled: to.Ptr(true), - ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Consumption/budgets/swaggerDemo"), - }}, - Metric: to.Ptr(armcostmanagement.MetricTypeActualCost), - Pivots: []*armcostmanagement.PivotProperties{ - { - Name: to.Ptr("ServiceName"), - Type: to.Ptr(armcostmanagement.PivotTypeDimension), - }, - { - Name: to.Ptr("MeterCategory"), - Type: to.Ptr(armcostmanagement.PivotTypeDimension), - }, - { - Name: to.Ptr("swaggerTagKey"), - Type: to.Ptr(armcostmanagement.PivotTypeTagKey), - }}, - Query: &armcostmanagement.ReportConfigDefinition{ - Type: to.Ptr(armcostmanagement.ReportTypeUsage), - DataSet: &armcostmanagement.ReportConfigDataset{ - Aggregation: map[string]*armcostmanagement.ReportConfigAggregation{ - "totalCost": { - Name: to.Ptr("PreTaxCost"), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), - }, - }, - Granularity: to.Ptr(armcostmanagement.ReportGranularityTypeDaily), - Grouping: []*armcostmanagement.ReportConfigGrouping{}, - Sorting: []*armcostmanagement.ReportConfigSorting{ - { - Name: to.Ptr("UsageDate"), - Direction: to.Ptr(armcostmanagement.ReportConfigSortingTypeAscending), - }}, - }, - Timeframe: to.Ptr(armcostmanagement.ReportTimeframeTypeMonthToDate), - }, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.View = armcostmanagement.View{ - // Name: to.Ptr("swaggerExample"), - // Type: to.Ptr("Microsoft.CostManagement/Views"), - // ETag: to.Ptr("\"1d4ffa5a9c2430c\""), - // ID: to.Ptr("/providers/Microsoft.CostManagement/views/swaggerExample"), - // Properties: &armcostmanagement.ViewProperties{ - // Accumulated: to.Ptr(armcostmanagement.AccumulatedTypeTrue), - // Chart: to.Ptr(armcostmanagement.ChartTypeTable), - // DisplayName: to.Ptr("swagger Example"), - // Kpis: []*armcostmanagement.KpiProperties{ - // { - // Type: to.Ptr(armcostmanagement.KpiTypeForecast), - // Enabled: to.Ptr(true), - // }, - // { - // Type: to.Ptr(armcostmanagement.KpiTypeBudget), - // Enabled: to.Ptr(true), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Consumption/budgets/swaggerDemo"), - // }}, - // Metric: to.Ptr(armcostmanagement.MetricTypeActualCost), - // Pivots: []*armcostmanagement.PivotProperties{ - // { - // Name: to.Ptr("ServiceName"), - // Type: to.Ptr(armcostmanagement.PivotTypeDimension), - // }, - // { - // Name: to.Ptr("MeterCategory"), - // Type: to.Ptr(armcostmanagement.PivotTypeDimension), - // }, - // { - // Name: to.Ptr("swaggerTagKey"), - // Type: to.Ptr(armcostmanagement.PivotTypeTagKey), - // }}, - // Query: &armcostmanagement.ReportConfigDefinition{ - // Type: to.Ptr(armcostmanagement.ReportTypeUsage), - // DataSet: &armcostmanagement.ReportConfigDataset{ - // Aggregation: map[string]*armcostmanagement.ReportConfigAggregation{ - // "totalCost": &armcostmanagement.ReportConfigAggregation{ - // Name: to.Ptr("PreTaxCost"), - // Function: to.Ptr(armcostmanagement.FunctionTypeSum), - // }, - // }, - // Granularity: to.Ptr(armcostmanagement.ReportGranularityTypeDaily), - // Grouping: []*armcostmanagement.ReportConfigGrouping{ - // }, - // Sorting: []*armcostmanagement.ReportConfigSorting{ - // { - // Name: to.Ptr("UsageDate"), - // Direction: to.Ptr(armcostmanagement.ReportConfigSortingTypeAscending), - // }}, - // }, - // Timeframe: to.Ptr(armcostmanagement.ReportTimeframeTypeMonthToDate), - // }, - // Scope: to.Ptr(""), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/PrivateViewDelete.json -func ExampleViewsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewViewsClient().Delete(ctx, "TestView", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ViewByResourceGroup.json -func ExampleViewsClient_GetByScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewViewsClient().GetByScope(ctx, "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG", "swaggerExample", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.View = armcostmanagement.View{ - // Name: to.Ptr("swaggerExample"), - // Type: to.Ptr("Microsoft.CostManagement/Views"), - // ETag: to.Ptr("\"1d4ff9fe66f1d10\""), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.CostManagement/views/swaggerExample"), - // Properties: &armcostmanagement.ViewProperties{ - // Accumulated: to.Ptr(armcostmanagement.AccumulatedTypeTrue), - // Chart: to.Ptr(armcostmanagement.ChartTypeTable), - // DisplayName: to.Ptr("swagger Example"), - // Kpis: []*armcostmanagement.KpiProperties{ - // { - // Type: to.Ptr(armcostmanagement.KpiTypeForecast), - // Enabled: to.Ptr(true), - // }, - // { - // Type: to.Ptr(armcostmanagement.KpiTypeBudget), - // Enabled: to.Ptr(true), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Consumption/budgets/swaggerDemo"), - // }}, - // Metric: to.Ptr(armcostmanagement.MetricTypeActualCost), - // Pivots: []*armcostmanagement.PivotProperties{ - // { - // Name: to.Ptr("ServiceName"), - // Type: to.Ptr(armcostmanagement.PivotTypeDimension), - // }, - // { - // Name: to.Ptr("MeterCategory"), - // Type: to.Ptr(armcostmanagement.PivotTypeDimension), - // }, - // { - // Name: to.Ptr("swaggerTagKey"), - // Type: to.Ptr(armcostmanagement.PivotTypeTagKey), - // }}, - // Query: &armcostmanagement.ReportConfigDefinition{ - // Type: to.Ptr(armcostmanagement.ReportTypeUsage), - // DataSet: &armcostmanagement.ReportConfigDataset{ - // Aggregation: map[string]*armcostmanagement.ReportConfigAggregation{ - // "totalCost": &armcostmanagement.ReportConfigAggregation{ - // Name: to.Ptr("PreTaxCost"), - // Function: to.Ptr(armcostmanagement.FunctionTypeSum), - // }, - // }, - // Granularity: to.Ptr(armcostmanagement.ReportGranularityTypeDaily), - // Grouping: []*armcostmanagement.ReportConfigGrouping{ - // }, - // Sorting: []*armcostmanagement.ReportConfigSorting{ - // { - // Name: to.Ptr("UsageDate"), - // Direction: to.Ptr(armcostmanagement.ReportConfigSortingTypeAscending), - // }}, - // }, - // Timeframe: to.Ptr(armcostmanagement.ReportTimeframeTypeMonthToDate), - // }, - // Scope: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ViewCreateOrUpdateByResourceGroup.json -func ExampleViewsClient_CreateOrUpdateByScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewViewsClient().CreateOrUpdateByScope(ctx, "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG", "swaggerExample", armcostmanagement.View{ - ETag: to.Ptr("\"1d4ff9fe66f1d10\""), - Properties: &armcostmanagement.ViewProperties{ - Accumulated: to.Ptr(armcostmanagement.AccumulatedTypeTrue), - Chart: to.Ptr(armcostmanagement.ChartTypeTable), - DisplayName: to.Ptr("swagger Example"), - Kpis: []*armcostmanagement.KpiProperties{ - { - Type: to.Ptr(armcostmanagement.KpiTypeForecast), - Enabled: to.Ptr(true), - }, - { - Type: to.Ptr(armcostmanagement.KpiTypeBudget), - Enabled: to.Ptr(true), - ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Consumption/budgets/swaggerDemo"), - }}, - Metric: to.Ptr(armcostmanagement.MetricTypeActualCost), - Pivots: []*armcostmanagement.PivotProperties{ - { - Name: to.Ptr("ServiceName"), - Type: to.Ptr(armcostmanagement.PivotTypeDimension), - }, - { - Name: to.Ptr("MeterCategory"), - Type: to.Ptr(armcostmanagement.PivotTypeDimension), - }, - { - Name: to.Ptr("swaggerTagKey"), - Type: to.Ptr(armcostmanagement.PivotTypeTagKey), - }}, - Query: &armcostmanagement.ReportConfigDefinition{ - Type: to.Ptr(armcostmanagement.ReportTypeUsage), - DataSet: &armcostmanagement.ReportConfigDataset{ - Aggregation: map[string]*armcostmanagement.ReportConfigAggregation{ - "totalCost": { - Name: to.Ptr("PreTaxCost"), - Function: to.Ptr(armcostmanagement.FunctionTypeSum), - }, - }, - Granularity: to.Ptr(armcostmanagement.ReportGranularityTypeDaily), - Grouping: []*armcostmanagement.ReportConfigGrouping{}, - Sorting: []*armcostmanagement.ReportConfigSorting{ - { - Name: to.Ptr("UsageDate"), - Direction: to.Ptr(armcostmanagement.ReportConfigSortingTypeAscending), - }}, - }, - Timeframe: to.Ptr(armcostmanagement.ReportTimeframeTypeMonthToDate), - }, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.View = armcostmanagement.View{ - // Name: to.Ptr("swaggerExample"), - // Type: to.Ptr("Microsoft.CostManagement/Views"), - // ETag: to.Ptr("\"1d4ffa5a9c2430c\""), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.CostManagement/views/swaggerExample"), - // Properties: &armcostmanagement.ViewProperties{ - // Accumulated: to.Ptr(armcostmanagement.AccumulatedTypeTrue), - // Chart: to.Ptr(armcostmanagement.ChartTypeTable), - // DisplayName: to.Ptr("swagger Example"), - // Kpis: []*armcostmanagement.KpiProperties{ - // { - // Type: to.Ptr(armcostmanagement.KpiTypeForecast), - // Enabled: to.Ptr(true), - // }, - // { - // Type: to.Ptr(armcostmanagement.KpiTypeBudget), - // Enabled: to.Ptr(true), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Consumption/budgets/swaggerDemo"), - // }}, - // Metric: to.Ptr(armcostmanagement.MetricTypeActualCost), - // Pivots: []*armcostmanagement.PivotProperties{ - // { - // Name: to.Ptr("ServiceName"), - // Type: to.Ptr(armcostmanagement.PivotTypeDimension), - // }, - // { - // Name: to.Ptr("MeterCategory"), - // Type: to.Ptr(armcostmanagement.PivotTypeDimension), - // }, - // { - // Name: to.Ptr("swaggerTagKey"), - // Type: to.Ptr(armcostmanagement.PivotTypeTagKey), - // }}, - // Query: &armcostmanagement.ReportConfigDefinition{ - // Type: to.Ptr(armcostmanagement.ReportTypeUsage), - // DataSet: &armcostmanagement.ReportConfigDataset{ - // Aggregation: map[string]*armcostmanagement.ReportConfigAggregation{ - // "totalCost": &armcostmanagement.ReportConfigAggregation{ - // Name: to.Ptr("PreTaxCost"), - // Function: to.Ptr(armcostmanagement.FunctionTypeSum), - // }, - // }, - // Granularity: to.Ptr(armcostmanagement.ReportGranularityTypeDaily), - // Grouping: []*armcostmanagement.ReportConfigGrouping{ - // }, - // Sorting: []*armcostmanagement.ReportConfigSorting{ - // { - // Name: to.Ptr("UsageDate"), - // Direction: to.Ptr(armcostmanagement.ReportConfigSortingTypeAscending), - // }}, - // }, - // Timeframe: to.Ptr(armcostmanagement.ReportTimeframeTypeMonthToDate), - // }, - // Scope: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG"), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2022-10-01/examples/ViewDeleteByResourceGroup.json -func ExampleViewsClient_DeleteByScope() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armcostmanagement.NewClientFactory(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = clientFactory.NewViewsClient().DeleteByScope(ctx, "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG", "TestView", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -}