diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/CHANGELOG.md b/sdk/resourcemanager/costmanagement/armcostmanagement/CHANGELOG.md index 3bce11468810..f139dd0ab85b 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/CHANGELOG.md +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/CHANGELOG.md @@ -1,5 +1,34 @@ # Release History +## 1.1.0 (2022-08-16) +### Features Added + +- New const `CostDetailsDataFormatCSVCostDetailsDataFormat` +- New const `CostDetailsMetricTypeAmortizedCostCostDetailsMetricType` +- New const `CostDetailsStatusTypeFailedCostDetailsStatusType` +- New const `CostDetailsStatusTypeNoDataFoundCostDetailsStatusType` +- New const `CostDetailsStatusTypeCompletedCostDetailsStatusType` +- New const `CostDetailsMetricTypeActualCostCostDetailsMetricType` +- New function `PossibleCostDetailsStatusTypeValues() []CostDetailsStatusType` +- New function `NewGenerateCostDetailsReportClient(azcore.TokenCredential, *arm.ClientOptions) (*GenerateCostDetailsReportClient, error)` +- New function `*GenerateCostDetailsReportClient.BeginGetOperationResults(context.Context, string, string, *GenerateCostDetailsReportClientBeginGetOperationResultsOptions) (*runtime.Poller[GenerateCostDetailsReportClientGetOperationResultsResponse], error)` +- New function `*GenerateCostDetailsReportClient.BeginCreateOperation(context.Context, string, GenerateCostDetailsReportRequestDefinition, *GenerateCostDetailsReportClientBeginCreateOperationOptions) (*runtime.Poller[GenerateCostDetailsReportClientCreateOperationResponse], error)` +- New function `PossibleCostDetailsDataFormatValues() []CostDetailsDataFormat` +- New function `PossibleCostDetailsMetricTypeValues() []CostDetailsMetricType` +- New struct `BlobInfo` +- New struct `CostDetailsOperationResults` +- New struct `CostDetailsTimePeriod` +- New struct `GenerateCostDetailsReportClient` +- New struct `GenerateCostDetailsReportClientBeginCreateOperationOptions` +- New struct `GenerateCostDetailsReportClientBeginGetOperationResultsOptions` +- New struct `GenerateCostDetailsReportClientCreateOperationResponse` +- New struct `GenerateCostDetailsReportClientGetOperationResultsResponse` +- New struct `GenerateCostDetailsReportErrorResponse` +- New struct `GenerateCostDetailsReportRequestDefinition` +- New struct `ReportManifest` +- New struct `RequestContext` + + ## 1.0.0 (2022-05-18) The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/costmanagement/armcostmanagement` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html) since version 1.0.0, which contains breaking changes. diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_alerts_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/alerts_client.go similarity index 99% rename from sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_alerts_client.go rename to sdk/resourcemanager/costmanagement/armcostmanagement/alerts_client.go index dbf434140de9..95714bca4723 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_alerts_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/alerts_client.go @@ -5,6 +5,7 @@ // 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 diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/autorest.md b/sdk/resourcemanager/costmanagement/armcostmanagement/autorest.md index fb871c91e90d..5980d1944135 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/autorest.md +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/autorest.md @@ -5,8 +5,8 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/cost-management/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/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: 1.0.0 +module-version: 1.1.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_constants.go b/sdk/resourcemanager/costmanagement/armcostmanagement/constants.go similarity index 90% rename from sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_constants.go rename to sdk/resourcemanager/costmanagement/armcostmanagement/constants.go index 0ddb618dc87d..27950446d249 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_constants.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/constants.go @@ -5,12 +5,13 @@ // 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 const ( moduleName = "armcostmanagement" - moduleVersion = "v1.0.0" + moduleVersion = "v1.1.0" ) // AccumulatedType - Show costs accumulated over time. @@ -225,6 +226,60 @@ func PossibleChartTypeValues() []ChartType { } } +// CostDetailsDataFormat - The data format of the report +type CostDetailsDataFormat string + +const ( + // CostDetailsDataFormatCSVCostDetailsDataFormat - Csv data format. + CostDetailsDataFormatCSVCostDetailsDataFormat CostDetailsDataFormat = "Csv" +) + +// PossibleCostDetailsDataFormatValues returns the possible values for the CostDetailsDataFormat const type. +func PossibleCostDetailsDataFormatValues() []CostDetailsDataFormat { + return []CostDetailsDataFormat{ + CostDetailsDataFormatCSVCostDetailsDataFormat, + } +} + +// CostDetailsMetricType - The type of the detailed report. By default ActualCost is provided +type CostDetailsMetricType string + +const ( + // CostDetailsMetricTypeActualCostCostDetailsMetricType - Actual cost data. + CostDetailsMetricTypeActualCostCostDetailsMetricType CostDetailsMetricType = "ActualCost" + // CostDetailsMetricTypeAmortizedCostCostDetailsMetricType - Amortized cost data. + CostDetailsMetricTypeAmortizedCostCostDetailsMetricType CostDetailsMetricType = "AmortizedCost" +) + +// PossibleCostDetailsMetricTypeValues returns the possible values for the CostDetailsMetricType const type. +func PossibleCostDetailsMetricTypeValues() []CostDetailsMetricType { + return []CostDetailsMetricType{ + CostDetailsMetricTypeActualCostCostDetailsMetricType, + CostDetailsMetricTypeAmortizedCostCostDetailsMetricType, + } +} + +// CostDetailsStatusType - The status of the cost details operation +type CostDetailsStatusType string + +const ( + // CostDetailsStatusTypeCompletedCostDetailsStatusType - Operation is Completed. + CostDetailsStatusTypeCompletedCostDetailsStatusType CostDetailsStatusType = "Completed" + // CostDetailsStatusTypeFailedCostDetailsStatusType - Operation Failed. + CostDetailsStatusTypeFailedCostDetailsStatusType CostDetailsStatusType = "Failed" + // CostDetailsStatusTypeNoDataFoundCostDetailsStatusType - Operation is Completed and no cost data found. + CostDetailsStatusTypeNoDataFoundCostDetailsStatusType CostDetailsStatusType = "NoDataFound" +) + +// PossibleCostDetailsStatusTypeValues returns the possible values for the CostDetailsStatusType const type. +func PossibleCostDetailsStatusTypeValues() []CostDetailsStatusType { + return []CostDetailsStatusType{ + CostDetailsStatusTypeCompletedCostDetailsStatusType, + CostDetailsStatusTypeFailedCostDetailsStatusType, + CostDetailsStatusTypeNoDataFoundCostDetailsStatusType, + } +} + // ExecutionStatus - The last known status of the export execution. type ExecutionStatus string @@ -267,8 +322,7 @@ func PossibleExecutionTypeValues() []ExecutionType { } } -// 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. +// ExportType - The type of the query. type ExportType string const ( @@ -388,7 +442,7 @@ func PossibleGenerateDetailedCostReportMetricTypeValues() []GenerateDetailedCost } } -// GranularityType - The granularity of rows in the export. Currently only 'Daily' is supported. +// GranularityType - The granularity of rows in the forecast. type GranularityType string const ( @@ -697,7 +751,7 @@ func PossibleStatusTypeValues() []StatusType { } } -// TimeframeType - The time frame for pulling data for the export. If custom, then a specific time period must be provided. +// TimeframeType - The time frame for pulling data for the query. If custom, then a specific time period must be provided. type TimeframeType string const ( diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_dimensions_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/dimensions_client.go similarity index 99% rename from sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_dimensions_client.go rename to sdk/resourcemanager/costmanagement/armcostmanagement/dimensions_client.go index 7e46848abf84..b6493ea8b620 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_dimensions_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/dimensions_client.go @@ -5,6 +5,7 @@ // 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 diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_exports_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/exports_client.go similarity index 98% rename from sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_exports_client.go rename to sdk/resourcemanager/costmanagement/armcostmanagement/exports_client.go index d830dd68ce7e..53158a710ce0 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_exports_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/exports_client.go @@ -5,6 +5,7 @@ // 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 @@ -51,9 +52,9 @@ func NewExportsClient(credential azcore.TokenCredential, options *arm.ClientOpti return client, nil } -// CreateOrUpdate - The operation to create or update a export. Update operation requires latest eTag to be set in the request. -// You may obtain the latest eTag by performing a get operation. Create operation does not -// require eTag. +// CreateOrUpdate - The operation to create or update an export. You can optionally provide an eTag if desired as a form of +// concurrency control. To obtain the latest eTag for a given export, perform a get operation prior +// to your put operation. // If the operation fails it returns an *azcore.ResponseError type. // Generated from API version 2021-10-01 // scope - The scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for subscription diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_forecast_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/forecast_client.go similarity index 99% rename from sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_forecast_client.go rename to sdk/resourcemanager/costmanagement/armcostmanagement/forecast_client.go index f55d42df15fb..796e6300571d 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_forecast_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/forecast_client.go @@ -5,6 +5,7 @@ // 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 diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/generatecostdetailsreport_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/generatecostdetailsreport_client.go new file mode 100644 index 000000000000..4b61ff8a1342 --- /dev/null +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/generatecostdetailsreport_client.go @@ -0,0 +1,205 @@ +//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 + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "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" +) + +// GenerateCostDetailsReportClient contains the methods for the GenerateCostDetailsReport group. +// Don't use this type directly, use NewGenerateCostDetailsReportClient() instead. +type GenerateCostDetailsReportClient struct { + host string + pl runtime.Pipeline +} + +// NewGenerateCostDetailsReportClient creates a new instance of GenerateCostDetailsReportClient with the specified values. +// credential - used to authorize requests. Usually a credential from azidentity. +// options - pass nil to accept the default values. +func NewGenerateCostDetailsReportClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*GenerateCostDetailsReportClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &GenerateCostDetailsReportClient{ + host: ep, + pl: pl, + } + return client, nil +} + +// BeginCreateOperation - This API is the replacement for all previously release Usage Details APIs. Request to generate a +// cost details report for the provided date range, billing period (Only enterprise customers) or Invoice +// Id asynchronously at a certain scope. The initial call to request a report will return a 202 with a 'Location' and 'Retry-After' +// header. The 'Location' header will provide the endpoint to poll to get +// the result of the report generation. The 'Retry-After' provides the duration to wait before polling for the generated report. +// A call to poll the report operation will provide a 202 response with a +// 'Location' header if the operation is still in progress. Once the report generation operation completes, the polling endpoint +// will provide a 200 response along with details on the report blob(s) that +// are available for download. The details on the file(s) available for download will be available in the polling response +// body. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-05-01 +// scope - The scope associated with usage details operations. This includes '/subscriptions/{subscriptionId}/' for subscription +// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for +// Billing Account scope, '/providers/Microsoft.Billing/departments/{departmentId}' for Department scope, '/providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}' +// for EnrollmentAccount +// scope. Also, Modern Commerce Account scopes are '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for billingAccount +// scope, +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile +// scope, +// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' +// for invoiceSection scope, and +// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for partners. +// parameters - Parameters supplied to the Create cost details operation. +// options - GenerateCostDetailsReportClientBeginCreateOperationOptions contains the optional parameters for the GenerateCostDetailsReportClient.BeginCreateOperation +// method. +func (client *GenerateCostDetailsReportClient) BeginCreateOperation(ctx context.Context, scope string, parameters GenerateCostDetailsReportRequestDefinition, options *GenerateCostDetailsReportClientBeginCreateOperationOptions) (*runtime.Poller[GenerateCostDetailsReportClientCreateOperationResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOperation(ctx, scope, parameters, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[GenerateCostDetailsReportClientCreateOperationResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + } else { + return runtime.NewPollerFromResumeToken[GenerateCostDetailsReportClientCreateOperationResponse](options.ResumeToken, client.pl, nil) + } +} + +// CreateOperation - This API is the replacement for all previously release Usage Details APIs. Request to generate a cost +// details report for the provided date range, billing period (Only enterprise customers) or Invoice +// Id asynchronously at a certain scope. The initial call to request a report will return a 202 with a 'Location' and 'Retry-After' +// header. The 'Location' header will provide the endpoint to poll to get +// the result of the report generation. The 'Retry-After' provides the duration to wait before polling for the generated report. +// A call to poll the report operation will provide a 202 response with a +// 'Location' header if the operation is still in progress. Once the report generation operation completes, the polling endpoint +// will provide a 200 response along with details on the report blob(s) that +// are available for download. The details on the file(s) available for download will be available in the polling response +// body. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2022-05-01 +func (client *GenerateCostDetailsReportClient) createOperation(ctx context.Context, scope string, parameters GenerateCostDetailsReportRequestDefinition, options *GenerateCostDetailsReportClientBeginCreateOperationOptions) (*http.Response, error) { + req, err := client.createOperationCreateRequest(ctx, scope, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createOperationCreateRequest creates the CreateOperation request. +func (client *GenerateCostDetailsReportClient) createOperationCreateRequest(ctx context.Context, scope string, parameters GenerateCostDetailsReportRequestDefinition, options *GenerateCostDetailsReportClientBeginCreateOperationOptions) (*policy.Request, error) { + urlPath := "/{scope}/providers/Microsoft.CostManagement/generateCostDetailsReport" + urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, parameters) +} + +// 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-05-01 +// scope - The scope associated with usage details operations. This includes '/subscriptions/{subscriptionId}/' for subscription +// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for +// Billing Account scope, '/providers/Microsoft.Billing/departments/{departmentId}' for Department scope, '/providers/Microsoft.Billing/enrollmentAccounts/{enrollmentAccountId}' +// for EnrollmentAccount +// scope. Also, Modern Commerce Account scopes are '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for billingAccount +// scope, +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for billingProfile +// scope, +// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' +// for invoiceSection scope, and +// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for partners. +// operationID - The target operation Id. +// options - GenerateCostDetailsReportClientBeginGetOperationResultsOptions contains the optional parameters for the GenerateCostDetailsReportClient.BeginGetOperationResults +// method. +func (client *GenerateCostDetailsReportClient) BeginGetOperationResults(ctx context.Context, scope string, operationID string, options *GenerateCostDetailsReportClientBeginGetOperationResultsOptions) (*runtime.Poller[GenerateCostDetailsReportClientGetOperationResultsResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.getOperationResults(ctx, scope, operationID, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[GenerateCostDetailsReportClientGetOperationResultsResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + }) + } else { + return runtime.NewPollerFromResumeToken[GenerateCostDetailsReportClientGetOperationResultsResponse](options.ResumeToken, client.pl, nil) + } +} + +// GetOperationResults - 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-05-01 +func (client *GenerateCostDetailsReportClient) getOperationResults(ctx context.Context, scope string, operationID string, options *GenerateCostDetailsReportClientBeginGetOperationResultsOptions) (*http.Response, error) { + req, err := client.getOperationResultsCreateRequest(ctx, scope, operationID, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// getOperationResultsCreateRequest creates the GetOperationResults request. +func (client *GenerateCostDetailsReportClient) getOperationResultsCreateRequest(ctx context.Context, scope string, operationID string, options *GenerateCostDetailsReportClientBeginGetOperationResultsOptions) (*policy.Request, error) { + urlPath := "/{scope}/providers/Microsoft.CostManagement/costDetailsOperationResults/{operationId}" + urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2022-05-01") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_generatedetailedcostreport_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreport_client.go similarity index 99% rename from sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_generatedetailedcostreport_client.go rename to sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreport_client.go index a5f4fa2be155..398001a29efb 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_generatedetailedcostreport_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreport_client.go @@ -5,6 +5,7 @@ // 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 diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_generatedetailedcostreportoperationresults_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationresults_client.go similarity index 99% rename from sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_generatedetailedcostreportoperationresults_client.go rename to sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationresults_client.go index 3a2fbfb7216f..75e5d4a21eea 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_generatedetailedcostreportoperationresults_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationresults_client.go @@ -5,6 +5,7 @@ // 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 diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_generatedetailedcostreportoperationstatus_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationstatus_client.go similarity index 99% rename from sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_generatedetailedcostreportoperationstatus_client.go rename to sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationstatus_client.go index a6e6d8cf7ec2..6afce5d08094 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_generatedetailedcostreportoperationstatus_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/generatedetailedcostreportoperationstatus_client.go @@ -5,6 +5,7 @@ // 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 diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_generatereservationdetailsreport_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/generatereservationdetailsreport_client.go similarity index 99% rename from sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_generatereservationdetailsreport_client.go rename to sdk/resourcemanager/costmanagement/armcostmanagement/generatereservationdetailsreport_client.go index c7670ad08511..23802e69ba9f 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_generatereservationdetailsreport_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/generatereservationdetailsreport_client.go @@ -5,6 +5,7 @@ // 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 diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/go.mod b/sdk/resourcemanager/costmanagement/armcostmanagement/go.mod index d30fc671b6e9..bf70ef5cb919 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.0.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0 -) +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 // indirect - github.com/golang-jwt/jwt v3.2.1+incompatible // indirect - github.com/google/uuid v1.1.1 // indirect - github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect - golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect - golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect golang.org/x/text v0.3.7 // indirect + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect ) diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/go.sum b/sdk/resourcemanager/costmanagement/armcostmanagement/go.sum index ed5b814680ee..3afb578030a5 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/go.sum +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/go.sum @@ -1,33 +1,15 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 h1:sVPhtT2qjO86rTUaWMr4WoES4TkjGnzcioXcnHV9s5k= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0 h1:Yoicul8bnVdQrhDMTHxdEckRGX01XvwXDHUT9zYZ3k0= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.0.0/go.mod h1:+6sju8gk8FRmSajX3Oz4G5Gm7P+mbqE9FVaXXFYTkCM= github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 h1:WVsrXCnHlDDX8ls+tootqRE87/hL9S/g4ewig9RsD/c= -github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= -github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c= -github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= -github.com/golang-jwt/jwt/v4 v4.2.0 h1:besgBTC8w8HjP6NzQdxwKH9Z5oQMZ24ThTrHp3cZ8eU= -github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= -github.com/google/uuid v1.1.1/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/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ= +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.0.0-20220511200225-c6db032c6c88 h1:Tgea0cVUD0ivh5ADBX4WwuI12DUd2to3nCYe2eayMIw= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -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.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_models.go b/sdk/resourcemanager/costmanagement/armcostmanagement/models.go similarity index 88% rename from sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_models.go rename to sdk/resourcemanager/costmanagement/armcostmanagement/models.go index 9ba5a9006989..bed77a410782 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_models.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/models.go @@ -5,6 +5,7 @@ // 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 @@ -175,6 +176,15 @@ type AlertsResult struct { Value []*Alert `json:"value,omitempty" azure:"ro"` } +// BlobInfo - The blob information generated by this operation. +type BlobInfo struct { + // Link to the blob to download file. + BlobLink *string `json:"blobLink,omitempty"` + + // Bytes in the blob. + ByteCount *int64 `json:"byteCount,omitempty"` +} + // CommonExportProperties - The common properties of the export. type CommonExportProperties struct { // REQUIRED; Has the definition for the export. @@ -197,6 +207,40 @@ type CommonExportProperties struct { NextRunTimeEstimate *time.Time `json:"nextRunTimeEstimate,omitempty" azure:"ro"` } +// CostDetailsOperationResults - The result of the long running operation for cost details Api. +type CostDetailsOperationResults struct { + // The details of the error. + Error *ErrorDetails `json:"error,omitempty"` + + // The id of the long running operation. + ID *string `json:"id,omitempty"` + + // The manifest of the report generated by the operation. + Manifest *ReportManifest `json:"manifest,omitempty"` + + // The name of the long running operation. + Name *string `json:"name,omitempty"` + + // The status of the cost details operation + Status *CostDetailsStatusType `json:"status,omitempty"` + + // The type of the long running operation. + Type *string `json:"type,omitempty"` + + // The time at which report URL becomes invalid/expires in UTC e.g. 2020-12-08T05:55:59.4394737Z. + ValidTill *time.Time `json:"validTill,omitempty"` +} + +// CostDetailsTimePeriod - The start and end date for pulling data for the cost detailed report. API only allows data to be +// pulled for 1 month or less and no older than 13 months. +type CostDetailsTimePeriod struct { + // REQUIRED; The end date to pull data to. example format 2020-03-15 + End *string `json:"end,omitempty"` + + // REQUIRED; The start date to pull data from. example format 2020-03-15 + Start *string `json:"start,omitempty"` +} + // Dimension - List of Dimension. type Dimension struct { // Dimension properties. @@ -630,6 +674,68 @@ type ForecastDefinition struct { TimePeriod *QueryTimePeriod `json:"timePeriod,omitempty"` } +// 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 +} + +// GenerateCostDetailsReportErrorResponse - Error response indicates that the service is not able to process the incoming +// request. The reason is provided in the error message. +// Some Error responses: +// * 400 Bad Request - Invalid Request Payload. Request payload provided is not in a json format or had an invalid member +// not accepted in the request payload. +// +// * 400 Bad Request - Invalid request payload: can only have either timePeriod or invoiceId or billingPeriod. API only allows +// data to be pulled for either timePeriod or invoiceId or billingPeriod. +// Customer should provide only one of these parameters. +// +// * 400 Bad Request - Start date must be after . API only allows data to be pulled no older than 13 months from now. +// +// * 400 Bad Request - The maximum allowed date range is 1 months. API only allows data to be pulled for 1 month or less. +// +// * 429 TooManyRequests - Request is throttled. Retry after waiting for the time specified in the "retry-after" header. +// +// * 503 ServiceUnavailable - Service is temporarily unavailable. Retry after waiting for the time specified in the "Retry-After" +// header. +type GenerateCostDetailsReportErrorResponse struct { + // The details of the error. + Error *ErrorDetails `json:"error,omitempty"` +} + +// GenerateCostDetailsReportRequestDefinition - The definition of a cost detailed report. +type GenerateCostDetailsReportRequestDefinition struct { + // This parameter can be used only by Enterprise Agreement customers. Use the YearMonth(e.g. 202008) format. This parameter + // cannot be used alongside either the invoiceId or timePeriod parameters. If a + // timePeriod, invoiceId or billingPeriod parameter is not provided in the request body the API will return the current month's + // cost. + BillingPeriod *string `json:"billingPeriod,omitempty"` + + // This parameter can only be used by Microsoft Customer Agreement customers. Additionally, it can only be used at the Billing + // Profile or Customer scope. This parameter cannot be used alongside either + // the billingPeriod or timePeriod parameters. If a timePeriod, invoiceId or billingPeriod parameter is not provided in the + // request body the API will return the current month's cost. + InvoiceID *string `json:"invoiceId,omitempty"` + + // The type of the detailed report. By default ActualCost is provided + Metric *CostDetailsMetricType `json:"metric,omitempty"` + + // The specific date range of cost details requested for the report. This parameter cannot be used alongside either the invoiceId + // or billingPeriod parameters. If a timePeriod, invoiceId or billingPeriod + // parameter is not provided in the request body the API will return the current month's cost. API only allows data to be + // pulled for 1 month or less and no older than 13 months. If no timePeriod or + // billingPeriod or invoiceId is provided the API defaults to the open month time period + TimePeriod *CostDetailsTimePeriod `json:"timePeriod,omitempty"` +} + // GenerateDetailedCostReportClientBeginCreateOperationOptions contains the optional parameters for the GenerateDetailedCostReportClient.BeginCreateOperation // method. type GenerateDetailedCostReportClientBeginCreateOperationOptions struct { @@ -1103,6 +1209,30 @@ type ReportConfigTimePeriod struct { To *time.Time `json:"to,omitempty"` } +// ReportManifest - The manifest of the report generated by the operation. +type ReportManifest struct { + // The total number of blobs. + BlobCount *int32 `json:"blobCount,omitempty"` + + // List of blob information generated by this operation. + Blobs []*BlobInfo `json:"blobs,omitempty"` + + // The total number of bytes in all blobs. + ByteCount *int64 `json:"byteCount,omitempty"` + + // Is the data in compressed format. + CompressData *bool `json:"compressData,omitempty"` + + // The data format of the report + DataFormat *CostDetailsDataFormat `json:"dataFormat,omitempty"` + + // The Manifest version. + ManifestVersion *string `json:"manifestVersion,omitempty"` + + // The context of the Cost Details request. + RequestContext *RequestContext `json:"requestContext,omitempty"` +} + // ReportURL - The URL to download the generated report. type ReportURL struct { // The CSV file from the reportUrl blob link consists of reservation usage data with the following schema at daily granularity @@ -1112,6 +1242,15 @@ type ReportURL struct { ValidUntil *time.Time `json:"validUntil,omitempty"` } +// RequestContext - The context of the Cost Details request. +type RequestContext struct { + // The request payload body provided in Cost Details call + RequestBody *GenerateCostDetailsReportRequestDefinition `json:"requestBody,omitempty"` + + // The request scope of the request. + RequestScope *string `json:"requestScope,omitempty"` +} + // Resource - The Resource model definition. type Resource struct { // READ-ONLY; ETag of the resource. diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/models_serde.go b/sdk/resourcemanager/costmanagement/armcostmanagement/models_serde.go new file mode 100644 index 000000000000..680aa6447afd --- /dev/null +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/models_serde.go @@ -0,0 +1,2883 @@ +//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 + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type Alert. +func (a Alert) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "eTag", a.ETag) + populate(objectMap, "id", a.ID) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Alert. +func (a *Alert) 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 "eTag": + err = unpopulate(val, "ETag", &a.ETag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &a.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + 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 AlertProperties. +func (a AlertProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "closeTime", a.CloseTime) + populate(objectMap, "costEntityId", a.CostEntityID) + populate(objectMap, "creationTime", a.CreationTime) + populate(objectMap, "definition", a.Definition) + populate(objectMap, "description", a.Description) + populate(objectMap, "details", a.Details) + populate(objectMap, "modificationTime", a.ModificationTime) + populate(objectMap, "source", a.Source) + populate(objectMap, "status", a.Status) + populate(objectMap, "statusModificationTime", a.StatusModificationTime) + populate(objectMap, "statusModificationUserName", a.StatusModificationUserName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AlertProperties. +func (a *AlertProperties) 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 "closeTime": + err = unpopulate(val, "CloseTime", &a.CloseTime) + delete(rawMsg, key) + case "costEntityId": + err = unpopulate(val, "CostEntityID", &a.CostEntityID) + delete(rawMsg, key) + case "creationTime": + err = unpopulate(val, "CreationTime", &a.CreationTime) + delete(rawMsg, key) + case "definition": + err = unpopulate(val, "Definition", &a.Definition) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &a.Description) + delete(rawMsg, key) + case "details": + err = unpopulate(val, "Details", &a.Details) + delete(rawMsg, key) + case "modificationTime": + err = unpopulate(val, "ModificationTime", &a.ModificationTime) + delete(rawMsg, key) + case "source": + err = unpopulate(val, "Source", &a.Source) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &a.Status) + delete(rawMsg, key) + case "statusModificationTime": + err = unpopulate(val, "StatusModificationTime", &a.StatusModificationTime) + delete(rawMsg, key) + case "statusModificationUserName": + err = unpopulate(val, "StatusModificationUserName", &a.StatusModificationUserName) + 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 AlertPropertiesDefinition. +func (a AlertPropertiesDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "category", a.Category) + populate(objectMap, "criteria", a.Criteria) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AlertPropertiesDefinition. +func (a *AlertPropertiesDefinition) 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 "category": + err = unpopulate(val, "Category", &a.Category) + delete(rawMsg, key) + case "criteria": + err = unpopulate(val, "Criteria", &a.Criteria) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + 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 AlertPropertiesDetails. +func (a AlertPropertiesDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "amount", a.Amount) + populate(objectMap, "companyName", a.CompanyName) + populate(objectMap, "contactEmails", a.ContactEmails) + populate(objectMap, "contactGroups", a.ContactGroups) + populate(objectMap, "contactRoles", a.ContactRoles) + populate(objectMap, "currentSpend", a.CurrentSpend) + populate(objectMap, "departmentName", a.DepartmentName) + populate(objectMap, "enrollmentEndDate", a.EnrollmentEndDate) + populate(objectMap, "enrollmentNumber", a.EnrollmentNumber) + populate(objectMap, "enrollmentStartDate", a.EnrollmentStartDate) + populate(objectMap, "invoicingThreshold", a.InvoicingThreshold) + populate(objectMap, "meterFilter", a.MeterFilter) + populate(objectMap, "operator", a.Operator) + populate(objectMap, "overridingAlert", a.OverridingAlert) + populate(objectMap, "periodStartDate", a.PeriodStartDate) + populate(objectMap, "resourceFilter", a.ResourceFilter) + populate(objectMap, "resourceGroupFilter", a.ResourceGroupFilter) + populate(objectMap, "tagFilter", &a.TagFilter) + populate(objectMap, "threshold", a.Threshold) + populate(objectMap, "timeGrainType", a.TimeGrainType) + populate(objectMap, "triggeredBy", a.TriggeredBy) + populate(objectMap, "unit", a.Unit) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AlertPropertiesDetails. +func (a *AlertPropertiesDetails) 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 "amount": + err = unpopulate(val, "Amount", &a.Amount) + delete(rawMsg, key) + case "companyName": + err = unpopulate(val, "CompanyName", &a.CompanyName) + delete(rawMsg, key) + case "contactEmails": + err = unpopulate(val, "ContactEmails", &a.ContactEmails) + delete(rawMsg, key) + case "contactGroups": + err = unpopulate(val, "ContactGroups", &a.ContactGroups) + delete(rawMsg, key) + case "contactRoles": + err = unpopulate(val, "ContactRoles", &a.ContactRoles) + delete(rawMsg, key) + case "currentSpend": + err = unpopulate(val, "CurrentSpend", &a.CurrentSpend) + delete(rawMsg, key) + case "departmentName": + err = unpopulate(val, "DepartmentName", &a.DepartmentName) + delete(rawMsg, key) + case "enrollmentEndDate": + err = unpopulate(val, "EnrollmentEndDate", &a.EnrollmentEndDate) + delete(rawMsg, key) + case "enrollmentNumber": + err = unpopulate(val, "EnrollmentNumber", &a.EnrollmentNumber) + delete(rawMsg, key) + case "enrollmentStartDate": + err = unpopulate(val, "EnrollmentStartDate", &a.EnrollmentStartDate) + delete(rawMsg, key) + case "invoicingThreshold": + err = unpopulate(val, "InvoicingThreshold", &a.InvoicingThreshold) + delete(rawMsg, key) + case "meterFilter": + err = unpopulate(val, "MeterFilter", &a.MeterFilter) + delete(rawMsg, key) + case "operator": + err = unpopulate(val, "Operator", &a.Operator) + delete(rawMsg, key) + case "overridingAlert": + err = unpopulate(val, "OverridingAlert", &a.OverridingAlert) + delete(rawMsg, key) + case "periodStartDate": + err = unpopulate(val, "PeriodStartDate", &a.PeriodStartDate) + delete(rawMsg, key) + case "resourceFilter": + err = unpopulate(val, "ResourceFilter", &a.ResourceFilter) + delete(rawMsg, key) + case "resourceGroupFilter": + err = unpopulate(val, "ResourceGroupFilter", &a.ResourceGroupFilter) + delete(rawMsg, key) + case "tagFilter": + err = unpopulate(val, "TagFilter", &a.TagFilter) + delete(rawMsg, key) + case "threshold": + err = unpopulate(val, "Threshold", &a.Threshold) + delete(rawMsg, key) + case "timeGrainType": + err = unpopulate(val, "TimeGrainType", &a.TimeGrainType) + delete(rawMsg, key) + case "triggeredBy": + err = unpopulate(val, "TriggeredBy", &a.TriggeredBy) + delete(rawMsg, key) + case "unit": + err = unpopulate(val, "Unit", &a.Unit) + 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 AlertsResult. +func (a AlertsResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AlertsResult. +func (a *AlertsResult) 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 "nextLink": + err = unpopulate(val, "NextLink", &a.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &a.Value) + 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 BlobInfo. +func (b BlobInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "blobLink", b.BlobLink) + populate(objectMap, "byteCount", b.ByteCount) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BlobInfo. +func (b *BlobInfo) 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 "blobLink": + err = unpopulate(val, "BlobLink", &b.BlobLink) + delete(rawMsg, key) + case "byteCount": + err = unpopulate(val, "ByteCount", &b.ByteCount) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CommonExportProperties. +func (c CommonExportProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "definition", c.Definition) + populate(objectMap, "deliveryInfo", c.DeliveryInfo) + populate(objectMap, "format", c.Format) + populateTimeRFC3339(objectMap, "nextRunTimeEstimate", c.NextRunTimeEstimate) + populate(objectMap, "partitionData", c.PartitionData) + populate(objectMap, "runHistory", c.RunHistory) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CommonExportProperties. +func (c *CommonExportProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "definition": + err = unpopulate(val, "Definition", &c.Definition) + delete(rawMsg, key) + case "deliveryInfo": + err = unpopulate(val, "DeliveryInfo", &c.DeliveryInfo) + delete(rawMsg, key) + case "format": + err = unpopulate(val, "Format", &c.Format) + delete(rawMsg, key) + case "nextRunTimeEstimate": + err = unpopulateTimeRFC3339(val, "NextRunTimeEstimate", &c.NextRunTimeEstimate) + delete(rawMsg, key) + case "partitionData": + err = unpopulate(val, "PartitionData", &c.PartitionData) + delete(rawMsg, key) + case "runHistory": + err = unpopulate(val, "RunHistory", &c.RunHistory) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CostDetailsOperationResults. +func (c CostDetailsOperationResults) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "error", c.Error) + populate(objectMap, "id", c.ID) + populate(objectMap, "manifest", c.Manifest) + populate(objectMap, "name", c.Name) + populate(objectMap, "status", c.Status) + populate(objectMap, "type", c.Type) + populateTimeRFC3339(objectMap, "validTill", c.ValidTill) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CostDetailsOperationResults. +func (c *CostDetailsOperationResults) 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 "error": + err = unpopulate(val, "Error", &c.Error) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &c.ID) + delete(rawMsg, key) + case "manifest": + err = unpopulate(val, "Manifest", &c.Manifest) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &c.Status) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) + delete(rawMsg, key) + 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]interface{}) + 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 { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Dimension. +func (d Dimension) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "eTag", d.ETag) + populate(objectMap, "id", d.ID) + populate(objectMap, "location", d.Location) + populate(objectMap, "name", d.Name) + populate(objectMap, "properties", d.Properties) + populate(objectMap, "sku", d.SKU) + populate(objectMap, "tags", d.Tags) + populate(objectMap, "type", d.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Dimension. +func (d *Dimension) 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", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "eTag": + err = unpopulate(val, "ETag", &d.ETag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &d.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &d.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &d.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &d.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &d.SKU) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &d.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &d.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DimensionProperties. +func (d DimensionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "category", d.Category) + populate(objectMap, "data", d.Data) + populate(objectMap, "description", d.Description) + populate(objectMap, "filterEnabled", d.FilterEnabled) + populate(objectMap, "groupingEnabled", d.GroupingEnabled) + populate(objectMap, "nextLink", d.NextLink) + populate(objectMap, "total", d.Total) + populateTimeRFC3339(objectMap, "usageEnd", d.UsageEnd) + populateTimeRFC3339(objectMap, "usageStart", d.UsageStart) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DimensionProperties. +func (d *DimensionProperties) 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", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "category": + err = unpopulate(val, "Category", &d.Category) + delete(rawMsg, key) + case "data": + err = unpopulate(val, "Data", &d.Data) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &d.Description) + delete(rawMsg, key) + case "filterEnabled": + err = unpopulate(val, "FilterEnabled", &d.FilterEnabled) + delete(rawMsg, key) + case "groupingEnabled": + err = unpopulate(val, "GroupingEnabled", &d.GroupingEnabled) + delete(rawMsg, key) + case "nextLink": + err = unpopulate(val, "NextLink", &d.NextLink) + delete(rawMsg, key) + case "total": + err = unpopulate(val, "Total", &d.Total) + delete(rawMsg, key) + case "usageEnd": + err = unpopulateTimeRFC3339(val, "UsageEnd", &d.UsageEnd) + delete(rawMsg, key) + case "usageStart": + err = unpopulateTimeRFC3339(val, "UsageStart", &d.UsageStart) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DimensionsListResult. +func (d DimensionsListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DimensionsListResult. +func (d *DimensionsListResult) 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", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "value": + err = unpopulate(val, "Value", &d.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DismissAlertPayload. +func (d DismissAlertPayload) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", d.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DismissAlertPayload. +func (d *DismissAlertPayload) 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", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &d.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DownloadURL. +func (d DownloadURL) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "downloadUrl", d.DownloadURL) + populateTimeRFC3339(objectMap, "validTill", d.ValidTill) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DownloadURL. +func (d *DownloadURL) 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", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "downloadUrl": + err = unpopulate(val, "DownloadURL", &d.DownloadURL) + delete(rawMsg, key) + case "validTill": + err = unpopulateTimeRFC3339(val, "ValidTill", &d.ValidTill) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorDetails. +func (e ErrorDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "code", e.Code) + populate(objectMap, "message", e.Message) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorDetails. +func (e *ErrorDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "code": + err = unpopulate(val, "Code", &e.Code) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &e.Message) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorResponse. +func (e ErrorResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "error", e.Error) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ErrorResponse. +func (e *ErrorResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "error": + err = unpopulate(val, "Error", &e.Error) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Export. +func (e Export) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "eTag", e.ETag) + populate(objectMap, "id", e.ID) + populate(objectMap, "name", e.Name) + populate(objectMap, "properties", e.Properties) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Export. +func (e *Export) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "eTag": + err = unpopulate(val, "ETag", &e.ETag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &e.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &e.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &e.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &e.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExportDataset. +func (e ExportDataset) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "configuration", e.Configuration) + populate(objectMap, "granularity", e.Granularity) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExportDataset. +func (e *ExportDataset) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "configuration": + err = unpopulate(val, "Configuration", &e.Configuration) + delete(rawMsg, key) + case "granularity": + err = unpopulate(val, "Granularity", &e.Granularity) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExportDatasetConfiguration. +func (e ExportDatasetConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "columns", e.Columns) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExportDatasetConfiguration. +func (e *ExportDatasetConfiguration) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "columns": + err = unpopulate(val, "Columns", &e.Columns) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExportDefinition. +func (e ExportDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "dataSet", e.DataSet) + populate(objectMap, "timePeriod", e.TimePeriod) + populate(objectMap, "timeframe", e.Timeframe) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExportDefinition. +func (e *ExportDefinition) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "dataSet": + err = unpopulate(val, "DataSet", &e.DataSet) + delete(rawMsg, key) + case "timePeriod": + err = unpopulate(val, "TimePeriod", &e.TimePeriod) + delete(rawMsg, key) + case "timeframe": + err = unpopulate(val, "Timeframe", &e.Timeframe) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &e.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExportDeliveryDestination. +func (e ExportDeliveryDestination) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "container", e.Container) + populate(objectMap, "resourceId", e.ResourceID) + populate(objectMap, "rootFolderPath", e.RootFolderPath) + populate(objectMap, "sasToken", e.SasToken) + populate(objectMap, "storageAccount", e.StorageAccount) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExportDeliveryDestination. +func (e *ExportDeliveryDestination) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "container": + err = unpopulate(val, "Container", &e.Container) + delete(rawMsg, key) + case "resourceId": + err = unpopulate(val, "ResourceID", &e.ResourceID) + delete(rawMsg, key) + case "rootFolderPath": + err = unpopulate(val, "RootFolderPath", &e.RootFolderPath) + delete(rawMsg, key) + case "sasToken": + err = unpopulate(val, "SasToken", &e.SasToken) + delete(rawMsg, key) + case "storageAccount": + err = unpopulate(val, "StorageAccount", &e.StorageAccount) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExportDeliveryInfo. +func (e ExportDeliveryInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "destination", e.Destination) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExportDeliveryInfo. +func (e *ExportDeliveryInfo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "destination": + err = unpopulate(val, "Destination", &e.Destination) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExportExecution. +func (e ExportExecution) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "eTag", e.ETag) + populate(objectMap, "id", e.ID) + populate(objectMap, "name", e.Name) + populate(objectMap, "properties", e.Properties) + populate(objectMap, "type", e.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExportExecution. +func (e *ExportExecution) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "eTag": + err = unpopulate(val, "ETag", &e.ETag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &e.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &e.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &e.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &e.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExportExecutionListResult. +func (e ExportExecutionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExportExecutionListResult. +func (e *ExportExecutionListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "value": + err = unpopulate(val, "Value", &e.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExportExecutionProperties. +func (e ExportExecutionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "error", e.Error) + populate(objectMap, "executionType", e.ExecutionType) + populate(objectMap, "fileName", e.FileName) + populateTimeRFC3339(objectMap, "processingEndTime", e.ProcessingEndTime) + populateTimeRFC3339(objectMap, "processingStartTime", e.ProcessingStartTime) + populate(objectMap, "runSettings", e.RunSettings) + populate(objectMap, "status", e.Status) + populate(objectMap, "submittedBy", e.SubmittedBy) + populateTimeRFC3339(objectMap, "submittedTime", e.SubmittedTime) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExportExecutionProperties. +func (e *ExportExecutionProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "error": + err = unpopulate(val, "Error", &e.Error) + delete(rawMsg, key) + case "executionType": + err = unpopulate(val, "ExecutionType", &e.ExecutionType) + delete(rawMsg, key) + case "fileName": + err = unpopulate(val, "FileName", &e.FileName) + delete(rawMsg, key) + case "processingEndTime": + err = unpopulateTimeRFC3339(val, "ProcessingEndTime", &e.ProcessingEndTime) + delete(rawMsg, key) + case "processingStartTime": + err = unpopulateTimeRFC3339(val, "ProcessingStartTime", &e.ProcessingStartTime) + delete(rawMsg, key) + case "runSettings": + err = unpopulate(val, "RunSettings", &e.RunSettings) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &e.Status) + delete(rawMsg, key) + case "submittedBy": + err = unpopulate(val, "SubmittedBy", &e.SubmittedBy) + delete(rawMsg, key) + case "submittedTime": + err = unpopulateTimeRFC3339(val, "SubmittedTime", &e.SubmittedTime) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExportListResult. +func (e ExportListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExportListResult. +func (e *ExportListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "value": + err = unpopulate(val, "Value", &e.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExportProperties. +func (e ExportProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "definition", e.Definition) + populate(objectMap, "deliveryInfo", e.DeliveryInfo) + populate(objectMap, "format", e.Format) + populateTimeRFC3339(objectMap, "nextRunTimeEstimate", e.NextRunTimeEstimate) + populate(objectMap, "partitionData", e.PartitionData) + populate(objectMap, "runHistory", e.RunHistory) + populate(objectMap, "schedule", e.Schedule) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExportProperties. +func (e *ExportProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "definition": + err = unpopulate(val, "Definition", &e.Definition) + delete(rawMsg, key) + case "deliveryInfo": + err = unpopulate(val, "DeliveryInfo", &e.DeliveryInfo) + delete(rawMsg, key) + case "format": + err = unpopulate(val, "Format", &e.Format) + delete(rawMsg, key) + case "nextRunTimeEstimate": + err = unpopulateTimeRFC3339(val, "NextRunTimeEstimate", &e.NextRunTimeEstimate) + delete(rawMsg, key) + case "partitionData": + err = unpopulate(val, "PartitionData", &e.PartitionData) + delete(rawMsg, key) + case "runHistory": + err = unpopulate(val, "RunHistory", &e.RunHistory) + delete(rawMsg, key) + case "schedule": + err = unpopulate(val, "Schedule", &e.Schedule) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExportRecurrencePeriod. +func (e ExportRecurrencePeriod) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populateTimeRFC3339(objectMap, "from", e.From) + populateTimeRFC3339(objectMap, "to", e.To) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExportRecurrencePeriod. +func (e *ExportRecurrencePeriod) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "from": + err = unpopulateTimeRFC3339(val, "From", &e.From) + delete(rawMsg, key) + case "to": + err = unpopulateTimeRFC3339(val, "To", &e.To) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExportSchedule. +func (e ExportSchedule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "recurrence", e.Recurrence) + populate(objectMap, "recurrencePeriod", e.RecurrencePeriod) + populate(objectMap, "status", e.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExportSchedule. +func (e *ExportSchedule) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "recurrence": + err = unpopulate(val, "Recurrence", &e.Recurrence) + delete(rawMsg, key) + case "recurrencePeriod": + err = unpopulate(val, "RecurrencePeriod", &e.RecurrencePeriod) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &e.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ExportTimePeriod. +func (e ExportTimePeriod) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populateTimeRFC3339(objectMap, "from", e.From) + populateTimeRFC3339(objectMap, "to", e.To) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ExportTimePeriod. +func (e *ExportTimePeriod) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "from": + err = unpopulateTimeRFC3339(val, "From", &e.From) + delete(rawMsg, key) + case "to": + err = unpopulateTimeRFC3339(val, "To", &e.To) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ForecastDataset. +func (f ForecastDataset) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "aggregation", f.Aggregation) + populate(objectMap, "configuration", f.Configuration) + populate(objectMap, "filter", f.Filter) + populate(objectMap, "granularity", f.Granularity) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ForecastDataset. +func (f *ForecastDataset) 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 "aggregation": + err = unpopulate(val, "Aggregation", &f.Aggregation) + delete(rawMsg, key) + case "configuration": + err = unpopulate(val, "Configuration", &f.Configuration) + delete(rawMsg, key) + case "filter": + err = unpopulate(val, "Filter", &f.Filter) + delete(rawMsg, key) + case "granularity": + err = unpopulate(val, "Granularity", &f.Granularity) + 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 ForecastDefinition. +func (f ForecastDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "dataset", f.Dataset) + populate(objectMap, "includeActualCost", f.IncludeActualCost) + populate(objectMap, "includeFreshPartialCost", f.IncludeFreshPartialCost) + populate(objectMap, "timePeriod", f.TimePeriod) + populate(objectMap, "timeframe", f.Timeframe) + populate(objectMap, "type", f.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ForecastDefinition. +func (f *ForecastDefinition) 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 "dataset": + err = unpopulate(val, "Dataset", &f.Dataset) + delete(rawMsg, key) + case "includeActualCost": + err = unpopulate(val, "IncludeActualCost", &f.IncludeActualCost) + delete(rawMsg, key) + case "includeFreshPartialCost": + err = unpopulate(val, "IncludeFreshPartialCost", &f.IncludeFreshPartialCost) + delete(rawMsg, key) + case "timePeriod": + err = unpopulate(val, "TimePeriod", &f.TimePeriod) + delete(rawMsg, key) + case "timeframe": + err = unpopulate(val, "Timeframe", &f.Timeframe) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &f.Type) + 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 GenerateCostDetailsReportErrorResponse. +func (g GenerateCostDetailsReportErrorResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "error", g.Error) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GenerateCostDetailsReportErrorResponse. +func (g *GenerateCostDetailsReportErrorResponse) 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", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "error": + err = unpopulate(val, "Error", &g.Error) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GenerateCostDetailsReportRequestDefinition. +func (g GenerateCostDetailsReportRequestDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "billingPeriod", g.BillingPeriod) + populate(objectMap, "invoiceId", g.InvoiceID) + populate(objectMap, "metric", g.Metric) + populate(objectMap, "timePeriod", g.TimePeriod) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GenerateCostDetailsReportRequestDefinition. +func (g *GenerateCostDetailsReportRequestDefinition) 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", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "billingPeriod": + err = unpopulate(val, "BillingPeriod", &g.BillingPeriod) + delete(rawMsg, key) + case "invoiceId": + err = unpopulate(val, "InvoiceID", &g.InvoiceID) + delete(rawMsg, key) + case "metric": + err = unpopulate(val, "Metric", &g.Metric) + delete(rawMsg, key) + case "timePeriod": + err = unpopulate(val, "TimePeriod", &g.TimePeriod) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GenerateDetailedCostReportDefinition. +func (g GenerateDetailedCostReportDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "billingPeriod", g.BillingPeriod) + populate(objectMap, "customerId", g.CustomerID) + populate(objectMap, "invoiceId", g.InvoiceID) + populate(objectMap, "metric", g.Metric) + populate(objectMap, "timePeriod", g.TimePeriod) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GenerateDetailedCostReportDefinition. +func (g *GenerateDetailedCostReportDefinition) 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", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "billingPeriod": + err = unpopulate(val, "BillingPeriod", &g.BillingPeriod) + delete(rawMsg, key) + case "customerId": + err = unpopulate(val, "CustomerID", &g.CustomerID) + delete(rawMsg, key) + case "invoiceId": + err = unpopulate(val, "InvoiceID", &g.InvoiceID) + delete(rawMsg, key) + case "metric": + err = unpopulate(val, "Metric", &g.Metric) + delete(rawMsg, key) + case "timePeriod": + err = unpopulate(val, "TimePeriod", &g.TimePeriod) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GenerateDetailedCostReportErrorResponse. +func (g GenerateDetailedCostReportErrorResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "error", g.Error) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GenerateDetailedCostReportErrorResponse. +func (g *GenerateDetailedCostReportErrorResponse) 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", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "error": + err = unpopulate(val, "Error", &g.Error) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GenerateDetailedCostReportOperationResult. +func (g GenerateDetailedCostReportOperationResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", g.ID) + populate(objectMap, "name", g.Name) + populate(objectMap, "properties", g.Properties) + populate(objectMap, "type", g.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GenerateDetailedCostReportOperationResult. +func (g *GenerateDetailedCostReportOperationResult) 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", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &g.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &g.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &g.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &g.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GenerateDetailedCostReportOperationStatuses. +func (g GenerateDetailedCostReportOperationStatuses) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "error", g.Error) + populate(objectMap, "id", g.ID) + populate(objectMap, "name", g.Name) + populate(objectMap, "properties", g.Properties) + populate(objectMap, "status", g.Status) + populate(objectMap, "type", g.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GenerateDetailedCostReportOperationStatuses. +func (g *GenerateDetailedCostReportOperationStatuses) 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", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "error": + err = unpopulate(val, "Error", &g.Error) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &g.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &g.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &g.Properties) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &g.Status) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &g.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GenerateDetailedCostReportTimePeriod. +func (g GenerateDetailedCostReportTimePeriod) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "end", g.End) + populate(objectMap, "start", g.Start) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GenerateDetailedCostReportTimePeriod. +func (g *GenerateDetailedCostReportTimePeriod) 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", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "end": + err = unpopulate(val, "End", &g.End) + delete(rawMsg, key) + case "start": + err = unpopulate(val, "Start", &g.Start) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type KpiProperties. +func (k KpiProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "enabled", k.Enabled) + populate(objectMap, "id", k.ID) + populate(objectMap, "type", k.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type KpiProperties. +func (k *KpiProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "enabled": + err = unpopulate(val, "Enabled", &k.Enabled) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &k.ID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &k.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "display", o.Display) + populate(objectMap, "id", o.ID) + populate(objectMap, "name", o.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. +func (o *Operation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "display": + err = unpopulate(val, "Display", &o.Display) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &o.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "description", o.Description) + populate(objectMap, "operation", o.Operation) + populate(objectMap, "provider", o.Provider) + populate(objectMap, "resource", o.Resource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay. +func (o *OperationDisplay) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &o.Description) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &o.Operation) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &o.Provider) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &o.Resource) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationListResult. +func (o *OperationListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &o.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &o.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationStatus. +func (o OperationStatus) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", o.Properties) + populate(objectMap, "status", o.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationStatus. +func (o *OperationStatus) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &o.Properties) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &o.Status) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PivotProperties. +func (p PivotProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "name", p.Name) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PivotProperties. +func (p *PivotProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ProxyResource. +func (p ProxyResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "eTag", p.ETag) + populate(objectMap, "id", p.ID) + populate(objectMap, "name", p.Name) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ProxyResource. +func (p *ProxyResource) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "eTag": + err = unpopulate(val, "ETag", &p.ETag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type QueryAggregation. +func (q QueryAggregation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "function", q.Function) + populate(objectMap, "name", q.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type QueryAggregation. +func (q *QueryAggregation) 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", q, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "function": + err = unpopulate(val, "Function", &q.Function) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &q.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", q, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type QueryColumn. +func (q QueryColumn) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "name", q.Name) + populate(objectMap, "type", q.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type QueryColumn. +func (q *QueryColumn) 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", q, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &q.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &q.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", q, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type QueryComparisonExpression. +func (q QueryComparisonExpression) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "name", q.Name) + populate(objectMap, "operator", q.Operator) + populate(objectMap, "values", q.Values) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type QueryComparisonExpression. +func (q *QueryComparisonExpression) 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", q, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &q.Name) + delete(rawMsg, key) + case "operator": + err = unpopulate(val, "Operator", &q.Operator) + delete(rawMsg, key) + case "values": + err = unpopulate(val, "Values", &q.Values) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", q, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type QueryDataset. +func (q QueryDataset) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "aggregation", q.Aggregation) + populate(objectMap, "configuration", q.Configuration) + populate(objectMap, "filter", q.Filter) + populate(objectMap, "granularity", q.Granularity) + populate(objectMap, "grouping", q.Grouping) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type QueryDataset. +func (q *QueryDataset) 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", q, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "aggregation": + err = unpopulate(val, "Aggregation", &q.Aggregation) + delete(rawMsg, key) + case "configuration": + err = unpopulate(val, "Configuration", &q.Configuration) + delete(rawMsg, key) + case "filter": + err = unpopulate(val, "Filter", &q.Filter) + delete(rawMsg, key) + case "granularity": + err = unpopulate(val, "Granularity", &q.Granularity) + delete(rawMsg, key) + case "grouping": + err = unpopulate(val, "Grouping", &q.Grouping) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", q, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type QueryDatasetConfiguration. +func (q QueryDatasetConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "columns", q.Columns) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type QueryDatasetConfiguration. +func (q *QueryDatasetConfiguration) 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", q, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "columns": + err = unpopulate(val, "Columns", &q.Columns) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", q, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type QueryDefinition. +func (q QueryDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "dataset", q.Dataset) + populate(objectMap, "timePeriod", q.TimePeriod) + populate(objectMap, "timeframe", q.Timeframe) + populate(objectMap, "type", q.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type QueryDefinition. +func (q *QueryDefinition) 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", q, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "dataset": + err = unpopulate(val, "Dataset", &q.Dataset) + delete(rawMsg, key) + case "timePeriod": + err = unpopulate(val, "TimePeriod", &q.TimePeriod) + delete(rawMsg, key) + case "timeframe": + err = unpopulate(val, "Timeframe", &q.Timeframe) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &q.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", q, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type QueryFilter. +func (q QueryFilter) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "and", q.And) + populate(objectMap, "dimensions", q.Dimensions) + populate(objectMap, "or", q.Or) + populate(objectMap, "tags", q.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type QueryFilter. +func (q *QueryFilter) 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", q, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "and": + err = unpopulate(val, "And", &q.And) + delete(rawMsg, key) + case "dimensions": + err = unpopulate(val, "Dimensions", &q.Dimensions) + delete(rawMsg, key) + case "or": + err = unpopulate(val, "Or", &q.Or) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &q.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", q, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type QueryGrouping. +func (q QueryGrouping) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "name", q.Name) + populate(objectMap, "type", q.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type QueryGrouping. +func (q *QueryGrouping) 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", q, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &q.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &q.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", q, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type QueryProperties. +func (q QueryProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "columns", q.Columns) + populate(objectMap, "nextLink", q.NextLink) + populate(objectMap, "rows", q.Rows) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type QueryProperties. +func (q *QueryProperties) 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", q, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "columns": + err = unpopulate(val, "Columns", &q.Columns) + delete(rawMsg, key) + case "nextLink": + err = unpopulate(val, "NextLink", &q.NextLink) + delete(rawMsg, key) + case "rows": + err = unpopulate(val, "Rows", &q.Rows) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", q, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type QueryResult. +func (q QueryResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "eTag", q.ETag) + populate(objectMap, "id", q.ID) + populate(objectMap, "location", q.Location) + populate(objectMap, "name", q.Name) + populate(objectMap, "properties", q.Properties) + populate(objectMap, "sku", q.SKU) + populate(objectMap, "tags", q.Tags) + populate(objectMap, "type", q.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type QueryResult. +func (q *QueryResult) 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", q, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "eTag": + err = unpopulate(val, "ETag", &q.ETag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &q.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &q.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &q.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &q.Properties) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &q.SKU) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &q.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &q.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", q, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type QueryTimePeriod. +func (q QueryTimePeriod) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populateTimeRFC3339(objectMap, "from", q.From) + populateTimeRFC3339(objectMap, "to", q.To) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type QueryTimePeriod. +func (q *QueryTimePeriod) 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", q, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "from": + err = unpopulateTimeRFC3339(val, "From", &q.From) + delete(rawMsg, key) + case "to": + err = unpopulateTimeRFC3339(val, "To", &q.To) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", q, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReportConfigAggregation. +func (r ReportConfigAggregation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "function", r.Function) + populate(objectMap, "name", r.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReportConfigAggregation. +func (r *ReportConfigAggregation) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "function": + err = unpopulate(val, "Function", &r.Function) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReportConfigComparisonExpression. +func (r ReportConfigComparisonExpression) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "name", r.Name) + populate(objectMap, "operator", r.Operator) + populate(objectMap, "values", r.Values) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReportConfigComparisonExpression. +func (r *ReportConfigComparisonExpression) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "operator": + err = unpopulate(val, "Operator", &r.Operator) + delete(rawMsg, key) + case "values": + err = unpopulate(val, "Values", &r.Values) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReportConfigDataset. +func (r ReportConfigDataset) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "aggregation", r.Aggregation) + populate(objectMap, "configuration", r.Configuration) + populate(objectMap, "filter", r.Filter) + populate(objectMap, "granularity", r.Granularity) + populate(objectMap, "grouping", r.Grouping) + populate(objectMap, "sorting", r.Sorting) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReportConfigDataset. +func (r *ReportConfigDataset) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "aggregation": + err = unpopulate(val, "Aggregation", &r.Aggregation) + delete(rawMsg, key) + case "configuration": + err = unpopulate(val, "Configuration", &r.Configuration) + delete(rawMsg, key) + case "filter": + err = unpopulate(val, "Filter", &r.Filter) + delete(rawMsg, key) + case "granularity": + err = unpopulate(val, "Granularity", &r.Granularity) + delete(rawMsg, key) + case "grouping": + err = unpopulate(val, "Grouping", &r.Grouping) + delete(rawMsg, key) + case "sorting": + err = unpopulate(val, "Sorting", &r.Sorting) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReportConfigDatasetConfiguration. +func (r ReportConfigDatasetConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "columns", r.Columns) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReportConfigDatasetConfiguration. +func (r *ReportConfigDatasetConfiguration) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "columns": + err = unpopulate(val, "Columns", &r.Columns) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReportConfigDefinition. +func (r ReportConfigDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "dataSet", r.DataSet) + populate(objectMap, "includeMonetaryCommitment", r.IncludeMonetaryCommitment) + populate(objectMap, "timePeriod", r.TimePeriod) + populate(objectMap, "timeframe", r.Timeframe) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReportConfigDefinition. +func (r *ReportConfigDefinition) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "dataSet": + err = unpopulate(val, "DataSet", &r.DataSet) + delete(rawMsg, key) + case "includeMonetaryCommitment": + err = unpopulate(val, "IncludeMonetaryCommitment", &r.IncludeMonetaryCommitment) + delete(rawMsg, key) + case "timePeriod": + err = unpopulate(val, "TimePeriod", &r.TimePeriod) + delete(rawMsg, key) + case "timeframe": + err = unpopulate(val, "Timeframe", &r.Timeframe) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReportConfigFilter. +func (r ReportConfigFilter) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "and", r.And) + populate(objectMap, "dimensions", r.Dimensions) + populate(objectMap, "or", r.Or) + populate(objectMap, "tags", r.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReportConfigFilter. +func (r *ReportConfigFilter) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "and": + err = unpopulate(val, "And", &r.And) + delete(rawMsg, key) + case "dimensions": + err = unpopulate(val, "Dimensions", &r.Dimensions) + delete(rawMsg, key) + case "or": + err = unpopulate(val, "Or", &r.Or) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &r.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReportConfigGrouping. +func (r ReportConfigGrouping) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "name", r.Name) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReportConfigGrouping. +func (r *ReportConfigGrouping) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReportConfigSorting. +func (r ReportConfigSorting) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "direction", r.Direction) + populate(objectMap, "name", r.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReportConfigSorting. +func (r *ReportConfigSorting) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "direction": + err = unpopulate(val, "Direction", &r.Direction) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReportConfigTimePeriod. +func (r ReportConfigTimePeriod) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populateTimeRFC3339(objectMap, "from", r.From) + populateTimeRFC3339(objectMap, "to", r.To) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReportConfigTimePeriod. +func (r *ReportConfigTimePeriod) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "from": + err = unpopulateTimeRFC3339(val, "From", &r.From) + delete(rawMsg, key) + case "to": + err = unpopulateTimeRFC3339(val, "To", &r.To) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReportManifest. +func (r ReportManifest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "blobCount", r.BlobCount) + populate(objectMap, "blobs", r.Blobs) + populate(objectMap, "byteCount", r.ByteCount) + populate(objectMap, "compressData", r.CompressData) + populate(objectMap, "dataFormat", r.DataFormat) + populate(objectMap, "manifestVersion", r.ManifestVersion) + populate(objectMap, "requestContext", r.RequestContext) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReportManifest. +func (r *ReportManifest) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "blobCount": + err = unpopulate(val, "BlobCount", &r.BlobCount) + delete(rawMsg, key) + case "blobs": + err = unpopulate(val, "Blobs", &r.Blobs) + delete(rawMsg, key) + case "byteCount": + err = unpopulate(val, "ByteCount", &r.ByteCount) + delete(rawMsg, key) + case "compressData": + err = unpopulate(val, "CompressData", &r.CompressData) + delete(rawMsg, key) + case "dataFormat": + err = unpopulate(val, "DataFormat", &r.DataFormat) + delete(rawMsg, key) + case "manifestVersion": + err = unpopulate(val, "ManifestVersion", &r.ManifestVersion) + delete(rawMsg, key) + case "requestContext": + err = unpopulate(val, "RequestContext", &r.RequestContext) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ReportURL. +func (r ReportURL) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "reportUrl", r.ReportURL) + populateTimeRFC3339(objectMap, "validUntil", r.ValidUntil) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReportURL. +func (r *ReportURL) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "reportUrl": + err = unpopulate(val, "ReportURL", &r.ReportURL) + delete(rawMsg, key) + case "validUntil": + err = unpopulateTimeRFC3339(val, "ValidUntil", &r.ValidUntil) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RequestContext. +func (r RequestContext) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "requestBody", r.RequestBody) + populate(objectMap, "requestScope", r.RequestScope) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RequestContext. +func (r *RequestContext) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "requestBody": + err = unpopulate(val, "RequestBody", &r.RequestBody) + delete(rawMsg, key) + case "requestScope": + err = unpopulate(val, "RequestScope", &r.RequestScope) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "eTag", r.ETag) + populate(objectMap, "id", r.ID) + populate(objectMap, "location", r.Location) + populate(objectMap, "name", r.Name) + populate(objectMap, "sku", r.SKU) + populate(objectMap, "tags", r.Tags) + populate(objectMap, "type", r.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Resource. +func (r *Resource) 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", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "eTag": + err = unpopulate(val, "ETag", &r.ETag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &r.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &r.Name) + delete(rawMsg, key) + case "sku": + err = unpopulate(val, "SKU", &r.SKU) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &r.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &r.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Status. +func (s Status) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "status", s.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Status. +func (s *Status) 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 "status": + err = unpopulate(val, "Status", &s.Status) + 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 View. +func (v View) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "eTag", v.ETag) + populate(objectMap, "id", v.ID) + populate(objectMap, "name", v.Name) + populate(objectMap, "properties", v.Properties) + populate(objectMap, "type", v.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type View. +func (v *View) 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", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "eTag": + err = unpopulate(val, "ETag", &v.ETag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &v.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &v.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &v.Properties) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &v.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ViewListResult. +func (v ViewListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", v.NextLink) + populate(objectMap, "value", v.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ViewListResult. +func (v *ViewListResult) 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", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &v.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &v.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ViewProperties. +func (v ViewProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "accumulated", v.Accumulated) + populate(objectMap, "chart", v.Chart) + populateTimeRFC3339(objectMap, "createdOn", v.CreatedOn) + populate(objectMap, "currency", v.Currency) + populate(objectMap, "dateRange", v.DateRange) + populate(objectMap, "displayName", v.DisplayName) + populate(objectMap, "kpis", v.Kpis) + populate(objectMap, "metric", v.Metric) + populateTimeRFC3339(objectMap, "modifiedOn", v.ModifiedOn) + populate(objectMap, "pivots", v.Pivots) + populate(objectMap, "query", v.Query) + populate(objectMap, "scope", v.Scope) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ViewProperties. +func (v *ViewProperties) 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", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "accumulated": + err = unpopulate(val, "Accumulated", &v.Accumulated) + delete(rawMsg, key) + case "chart": + err = unpopulate(val, "Chart", &v.Chart) + delete(rawMsg, key) + case "createdOn": + err = unpopulateTimeRFC3339(val, "CreatedOn", &v.CreatedOn) + delete(rawMsg, key) + case "currency": + err = unpopulate(val, "Currency", &v.Currency) + delete(rawMsg, key) + case "dateRange": + err = unpopulate(val, "DateRange", &v.DateRange) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &v.DisplayName) + delete(rawMsg, key) + case "kpis": + err = unpopulate(val, "Kpis", &v.Kpis) + delete(rawMsg, key) + case "metric": + err = unpopulate(val, "Metric", &v.Metric) + delete(rawMsg, key) + case "modifiedOn": + err = unpopulateTimeRFC3339(val, "ModifiedOn", &v.ModifiedOn) + delete(rawMsg, key) + case "pivots": + err = unpopulate(val, "Pivots", &v.Pivots) + delete(rawMsg, key) + case "query": + err = unpopulate(val, "Query", &v.Query) + delete(rawMsg, key) + case "scope": + err = unpopulate(val, "Scope", &v.Scope) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +func populate(m map[string]interface{}, k string, v interface{}) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v interface{}) error { + if data == nil { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_operations_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/operations_client.go similarity index 99% rename from sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_operations_client.go rename to sdk/resourcemanager/costmanagement/armcostmanagement/operations_client.go index f34e2f76b719..33eb2e0649fd 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_operations_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/operations_client.go @@ -5,6 +5,7 @@ // 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 diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_query_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/query_client.go similarity index 99% rename from sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_query_client.go rename to sdk/resourcemanager/costmanagement/armcostmanagement/query_client.go index 33fb2aa9eb69..90b981a3fb29 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_query_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/query_client.go @@ -5,6 +5,7 @@ // 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 diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_response_types.go b/sdk/resourcemanager/costmanagement/armcostmanagement/response_types.go similarity index 91% rename from sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_response_types.go rename to sdk/resourcemanager/costmanagement/armcostmanagement/response_types.go index 0f40aeaffec8..4d6ead381070 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_response_types.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/response_types.go @@ -5,6 +5,7 @@ // 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 @@ -78,6 +79,16 @@ type ForecastClientUsageResponse struct { QueryResult } +// GenerateCostDetailsReportClientCreateOperationResponse contains the response from method GenerateCostDetailsReportClient.CreateOperation. +type GenerateCostDetailsReportClientCreateOperationResponse struct { + CostDetailsOperationResults +} + +// GenerateCostDetailsReportClientGetOperationResultsResponse contains the response from method GenerateCostDetailsReportClient.GetOperationResults. +type GenerateCostDetailsReportClientGetOperationResultsResponse struct { + CostDetailsOperationResults +} + // GenerateDetailedCostReportClientCreateOperationResponse contains the response from method GenerateDetailedCostReportClient.CreateOperation. type GenerateDetailedCostReportClientCreateOperationResponse struct { GenerateDetailedCostReportOperationResult diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_time_rfc3339.go b/sdk/resourcemanager/costmanagement/armcostmanagement/time_rfc3339.go similarity index 99% rename from sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_time_rfc3339.go rename to sdk/resourcemanager/costmanagement/armcostmanagement/time_rfc3339.go index 3fccf88c1d9f..354f35ff7608 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_time_rfc3339.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/time_rfc3339.go @@ -5,6 +5,7 @@ // 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 diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_views_client.go b/sdk/resourcemanager/costmanagement/armcostmanagement/views_client.go similarity index 99% rename from sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_views_client.go rename to sdk/resourcemanager/costmanagement/armcostmanagement/views_client.go index 51a00b3475a9..5d33c1f4c8e5 100644 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_views_client.go +++ b/sdk/resourcemanager/costmanagement/armcostmanagement/views_client.go @@ -5,6 +5,7 @@ // 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 diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/ze_generated_example_alerts_client_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/ze_generated_example_alerts_client_test.go deleted file mode 100644 index 92055388efb4..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/ze_generated_example_alerts_client_test.go +++ /dev/null @@ -1,110 +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. - -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" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2021-10-01/examples/BillingAccountAlerts.json -func ExampleAlertsClient_List() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armcostmanagement.NewAlertsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.List(ctx, - "providers/Microsoft.Billing/billingAccounts/12345:6789", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2021-10-01/examples/SingleResourceGroupAlert.json -func ExampleAlertsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armcostmanagement.NewAlertsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.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) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2021-10-01/examples/DismissResourceGroupAlerts.json -func ExampleAlertsClient_Dismiss() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armcostmanagement.NewAlertsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.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) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2021-10-01/examples/ExternalBillingAccountAlerts.json -func ExampleAlertsClient_ListExternal() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armcostmanagement.NewAlertsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.ListExternal(ctx, - armcostmanagement.ExternalCloudProviderTypeExternalBillingAccounts, - "100", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/ze_generated_example_dimensions_client_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/ze_generated_example_dimensions_client_test.go deleted file mode 100644 index 6cd634d0f3b2..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/ze_generated_example_dimensions_client_test.go +++ /dev/null @@ -1,76 +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. - -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" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2021-10-01/examples/BillingAccountDimensionsList.json -func ExampleDimensionsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armcostmanagement.NewDimensionsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager("providers/Microsoft.Billing/billingAccounts/100", - &armcostmanagement.DimensionsClientListOptions{Filter: nil, - Expand: nil, - Skiptoken: nil, - Top: nil, - }) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2021-10-01/examples/ExternalBillingAccountsDimensions.json -func ExampleDimensionsClient_NewByExternalCloudProviderTypePager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armcostmanagement.NewDimensionsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewByExternalCloudProviderTypePager(armcostmanagement.ExternalCloudProviderTypeExternalBillingAccounts, - "100", - &armcostmanagement.DimensionsClientByExternalCloudProviderTypeOptions{Filter: nil, - Expand: nil, - Skiptoken: nil, - Top: nil, - }) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/ze_generated_example_exports_client_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/ze_generated_example_exports_client_test.go deleted file mode 100644 index 7d71bd5cc537..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/ze_generated_example_exports_client_test.go +++ /dev/null @@ -1,182 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -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" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2021-10-01/examples/ExportsGetByBillingAccount.json -func ExampleExportsClient_List() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armcostmanagement.NewExportsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.List(ctx, - "providers/Microsoft.Billing/billingAccounts/123456", - &armcostmanagement.ExportsClientListOptions{Expand: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2021-10-01/examples/ExportGetByBillingAccount.json -func ExampleExportsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armcostmanagement.NewExportsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "providers/Microsoft.Billing/billingAccounts/123456", - "TestExport", - &armcostmanagement.ExportsClientGetOptions{Expand: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2021-10-01/examples/ExportCreateOrUpdateByBillingAccount.json -func ExampleExportsClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armcostmanagement.NewExportsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.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) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2021-10-01/examples/ExportDeleteByBillingAccount.json -func ExampleExportsClient_Delete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armcostmanagement.NewExportsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.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/tree/main/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2021-10-01/examples/ExportRunByBillingAccount.json -func ExampleExportsClient_Execute() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armcostmanagement.NewExportsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.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/tree/main/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2021-10-01/examples/ExportRunHistoryGetByBillingAccount.json -func ExampleExportsClient_GetExecutionHistory() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armcostmanagement.NewExportsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetExecutionHistory(ctx, - "providers/Microsoft.Billing/billingAccounts/123456", - "TestExport", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/ze_generated_example_forecast_client_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/ze_generated_example_forecast_client_test.go deleted file mode 100644 index c724a4e47ebc..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/ze_generated_example_forecast_client_test.go +++ /dev/null @@ -1,141 +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. - -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" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2021-10-01/examples/BillingAccountForecast.json -func ExampleForecastClient_Usage() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armcostmanagement.NewForecastClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Usage(ctx, - "providers/Microsoft.Billing/billingAccounts/12345:6789", - armcostmanagement.ForecastDefinition{ - Type: to.Ptr(armcostmanagement.ForecastTypeUsage), - Dataset: &armcostmanagement.ForecastDataset{ - 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), - }, - IncludeActualCost: to.Ptr(false), - IncludeFreshPartialCost: to.Ptr(false), - Timeframe: to.Ptr(armcostmanagement.ForecastTimeframeTypeMonthToDate), - }, - &armcostmanagement.ForecastClientUsageOptions{Filter: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2021-10-01/examples/ExternalBillingAccountForecast.json -func ExampleForecastClient_ExternalCloudProviderUsage() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armcostmanagement.NewForecastClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.ExternalCloudProviderUsage(ctx, - armcostmanagement.ExternalCloudProviderTypeExternalBillingAccounts, - "100", - armcostmanagement.ForecastDefinition{ - Type: to.Ptr(armcostmanagement.ForecastTypeUsage), - Dataset: &armcostmanagement.ForecastDataset{ - 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.ForecastTimeframeTypeMonthToDate), - }, - &armcostmanagement.ForecastClientExternalCloudProviderUsageOptions{Filter: nil}) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/ze_generated_example_generatedetailedcostreport_client_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/ze_generated_example_generatedetailedcostreport_client_test.go deleted file mode 100644 index 63e6ca56c39b..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/ze_generated_example_generatedetailedcostreport_client_test.go +++ /dev/null @@ -1,47 +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. - -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" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2021-10-01/examples/GenerateDetailedCostReportByBillingAccountLegacyAndBillingPeriod.json -func ExampleGenerateDetailedCostReportClient_BeginCreateOperation() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armcostmanagement.NewGenerateDetailedCostReportClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := client.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) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/ze_generated_example_generatedetailedcostreportoperationresults_client_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/ze_generated_example_generatedetailedcostreportoperationresults_client_test.go deleted file mode 100644 index d1a694dc4e16..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/ze_generated_example_generatedetailedcostreportoperationresults_client_test.go +++ /dev/null @@ -1,39 +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. - -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" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2021-10-01/examples/GenerateDetailedCostReportOperationResultsBySubscriptionScope.json -func ExampleGenerateDetailedCostReportOperationResultsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armcostmanagement.NewGenerateDetailedCostReportOperationResultsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.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) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/ze_generated_example_generatedetailedcostreportoperationstatus_client_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/ze_generated_example_generatedetailedcostreportoperationstatus_client_test.go deleted file mode 100644 index d44468312399..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/ze_generated_example_generatedetailedcostreportoperationstatus_client_test.go +++ /dev/null @@ -1,39 +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. - -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" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2021-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() - client, err := armcostmanagement.NewGenerateDetailedCostReportOperationStatusClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.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) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/ze_generated_example_generatereservationdetailsreport_client_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/ze_generated_example_generatereservationdetailsreport_client_test.go deleted file mode 100644 index f77b0ff8d03b..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/ze_generated_example_generatereservationdetailsreport_client_test.go +++ /dev/null @@ -1,9 +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. - -package armcostmanagement_test diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/ze_generated_example_operations_client_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/ze_generated_example_operations_client_test.go deleted file mode 100644 index 6c79f13be4ba..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/ze_generated_example_operations_client_test.go +++ /dev/null @@ -1,41 +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. - -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" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2021-10-01/examples/OperationList.json -func ExampleOperationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armcostmanagement.NewOperationsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/ze_generated_example_query_client_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/ze_generated_example_query_client_test.go deleted file mode 100644 index 87bad79d9da3..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/ze_generated_example_query_client_test.go +++ /dev/null @@ -1,139 +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. - -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" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2021-10-01/examples/BillingAccountQuery.json -func ExampleQueryClient_Usage() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armcostmanagement.NewQueryClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.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) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2021-10-01/examples/ExternalBillingAccountsQuery.json -func ExampleQueryClient_UsageByExternalCloudProviderType() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client, err := armcostmanagement.NewQueryClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.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) - } - // TODO: use response item - _ = res -} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/ze_generated_example_views_client_test.go b/sdk/resourcemanager/costmanagement/armcostmanagement/ze_generated_example_views_client_test.go deleted file mode 100644 index 81dbb2a60921..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/ze_generated_example_views_client_test.go +++ /dev/null @@ -1,294 +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. - -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" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2021-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() - client, err := armcostmanagement.NewViewsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListPager(nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2021-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() - client, err := armcostmanagement.NewViewsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := client.NewListByScopePager("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG", - nil) - for pager.More() { - nextResult, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range nextResult.Value { - // TODO: use page item - _ = v - } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2021-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() - client, err := armcostmanagement.NewViewsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.Get(ctx, - "swaggerExample", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2021-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() - client, err := armcostmanagement.NewViewsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.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) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2021-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() - client, err := armcostmanagement.NewViewsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.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/tree/main/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2021-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() - client, err := armcostmanagement.NewViewsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.GetByScope(ctx, - "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG", - "swaggerExample", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2021-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() - client, err := armcostmanagement.NewViewsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := client.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) - } - // TODO: use response item - _ = res -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/tree/main/specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2021-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() - client, err := armcostmanagement.NewViewsClient(cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - _, err = client.DeleteByScope(ctx, - "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG", - "TestView", - nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } -} diff --git a/sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_models_serde.go b/sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_models_serde.go deleted file mode 100644 index 2eb55f6d045e..000000000000 --- a/sdk/resourcemanager/costmanagement/armcostmanagement/zz_generated_models_serde.go +++ /dev/null @@ -1,612 +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. - -package armcostmanagement - -import ( - "encoding/json" - "fmt" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" -) - -// MarshalJSON implements the json.Marshaller interface for type AlertPropertiesDetails. -func (a AlertPropertiesDetails) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "amount", a.Amount) - populate(objectMap, "companyName", a.CompanyName) - populate(objectMap, "contactEmails", a.ContactEmails) - populate(objectMap, "contactGroups", a.ContactGroups) - populate(objectMap, "contactRoles", a.ContactRoles) - populate(objectMap, "currentSpend", a.CurrentSpend) - populate(objectMap, "departmentName", a.DepartmentName) - populate(objectMap, "enrollmentEndDate", a.EnrollmentEndDate) - populate(objectMap, "enrollmentNumber", a.EnrollmentNumber) - populate(objectMap, "enrollmentStartDate", a.EnrollmentStartDate) - populate(objectMap, "invoicingThreshold", a.InvoicingThreshold) - populate(objectMap, "meterFilter", a.MeterFilter) - populate(objectMap, "operator", a.Operator) - populate(objectMap, "overridingAlert", a.OverridingAlert) - populate(objectMap, "periodStartDate", a.PeriodStartDate) - populate(objectMap, "resourceFilter", a.ResourceFilter) - populate(objectMap, "resourceGroupFilter", a.ResourceGroupFilter) - populate(objectMap, "tagFilter", &a.TagFilter) - populate(objectMap, "threshold", a.Threshold) - populate(objectMap, "timeGrainType", a.TimeGrainType) - populate(objectMap, "triggeredBy", a.TriggeredBy) - populate(objectMap, "unit", a.Unit) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type CommonExportProperties. -func (c CommonExportProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "definition", c.Definition) - populate(objectMap, "deliveryInfo", c.DeliveryInfo) - populate(objectMap, "format", c.Format) - populateTimeRFC3339(objectMap, "nextRunTimeEstimate", c.NextRunTimeEstimate) - populate(objectMap, "partitionData", c.PartitionData) - populate(objectMap, "runHistory", c.RunHistory) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type CommonExportProperties. -func (c *CommonExportProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", c, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "definition": - err = unpopulate(val, "Definition", &c.Definition) - delete(rawMsg, key) - case "deliveryInfo": - err = unpopulate(val, "DeliveryInfo", &c.DeliveryInfo) - delete(rawMsg, key) - case "format": - err = unpopulate(val, "Format", &c.Format) - delete(rawMsg, key) - case "nextRunTimeEstimate": - err = unpopulateTimeRFC3339(val, "NextRunTimeEstimate", &c.NextRunTimeEstimate) - delete(rawMsg, key) - case "partitionData": - err = unpopulate(val, "PartitionData", &c.PartitionData) - delete(rawMsg, key) - case "runHistory": - err = unpopulate(val, "RunHistory", &c.RunHistory) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", c, err) - } - } - return nil -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DimensionProperties. -func (d *DimensionProperties) 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", d, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "category": - err = unpopulate(val, "Category", &d.Category) - delete(rawMsg, key) - case "data": - err = unpopulate(val, "Data", &d.Data) - delete(rawMsg, key) - case "description": - err = unpopulate(val, "Description", &d.Description) - delete(rawMsg, key) - case "filterEnabled": - err = unpopulate(val, "FilterEnabled", &d.FilterEnabled) - delete(rawMsg, key) - case "groupingEnabled": - err = unpopulate(val, "GroupingEnabled", &d.GroupingEnabled) - delete(rawMsg, key) - case "nextLink": - err = unpopulate(val, "NextLink", &d.NextLink) - delete(rawMsg, key) - case "total": - err = unpopulate(val, "Total", &d.Total) - delete(rawMsg, key) - case "usageEnd": - err = unpopulateTimeRFC3339(val, "UsageEnd", &d.UsageEnd) - delete(rawMsg, key) - case "usageStart": - err = unpopulateTimeRFC3339(val, "UsageStart", &d.UsageStart) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type DismissAlertPayload. -func (d DismissAlertPayload) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "properties", d.Properties) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type DownloadURL. -func (d *DownloadURL) 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", d, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "downloadUrl": - err = unpopulate(val, "DownloadURL", &d.DownloadURL) - delete(rawMsg, key) - case "validTill": - err = unpopulateTimeRFC3339(val, "ValidTill", &d.ValidTill) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", d, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type ExportDatasetConfiguration. -func (e ExportDatasetConfiguration) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "columns", e.Columns) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ExportExecutionListResult. -func (e ExportExecutionListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "value", e.Value) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ExportExecutionProperties. -func (e ExportExecutionProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "error", e.Error) - populate(objectMap, "executionType", e.ExecutionType) - populate(objectMap, "fileName", e.FileName) - populateTimeRFC3339(objectMap, "processingEndTime", e.ProcessingEndTime) - populateTimeRFC3339(objectMap, "processingStartTime", e.ProcessingStartTime) - populate(objectMap, "runSettings", e.RunSettings) - populate(objectMap, "status", e.Status) - populate(objectMap, "submittedBy", e.SubmittedBy) - populateTimeRFC3339(objectMap, "submittedTime", e.SubmittedTime) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ExportExecutionProperties. -func (e *ExportExecutionProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "error": - err = unpopulate(val, "Error", &e.Error) - delete(rawMsg, key) - case "executionType": - err = unpopulate(val, "ExecutionType", &e.ExecutionType) - delete(rawMsg, key) - case "fileName": - err = unpopulate(val, "FileName", &e.FileName) - delete(rawMsg, key) - case "processingEndTime": - err = unpopulateTimeRFC3339(val, "ProcessingEndTime", &e.ProcessingEndTime) - delete(rawMsg, key) - case "processingStartTime": - err = unpopulateTimeRFC3339(val, "ProcessingStartTime", &e.ProcessingStartTime) - delete(rawMsg, key) - case "runSettings": - err = unpopulate(val, "RunSettings", &e.RunSettings) - delete(rawMsg, key) - case "status": - err = unpopulate(val, "Status", &e.Status) - delete(rawMsg, key) - case "submittedBy": - err = unpopulate(val, "SubmittedBy", &e.SubmittedBy) - delete(rawMsg, key) - case "submittedTime": - err = unpopulateTimeRFC3339(val, "SubmittedTime", &e.SubmittedTime) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type ExportProperties. -func (e ExportProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "definition", e.Definition) - populate(objectMap, "deliveryInfo", e.DeliveryInfo) - populate(objectMap, "format", e.Format) - populateTimeRFC3339(objectMap, "nextRunTimeEstimate", e.NextRunTimeEstimate) - populate(objectMap, "partitionData", e.PartitionData) - populate(objectMap, "runHistory", e.RunHistory) - populate(objectMap, "schedule", e.Schedule) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ExportProperties. -func (e *ExportProperties) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "definition": - err = unpopulate(val, "Definition", &e.Definition) - delete(rawMsg, key) - case "deliveryInfo": - err = unpopulate(val, "DeliveryInfo", &e.DeliveryInfo) - delete(rawMsg, key) - case "format": - err = unpopulate(val, "Format", &e.Format) - delete(rawMsg, key) - case "nextRunTimeEstimate": - err = unpopulateTimeRFC3339(val, "NextRunTimeEstimate", &e.NextRunTimeEstimate) - delete(rawMsg, key) - case "partitionData": - err = unpopulate(val, "PartitionData", &e.PartitionData) - delete(rawMsg, key) - case "runHistory": - err = unpopulate(val, "RunHistory", &e.RunHistory) - delete(rawMsg, key) - case "schedule": - err = unpopulate(val, "Schedule", &e.Schedule) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type ExportRecurrencePeriod. -func (e ExportRecurrencePeriod) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populateTimeRFC3339(objectMap, "from", e.From) - populateTimeRFC3339(objectMap, "to", e.To) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ExportRecurrencePeriod. -func (e *ExportRecurrencePeriod) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "from": - err = unpopulateTimeRFC3339(val, "From", &e.From) - delete(rawMsg, key) - case "to": - err = unpopulateTimeRFC3339(val, "To", &e.To) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type ExportTimePeriod. -func (e ExportTimePeriod) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populateTimeRFC3339(objectMap, "from", e.From) - populateTimeRFC3339(objectMap, "to", e.To) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ExportTimePeriod. -func (e *ExportTimePeriod) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "from": - err = unpopulateTimeRFC3339(val, "From", &e.From) - delete(rawMsg, key) - case "to": - err = unpopulateTimeRFC3339(val, "To", &e.To) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", e, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type ForecastDataset. -func (f ForecastDataset) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "aggregation", f.Aggregation) - populate(objectMap, "configuration", f.Configuration) - populate(objectMap, "filter", f.Filter) - populate(objectMap, "granularity", f.Granularity) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type QueryComparisonExpression. -func (q QueryComparisonExpression) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "name", q.Name) - populate(objectMap, "operator", q.Operator) - populate(objectMap, "values", q.Values) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type QueryDataset. -func (q QueryDataset) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "aggregation", q.Aggregation) - populate(objectMap, "configuration", q.Configuration) - populate(objectMap, "filter", q.Filter) - populate(objectMap, "granularity", q.Granularity) - populate(objectMap, "grouping", q.Grouping) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type QueryDatasetConfiguration. -func (q QueryDatasetConfiguration) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "columns", q.Columns) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type QueryFilter. -func (q QueryFilter) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "and", q.And) - populate(objectMap, "dimensions", q.Dimensions) - populate(objectMap, "or", q.Or) - populate(objectMap, "tags", q.Tags) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type QueryTimePeriod. -func (q QueryTimePeriod) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populateTimeRFC3339(objectMap, "from", q.From) - populateTimeRFC3339(objectMap, "to", q.To) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type QueryTimePeriod. -func (q *QueryTimePeriod) 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", q, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "from": - err = unpopulateTimeRFC3339(val, "From", &q.From) - delete(rawMsg, key) - case "to": - err = unpopulateTimeRFC3339(val, "To", &q.To) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", q, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type ReportConfigComparisonExpression. -func (r ReportConfigComparisonExpression) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "name", r.Name) - populate(objectMap, "operator", r.Operator) - populate(objectMap, "values", r.Values) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ReportConfigDataset. -func (r ReportConfigDataset) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "aggregation", r.Aggregation) - populate(objectMap, "configuration", r.Configuration) - populate(objectMap, "filter", r.Filter) - populate(objectMap, "granularity", r.Granularity) - populate(objectMap, "grouping", r.Grouping) - populate(objectMap, "sorting", r.Sorting) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ReportConfigDatasetConfiguration. -func (r ReportConfigDatasetConfiguration) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "columns", r.Columns) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ReportConfigFilter. -func (r ReportConfigFilter) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "and", r.And) - populate(objectMap, "dimensions", r.Dimensions) - populate(objectMap, "or", r.Or) - populate(objectMap, "tags", r.Tags) - return json.Marshal(objectMap) -} - -// MarshalJSON implements the json.Marshaller interface for type ReportConfigTimePeriod. -func (r ReportConfigTimePeriod) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populateTimeRFC3339(objectMap, "from", r.From) - populateTimeRFC3339(objectMap, "to", r.To) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ReportConfigTimePeriod. -func (r *ReportConfigTimePeriod) 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", r, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "from": - err = unpopulateTimeRFC3339(val, "From", &r.From) - delete(rawMsg, key) - case "to": - err = unpopulateTimeRFC3339(val, "To", &r.To) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - } - return nil -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ReportURL. -func (r *ReportURL) 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", r, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "reportUrl": - err = unpopulate(val, "ReportURL", &r.ReportURL) - delete(rawMsg, key) - case "validUntil": - err = unpopulateTimeRFC3339(val, "ValidUntil", &r.ValidUntil) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", r, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type ViewProperties. -func (v ViewProperties) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "accumulated", v.Accumulated) - populate(objectMap, "chart", v.Chart) - populateTimeRFC3339(objectMap, "createdOn", v.CreatedOn) - populate(objectMap, "currency", v.Currency) - populate(objectMap, "dateRange", v.DateRange) - populate(objectMap, "displayName", v.DisplayName) - populate(objectMap, "kpis", v.Kpis) - populate(objectMap, "metric", v.Metric) - populateTimeRFC3339(objectMap, "modifiedOn", v.ModifiedOn) - populate(objectMap, "pivots", v.Pivots) - populate(objectMap, "query", v.Query) - populate(objectMap, "scope", v.Scope) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type ViewProperties. -func (v *ViewProperties) 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", v, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "accumulated": - err = unpopulate(val, "Accumulated", &v.Accumulated) - delete(rawMsg, key) - case "chart": - err = unpopulate(val, "Chart", &v.Chart) - delete(rawMsg, key) - case "createdOn": - err = unpopulateTimeRFC3339(val, "CreatedOn", &v.CreatedOn) - delete(rawMsg, key) - case "currency": - err = unpopulate(val, "Currency", &v.Currency) - delete(rawMsg, key) - case "dateRange": - err = unpopulate(val, "DateRange", &v.DateRange) - delete(rawMsg, key) - case "displayName": - err = unpopulate(val, "DisplayName", &v.DisplayName) - delete(rawMsg, key) - case "kpis": - err = unpopulate(val, "Kpis", &v.Kpis) - delete(rawMsg, key) - case "metric": - err = unpopulate(val, "Metric", &v.Metric) - delete(rawMsg, key) - case "modifiedOn": - err = unpopulateTimeRFC3339(val, "ModifiedOn", &v.ModifiedOn) - delete(rawMsg, key) - case "pivots": - err = unpopulate(val, "Pivots", &v.Pivots) - delete(rawMsg, key) - case "query": - err = unpopulate(val, "Query", &v.Query) - delete(rawMsg, key) - case "scope": - err = unpopulate(val, "Scope", &v.Scope) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", v, err) - } - } - return nil -} - -func populate(m map[string]interface{}, k string, v interface{}) { - if v == nil { - return - } else if azcore.IsNullValue(v) { - m[k] = nil - } else if !reflect.ValueOf(v).IsNil() { - m[k] = v - } -} - -func unpopulate(data json.RawMessage, fn string, v interface{}) error { - if data == nil { - return nil - } - if err := json.Unmarshal(data, v); err != nil { - return fmt.Errorf("struct field %s: %v", fn, err) - } - return nil -}