diff --git a/services/costmanagement/mgmt/2018-05-31/costmanagement/CHANGELOG.md b/services/costmanagement/mgmt/2018-05-31/costmanagement/CHANGELOG.md index 52911e4cc5e4..a1ecf841edb0 100644 --- a/services/costmanagement/mgmt/2018-05-31/costmanagement/CHANGELOG.md +++ b/services/costmanagement/mgmt/2018-05-31/costmanagement/CHANGELOG.md @@ -1,2 +1,2 @@ -# Change History +# Unreleased diff --git a/services/costmanagement/mgmt/2018-05-31/costmanagement/_meta.json b/services/costmanagement/mgmt/2018-05-31/costmanagement/_meta.json index c32d89a0ca4b..4decc946d491 100644 --- a/services/costmanagement/mgmt/2018-05-31/costmanagement/_meta.json +++ b/services/costmanagement/mgmt/2018-05-31/costmanagement/_meta.json @@ -1,5 +1,5 @@ { - "commit": "3c764635e7d442b3e74caf593029fcd440b3ef82", + "commit": "f92aaf88f4c9d1ffb9a014eba196d887a9288c3a", "readme": "/_/azure-rest-api-specs/specification/cost-management/resource-manager/readme.md", "tag": "package-2018-05", "use": "@microsoft.azure/autorest.go@2.1.187", diff --git a/services/costmanagement/mgmt/2019-01-01/costmanagement/CHANGELOG.md b/services/costmanagement/mgmt/2019-01-01/costmanagement/CHANGELOG.md index 52911e4cc5e4..a1ecf841edb0 100644 --- a/services/costmanagement/mgmt/2019-01-01/costmanagement/CHANGELOG.md +++ b/services/costmanagement/mgmt/2019-01-01/costmanagement/CHANGELOG.md @@ -1,2 +1,2 @@ -# Change History +# Unreleased diff --git a/services/costmanagement/mgmt/2019-01-01/costmanagement/_meta.json b/services/costmanagement/mgmt/2019-01-01/costmanagement/_meta.json index ebbf8a464208..e1e64c49ed90 100644 --- a/services/costmanagement/mgmt/2019-01-01/costmanagement/_meta.json +++ b/services/costmanagement/mgmt/2019-01-01/costmanagement/_meta.json @@ -1,5 +1,5 @@ { - "commit": "3c764635e7d442b3e74caf593029fcd440b3ef82", + "commit": "f92aaf88f4c9d1ffb9a014eba196d887a9288c3a", "readme": "/_/azure-rest-api-specs/specification/cost-management/resource-manager/readme.md", "tag": "package-2019-01", "use": "@microsoft.azure/autorest.go@2.1.187", diff --git a/services/costmanagement/mgmt/2019-01-01/costmanagement/models.go b/services/costmanagement/mgmt/2019-01-01/costmanagement/models.go index e3c746f3dc8e..4ce56450086f 100644 --- a/services/costmanagement/mgmt/2019-01-01/costmanagement/models.go +++ b/services/costmanagement/mgmt/2019-01-01/costmanagement/models.go @@ -736,7 +736,7 @@ type QueryDataset struct { Grouping *[]QueryGrouping `json:"grouping,omitempty"` // Sorting - Array of sorting by columns in query. Sorting *[]QuerySortingConfiguration `json:"sorting,omitempty"` - // Filter - Has filter expression to use in the query. + // Filter - The filter expression to use in the query. Please reference our Query API REST documentation for how to properly format the filter. Filter *QueryFilter `json:"filter,omitempty"` } diff --git a/services/costmanagement/mgmt/2019-10-01/costmanagement/CHANGELOG.md b/services/costmanagement/mgmt/2019-10-01/costmanagement/CHANGELOG.md index 52911e4cc5e4..a1ecf841edb0 100644 --- a/services/costmanagement/mgmt/2019-10-01/costmanagement/CHANGELOG.md +++ b/services/costmanagement/mgmt/2019-10-01/costmanagement/CHANGELOG.md @@ -1,2 +1,2 @@ -# Change History +# Unreleased diff --git a/services/costmanagement/mgmt/2019-10-01/costmanagement/_meta.json b/services/costmanagement/mgmt/2019-10-01/costmanagement/_meta.json index 6063fe8e95f9..f8f9c405f17f 100644 --- a/services/costmanagement/mgmt/2019-10-01/costmanagement/_meta.json +++ b/services/costmanagement/mgmt/2019-10-01/costmanagement/_meta.json @@ -1,5 +1,5 @@ { - "commit": "3c764635e7d442b3e74caf593029fcd440b3ef82", + "commit": "f92aaf88f4c9d1ffb9a014eba196d887a9288c3a", "readme": "/_/azure-rest-api-specs/specification/cost-management/resource-manager/readme.md", "tag": "package-2019-10", "use": "@microsoft.azure/autorest.go@2.1.187", diff --git a/services/costmanagement/mgmt/2019-10-01/costmanagement/models.go b/services/costmanagement/mgmt/2019-10-01/costmanagement/models.go index 2ae859c2eaf5..c5b3724faaf3 100644 --- a/services/costmanagement/mgmt/2019-10-01/costmanagement/models.go +++ b/services/costmanagement/mgmt/2019-10-01/costmanagement/models.go @@ -669,7 +669,7 @@ type QueryDataset struct { Grouping *[]QueryGrouping `json:"grouping,omitempty"` // Sorting - Array of sorting by columns in query. Sorting *[]QuerySortingConfiguration `json:"sorting,omitempty"` - // Filter - Has filter expression to use in the query. + // Filter - The filter expression to use in the query. Please reference our Query API REST documentation for how to properly format the filter. Filter *QueryFilter `json:"filter,omitempty"` } diff --git a/services/costmanagement/mgmt/2019-11-01/costmanagement/CHANGELOG.md b/services/costmanagement/mgmt/2019-11-01/costmanagement/CHANGELOG.md index 52911e4cc5e4..a1ecf841edb0 100644 --- a/services/costmanagement/mgmt/2019-11-01/costmanagement/CHANGELOG.md +++ b/services/costmanagement/mgmt/2019-11-01/costmanagement/CHANGELOG.md @@ -1,2 +1,2 @@ -# Change History +# Unreleased diff --git a/services/costmanagement/mgmt/2019-11-01/costmanagement/_meta.json b/services/costmanagement/mgmt/2019-11-01/costmanagement/_meta.json index ec852ef94d9a..8cb6db3c725e 100644 --- a/services/costmanagement/mgmt/2019-11-01/costmanagement/_meta.json +++ b/services/costmanagement/mgmt/2019-11-01/costmanagement/_meta.json @@ -1,5 +1,5 @@ { - "commit": "b47572ab2069865484c493a4f679d4e72f8b303d", + "commit": "f92aaf88f4c9d1ffb9a014eba196d887a9288c3a", "readme": "/_/azure-rest-api-specs/specification/cost-management/resource-manager/readme.md", "tag": "package-2019-11", "use": "@microsoft.azure/autorest.go@2.1.187", diff --git a/services/costmanagement/mgmt/2019-11-01/costmanagement/models.go b/services/costmanagement/mgmt/2019-11-01/costmanagement/models.go index cbc9c8dd08d4..fe0dca5379b2 100644 --- a/services/costmanagement/mgmt/2019-11-01/costmanagement/models.go +++ b/services/costmanagement/mgmt/2019-11-01/costmanagement/models.go @@ -1126,14 +1126,14 @@ type QueryComparisonExpression struct { type QueryDataset struct { // Granularity - The granularity of rows in the query. Possible values include: 'GranularityTypeDaily' Granularity GranularityType `json:"granularity,omitempty"` - // Configuration - Has configuration information for the data in the export. The configuration will be ignored if aggregation and grouping are provided. - Configuration *QueryDatasetConfiguration `json:"configuration,omitempty"` // Aggregation - Dictionary of aggregation expression to use in the query. The key of each item in the dictionary is the alias for the aggregated column. Query can have up to 2 aggregation clauses. Aggregation map[string]*QueryAggregation `json:"aggregation"` // Grouping - Array of group by expression to use in the query. Query can have up to 2 group by clauses. Grouping *[]QueryGrouping `json:"grouping,omitempty"` // Filter - The filter expression to use in the query. Please reference our Query API REST documentation for how to properly format the filter. Filter *QueryFilter `json:"filter,omitempty"` + // Configuration - Has configuration information for the data in the export. The configuration will be ignored if aggregation and grouping are provided. + Configuration *QueryDatasetConfiguration `json:"configuration,omitempty"` } // MarshalJSON is the custom marshaler for QueryDataset. @@ -1142,9 +1142,6 @@ func (qd QueryDataset) MarshalJSON() ([]byte, error) { if qd.Granularity != "" { objectMap["granularity"] = qd.Granularity } - if qd.Configuration != nil { - objectMap["configuration"] = qd.Configuration - } if qd.Aggregation != nil { objectMap["aggregation"] = qd.Aggregation } @@ -1154,6 +1151,9 @@ func (qd QueryDataset) MarshalJSON() ([]byte, error) { if qd.Filter != nil { objectMap["filter"] = qd.Filter } + if qd.Configuration != nil { + objectMap["configuration"] = qd.Configuration + } return json.Marshal(objectMap) } diff --git a/services/costmanagement/mgmt/2020-06-01/costmanagement/CHANGELOG.md b/services/costmanagement/mgmt/2020-06-01/costmanagement/CHANGELOG.md index 52911e4cc5e4..a1ecf841edb0 100644 --- a/services/costmanagement/mgmt/2020-06-01/costmanagement/CHANGELOG.md +++ b/services/costmanagement/mgmt/2020-06-01/costmanagement/CHANGELOG.md @@ -1,2 +1,2 @@ -# Change History +# Unreleased diff --git a/services/costmanagement/mgmt/2020-06-01/costmanagement/_meta.json b/services/costmanagement/mgmt/2020-06-01/costmanagement/_meta.json index 9d744e74962b..fb88a025b9c0 100644 --- a/services/costmanagement/mgmt/2020-06-01/costmanagement/_meta.json +++ b/services/costmanagement/mgmt/2020-06-01/costmanagement/_meta.json @@ -1,5 +1,5 @@ { - "commit": "e0f8b9ab0f5fe5e71b7429ebfea8a33c19ec9d8d", + "commit": "f92aaf88f4c9d1ffb9a014eba196d887a9288c3a", "readme": "/_/azure-rest-api-specs/specification/cost-management/resource-manager/readme.md", "tag": "package-2020-06", "use": "@microsoft.azure/autorest.go@2.1.187", diff --git a/services/costmanagement/mgmt/2020-06-01/costmanagement/forecast.go b/services/costmanagement/mgmt/2020-06-01/costmanagement/forecast.go index fac797fa2654..46fb762aa5d9 100644 --- a/services/costmanagement/mgmt/2020-06-01/costmanagement/forecast.go +++ b/services/costmanagement/mgmt/2020-06-01/costmanagement/forecast.go @@ -59,7 +59,7 @@ func (client ForecastClient) ExternalCloudProviderUsage(ctx context.Context, ext Chain: []validation.Constraint{{Target: "parameters.TimePeriod.From", Name: validation.Null, Rule: true, Chain: nil}, {Target: "parameters.TimePeriod.To", Name: validation.Null, Rule: true, Chain: nil}, }}, - {Target: "parameters.Dataset", Name: validation.Null, Rule: false, + {Target: "parameters.Dataset", Name: validation.Null, Rule: true, Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.And", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.And", Name: validation.MinItems, Rule: 2, Chain: nil}}}, @@ -185,7 +185,7 @@ func (client ForecastClient) Usage(ctx context.Context, scope string, parameters Chain: []validation.Constraint{{Target: "parameters.TimePeriod.From", Name: validation.Null, Rule: true, Chain: nil}, {Target: "parameters.TimePeriod.To", Name: validation.Null, Rule: true, Chain: nil}, }}, - {Target: "parameters.Dataset", Name: validation.Null, Rule: false, + {Target: "parameters.Dataset", Name: validation.Null, Rule: true, Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.And", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.And", Name: validation.MinItems, Rule: 2, Chain: nil}}}, diff --git a/services/costmanagement/mgmt/2020-06-01/costmanagement/models.go b/services/costmanagement/mgmt/2020-06-01/costmanagement/models.go index c7d565ccb065..b4198fcb49ad 100644 --- a/services/costmanagement/mgmt/2020-06-01/costmanagement/models.go +++ b/services/costmanagement/mgmt/2020-06-01/costmanagement/models.go @@ -1064,7 +1064,7 @@ type QueryDataset struct { Aggregation map[string]*QueryAggregation `json:"aggregation"` // Grouping - Array of group by expression to use in the query. Query can have up to 2 group by clauses. Grouping *[]QueryGrouping `json:"grouping,omitempty"` - // Filter - Has filter expression to use in the query. + // Filter - The filter expression to use in the query. Please reference our Query API REST documentation for how to properly format the filter. Filter *QueryFilter `json:"filter,omitempty"` } diff --git a/services/costmanagement/mgmt/2020-06-01/costmanagement/query.go b/services/costmanagement/mgmt/2020-06-01/costmanagement/query.go index 0b92b9093f7e..a81886b8cf54 100644 --- a/services/costmanagement/mgmt/2020-06-01/costmanagement/query.go +++ b/services/costmanagement/mgmt/2020-06-01/costmanagement/query.go @@ -66,7 +66,7 @@ func (client QueryClient) Usage(ctx context.Context, scope string, parameters Qu Chain: []validation.Constraint{{Target: "parameters.TimePeriod.From", Name: validation.Null, Rule: true, Chain: nil}, {Target: "parameters.TimePeriod.To", Name: validation.Null, Rule: true, Chain: nil}, }}, - {Target: "parameters.Dataset", Name: validation.Null, Rule: false, + {Target: "parameters.Dataset", Name: validation.Null, Rule: true, Chain: []validation.Constraint{{Target: "parameters.Dataset.Grouping", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "parameters.Dataset.Grouping", Name: validation.MaxItems, Rule: 2, Chain: nil}}}, {Target: "parameters.Dataset.Filter", Name: validation.Null, Rule: false, @@ -178,7 +178,7 @@ func (client QueryClient) UsageByExternalCloudProviderType(ctx context.Context, Chain: []validation.Constraint{{Target: "parameters.TimePeriod.From", Name: validation.Null, Rule: true, Chain: nil}, {Target: "parameters.TimePeriod.To", Name: validation.Null, Rule: true, Chain: nil}, }}, - {Target: "parameters.Dataset", Name: validation.Null, Rule: false, + {Target: "parameters.Dataset", Name: validation.Null, Rule: true, Chain: []validation.Constraint{{Target: "parameters.Dataset.Grouping", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "parameters.Dataset.Grouping", Name: validation.MaxItems, Rule: 2, Chain: nil}}}, {Target: "parameters.Dataset.Filter", Name: validation.Null, Rule: false, diff --git a/services/costmanagement/mgmt/2021-01-01/costmanagement/CHANGELOG.md b/services/costmanagement/mgmt/2021-01-01/costmanagement/CHANGELOG.md new file mode 100644 index 000000000000..a1ecf841edb0 --- /dev/null +++ b/services/costmanagement/mgmt/2021-01-01/costmanagement/CHANGELOG.md @@ -0,0 +1,2 @@ +# Unreleased + diff --git a/services/costmanagement/mgmt/2021-01-01/costmanagement/_meta.json b/services/costmanagement/mgmt/2021-01-01/costmanagement/_meta.json new file mode 100644 index 000000000000..5ab96f910303 --- /dev/null +++ b/services/costmanagement/mgmt/2021-01-01/costmanagement/_meta.json @@ -0,0 +1,11 @@ +{ + "commit": "f92aaf88f4c9d1ffb9a014eba196d887a9288c3a", + "readme": "/_/azure-rest-api-specs/specification/cost-management/resource-manager/readme.md", + "tag": "package-2021-01", + "use": "@microsoft.azure/autorest.go@2.1.187", + "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", + "autorest_command": "autorest --use=@microsoft.azure/autorest.go@2.1.187 --tag=package-2021-01 --go-sdk-folder=/_/azure-sdk-for-go --go --verbose --use-onever --version=2.0.4421 --go.license-header=MICROSOFT_MIT_NO_VERSION /_/azure-rest-api-specs/specification/cost-management/resource-manager/readme.md", + "additional_properties": { + "additional_options": "--go --verbose --use-onever --version=2.0.4421 --go.license-header=MICROSOFT_MIT_NO_VERSION" + } +} \ No newline at end of file diff --git a/services/costmanagement/mgmt/2021-01-01/costmanagement/alerts.go b/services/costmanagement/mgmt/2021-01-01/costmanagement/alerts.go new file mode 100644 index 000000000000..38e55cab4324 --- /dev/null +++ b/services/costmanagement/mgmt/2021-01-01/costmanagement/alerts.go @@ -0,0 +1,374 @@ +package costmanagement + +// 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// AlertsClient is the client for the Alerts methods of the Costmanagement service. +type AlertsClient struct { + BaseClient +} + +// NewAlertsClient creates an instance of the AlertsClient client. +func NewAlertsClient(subscriptionID string) AlertsClient { + return NewAlertsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAlertsClientWithBaseURI creates an instance of the AlertsClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewAlertsClientWithBaseURI(baseURI string, subscriptionID string) AlertsClient { + return AlertsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Dismiss dismisses the specified alert +// Parameters: +// scope - the scope associated with alerts operations. This includes '/subscriptions/{subscriptionId}/' for +// subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup +// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department +// scope, +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' +// for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId} for +// Management Group scope, +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for +// billingProfile scope, +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' +// for invoiceSection scope, and +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for +// partners. +// alertID - alert ID +// parameters - parameters supplied to the Dismiss Alert operation. +func (client AlertsClient) Dismiss(ctx context.Context, scope string, alertID string, parameters DismissAlertPayload) (result Alert, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.Dismiss") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DismissPreparer(ctx, scope, alertID, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.AlertsClient", "Dismiss", nil, "Failure preparing request") + return + } + + resp, err := client.DismissSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "costmanagement.AlertsClient", "Dismiss", resp, "Failure sending request") + return + } + + result, err = client.DismissResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.AlertsClient", "Dismiss", resp, "Failure responding to request") + return + } + + return +} + +// DismissPreparer prepares the Dismiss request. +func (client AlertsClient) DismissPreparer(ctx context.Context, scope string, alertID string, parameters DismissAlertPayload) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "alertId": alertID, + "scope": scope, + } + + const APIVersion = "2020-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.CostManagement/alerts/{alertId}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DismissSender sends the Dismiss request. The method will close the +// http.Response Body if it receives an error. +func (client AlertsClient) DismissSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// DismissResponder handles the response to the Dismiss request. The method always +// closes the http.Response Body. +func (client AlertsClient) DismissResponder(resp *http.Response) (result Alert, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets the alert for the scope by alert ID. +// Parameters: +// scope - the scope associated with alerts operations. This includes '/subscriptions/{subscriptionId}/' for +// subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup +// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department +// scope, +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' +// for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId} for +// Management Group scope, +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for +// billingProfile scope, +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' +// for invoiceSection scope, and +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for +// partners. +// alertID - alert ID +func (client AlertsClient) Get(ctx context.Context, scope string, alertID string) (result Alert, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, scope, alertID) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.AlertsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "costmanagement.AlertsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.AlertsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client AlertsClient) GetPreparer(ctx context.Context, scope string, alertID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "alertId": alertID, + "scope": scope, + } + + const APIVersion = "2020-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.CostManagement/alerts/{alertId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client AlertsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AlertsClient) GetResponder(resp *http.Response) (result Alert, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists the alerts for scope defined. +// Parameters: +// scope - the scope associated with alerts operations. This includes '/subscriptions/{subscriptionId}/' for +// subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup +// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department +// scope, +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' +// for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId} for +// Management Group scope, +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for +// billingProfile scope, +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' +// for invoiceSection scope, and +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for +// partners. +func (client AlertsClient) List(ctx context.Context, scope string) (result AlertsResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx, scope) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.AlertsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "costmanagement.AlertsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.AlertsClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client AlertsClient) ListPreparer(ctx context.Context, scope string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "scope": scope, + } + + const APIVersion = "2020-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.CostManagement/alerts", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client AlertsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client AlertsClient) ListResponder(resp *http.Response) (result AlertsResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListExternal lists the Alerts for external cloud provider type defined. +// Parameters: +// externalCloudProviderType - the external cloud provider type associated with dimension/query operations. +// This includes 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated +// account. +// externalCloudProviderID - this can be '{externalSubscriptionId}' for linked account or +// '{externalBillingAccountId}' for consolidated account used with dimension/query operations. +func (client AlertsClient) ListExternal(ctx context.Context, externalCloudProviderType ExternalCloudProviderType, externalCloudProviderID string) (result AlertsResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AlertsClient.ListExternal") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListExternalPreparer(ctx, externalCloudProviderType, externalCloudProviderID) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.AlertsClient", "ListExternal", nil, "Failure preparing request") + return + } + + resp, err := client.ListExternalSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "costmanagement.AlertsClient", "ListExternal", resp, "Failure sending request") + return + } + + result, err = client.ListExternalResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.AlertsClient", "ListExternal", resp, "Failure responding to request") + return + } + + return +} + +// ListExternalPreparer prepares the ListExternal request. +func (client AlertsClient) ListExternalPreparer(ctx context.Context, externalCloudProviderType ExternalCloudProviderType, externalCloudProviderID string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "externalCloudProviderId": autorest.Encode("path", externalCloudProviderID), + "externalCloudProviderType": autorest.Encode("path", externalCloudProviderType), + } + + const APIVersion = "2020-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.CostManagement/{externalCloudProviderType}/{externalCloudProviderId}/alerts", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListExternalSender sends the ListExternal request. The method will close the +// http.Response Body if it receives an error. +func (client AlertsClient) ListExternalSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListExternalResponder handles the response to the ListExternal request. The method always +// closes the http.Response Body. +func (client AlertsClient) ListExternalResponder(resp *http.Response) (result AlertsResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/costmanagement/mgmt/2021-01-01/costmanagement/client.go b/services/costmanagement/mgmt/2021-01-01/costmanagement/client.go new file mode 100644 index 000000000000..f03c2e770e7f --- /dev/null +++ b/services/costmanagement/mgmt/2021-01-01/costmanagement/client.go @@ -0,0 +1,41 @@ +// Package costmanagement implements the Azure ARM Costmanagement service API version . +// +// +package costmanagement + +// 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. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Costmanagement + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Costmanagement. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with +// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/services/costmanagement/mgmt/2021-01-01/costmanagement/costmanagementapi/interfaces.go b/services/costmanagement/mgmt/2021-01-01/costmanagement/costmanagementapi/interfaces.go new file mode 100644 index 000000000000..6f80ac5daa27 --- /dev/null +++ b/services/costmanagement/mgmt/2021-01-01/costmanagement/costmanagementapi/interfaces.go @@ -0,0 +1,104 @@ +package costmanagementapi + +// 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. + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/services/costmanagement/mgmt/2021-01-01/costmanagement" + "github.com/Azure/go-autorest/autorest" +) + +// ExportsClientAPI contains the set of methods on the ExportsClient type. +type ExportsClientAPI interface { + CreateOrUpdate(ctx context.Context, scope string, exportName string, parameters costmanagement.Export) (result costmanagement.Export, err error) + Delete(ctx context.Context, scope string, exportName string) (result autorest.Response, err error) + Execute(ctx context.Context, scope string, exportName string) (result autorest.Response, err error) + Get(ctx context.Context, scope string, exportName string, expand string) (result costmanagement.Export, err error) + GetExecutionHistory(ctx context.Context, scope string, exportName string) (result costmanagement.ExportExecutionListResult, err error) + List(ctx context.Context, scope string, expand string) (result costmanagement.ExportListResult, err error) +} + +var _ ExportsClientAPI = (*costmanagement.ExportsClient)(nil) + +// GenerateDetailedCostReportClientAPI contains the set of methods on the GenerateDetailedCostReportClient type. +type GenerateDetailedCostReportClientAPI interface { + CreateOperation(ctx context.Context, scope string, parameters costmanagement.GenerateDetailedCostReportDefinition) (result costmanagement.GenerateDetailedCostReportCreateOperationFuture, err error) +} + +var _ GenerateDetailedCostReportClientAPI = (*costmanagement.GenerateDetailedCostReportClient)(nil) + +// GenerateDetailedCostReportOperationResultsClientAPI contains the set of methods on the GenerateDetailedCostReportOperationResultsClient type. +type GenerateDetailedCostReportOperationResultsClientAPI interface { + Get(ctx context.Context, operationID string, scope string) (result costmanagement.GenerateDetailedCostReportOperationResult, err error) +} + +var _ GenerateDetailedCostReportOperationResultsClientAPI = (*costmanagement.GenerateDetailedCostReportOperationResultsClient)(nil) + +// GenerateDetailedCostReportOperationStatusClientAPI contains the set of methods on the GenerateDetailedCostReportOperationStatusClient type. +type GenerateDetailedCostReportOperationStatusClientAPI interface { + Get(ctx context.Context, operationID string, scope string) (result costmanagement.GenerateDetailedCostReportOperationStatuses, err error) +} + +var _ GenerateDetailedCostReportOperationStatusClientAPI = (*costmanagement.GenerateDetailedCostReportOperationStatusClient)(nil) + +// ViewsClientAPI contains the set of methods on the ViewsClient type. +type ViewsClientAPI interface { + CreateOrUpdate(ctx context.Context, viewName string, parameters costmanagement.View) (result costmanagement.View, err error) + CreateOrUpdateByScope(ctx context.Context, scope string, viewName string, parameters costmanagement.View) (result costmanagement.View, err error) + Delete(ctx context.Context, viewName string) (result autorest.Response, err error) + DeleteByScope(ctx context.Context, scope string, viewName string) (result autorest.Response, err error) + Get(ctx context.Context, viewName string) (result costmanagement.View, err error) + GetByScope(ctx context.Context, scope string, viewName string) (result costmanagement.View, err error) + List(ctx context.Context) (result costmanagement.ViewListResultPage, err error) + ListComplete(ctx context.Context) (result costmanagement.ViewListResultIterator, err error) + ListByScope(ctx context.Context, scope string) (result costmanagement.ViewListResultPage, err error) + ListByScopeComplete(ctx context.Context, scope string) (result costmanagement.ViewListResultIterator, err error) +} + +var _ ViewsClientAPI = (*costmanagement.ViewsClient)(nil) + +// AlertsClientAPI contains the set of methods on the AlertsClient type. +type AlertsClientAPI interface { + Dismiss(ctx context.Context, scope string, alertID string, parameters costmanagement.DismissAlertPayload) (result costmanagement.Alert, err error) + Get(ctx context.Context, scope string, alertID string) (result costmanagement.Alert, err error) + List(ctx context.Context, scope string) (result costmanagement.AlertsResult, err error) + ListExternal(ctx context.Context, externalCloudProviderType costmanagement.ExternalCloudProviderType, externalCloudProviderID string) (result costmanagement.AlertsResult, err error) +} + +var _ AlertsClientAPI = (*costmanagement.AlertsClient)(nil) + +// ForecastClientAPI contains the set of methods on the ForecastClient type. +type ForecastClientAPI interface { + ExternalCloudProviderUsage(ctx context.Context, externalCloudProviderType costmanagement.ExternalCloudProviderType, externalCloudProviderID string, parameters costmanagement.ForecastDefinition, filter string) (result costmanagement.QueryResult, err error) + Usage(ctx context.Context, scope string, parameters costmanagement.ForecastDefinition, filter string) (result costmanagement.QueryResult, err error) +} + +var _ ForecastClientAPI = (*costmanagement.ForecastClient)(nil) + +// DimensionsClientAPI contains the set of methods on the DimensionsClient type. +type DimensionsClientAPI interface { + ByExternalCloudProviderType(ctx context.Context, externalCloudProviderType costmanagement.ExternalCloudProviderType, externalCloudProviderID string, filter string, expand string, skiptoken string, top *int32) (result costmanagement.DimensionsListResult, err error) + List(ctx context.Context, scope string, filter string, expand string, skiptoken string, top *int32) (result costmanagement.DimensionsListResult, err error) +} + +var _ DimensionsClientAPI = (*costmanagement.DimensionsClient)(nil) + +// QueryClientAPI contains the set of methods on the QueryClient type. +type QueryClientAPI interface { + Usage(ctx context.Context, scope string, parameters costmanagement.QueryDefinition) (result costmanagement.QueryResult, err error) + UsageByExternalCloudProviderType(ctx context.Context, externalCloudProviderType costmanagement.ExternalCloudProviderType, externalCloudProviderID string, parameters costmanagement.QueryDefinition) (result costmanagement.QueryResult, err error) +} + +var _ QueryClientAPI = (*costmanagement.QueryClient)(nil) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result costmanagement.OperationListResultPage, err error) + ListComplete(ctx context.Context) (result costmanagement.OperationListResultIterator, err error) +} + +var _ OperationsClientAPI = (*costmanagement.OperationsClient)(nil) diff --git a/services/costmanagement/mgmt/2021-01-01/costmanagement/dimensions.go b/services/costmanagement/mgmt/2021-01-01/costmanagement/dimensions.go new file mode 100644 index 000000000000..3d08677933fc --- /dev/null +++ b/services/costmanagement/mgmt/2021-01-01/costmanagement/dimensions.go @@ -0,0 +1,254 @@ +package costmanagement + +// 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// DimensionsClient is the client for the Dimensions methods of the Costmanagement service. +type DimensionsClient struct { + BaseClient +} + +// NewDimensionsClient creates an instance of the DimensionsClient client. +func NewDimensionsClient(subscriptionID string) DimensionsClient { + return NewDimensionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewDimensionsClientWithBaseURI creates an instance of the DimensionsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewDimensionsClientWithBaseURI(baseURI string, subscriptionID string) DimensionsClient { + return DimensionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ByExternalCloudProviderType lists the dimensions by the external cloud provider type. +// Parameters: +// externalCloudProviderType - the external cloud provider type associated with dimension/query operations. +// This includes 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated +// account. +// externalCloudProviderID - this can be '{externalSubscriptionId}' for linked account or +// '{externalBillingAccountId}' for consolidated account used with dimension/query operations. +// filter - may be used to filter dimensions by properties/category, properties/usageStart, +// properties/usageEnd. Supported operators are 'eq','lt', 'gt', 'le', 'ge'. +// expand - may be used to expand the properties/data within a dimension category. By default, data is not +// included when listing dimensions. +// skiptoken - skiptoken is only used if a previous operation returned a partial result. If a previous response +// contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that +// specifies a starting point to use for subsequent calls. +// top - may be used to limit the number of results to the most recent N dimension data. +func (client DimensionsClient) ByExternalCloudProviderType(ctx context.Context, externalCloudProviderType ExternalCloudProviderType, externalCloudProviderID string, filter string, expand string, skiptoken string, top *int32) (result DimensionsListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DimensionsClient.ByExternalCloudProviderType") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMaximum, Rule: int64(1000), Chain: nil}, + {Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("costmanagement.DimensionsClient", "ByExternalCloudProviderType", err.Error()) + } + + req, err := client.ByExternalCloudProviderTypePreparer(ctx, externalCloudProviderType, externalCloudProviderID, filter, expand, skiptoken, top) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.DimensionsClient", "ByExternalCloudProviderType", nil, "Failure preparing request") + return + } + + resp, err := client.ByExternalCloudProviderTypeSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "costmanagement.DimensionsClient", "ByExternalCloudProviderType", resp, "Failure sending request") + return + } + + result, err = client.ByExternalCloudProviderTypeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.DimensionsClient", "ByExternalCloudProviderType", resp, "Failure responding to request") + return + } + + return +} + +// ByExternalCloudProviderTypePreparer prepares the ByExternalCloudProviderType request. +func (client DimensionsClient) ByExternalCloudProviderTypePreparer(ctx context.Context, externalCloudProviderType ExternalCloudProviderType, externalCloudProviderID string, filter string, expand string, skiptoken string, top *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "externalCloudProviderId": autorest.Encode("path", externalCloudProviderID), + "externalCloudProviderType": autorest.Encode("path", externalCloudProviderType), + } + + const APIVersion = "2020-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + if len(skiptoken) > 0 { + queryParameters["$skiptoken"] = autorest.Encode("query", skiptoken) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.CostManagement/{externalCloudProviderType}/{externalCloudProviderId}/dimensions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ByExternalCloudProviderTypeSender sends the ByExternalCloudProviderType request. The method will close the +// http.Response Body if it receives an error. +func (client DimensionsClient) ByExternalCloudProviderTypeSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ByExternalCloudProviderTypeResponder handles the response to the ByExternalCloudProviderType request. The method always +// closes the http.Response Body. +func (client DimensionsClient) ByExternalCloudProviderTypeResponder(resp *http.Response) (result DimensionsListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists the dimensions by the defined scope. +// Parameters: +// scope - the scope associated with dimension operations. This includes '/subscriptions/{subscriptionId}/' for +// subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup +// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department +// scope, +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' +// for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId}' for +// Management Group scope, +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for +// billingProfile scope, +// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' +// for invoiceSection scope, and +// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for +// partners. +// filter - may be used to filter dimensions by properties/category, properties/usageStart, +// properties/usageEnd. Supported operators are 'eq','lt', 'gt', 'le', 'ge'. +// expand - may be used to expand the properties/data within a dimension category. By default, data is not +// included when listing dimensions. +// skiptoken - skiptoken is only used if a previous operation returned a partial result. If a previous response +// contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that +// specifies a starting point to use for subsequent calls. +// top - may be used to limit the number of results to the most recent N dimension data. +func (client DimensionsClient) List(ctx context.Context, scope string, filter string, expand string, skiptoken string, top *int32) (result DimensionsListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DimensionsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMaximum, Rule: int64(1000), Chain: nil}, + {Target: "top", Name: validation.InclusiveMinimum, Rule: int64(1), Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("costmanagement.DimensionsClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, scope, filter, expand, skiptoken, top) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.DimensionsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "costmanagement.DimensionsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.DimensionsClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client DimensionsClient) ListPreparer(ctx context.Context, scope string, filter string, expand string, skiptoken string, top *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "scope": scope, + } + + const APIVersion = "2020-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + if len(skiptoken) > 0 { + queryParameters["$skiptoken"] = autorest.Encode("query", skiptoken) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.CostManagement/dimensions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client DimensionsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client DimensionsClient) ListResponder(resp *http.Response) (result DimensionsListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/costmanagement/mgmt/2021-01-01/costmanagement/enums.go b/services/costmanagement/mgmt/2021-01-01/costmanagement/enums.go new file mode 100644 index 000000000000..5b88c6dba9e5 --- /dev/null +++ b/services/costmanagement/mgmt/2021-01-01/costmanagement/enums.go @@ -0,0 +1,586 @@ +package costmanagement + +// 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. + +// AccumulatedType enumerates the values for accumulated type. +type AccumulatedType string + +const ( + // False ... + False AccumulatedType = "false" + // True ... + True AccumulatedType = "true" +) + +// PossibleAccumulatedTypeValues returns an array of possible values for the AccumulatedType const type. +func PossibleAccumulatedTypeValues() []AccumulatedType { + return []AccumulatedType{False, True} +} + +// AlertCategory enumerates the values for alert category. +type AlertCategory string + +const ( + // Billing ... + Billing AlertCategory = "Billing" + // Cost ... + Cost AlertCategory = "Cost" + // System ... + System AlertCategory = "System" + // Usage ... + Usage AlertCategory = "Usage" +) + +// PossibleAlertCategoryValues returns an array of possible values for the AlertCategory const type. +func PossibleAlertCategoryValues() []AlertCategory { + return []AlertCategory{Billing, Cost, System, Usage} +} + +// AlertCriteria enumerates the values for alert criteria. +type AlertCriteria string + +const ( + // CostThresholdExceeded ... + CostThresholdExceeded AlertCriteria = "CostThresholdExceeded" + // CreditThresholdApproaching ... + CreditThresholdApproaching AlertCriteria = "CreditThresholdApproaching" + // CreditThresholdReached ... + CreditThresholdReached AlertCriteria = "CreditThresholdReached" + // CrossCloudCollectionError ... + CrossCloudCollectionError AlertCriteria = "CrossCloudCollectionError" + // CrossCloudNewDataAvailable ... + CrossCloudNewDataAvailable AlertCriteria = "CrossCloudNewDataAvailable" + // ForecastCostThresholdExceeded ... + ForecastCostThresholdExceeded AlertCriteria = "ForecastCostThresholdExceeded" + // ForecastUsageThresholdExceeded ... + ForecastUsageThresholdExceeded AlertCriteria = "ForecastUsageThresholdExceeded" + // GeneralThresholdError ... + GeneralThresholdError AlertCriteria = "GeneralThresholdError" + // InvoiceDueDateApproaching ... + InvoiceDueDateApproaching AlertCriteria = "InvoiceDueDateApproaching" + // InvoiceDueDateReached ... + InvoiceDueDateReached AlertCriteria = "InvoiceDueDateReached" + // MultiCurrency ... + MultiCurrency AlertCriteria = "MultiCurrency" + // QuotaThresholdApproaching ... + QuotaThresholdApproaching AlertCriteria = "QuotaThresholdApproaching" + // QuotaThresholdReached ... + QuotaThresholdReached AlertCriteria = "QuotaThresholdReached" + // UsageThresholdExceeded ... + UsageThresholdExceeded AlertCriteria = "UsageThresholdExceeded" +) + +// PossibleAlertCriteriaValues returns an array of possible values for the AlertCriteria const type. +func PossibleAlertCriteriaValues() []AlertCriteria { + return []AlertCriteria{CostThresholdExceeded, CreditThresholdApproaching, CreditThresholdReached, CrossCloudCollectionError, CrossCloudNewDataAvailable, ForecastCostThresholdExceeded, ForecastUsageThresholdExceeded, GeneralThresholdError, InvoiceDueDateApproaching, InvoiceDueDateReached, MultiCurrency, QuotaThresholdApproaching, QuotaThresholdReached, UsageThresholdExceeded} +} + +// AlertOperator enumerates the values for alert operator. +type AlertOperator string + +const ( + // EqualTo ... + EqualTo AlertOperator = "EqualTo" + // GreaterThan ... + GreaterThan AlertOperator = "GreaterThan" + // GreaterThanOrEqualTo ... + GreaterThanOrEqualTo AlertOperator = "GreaterThanOrEqualTo" + // LessThan ... + LessThan AlertOperator = "LessThan" + // LessThanOrEqualTo ... + LessThanOrEqualTo AlertOperator = "LessThanOrEqualTo" + // None ... + None AlertOperator = "None" +) + +// PossibleAlertOperatorValues returns an array of possible values for the AlertOperator const type. +func PossibleAlertOperatorValues() []AlertOperator { + return []AlertOperator{EqualTo, GreaterThan, GreaterThanOrEqualTo, LessThan, LessThanOrEqualTo, None} +} + +// AlertSource enumerates the values for alert source. +type AlertSource string + +const ( + // Preset ... + Preset AlertSource = "Preset" + // User ... + User AlertSource = "User" +) + +// PossibleAlertSourceValues returns an array of possible values for the AlertSource const type. +func PossibleAlertSourceValues() []AlertSource { + return []AlertSource{Preset, User} +} + +// AlertStatus enumerates the values for alert status. +type AlertStatus string + +const ( + // AlertStatusActive ... + AlertStatusActive AlertStatus = "Active" + // AlertStatusDismissed ... + AlertStatusDismissed AlertStatus = "Dismissed" + // AlertStatusNone ... + AlertStatusNone AlertStatus = "None" + // AlertStatusOverridden ... + AlertStatusOverridden AlertStatus = "Overridden" + // AlertStatusResolved ... + AlertStatusResolved AlertStatus = "Resolved" +) + +// PossibleAlertStatusValues returns an array of possible values for the AlertStatus const type. +func PossibleAlertStatusValues() []AlertStatus { + return []AlertStatus{AlertStatusActive, AlertStatusDismissed, AlertStatusNone, AlertStatusOverridden, AlertStatusResolved} +} + +// AlertTimeGrainType enumerates the values for alert time grain type. +type AlertTimeGrainType string + +const ( + // AlertTimeGrainTypeAnnually ... + AlertTimeGrainTypeAnnually AlertTimeGrainType = "Annually" + // AlertTimeGrainTypeBillingAnnual ... + AlertTimeGrainTypeBillingAnnual AlertTimeGrainType = "BillingAnnual" + // AlertTimeGrainTypeBillingMonth ... + AlertTimeGrainTypeBillingMonth AlertTimeGrainType = "BillingMonth" + // AlertTimeGrainTypeBillingQuarter ... + AlertTimeGrainTypeBillingQuarter AlertTimeGrainType = "BillingQuarter" + // AlertTimeGrainTypeMonthly ... + AlertTimeGrainTypeMonthly AlertTimeGrainType = "Monthly" + // AlertTimeGrainTypeNone ... + AlertTimeGrainTypeNone AlertTimeGrainType = "None" + // AlertTimeGrainTypeQuarterly ... + AlertTimeGrainTypeQuarterly AlertTimeGrainType = "Quarterly" +) + +// PossibleAlertTimeGrainTypeValues returns an array of possible values for the AlertTimeGrainType const type. +func PossibleAlertTimeGrainTypeValues() []AlertTimeGrainType { + return []AlertTimeGrainType{AlertTimeGrainTypeAnnually, AlertTimeGrainTypeBillingAnnual, AlertTimeGrainTypeBillingMonth, AlertTimeGrainTypeBillingQuarter, AlertTimeGrainTypeMonthly, AlertTimeGrainTypeNone, AlertTimeGrainTypeQuarterly} +} + +// AlertType enumerates the values for alert type. +type AlertType string + +const ( + // Budget ... + Budget AlertType = "Budget" + // BudgetForecast ... + BudgetForecast AlertType = "BudgetForecast" + // Credit ... + Credit AlertType = "Credit" + // General ... + General AlertType = "General" + // Invoice ... + Invoice AlertType = "Invoice" + // Quota ... + Quota AlertType = "Quota" + // XCloud ... + XCloud AlertType = "xCloud" +) + +// PossibleAlertTypeValues returns an array of possible values for the AlertType const type. +func PossibleAlertTypeValues() []AlertType { + return []AlertType{Budget, BudgetForecast, Credit, General, Invoice, Quota, XCloud} +} + +// ChartType enumerates the values for chart type. +type ChartType string + +const ( + // Area ... + Area ChartType = "Area" + // GroupedColumn ... + GroupedColumn ChartType = "GroupedColumn" + // Line ... + Line ChartType = "Line" + // StackedColumn ... + StackedColumn ChartType = "StackedColumn" + // Table ... + Table ChartType = "Table" +) + +// PossibleChartTypeValues returns an array of possible values for the ChartType const type. +func PossibleChartTypeValues() []ChartType { + return []ChartType{Area, GroupedColumn, Line, StackedColumn, Table} +} + +// Direction enumerates the values for direction. +type Direction string + +const ( + // Ascending ... + Ascending Direction = "Ascending" + // Descending ... + Descending Direction = "Descending" +) + +// PossibleDirectionValues returns an array of possible values for the Direction const type. +func PossibleDirectionValues() []Direction { + return []Direction{Ascending, Descending} +} + +// ExecutionStatus enumerates the values for execution status. +type ExecutionStatus string + +const ( + // Completed ... + Completed ExecutionStatus = "Completed" + // DataNotAvailable ... + DataNotAvailable ExecutionStatus = "DataNotAvailable" + // Failed ... + Failed ExecutionStatus = "Failed" + // InProgress ... + InProgress ExecutionStatus = "InProgress" + // NewDataNotAvailable ... + NewDataNotAvailable ExecutionStatus = "NewDataNotAvailable" + // Queued ... + Queued ExecutionStatus = "Queued" + // Timeout ... + Timeout ExecutionStatus = "Timeout" +) + +// PossibleExecutionStatusValues returns an array of possible values for the ExecutionStatus const type. +func PossibleExecutionStatusValues() []ExecutionStatus { + return []ExecutionStatus{Completed, DataNotAvailable, Failed, InProgress, NewDataNotAvailable, Queued, Timeout} +} + +// ExecutionType enumerates the values for execution type. +type ExecutionType string + +const ( + // OnDemand ... + OnDemand ExecutionType = "OnDemand" + // Scheduled ... + Scheduled ExecutionType = "Scheduled" +) + +// PossibleExecutionTypeValues returns an array of possible values for the ExecutionType const type. +func PossibleExecutionTypeValues() []ExecutionType { + return []ExecutionType{OnDemand, Scheduled} +} + +// ExportType enumerates the values for export type. +type ExportType string + +const ( + // ExportTypeActualCost ... + ExportTypeActualCost ExportType = "ActualCost" + // ExportTypeAmortizedCost ... + ExportTypeAmortizedCost ExportType = "AmortizedCost" + // ExportTypeUsage ... + ExportTypeUsage ExportType = "Usage" +) + +// PossibleExportTypeValues returns an array of possible values for the ExportType const type. +func PossibleExportTypeValues() []ExportType { + return []ExportType{ExportTypeActualCost, ExportTypeAmortizedCost, ExportTypeUsage} +} + +// ExternalCloudProviderType enumerates the values for external cloud provider type. +type ExternalCloudProviderType string + +const ( + // ExternalBillingAccounts ... + ExternalBillingAccounts ExternalCloudProviderType = "externalBillingAccounts" + // ExternalSubscriptions ... + ExternalSubscriptions ExternalCloudProviderType = "externalSubscriptions" +) + +// PossibleExternalCloudProviderTypeValues returns an array of possible values for the ExternalCloudProviderType const type. +func PossibleExternalCloudProviderTypeValues() []ExternalCloudProviderType { + return []ExternalCloudProviderType{ExternalBillingAccounts, ExternalSubscriptions} +} + +// ForecastTimeframeType enumerates the values for forecast timeframe type. +type ForecastTimeframeType string + +const ( + // BillingMonthToDate ... + BillingMonthToDate ForecastTimeframeType = "BillingMonthToDate" + // Custom ... + Custom ForecastTimeframeType = "Custom" + // MonthToDate ... + MonthToDate ForecastTimeframeType = "MonthToDate" + // TheLastBillingMonth ... + TheLastBillingMonth ForecastTimeframeType = "TheLastBillingMonth" + // TheLastMonth ... + TheLastMonth ForecastTimeframeType = "TheLastMonth" + // WeekToDate ... + WeekToDate ForecastTimeframeType = "WeekToDate" +) + +// PossibleForecastTimeframeTypeValues returns an array of possible values for the ForecastTimeframeType const type. +func PossibleForecastTimeframeTypeValues() []ForecastTimeframeType { + return []ForecastTimeframeType{BillingMonthToDate, Custom, MonthToDate, TheLastBillingMonth, TheLastMonth, WeekToDate} +} + +// ForecastType enumerates the values for forecast type. +type ForecastType string + +const ( + // ForecastTypeActualCost ... + ForecastTypeActualCost ForecastType = "ActualCost" + // ForecastTypeAmortizedCost ... + ForecastTypeAmortizedCost ForecastType = "AmortizedCost" + // ForecastTypeUsage ... + ForecastTypeUsage ForecastType = "Usage" +) + +// PossibleForecastTypeValues returns an array of possible values for the ForecastType const type. +func PossibleForecastTypeValues() []ForecastType { + return []ForecastType{ForecastTypeActualCost, ForecastTypeAmortizedCost, ForecastTypeUsage} +} + +// FormatType enumerates the values for format type. +type FormatType string + +const ( + // Csv ... + Csv FormatType = "Csv" +) + +// PossibleFormatTypeValues returns an array of possible values for the FormatType const type. +func PossibleFormatTypeValues() []FormatType { + return []FormatType{Csv} +} + +// GenerateDetailedCostReportMetricType enumerates the values for generate detailed cost report metric type. +type GenerateDetailedCostReportMetricType string + +const ( + // ActualCost ... + ActualCost GenerateDetailedCostReportMetricType = "ActualCost" + // AmortizedCost ... + AmortizedCost GenerateDetailedCostReportMetricType = "AmortizedCost" +) + +// PossibleGenerateDetailedCostReportMetricTypeValues returns an array of possible values for the GenerateDetailedCostReportMetricType const type. +func PossibleGenerateDetailedCostReportMetricTypeValues() []GenerateDetailedCostReportMetricType { + return []GenerateDetailedCostReportMetricType{ActualCost, AmortizedCost} +} + +// GranularityType enumerates the values for granularity type. +type GranularityType string + +const ( + // Daily ... + Daily GranularityType = "Daily" +) + +// PossibleGranularityTypeValues returns an array of possible values for the GranularityType const type. +func PossibleGranularityTypeValues() []GranularityType { + return []GranularityType{Daily} +} + +// KpiTypeType enumerates the values for kpi type type. +type KpiTypeType string + +const ( + // KpiTypeTypeBudget ... + KpiTypeTypeBudget KpiTypeType = "Budget" + // KpiTypeTypeForecast ... + KpiTypeTypeForecast KpiTypeType = "Forecast" +) + +// PossibleKpiTypeTypeValues returns an array of possible values for the KpiTypeType const type. +func PossibleKpiTypeTypeValues() []KpiTypeType { + return []KpiTypeType{KpiTypeTypeBudget, KpiTypeTypeForecast} +} + +// MetricType enumerates the values for metric type. +type MetricType string + +const ( + // MetricTypeActualCost ... + MetricTypeActualCost MetricType = "ActualCost" + // MetricTypeAHUB ... + MetricTypeAHUB MetricType = "AHUB" + // MetricTypeAmortizedCost ... + MetricTypeAmortizedCost MetricType = "AmortizedCost" +) + +// PossibleMetricTypeValues returns an array of possible values for the MetricType const type. +func PossibleMetricTypeValues() []MetricType { + return []MetricType{MetricTypeActualCost, MetricTypeAHUB, MetricTypeAmortizedCost} +} + +// OperationStatusType enumerates the values for operation status type. +type OperationStatusType string + +const ( + // OperationStatusTypeCompleted ... + OperationStatusTypeCompleted OperationStatusType = "Completed" + // OperationStatusTypeFailed ... + OperationStatusTypeFailed OperationStatusType = "Failed" + // OperationStatusTypeInProgress ... + OperationStatusTypeInProgress OperationStatusType = "InProgress" + // OperationStatusTypeNoDataFound ... + OperationStatusTypeNoDataFound OperationStatusType = "NoDataFound" + // OperationStatusTypeQueued ... + OperationStatusTypeQueued OperationStatusType = "Queued" + // OperationStatusTypeReadyToDownload ... + OperationStatusTypeReadyToDownload OperationStatusType = "ReadyToDownload" + // OperationStatusTypeTimedOut ... + OperationStatusTypeTimedOut OperationStatusType = "TimedOut" +) + +// PossibleOperationStatusTypeValues returns an array of possible values for the OperationStatusType const type. +func PossibleOperationStatusTypeValues() []OperationStatusType { + return []OperationStatusType{OperationStatusTypeCompleted, OperationStatusTypeFailed, OperationStatusTypeInProgress, OperationStatusTypeNoDataFound, OperationStatusTypeQueued, OperationStatusTypeReadyToDownload, OperationStatusTypeTimedOut} +} + +// OperatorType enumerates the values for operator type. +type OperatorType string + +const ( + // Contains ... + Contains OperatorType = "Contains" + // In ... + In OperatorType = "In" +) + +// PossibleOperatorTypeValues returns an array of possible values for the OperatorType const type. +func PossibleOperatorTypeValues() []OperatorType { + return []OperatorType{Contains, In} +} + +// PivotTypeType enumerates the values for pivot type type. +type PivotTypeType string + +const ( + // PivotTypeTypeDimension ... + PivotTypeTypeDimension PivotTypeType = "Dimension" + // PivotTypeTypeTagKey ... + PivotTypeTypeTagKey PivotTypeType = "TagKey" +) + +// PossiblePivotTypeTypeValues returns an array of possible values for the PivotTypeType const type. +func PossiblePivotTypeTypeValues() []PivotTypeType { + return []PivotTypeType{PivotTypeTypeDimension, PivotTypeTypeTagKey} +} + +// QueryColumnType enumerates the values for query column type. +type QueryColumnType string + +const ( + // QueryColumnTypeDimension ... + QueryColumnTypeDimension QueryColumnType = "Dimension" + // QueryColumnTypeTag ... + QueryColumnTypeTag QueryColumnType = "Tag" +) + +// PossibleQueryColumnTypeValues returns an array of possible values for the QueryColumnType const type. +func PossibleQueryColumnTypeValues() []QueryColumnType { + return []QueryColumnType{QueryColumnTypeDimension, QueryColumnTypeTag} +} + +// RecurrenceType enumerates the values for recurrence type. +type RecurrenceType string + +const ( + // RecurrenceTypeAnnually ... + RecurrenceTypeAnnually RecurrenceType = "Annually" + // RecurrenceTypeDaily ... + RecurrenceTypeDaily RecurrenceType = "Daily" + // RecurrenceTypeMonthly ... + RecurrenceTypeMonthly RecurrenceType = "Monthly" + // RecurrenceTypeWeekly ... + RecurrenceTypeWeekly RecurrenceType = "Weekly" +) + +// PossibleRecurrenceTypeValues returns an array of possible values for the RecurrenceType const type. +func PossibleRecurrenceTypeValues() []RecurrenceType { + return []RecurrenceType{RecurrenceTypeAnnually, RecurrenceTypeDaily, RecurrenceTypeMonthly, RecurrenceTypeWeekly} +} + +// ReportConfigColumnType enumerates the values for report config column type. +type ReportConfigColumnType string + +const ( + // ReportConfigColumnTypeDimension ... + ReportConfigColumnTypeDimension ReportConfigColumnType = "Dimension" + // ReportConfigColumnTypeTag ... + ReportConfigColumnTypeTag ReportConfigColumnType = "Tag" +) + +// PossibleReportConfigColumnTypeValues returns an array of possible values for the ReportConfigColumnType const type. +func PossibleReportConfigColumnTypeValues() []ReportConfigColumnType { + return []ReportConfigColumnType{ReportConfigColumnTypeDimension, ReportConfigColumnTypeTag} +} + +// ReportGranularityType enumerates the values for report granularity type. +type ReportGranularityType string + +const ( + // ReportGranularityTypeDaily ... + ReportGranularityTypeDaily ReportGranularityType = "Daily" + // ReportGranularityTypeMonthly ... + ReportGranularityTypeMonthly ReportGranularityType = "Monthly" +) + +// PossibleReportGranularityTypeValues returns an array of possible values for the ReportGranularityType const type. +func PossibleReportGranularityTypeValues() []ReportGranularityType { + return []ReportGranularityType{ReportGranularityTypeDaily, ReportGranularityTypeMonthly} +} + +// ReportTimeframeType enumerates the values for report timeframe type. +type ReportTimeframeType string + +const ( + // ReportTimeframeTypeCustom ... + ReportTimeframeTypeCustom ReportTimeframeType = "Custom" + // ReportTimeframeTypeMonthToDate ... + ReportTimeframeTypeMonthToDate ReportTimeframeType = "MonthToDate" + // ReportTimeframeTypeWeekToDate ... + ReportTimeframeTypeWeekToDate ReportTimeframeType = "WeekToDate" + // ReportTimeframeTypeYearToDate ... + ReportTimeframeTypeYearToDate ReportTimeframeType = "YearToDate" +) + +// PossibleReportTimeframeTypeValues returns an array of possible values for the ReportTimeframeType const type. +func PossibleReportTimeframeTypeValues() []ReportTimeframeType { + return []ReportTimeframeType{ReportTimeframeTypeCustom, ReportTimeframeTypeMonthToDate, ReportTimeframeTypeWeekToDate, ReportTimeframeTypeYearToDate} +} + +// StatusType enumerates the values for status type. +type StatusType string + +const ( + // Active ... + Active StatusType = "Active" + // Inactive ... + Inactive StatusType = "Inactive" +) + +// PossibleStatusTypeValues returns an array of possible values for the StatusType const type. +func PossibleStatusTypeValues() []StatusType { + return []StatusType{Active, Inactive} +} + +// TimeframeType enumerates the values for timeframe type. +type TimeframeType string + +const ( + // TimeframeTypeBillingMonthToDate ... + TimeframeTypeBillingMonthToDate TimeframeType = "BillingMonthToDate" + // TimeframeTypeCustom ... + TimeframeTypeCustom TimeframeType = "Custom" + // TimeframeTypeMonthToDate ... + TimeframeTypeMonthToDate TimeframeType = "MonthToDate" + // TimeframeTypeTheLastBillingMonth ... + TimeframeTypeTheLastBillingMonth TimeframeType = "TheLastBillingMonth" + // TimeframeTypeTheLastMonth ... + TimeframeTypeTheLastMonth TimeframeType = "TheLastMonth" + // TimeframeTypeWeekToDate ... + TimeframeTypeWeekToDate TimeframeType = "WeekToDate" +) + +// PossibleTimeframeTypeValues returns an array of possible values for the TimeframeType const type. +func PossibleTimeframeTypeValues() []TimeframeType { + return []TimeframeType{TimeframeTypeBillingMonthToDate, TimeframeTypeCustom, TimeframeTypeMonthToDate, TimeframeTypeTheLastBillingMonth, TimeframeTypeTheLastMonth, TimeframeTypeWeekToDate} +} diff --git a/services/costmanagement/mgmt/2021-01-01/costmanagement/exports.go b/services/costmanagement/mgmt/2021-01-01/costmanagement/exports.go new file mode 100644 index 000000000000..6e9e5acbe74f --- /dev/null +++ b/services/costmanagement/mgmt/2021-01-01/costmanagement/exports.go @@ -0,0 +1,581 @@ +package costmanagement + +// 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ExportsClient is the client for the Exports methods of the Costmanagement service. +type ExportsClient struct { + BaseClient +} + +// NewExportsClient creates an instance of the ExportsClient client. +func NewExportsClient(subscriptionID string) ExportsClient { + return NewExportsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewExportsClientWithBaseURI creates an instance of the ExportsClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewExportsClientWithBaseURI(baseURI string, subscriptionID string) ExportsClient { + return ExportsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// 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. +// Parameters: +// scope - the scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for +// subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup +// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department +// scope, +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' +// for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId} for +// Management Group scope, +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for +// billingProfile scope, +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' +// for invoiceSection scope, and +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for +// partners. +// exportName - export Name. +// parameters - parameters supplied to the CreateOrUpdate Export operation. +func (client ExportsClient) CreateOrUpdate(ctx context.Context, scope string, exportName string, parameters Export) (result Export, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExportsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ExportProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ExportProperties.Schedule", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ExportProperties.Schedule.RecurrencePeriod", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ExportProperties.Schedule.RecurrencePeriod.From", Name: validation.Null, Rule: true, Chain: nil}}}, + }}, + }}}}}); err != nil { + return result, validation.NewError("costmanagement.ExportsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, scope, exportName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ExportsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "costmanagement.ExportsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ExportsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ExportsClient) CreateOrUpdatePreparer(ctx context.Context, scope string, exportName string, parameters Export) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "exportName": autorest.Encode("path", exportName), + "scope": scope, + } + + const APIVersion = "2021-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.CostManagement/exports/{exportName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ExportsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ExportsClient) CreateOrUpdateResponder(resp *http.Response) (result Export, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete the operation to delete a export. +// Parameters: +// scope - the scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for +// subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup +// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department +// scope, +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' +// for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId} for +// Management Group scope, +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for +// billingProfile scope, +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' +// for invoiceSection scope, and +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for +// partners. +// exportName - export Name. +func (client ExportsClient) Delete(ctx context.Context, scope string, exportName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExportsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, scope, exportName) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ExportsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "costmanagement.ExportsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ExportsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ExportsClient) DeletePreparer(ctx context.Context, scope string, exportName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "exportName": autorest.Encode("path", exportName), + "scope": scope, + } + + const APIVersion = "2021-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.CostManagement/exports/{exportName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ExportsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ExportsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Execute the operation to execute an export. +// Parameters: +// scope - the scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for +// subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup +// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department +// scope, +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' +// for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId} for +// Management Group scope, +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for +// billingProfile scope, +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' +// for invoiceSection scope, and +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for +// partners. +// exportName - export Name. +func (client ExportsClient) Execute(ctx context.Context, scope string, exportName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExportsClient.Execute") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ExecutePreparer(ctx, scope, exportName) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ExportsClient", "Execute", nil, "Failure preparing request") + return + } + + resp, err := client.ExecuteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "costmanagement.ExportsClient", "Execute", resp, "Failure sending request") + return + } + + result, err = client.ExecuteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ExportsClient", "Execute", resp, "Failure responding to request") + return + } + + return +} + +// ExecutePreparer prepares the Execute request. +func (client ExportsClient) ExecutePreparer(ctx context.Context, scope string, exportName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "exportName": autorest.Encode("path", exportName), + "scope": scope, + } + + const APIVersion = "2021-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.CostManagement/exports/{exportName}/run", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ExecuteSender sends the Execute request. The method will close the +// http.Response Body if it receives an error. +func (client ExportsClient) ExecuteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ExecuteResponder handles the response to the Execute request. The method always +// closes the http.Response Body. +func (client ExportsClient) ExecuteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get the operation to get the export for the defined scope by export name. +// Parameters: +// scope - the scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for +// subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup +// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department +// scope, +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' +// for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId} for +// Management Group scope, +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for +// billingProfile scope, +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' +// for invoiceSection scope, and +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for +// partners. +// exportName - export Name. +// expand - may be used to expand the properties within an export. Currently only 'runHistory' is supported and +// will return information for the last 10 executions of the export. +func (client ExportsClient) Get(ctx context.Context, scope string, exportName string, expand string) (result Export, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExportsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, scope, exportName, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ExportsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "costmanagement.ExportsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ExportsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ExportsClient) GetPreparer(ctx context.Context, scope string, exportName string, expand string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "exportName": autorest.Encode("path", exportName), + "scope": scope, + } + + const APIVersion = "2021-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.CostManagement/exports/{exportName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ExportsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ExportsClient) GetResponder(resp *http.Response) (result Export, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetExecutionHistory the operation to get the execution history of an export for the defined scope and export name. +// Parameters: +// scope - the scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for +// subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup +// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department +// scope, +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' +// for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId} for +// Management Group scope, +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for +// billingProfile scope, +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' +// for invoiceSection scope, and +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for +// partners. +// exportName - export Name. +func (client ExportsClient) GetExecutionHistory(ctx context.Context, scope string, exportName string) (result ExportExecutionListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExportsClient.GetExecutionHistory") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetExecutionHistoryPreparer(ctx, scope, exportName) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ExportsClient", "GetExecutionHistory", nil, "Failure preparing request") + return + } + + resp, err := client.GetExecutionHistorySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "costmanagement.ExportsClient", "GetExecutionHistory", resp, "Failure sending request") + return + } + + result, err = client.GetExecutionHistoryResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ExportsClient", "GetExecutionHistory", resp, "Failure responding to request") + return + } + + return +} + +// GetExecutionHistoryPreparer prepares the GetExecutionHistory request. +func (client ExportsClient) GetExecutionHistoryPreparer(ctx context.Context, scope string, exportName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "exportName": autorest.Encode("path", exportName), + "scope": scope, + } + + const APIVersion = "2021-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.CostManagement/exports/{exportName}/runHistory", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetExecutionHistorySender sends the GetExecutionHistory request. The method will close the +// http.Response Body if it receives an error. +func (client ExportsClient) GetExecutionHistorySender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetExecutionHistoryResponder handles the response to the GetExecutionHistory request. The method always +// closes the http.Response Body. +func (client ExportsClient) GetExecutionHistoryResponder(resp *http.Response) (result ExportExecutionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List the operation to list all exports at the given scope. +// Parameters: +// scope - the scope associated with export operations. This includes '/subscriptions/{subscriptionId}/' for +// subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup +// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department +// scope, +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' +// for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId} for +// Management Group scope, +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for +// billingProfile scope, +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' +// for invoiceSection scope, and +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for +// partners. +// expand - may be used to expand the properties within an export. Currently only 'runHistory' is supported and +// will return information for the last execution of each export. +func (client ExportsClient) List(ctx context.Context, scope string, expand string) (result ExportListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ExportsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx, scope, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ExportsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "costmanagement.ExportsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ExportsClient", "List", resp, "Failure responding to request") + return + } + + return +} + +// ListPreparer prepares the List request. +func (client ExportsClient) ListPreparer(ctx context.Context, scope string, expand string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "scope": scope, + } + + const APIVersion = "2021-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.CostManagement/exports", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ExportsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ExportsClient) ListResponder(resp *http.Response) (result ExportListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/costmanagement/mgmt/2021-01-01/costmanagement/forecast.go b/services/costmanagement/mgmt/2021-01-01/costmanagement/forecast.go new file mode 100644 index 000000000000..46fb762aa5d9 --- /dev/null +++ b/services/costmanagement/mgmt/2021-01-01/costmanagement/forecast.go @@ -0,0 +1,274 @@ +package costmanagement + +// 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ForecastClient is the client for the Forecast methods of the Costmanagement service. +type ForecastClient struct { + BaseClient +} + +// NewForecastClient creates an instance of the ForecastClient client. +func NewForecastClient(subscriptionID string) ForecastClient { + return NewForecastClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewForecastClientWithBaseURI creates an instance of the ForecastClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewForecastClientWithBaseURI(baseURI string, subscriptionID string) ForecastClient { + return ForecastClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ExternalCloudProviderUsage lists the forecast charges for external cloud provider type defined. +// Parameters: +// externalCloudProviderType - the external cloud provider type associated with dimension/query operations. +// This includes 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated +// account. +// externalCloudProviderID - this can be '{externalSubscriptionId}' for linked account or +// '{externalBillingAccountId}' for consolidated account used with dimension/query operations. +// parameters - parameters supplied to the CreateOrUpdate Forecast Config operation. +// filter - may be used to filter forecasts by properties/usageDate (Utc time), properties/chargeType or +// properties/grain. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support +// 'ne', 'or', or 'not'. +func (client ForecastClient) ExternalCloudProviderUsage(ctx context.Context, externalCloudProviderType ExternalCloudProviderType, externalCloudProviderID string, parameters ForecastDefinition, filter string) (result QueryResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ForecastClient.ExternalCloudProviderUsage") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.TimePeriod", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.TimePeriod.From", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.TimePeriod.To", Name: validation.Null, Rule: true, Chain: nil}, + }}, + {Target: "parameters.Dataset", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.And", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.And", Name: validation.MinItems, Rule: 2, Chain: nil}}}, + {Target: "parameters.Dataset.Filter.Or", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Or", Name: validation.MinItems, Rule: 2, Chain: nil}}}, + {Target: "parameters.Dataset.Filter.Not", Name: validation.Null, Rule: false, Chain: nil}, + {Target: "parameters.Dataset.Filter.Dimension", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Dimension.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Dataset.Filter.Dimension.Operator", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Dataset.Filter.Dimension.Values", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Dimension.Values", Name: validation.MinItems, Rule: 1, Chain: nil}}}, + }}, + {Target: "parameters.Dataset.Filter.Tag", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Tag.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Dataset.Filter.Tag.Operator", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Dataset.Filter.Tag.Values", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Tag.Values", Name: validation.MinItems, Rule: 1, Chain: nil}}}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewError("costmanagement.ForecastClient", "ExternalCloudProviderUsage", err.Error()) + } + + req, err := client.ExternalCloudProviderUsagePreparer(ctx, externalCloudProviderType, externalCloudProviderID, parameters, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ForecastClient", "ExternalCloudProviderUsage", nil, "Failure preparing request") + return + } + + resp, err := client.ExternalCloudProviderUsageSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "costmanagement.ForecastClient", "ExternalCloudProviderUsage", resp, "Failure sending request") + return + } + + result, err = client.ExternalCloudProviderUsageResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ForecastClient", "ExternalCloudProviderUsage", resp, "Failure responding to request") + return + } + + return +} + +// ExternalCloudProviderUsagePreparer prepares the ExternalCloudProviderUsage request. +func (client ForecastClient) ExternalCloudProviderUsagePreparer(ctx context.Context, externalCloudProviderType ExternalCloudProviderType, externalCloudProviderID string, parameters ForecastDefinition, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "externalCloudProviderId": autorest.Encode("path", externalCloudProviderID), + "externalCloudProviderType": autorest.Encode("path", externalCloudProviderType), + } + + const APIVersion = "2020-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.CostManagement/{externalCloudProviderType}/{externalCloudProviderId}/forecast", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ExternalCloudProviderUsageSender sends the ExternalCloudProviderUsage request. The method will close the +// http.Response Body if it receives an error. +func (client ForecastClient) ExternalCloudProviderUsageSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ExternalCloudProviderUsageResponder handles the response to the ExternalCloudProviderUsage request. The method always +// closes the http.Response Body. +func (client ForecastClient) ExternalCloudProviderUsageResponder(resp *http.Response) (result QueryResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Usage lists the forecast charges for scope defined. +// Parameters: +// scope - the scope associated with forecast operations. This includes '/subscriptions/{subscriptionId}/' for +// subscription scope, '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup +// scope, '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department +// scope, +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' +// for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId} for +// Management Group scope, +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for +// billingProfile scope, +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' +// for invoiceSection scope, and +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for +// partners. +// parameters - parameters supplied to the CreateOrUpdate Forecast Config operation. +// filter - may be used to filter forecasts by properties/usageDate (Utc time), properties/chargeType or +// properties/grain. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. It does not currently support +// 'ne', 'or', or 'not'. +func (client ForecastClient) Usage(ctx context.Context, scope string, parameters ForecastDefinition, filter string) (result QueryResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ForecastClient.Usage") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.TimePeriod", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.TimePeriod.From", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.TimePeriod.To", Name: validation.Null, Rule: true, Chain: nil}, + }}, + {Target: "parameters.Dataset", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.And", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.And", Name: validation.MinItems, Rule: 2, Chain: nil}}}, + {Target: "parameters.Dataset.Filter.Or", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Or", Name: validation.MinItems, Rule: 2, Chain: nil}}}, + {Target: "parameters.Dataset.Filter.Not", Name: validation.Null, Rule: false, Chain: nil}, + {Target: "parameters.Dataset.Filter.Dimension", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Dimension.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Dataset.Filter.Dimension.Operator", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Dataset.Filter.Dimension.Values", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Dimension.Values", Name: validation.MinItems, Rule: 1, Chain: nil}}}, + }}, + {Target: "parameters.Dataset.Filter.Tag", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Tag.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Dataset.Filter.Tag.Operator", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Dataset.Filter.Tag.Values", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Tag.Values", Name: validation.MinItems, Rule: 1, Chain: nil}}}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewError("costmanagement.ForecastClient", "Usage", err.Error()) + } + + req, err := client.UsagePreparer(ctx, scope, parameters, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ForecastClient", "Usage", nil, "Failure preparing request") + return + } + + resp, err := client.UsageSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "costmanagement.ForecastClient", "Usage", resp, "Failure sending request") + return + } + + result, err = client.UsageResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ForecastClient", "Usage", resp, "Failure responding to request") + return + } + + return +} + +// UsagePreparer prepares the Usage request. +func (client ForecastClient) UsagePreparer(ctx context.Context, scope string, parameters ForecastDefinition, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "scope": scope, + } + + const APIVersion = "2020-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.CostManagement/forecast", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UsageSender sends the Usage request. The method will close the +// http.Response Body if it receives an error. +func (client ForecastClient) UsageSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// UsageResponder handles the response to the Usage request. The method always +// closes the http.Response Body. +func (client ForecastClient) UsageResponder(resp *http.Response) (result QueryResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/costmanagement/mgmt/2021-01-01/costmanagement/generatedetailedcostreport.go b/services/costmanagement/mgmt/2021-01-01/costmanagement/generatedetailedcostreport.go new file mode 100644 index 000000000000..b39f0924ceab --- /dev/null +++ b/services/costmanagement/mgmt/2021-01-01/costmanagement/generatedetailedcostreport.go @@ -0,0 +1,136 @@ +package costmanagement + +// 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// GenerateDetailedCostReportClient is the client for the GenerateDetailedCostReport methods of the Costmanagement +// service. +type GenerateDetailedCostReportClient struct { + BaseClient +} + +// NewGenerateDetailedCostReportClient creates an instance of the GenerateDetailedCostReportClient client. +func NewGenerateDetailedCostReportClient(subscriptionID string) GenerateDetailedCostReportClient { + return NewGenerateDetailedCostReportClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewGenerateDetailedCostReportClientWithBaseURI creates an instance of the GenerateDetailedCostReportClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewGenerateDetailedCostReportClientWithBaseURI(baseURI string, subscriptionID string) GenerateDetailedCostReportClient { + return GenerateDetailedCostReportClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOperation generates the detailed cost report for provided date range, billing period(Only enterprise +// customers) or Invoice Id asynchronously at a certain scope. Call returns a 202 with header +// Azure-Consumption-AsyncOperation providing a link to the operation created. A call on the operation will provide the +// status and if the operation is completed the blob file where generated detailed cost report is being stored. +// Parameters: +// 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 detailed cost report operation. +func (client GenerateDetailedCostReportClient) CreateOperation(ctx context.Context, scope string, parameters GenerateDetailedCostReportDefinition) (result GenerateDetailedCostReportCreateOperationFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GenerateDetailedCostReportClient.CreateOperation") + defer func() { + sc := -1 + if result.FutureAPI != nil && result.FutureAPI.Response() != nil { + sc = result.FutureAPI.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.TimePeriod", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.TimePeriod.Start", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.TimePeriod.End", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("costmanagement.GenerateDetailedCostReportClient", "CreateOperation", err.Error()) + } + + req, err := client.CreateOperationPreparer(ctx, scope, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.GenerateDetailedCostReportClient", "CreateOperation", nil, "Failure preparing request") + return + } + + result, err = client.CreateOperationSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.GenerateDetailedCostReportClient", "CreateOperation", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOperationPreparer prepares the CreateOperation request. +func (client GenerateDetailedCostReportClient) CreateOperationPreparer(ctx context.Context, scope string, parameters GenerateDetailedCostReportDefinition) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "scope": scope, + } + + const APIVersion = "2021-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.CostManagement/generateDetailedCostReport", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOperationSender sends the CreateOperation request. The method will close the +// http.Response Body if it receives an error. +func (client GenerateDetailedCostReportClient) CreateOperationSender(req *http.Request) (future GenerateDetailedCostReportCreateOperationFuture, err error) { + var resp *http.Response + future.FutureAPI = &azure.Future{} + resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + return + } + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = future.result + return +} + +// CreateOperationResponder handles the response to the CreateOperation request. The method always +// closes the http.Response Body. +func (client GenerateDetailedCostReportClient) CreateOperationResponder(resp *http.Response) (result GenerateDetailedCostReportOperationResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/costmanagement/mgmt/2021-01-01/costmanagement/generatedetailedcostreportoperationresults.go b/services/costmanagement/mgmt/2021-01-01/costmanagement/generatedetailedcostreportoperationresults.go new file mode 100644 index 000000000000..37e3cc93f21c --- /dev/null +++ b/services/costmanagement/mgmt/2021-01-01/costmanagement/generatedetailedcostreportoperationresults.go @@ -0,0 +1,121 @@ +package costmanagement + +// 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// GenerateDetailedCostReportOperationResultsClient is the client for the GenerateDetailedCostReportOperationResults +// methods of the Costmanagement service. +type GenerateDetailedCostReportOperationResultsClient struct { + BaseClient +} + +// NewGenerateDetailedCostReportOperationResultsClient creates an instance of the +// GenerateDetailedCostReportOperationResultsClient client. +func NewGenerateDetailedCostReportOperationResultsClient(subscriptionID string) GenerateDetailedCostReportOperationResultsClient { + return NewGenerateDetailedCostReportOperationResultsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewGenerateDetailedCostReportOperationResultsClientWithBaseURI creates an instance of the +// GenerateDetailedCostReportOperationResultsClient client using a custom endpoint. Use this when interacting with an +// Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewGenerateDetailedCostReportOperationResultsClientWithBaseURI(baseURI string, subscriptionID string) GenerateDetailedCostReportOperationResultsClient { + return GenerateDetailedCostReportOperationResultsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get get the result of the specified operation. This link is provided in the GenerateDetailedCostReport creation +// request response header. +// Parameters: +// operationID - the target operation Id. +// 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. +func (client GenerateDetailedCostReportOperationResultsClient) Get(ctx context.Context, operationID string, scope string) (result GenerateDetailedCostReportOperationResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GenerateDetailedCostReportOperationResultsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, operationID, scope) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.GenerateDetailedCostReportOperationResultsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "costmanagement.GenerateDetailedCostReportOperationResultsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.GenerateDetailedCostReportOperationResultsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client GenerateDetailedCostReportOperationResultsClient) GetPreparer(ctx context.Context, operationID string, scope string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "operationId": autorest.Encode("path", operationID), + "scope": scope, + } + + const APIVersion = "2021-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.CostManagement/operationResults/{operationId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client GenerateDetailedCostReportOperationResultsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client GenerateDetailedCostReportOperationResultsClient) GetResponder(resp *http.Response) (result GenerateDetailedCostReportOperationResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/costmanagement/mgmt/2021-01-01/costmanagement/generatedetailedcostreportoperationstatus.go b/services/costmanagement/mgmt/2021-01-01/costmanagement/generatedetailedcostreportoperationstatus.go new file mode 100644 index 000000000000..abfece470723 --- /dev/null +++ b/services/costmanagement/mgmt/2021-01-01/costmanagement/generatedetailedcostreportoperationstatus.go @@ -0,0 +1,121 @@ +package costmanagement + +// 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// GenerateDetailedCostReportOperationStatusClient is the client for the GenerateDetailedCostReportOperationStatus +// methods of the Costmanagement service. +type GenerateDetailedCostReportOperationStatusClient struct { + BaseClient +} + +// NewGenerateDetailedCostReportOperationStatusClient creates an instance of the +// GenerateDetailedCostReportOperationStatusClient client. +func NewGenerateDetailedCostReportOperationStatusClient(subscriptionID string) GenerateDetailedCostReportOperationStatusClient { + return NewGenerateDetailedCostReportOperationStatusClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewGenerateDetailedCostReportOperationStatusClientWithBaseURI creates an instance of the +// GenerateDetailedCostReportOperationStatusClient client using a custom endpoint. Use this when interacting with an +// Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewGenerateDetailedCostReportOperationStatusClientWithBaseURI(baseURI string, subscriptionID string) GenerateDetailedCostReportOperationStatusClient { + return GenerateDetailedCostReportOperationStatusClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get get the status of the specified operation. This link is provided in the GenerateDetailedCostReport creation +// request response header. +// Parameters: +// operationID - the target operation Id. +// 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. +func (client GenerateDetailedCostReportOperationStatusClient) Get(ctx context.Context, operationID string, scope string) (result GenerateDetailedCostReportOperationStatuses, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/GenerateDetailedCostReportOperationStatusClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, operationID, scope) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.GenerateDetailedCostReportOperationStatusClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "costmanagement.GenerateDetailedCostReportOperationStatusClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.GenerateDetailedCostReportOperationStatusClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client GenerateDetailedCostReportOperationStatusClient) GetPreparer(ctx context.Context, operationID string, scope string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "operationId": autorest.Encode("path", operationID), + "scope": scope, + } + + const APIVersion = "2021-01-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.CostManagement/operationStatus/{operationId}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client GenerateDetailedCostReportOperationStatusClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client GenerateDetailedCostReportOperationStatusClient) GetResponder(resp *http.Response) (result GenerateDetailedCostReportOperationStatuses, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/costmanagement/mgmt/2021-01-01/costmanagement/models.go b/services/costmanagement/mgmt/2021-01-01/costmanagement/models.go new file mode 100644 index 000000000000..87c8b9cd029a --- /dev/null +++ b/services/costmanagement/mgmt/2021-01-01/costmanagement/models.go @@ -0,0 +1,2091 @@ +package costmanagement + +// 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. + +import ( + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "github.com/shopspring/decimal" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/costmanagement/mgmt/2021-01-01/costmanagement" + +// Alert an individual alert. +type Alert struct { + autorest.Response `json:"-"` + *AlertProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` + // Tags - READ-ONLY; Resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for Alert. +func (a Alert) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if a.AlertProperties != nil { + objectMap["properties"] = a.AlertProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Alert struct. +func (a *Alert) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var alertProperties AlertProperties + err = json.Unmarshal(*v, &alertProperties) + if err != nil { + return err + } + a.AlertProperties = &alertProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + a.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + a.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + a.Type = &typeVar + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + a.Tags = tags + } + } + } + + return nil +} + +// AlertProperties ... +type AlertProperties struct { + // Definition - defines the type of alert + Definition *AlertPropertiesDefinition `json:"definition,omitempty"` + // Description - Alert description + Description *string `json:"description,omitempty"` + // Source - Source of alert. Possible values include: 'Preset', 'User' + Source AlertSource `json:"source,omitempty"` + // Details - Alert details + Details *AlertPropertiesDetails `json:"details,omitempty"` + // CostEntityID - related budget + CostEntityID *string `json:"costEntityId,omitempty"` + // Status - alert status. Possible values include: 'AlertStatusNone', 'AlertStatusActive', 'AlertStatusOverridden', 'AlertStatusResolved', 'AlertStatusDismissed' + Status AlertStatus `json:"status,omitempty"` + // CreationTime - dateTime in which alert was created + CreationTime *string `json:"creationTime,omitempty"` + // CloseTime - dateTime in which alert was closed + CloseTime *string `json:"closeTime,omitempty"` + // ModificationTime - dateTime in which alert was last modified + ModificationTime *string `json:"modificationTime,omitempty"` + StatusModificationUserName *string `json:"statusModificationUserName,omitempty"` + // StatusModificationTime - dateTime in which the alert status was last modified + StatusModificationTime *string `json:"statusModificationTime,omitempty"` +} + +// AlertPropertiesDefinition defines the type of alert +type AlertPropertiesDefinition struct { + // Type - type of alert. Possible values include: 'Budget', 'Invoice', 'Credit', 'Quota', 'General', 'XCloud', 'BudgetForecast' + Type AlertType `json:"type,omitempty"` + // Category - Alert category. Possible values include: 'Cost', 'Usage', 'Billing', 'System' + Category AlertCategory `json:"category,omitempty"` + // Criteria - Criteria that triggered alert. Possible values include: 'CostThresholdExceeded', 'UsageThresholdExceeded', 'CreditThresholdApproaching', 'CreditThresholdReached', 'QuotaThresholdApproaching', 'QuotaThresholdReached', 'MultiCurrency', 'ForecastCostThresholdExceeded', 'ForecastUsageThresholdExceeded', 'InvoiceDueDateApproaching', 'InvoiceDueDateReached', 'CrossCloudNewDataAvailable', 'CrossCloudCollectionError', 'GeneralThresholdError' + Criteria AlertCriteria `json:"criteria,omitempty"` +} + +// AlertPropertiesDetails alert details +type AlertPropertiesDetails struct { + // TimeGrainType - Type of timegrain cadence. Possible values include: 'AlertTimeGrainTypeNone', 'AlertTimeGrainTypeMonthly', 'AlertTimeGrainTypeQuarterly', 'AlertTimeGrainTypeAnnually', 'AlertTimeGrainTypeBillingMonth', 'AlertTimeGrainTypeBillingQuarter', 'AlertTimeGrainTypeBillingAnnual' + TimeGrainType AlertTimeGrainType `json:"timeGrainType,omitempty"` + // PeriodStartDate - datetime of periodStartDate + PeriodStartDate *string `json:"periodStartDate,omitempty"` + // TriggeredBy - notificationId that triggered this alert + TriggeredBy *string `json:"triggeredBy,omitempty"` + // ResourceGroupFilter - array of resourceGroups to filter by + ResourceGroupFilter *[]interface{} `json:"resourceGroupFilter,omitempty"` + // ResourceFilter - array of resources to filter by + ResourceFilter *[]interface{} `json:"resourceFilter,omitempty"` + // MeterFilter - array of meters to filter by + MeterFilter *[]interface{} `json:"meterFilter,omitempty"` + // TagFilter - tags to filter by + TagFilter interface{} `json:"tagFilter,omitempty"` + // Threshold - notification threshold percentage as a decimal which activated this alert + Threshold *decimal.Decimal `json:"threshold,omitempty"` + // Operator - operator used to compare currentSpend with amount. Possible values include: 'None', 'EqualTo', 'GreaterThan', 'GreaterThanOrEqualTo', 'LessThan', 'LessThanOrEqualTo' + Operator AlertOperator `json:"operator,omitempty"` + // Amount - budget threshold amount + Amount *decimal.Decimal `json:"amount,omitempty"` + // Unit - unit of currency being used + Unit *string `json:"unit,omitempty"` + // CurrentSpend - current spend + CurrentSpend *decimal.Decimal `json:"currentSpend,omitempty"` + // ContactEmails - list of emails to contact + ContactEmails *[]string `json:"contactEmails,omitempty"` + // ContactGroups - list of action groups to broadcast to + ContactGroups *[]string `json:"contactGroups,omitempty"` + // ContactRoles - list of contact roles + ContactRoles *[]string `json:"contactRoles,omitempty"` + // OverridingAlert - overriding alert + OverridingAlert *string `json:"overridingAlert,omitempty"` +} + +// AlertsResult result of alerts. +type AlertsResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of alerts. + Value *[]Alert `json:"value,omitempty"` + // NextLink - READ-ONLY; URL to get the next set of alerts results if there are any. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for AlertsResult. +func (ar AlertsResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// CommonExportProperties the common properties of the export. +type CommonExportProperties struct { + // Format - The format of the export being delivered. Currently only 'Csv' is supported. Possible values include: 'Csv' + Format FormatType `json:"format,omitempty"` + // DeliveryInfo - Has delivery information for the export. + DeliveryInfo *ExportDeliveryInfo `json:"deliveryInfo,omitempty"` + // Definition - Has the definition for the export. + Definition *ExportDefinition `json:"definition,omitempty"` + // RunHistory - If requested, has the most recent execution history for the export. + RunHistory *ExportExecutionListResult `json:"runHistory,omitempty"` + // PartitionData - If set to true, exported data will be partitioned by size and placed in a blob directory together with a manifest file. Note: this option is currently available only for modern commerce scopes. + PartitionData *bool `json:"partitionData,omitempty"` + // NextRunTimeEstimate - READ-ONLY; If the export has an active schedule, provides an estimate of the next execution time. + NextRunTimeEstimate *date.Time `json:"nextRunTimeEstimate,omitempty"` +} + +// MarshalJSON is the custom marshaler for CommonExportProperties. +func (cep CommonExportProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cep.Format != "" { + objectMap["format"] = cep.Format + } + if cep.DeliveryInfo != nil { + objectMap["deliveryInfo"] = cep.DeliveryInfo + } + if cep.Definition != nil { + objectMap["definition"] = cep.Definition + } + if cep.RunHistory != nil { + objectMap["runHistory"] = cep.RunHistory + } + if cep.PartitionData != nil { + objectMap["partitionData"] = cep.PartitionData + } + return json.Marshal(objectMap) +} + +// Dimension ... +type Dimension struct { + *DimensionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` + // Tags - READ-ONLY; Resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for Dimension. +func (d Dimension) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if d.DimensionProperties != nil { + objectMap["properties"] = d.DimensionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Dimension struct. +func (d *Dimension) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var dimensionProperties DimensionProperties + err = json.Unmarshal(*v, &dimensionProperties) + if err != nil { + return err + } + d.DimensionProperties = &dimensionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + d.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + d.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + d.Type = &typeVar + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + d.Tags = tags + } + } + } + + return nil +} + +// DimensionProperties ... +type DimensionProperties struct { + // Description - READ-ONLY; Dimension description. + Description *string `json:"description,omitempty"` + // FilterEnabled - READ-ONLY; Filter enabled. + FilterEnabled *bool `json:"filterEnabled,omitempty"` + // GroupingEnabled - READ-ONLY; Grouping enabled. + GroupingEnabled *bool `json:"groupingEnabled,omitempty"` + Data *[]string `json:"data,omitempty"` + // Total - READ-ONLY; Total number of data for the dimension. + Total *int32 `json:"total,omitempty"` + // Category - READ-ONLY; Dimension category. + Category *string `json:"category,omitempty"` + // UsageStart - READ-ONLY; Usage start. + UsageStart *date.Time `json:"usageStart,omitempty"` + // UsageEnd - READ-ONLY; Usage end. + UsageEnd *date.Time `json:"usageEnd,omitempty"` + // NextLink - READ-ONLY; The link (url) to the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for DimensionProperties. +func (dp DimensionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dp.Data != nil { + objectMap["data"] = dp.Data + } + return json.Marshal(objectMap) +} + +// DimensionsListResult result of listing dimensions. It contains a list of available dimensions. +type DimensionsListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The list of dimensions. + Value *[]Dimension `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for DimensionsListResult. +func (dlr DimensionsListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// DismissAlertPayload the request payload to update an alert +type DismissAlertPayload struct { + *AlertProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for DismissAlertPayload. +func (dap DismissAlertPayload) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dap.AlertProperties != nil { + objectMap["properties"] = dap.AlertProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for DismissAlertPayload struct. +func (dap *DismissAlertPayload) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var alertProperties AlertProperties + err = json.Unmarshal(*v, &alertProperties) + if err != nil { + return err + } + dap.AlertProperties = &alertProperties + } + } + } + + return nil +} + +// DownloadURL the URL to download the generated report. +type DownloadURL struct { + // DownloadURL - The URL to download the generated report. + DownloadURL *string `json:"downloadUrl,omitempty"` + // ValidTill - The time at which report URL becomes invalid/expires in UTC e.g. 2020-12-08T05:55:59.4394737Z. + ValidTill *date.Time `json:"validTill,omitempty"` +} + +// ErrorDetails the details of the error. +type ErrorDetails struct { + // Code - READ-ONLY; Error code. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; Error message indicating why the operation failed. + Message *string `json:"message,omitempty"` +} + +// MarshalJSON is the custom marshaler for ErrorDetails. +func (ed ErrorDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ErrorResponse 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: +// +// * 429 TooManyRequests - Request is throttled. Retry after waiting for the time specified in the +// "x-ms-ratelimit-microsoft.consumption-retry-after" header. +// +// * 503 ServiceUnavailable - Service is temporarily unavailable. Retry after waiting for the time +// specified in the "Retry-After" header. +type ErrorResponse struct { + // Error - The details of the error. + Error *ErrorDetails `json:"error,omitempty"` +} + +// Export an export resource. +type Export struct { + autorest.Response `json:"-"` + *ExportProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` + // ETag - eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not. + ETag *string `json:"eTag,omitempty"` +} + +// MarshalJSON is the custom marshaler for Export. +func (e Export) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if e.ExportProperties != nil { + objectMap["properties"] = e.ExportProperties + } + if e.ETag != nil { + objectMap["eTag"] = e.ETag + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Export struct. +func (e *Export) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var exportProperties ExportProperties + err = json.Unmarshal(*v, &exportProperties) + if err != nil { + return err + } + e.ExportProperties = &exportProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + e.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + e.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + e.Type = &typeVar + } + case "eTag": + if v != nil { + var eTag string + err = json.Unmarshal(*v, &eTag) + if err != nil { + return err + } + e.ETag = &eTag + } + } + } + + return nil +} + +// ExportDataset the definition for data in the export. +type ExportDataset struct { + // Granularity - The granularity of rows in the export. Currently only 'Daily' is supported. Possible values include: 'Daily' + Granularity GranularityType `json:"granularity,omitempty"` + // Configuration - The export dataset configuration. + Configuration *ExportDatasetConfiguration `json:"configuration,omitempty"` +} + +// ExportDatasetConfiguration the export dataset configuration. Allows columns to be selected for the +// export. If not provided then the export will include all available columns. +type ExportDatasetConfiguration struct { + // Columns - Array of column names to be included in the export. If not provided then the export will include all available columns. The available columns can vary by customer channel (see examples). + Columns *[]string `json:"columns,omitempty"` +} + +// ExportDefinition the definition of an export. +type ExportDefinition struct { + // Type - 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. Possible values include: 'ExportTypeUsage', 'ExportTypeActualCost', 'ExportTypeAmortizedCost' + Type ExportType `json:"type,omitempty"` + // Timeframe - The time frame for pulling data for the export. If custom, then a specific time period must be provided. Possible values include: 'TimeframeTypeMonthToDate', 'TimeframeTypeBillingMonthToDate', 'TimeframeTypeTheLastMonth', 'TimeframeTypeTheLastBillingMonth', 'TimeframeTypeWeekToDate', 'TimeframeTypeCustom' + Timeframe TimeframeType `json:"timeframe,omitempty"` + // TimePeriod - Has time period for pulling data for the export. + TimePeriod *ExportTimePeriod `json:"timePeriod,omitempty"` + // DataSet - The definition for data in the export. + DataSet *ExportDataset `json:"dataSet,omitempty"` +} + +// ExportDeliveryDestination this represents the blob storage account location where exports of costs will +// be delivered. There are two ways to configure the destination. The approach recommended for most +// customers is to specify the resourceId of the storage account. This requires a one-time registration of +// the account's subscription with the Microsoft.CostManagementExports resource provider in order to give +// Azure Cost Management services access to the storage. When creating an export in the Azure portal this +// registration is performed automatically but API users may need to register the subscription explicitly +// (for more information see +// https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-supported-services ). +// Another way to configure the destination is available ONLY to Partners with a Microsoft Partner +// Agreement plan who are global admins of their billing account. These Partners, instead of specifying the +// resourceId of a storage account, can specify the storage account name along with a SAS token for the +// account. This allows exports of costs to a storage account in any tenant. The SAS token should be +// created for the blob service with Service/Container/Object resource types and with +// Read/Write/Delete/List/Add/Create permissions (for more information see +// https://docs.microsoft.com/en-us/azure/cost-management-billing/costs/export-cost-data-storage-account-sas-key +// ). +type ExportDeliveryDestination struct { + // ResourceID - The resource id of the storage account where exports will be delivered. This is not required if a sasToken and storageAccount are specified. + ResourceID *string `json:"resourceId,omitempty"` + // Container - The name of the container where exports will be uploaded. If the container does not exist it will be created. + Container *string `json:"container,omitempty"` + // RootFolderPath - The name of the directory where exports will be uploaded. + RootFolderPath *string `json:"rootFolderPath,omitempty"` + // SasToken - A SAS token for the storage account. For a restricted set of Azure customers this together with storageAccount can be specified instead of resourceId. Note: the value returned by the API for this property will always be obfuscated. Returning this same obfuscated value will not result in the SAS token being updated. To update this value a new SAS token must be specified. + SasToken *string `json:"sasToken,omitempty"` + // StorageAccount - The storage account where exports will be uploaded. For a restricted set of Azure customers this together with sasToken can be specified instead of resourceId. + StorageAccount *string `json:"storageAccount,omitempty"` +} + +// ExportDeliveryInfo the delivery information associated with a export. +type ExportDeliveryInfo struct { + // Destination - Has destination for the export being delivered. + Destination *ExportDeliveryDestination `json:"destination,omitempty"` +} + +// ExportExecution an export execution. +type ExportExecution struct { + *ExportExecutionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` + // ETag - eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not. + ETag *string `json:"eTag,omitempty"` +} + +// MarshalJSON is the custom marshaler for ExportExecution. +func (ee ExportExecution) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ee.ExportExecutionProperties != nil { + objectMap["properties"] = ee.ExportExecutionProperties + } + if ee.ETag != nil { + objectMap["eTag"] = ee.ETag + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ExportExecution struct. +func (ee *ExportExecution) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var exportExecutionProperties ExportExecutionProperties + err = json.Unmarshal(*v, &exportExecutionProperties) + if err != nil { + return err + } + ee.ExportExecutionProperties = &exportExecutionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ee.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ee.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ee.Type = &typeVar + } + case "eTag": + if v != nil { + var eTag string + err = json.Unmarshal(*v, &eTag) + if err != nil { + return err + } + ee.ETag = &eTag + } + } + } + + return nil +} + +// ExportExecutionListResult result of listing the execution history of an export. +type ExportExecutionListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; A list of export executions. + Value *[]ExportExecution `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for ExportExecutionListResult. +func (eelr ExportExecutionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ExportExecutionProperties the properties of the export execution. +type ExportExecutionProperties struct { + // ExecutionType - The type of the export execution. Possible values include: 'OnDemand', 'Scheduled' + ExecutionType ExecutionType `json:"executionType,omitempty"` + // Status - The last known status of the export execution. Possible values include: 'Queued', 'InProgress', 'Completed', 'Failed', 'Timeout', 'NewDataNotAvailable', 'DataNotAvailable' + Status ExecutionStatus `json:"status,omitempty"` + // SubmittedBy - The identifier for the entity that executed the export. For OnDemand executions it is the user email. For scheduled executions it is 'System'. + SubmittedBy *string `json:"submittedBy,omitempty"` + // SubmittedTime - The time when export was queued to be executed. + SubmittedTime *date.Time `json:"submittedTime,omitempty"` + // ProcessingStartTime - The time when export was picked up to be executed. + ProcessingStartTime *date.Time `json:"processingStartTime,omitempty"` + // ProcessingEndTime - The time when the export execution finished. + ProcessingEndTime *date.Time `json:"processingEndTime,omitempty"` + // FileName - The name of the exported file. + FileName *string `json:"fileName,omitempty"` + // RunSettings - The export settings that were in effect for this execution. + RunSettings *CommonExportProperties `json:"runSettings,omitempty"` + // Error - The details of any error. + Error *ErrorDetails `json:"error,omitempty"` +} + +// ExportListResult result of listing exports. It contains a list of available exports in the scope +// provided. +type ExportListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The list of exports. + Value *[]Export `json:"value,omitempty"` +} + +// MarshalJSON is the custom marshaler for ExportListResult. +func (elr ExportListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ExportProperties the properties of the export. +type ExportProperties struct { + // Schedule - Has schedule information for the export. + Schedule *ExportSchedule `json:"schedule,omitempty"` + // Format - The format of the export being delivered. Currently only 'Csv' is supported. Possible values include: 'Csv' + Format FormatType `json:"format,omitempty"` + // DeliveryInfo - Has delivery information for the export. + DeliveryInfo *ExportDeliveryInfo `json:"deliveryInfo,omitempty"` + // Definition - Has the definition for the export. + Definition *ExportDefinition `json:"definition,omitempty"` + // RunHistory - If requested, has the most recent execution history for the export. + RunHistory *ExportExecutionListResult `json:"runHistory,omitempty"` + // PartitionData - If set to true, exported data will be partitioned by size and placed in a blob directory together with a manifest file. Note: this option is currently available only for modern commerce scopes. + PartitionData *bool `json:"partitionData,omitempty"` + // NextRunTimeEstimate - READ-ONLY; If the export has an active schedule, provides an estimate of the next execution time. + NextRunTimeEstimate *date.Time `json:"nextRunTimeEstimate,omitempty"` +} + +// MarshalJSON is the custom marshaler for ExportProperties. +func (ep ExportProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ep.Schedule != nil { + objectMap["schedule"] = ep.Schedule + } + if ep.Format != "" { + objectMap["format"] = ep.Format + } + if ep.DeliveryInfo != nil { + objectMap["deliveryInfo"] = ep.DeliveryInfo + } + if ep.Definition != nil { + objectMap["definition"] = ep.Definition + } + if ep.RunHistory != nil { + objectMap["runHistory"] = ep.RunHistory + } + if ep.PartitionData != nil { + objectMap["partitionData"] = ep.PartitionData + } + return json.Marshal(objectMap) +} + +// ExportRecurrencePeriod the start and end date for recurrence schedule. +type ExportRecurrencePeriod struct { + // From - The start date of recurrence. + From *date.Time `json:"from,omitempty"` + // To - The end date of recurrence. + To *date.Time `json:"to,omitempty"` +} + +// ExportSchedule the schedule associated with the export. +type ExportSchedule struct { + // Status - The status of the export's schedule. If 'Inactive', the export's schedule is paused. Possible values include: 'Active', 'Inactive' + Status StatusType `json:"status,omitempty"` + // Recurrence - The schedule recurrence. Possible values include: 'RecurrenceTypeDaily', 'RecurrenceTypeWeekly', 'RecurrenceTypeMonthly', 'RecurrenceTypeAnnually' + Recurrence RecurrenceType `json:"recurrence,omitempty"` + // RecurrencePeriod - Has start and end date of the recurrence. The start date must be in future. If present, the end date must be greater than start date. + RecurrencePeriod *ExportRecurrencePeriod `json:"recurrencePeriod,omitempty"` +} + +// ExportTimePeriod the date range for data in the export. This should only be specified with timeFrame set +// to 'Custom'. The maximum date range is 3 months. +type ExportTimePeriod struct { + // From - The start date for export data. + From *date.Time `json:"from,omitempty"` + // To - The end date for export data. + To *date.Time `json:"to,omitempty"` +} + +// ForecastDataset the definition of data present in the forecast. +type ForecastDataset struct { + // Granularity - The granularity of rows in the forecast. Possible values include: 'Daily' + Granularity GranularityType `json:"granularity,omitempty"` + // Configuration - Has configuration information for the data in the export. The configuration will be ignored if aggregation and grouping are provided. + Configuration *QueryDatasetConfiguration `json:"configuration,omitempty"` + // Aggregation - Dictionary of aggregation expression to use in the forecast. The key of each item in the dictionary is the alias for the aggregated column. forecast can have up to 2 aggregation clauses. + Aggregation map[string]*QueryAggregation `json:"aggregation"` + // Filter - Has filter expression to use in the forecast. + Filter *QueryFilter `json:"filter,omitempty"` +} + +// MarshalJSON is the custom marshaler for ForecastDataset. +func (fd ForecastDataset) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if fd.Granularity != "" { + objectMap["granularity"] = fd.Granularity + } + if fd.Configuration != nil { + objectMap["configuration"] = fd.Configuration + } + if fd.Aggregation != nil { + objectMap["aggregation"] = fd.Aggregation + } + if fd.Filter != nil { + objectMap["filter"] = fd.Filter + } + return json.Marshal(objectMap) +} + +// ForecastDefinition the definition of a forecast. +type ForecastDefinition struct { + // Type - The type of the forecast. Possible values include: 'ForecastTypeUsage', 'ForecastTypeActualCost', 'ForecastTypeAmortizedCost' + Type ForecastType `json:"type,omitempty"` + // Timeframe - The time frame for pulling data for the forecast. If custom, then a specific time period must be provided. Possible values include: 'MonthToDate', 'BillingMonthToDate', 'TheLastMonth', 'TheLastBillingMonth', 'WeekToDate', 'Custom' + Timeframe ForecastTimeframeType `json:"timeframe,omitempty"` + // TimePeriod - Has time period for pulling data for the forecast. + TimePeriod *QueryTimePeriod `json:"timePeriod,omitempty"` + // Dataset - Has definition for data in this forecast. + Dataset *ForecastDataset `json:"dataset,omitempty"` + // IncludeActualCost - a boolean determining if actualCost will be included + IncludeActualCost *bool `json:"includeActualCost,omitempty"` + // IncludeFreshPartialCost - a boolean determining if FreshPartialCost will be included + IncludeFreshPartialCost *bool `json:"includeFreshPartialCost,omitempty"` +} + +// GenerateDetailedCostReportCreateOperationFuture an abstraction for monitoring and retrieving the results +// of a long-running operation. +type GenerateDetailedCostReportCreateOperationFuture struct { + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(GenerateDetailedCostReportClient) (GenerateDetailedCostReportOperationResult, error) +} + +// UnmarshalJSON is the custom unmarshaller for CreateFuture. +func (future *GenerateDetailedCostReportCreateOperationFuture) UnmarshalJSON(body []byte) error { + var azFuture azure.Future + if err := json.Unmarshal(body, &azFuture); err != nil { + return err + } + future.FutureAPI = &azFuture + future.Result = future.result + return nil +} + +// result is the default implementation for GenerateDetailedCostReportCreateOperationFuture.Result. +func (future *GenerateDetailedCostReportCreateOperationFuture) result(client GenerateDetailedCostReportClient) (gdcror GenerateDetailedCostReportOperationResult, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.GenerateDetailedCostReportCreateOperationFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + gdcror.Response.Response = future.Response() + err = azure.NewAsyncOpIncompleteError("costmanagement.GenerateDetailedCostReportCreateOperationFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if gdcror.Response.Response, err = future.GetResult(sender); err == nil && gdcror.Response.Response.StatusCode != http.StatusNoContent { + gdcror, err = client.CreateOperationResponder(gdcror.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.GenerateDetailedCostReportCreateOperationFuture", "Result", gdcror.Response.Response, "Failure responding to request") + } + } + return +} + +// GenerateDetailedCostReportDefinition the definition of a cost detailed report. +type GenerateDetailedCostReportDefinition struct { + // Metric - The type of the detailed report. By default ActualCost is provided. Possible values include: 'ActualCost', 'AmortizedCost' + Metric GenerateDetailedCostReportMetricType `json:"metric,omitempty"` + // TimePeriod - Has time period for pulling data for the cost detailed report. Can only have one of either timePeriod or invoiceId or billingPeriod parameters. If none provided current month cost is provided. + TimePeriod *GenerateDetailedCostReportTimePeriod `json:"timePeriod,omitempty"` + // BillingPeriod - Billing Period in YearMonth(e.g. 202008) format. Only for legacy enterprise customers can use this. Can only have one of either timePeriod or invoiceId or billingPeriod parameters. If none provided current month cost is provided. + BillingPeriod *string `json:"billingPeriod,omitempty"` + // InvoiceID - Invoice Id for PayAsYouGo customers and Modern billing profile scope. Can only have one of either timePeriod or invoiceId or billingPeriod parameters. If none provided current month cost is provided. + InvoiceID *string `json:"invoiceId,omitempty"` + // CustomerID - Customer Id for Modern (Invoice Id and billing profile is also required for this). + CustomerID *string `json:"customerId,omitempty"` +} + +// GenerateDetailedCostReportErrorResponse 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: +// +// * 413 Request Entity Too Large - Request is throttled. The amount of data required to fulfill the +// request exceeds the maximum size permitted of 2Gb. Please utilize our Exports feature instead. +// +// * 429 TooManyRequests - Request is throttled. Retry after waiting for the time specified in the +// "x-ms-ratelimit-microsoft.consumption-retry-after" header. +// +// * 503 ServiceUnavailable - Service is temporarily unavailable. Retry after waiting for the time +// specified in the "Retry-After" header. +type GenerateDetailedCostReportErrorResponse struct { + // Error - The details of the error. + Error *ErrorDetails `json:"error,omitempty"` +} + +// GenerateDetailedCostReportOperationResult the result of the long running operation for cost detailed +// report. +type GenerateDetailedCostReportOperationResult struct { + autorest.Response `json:"-"` + // ID - The id of the long running operation. + ID *string `json:"id,omitempty"` + // Name - The name of the long running operation. + Name *string `json:"name,omitempty"` + // Type - The type of the long running operation. + Type *string `json:"type,omitempty"` + // DownloadURL - The properties of the resource generated. + *DownloadURL `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for GenerateDetailedCostReportOperationResult. +func (gdcror GenerateDetailedCostReportOperationResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if gdcror.ID != nil { + objectMap["id"] = gdcror.ID + } + if gdcror.Name != nil { + objectMap["name"] = gdcror.Name + } + if gdcror.Type != nil { + objectMap["type"] = gdcror.Type + } + if gdcror.DownloadURL != nil { + objectMap["properties"] = gdcror.DownloadURL + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for GenerateDetailedCostReportOperationResult struct. +func (gdcror *GenerateDetailedCostReportOperationResult) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + gdcror.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + gdcror.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + gdcror.Type = &typeVar + } + case "properties": + if v != nil { + var downloadURL DownloadURL + err = json.Unmarshal(*v, &downloadURL) + if err != nil { + return err + } + gdcror.DownloadURL = &downloadURL + } + } + } + + return nil +} + +// GenerateDetailedCostReportOperationStatuses the status of the long running operation for cost detailed +// report. +type GenerateDetailedCostReportOperationStatuses struct { + autorest.Response `json:"-"` + // ID - The id of the long running operation. + ID *string `json:"id,omitempty"` + // Name - The name of the long running operation. + Name *string `json:"name,omitempty"` + // Status - The status of the long running operation. + Status *Status `json:"status,omitempty"` + // Type - The type of the long running operation. + Type *string `json:"type,omitempty"` + // Error - The details of the error. + Error *ErrorDetails `json:"error,omitempty"` + // DownloadURL - The properties of the resource generated. + *DownloadURL `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for GenerateDetailedCostReportOperationStatuses. +func (gdcros GenerateDetailedCostReportOperationStatuses) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if gdcros.ID != nil { + objectMap["id"] = gdcros.ID + } + if gdcros.Name != nil { + objectMap["name"] = gdcros.Name + } + if gdcros.Status != nil { + objectMap["status"] = gdcros.Status + } + if gdcros.Type != nil { + objectMap["type"] = gdcros.Type + } + if gdcros.Error != nil { + objectMap["error"] = gdcros.Error + } + if gdcros.DownloadURL != nil { + objectMap["properties"] = gdcros.DownloadURL + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for GenerateDetailedCostReportOperationStatuses struct. +func (gdcros *GenerateDetailedCostReportOperationStatuses) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + gdcros.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + gdcros.Name = &name + } + case "status": + if v != nil { + var status Status + err = json.Unmarshal(*v, &status) + if err != nil { + return err + } + gdcros.Status = &status + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + gdcros.Type = &typeVar + } + case "error": + if v != nil { + var errorVar ErrorDetails + err = json.Unmarshal(*v, &errorVar) + if err != nil { + return err + } + gdcros.Error = &errorVar + } + case "properties": + if v != nil { + var downloadURL DownloadURL + err = json.Unmarshal(*v, &downloadURL) + if err != nil { + return err + } + gdcros.DownloadURL = &downloadURL + } + } + } + + return nil +} + +// GenerateDetailedCostReportTimePeriod the start and end date for pulling data for the cost detailed +// report. +type GenerateDetailedCostReportTimePeriod struct { + // Start - The start date to pull data from. example format 2020-03-15 + Start *string `json:"start,omitempty"` + // End - The end date to pull data to. example format 2020-03-15 + End *string `json:"end,omitempty"` +} + +// KpiProperties each KPI must contain a 'type' and 'enabled' key. +type KpiProperties struct { + // Type - KPI type (Forecast, Budget). Possible values include: 'KpiTypeTypeForecast', 'KpiTypeTypeBudget' + Type KpiTypeType `json:"type,omitempty"` + // ID - ID of resource related to metric (budget). + ID *string `json:"id,omitempty"` + // Enabled - show the KPI in the UI? + Enabled *bool `json:"enabled,omitempty"` +} + +// Operation a Cost management REST API operation. +type Operation struct { + // Name - READ-ONLY; Operation name: {provider}/{resource}/{operation}. + Name *string `json:"name,omitempty"` + // Display - The object that represents the operation. + Display *OperationDisplay `json:"display,omitempty"` +} + +// MarshalJSON is the custom marshaler for Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if o.Display != nil { + objectMap["display"] = o.Display + } + return json.Marshal(objectMap) +} + +// OperationDisplay the object that represents the operation. +type OperationDisplay struct { + // Provider - READ-ONLY; Service provider: Microsoft.CostManagement. + Provider *string `json:"provider,omitempty"` + // Resource - READ-ONLY; Resource on which the operation is performed: Dimensions, Query. + Resource *string `json:"resource,omitempty"` + // Operation - READ-ONLY; Operation type: Read, write, delete, etc. + Operation *string `json:"operation,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// OperationListResult result of listing cost management operations. It contains a list of operations and a +// URL link to get the next set of results. +type OperationListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; List of cost management operations supported by the Microsoft.CostManagement resource provider. + Value *[]Operation `json:"value,omitempty"` + // NextLink - READ-ONLY; URL to get the next set of operation list results if there are any. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for OperationListResult. +func (olr OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// OperationListResultIterator provides access to a complete listing of Operation values. +type OperationListResultIterator struct { + i int + page OperationListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *OperationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OperationListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter OperationListResultIterator) Response() OperationListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter OperationListResultIterator) Value() Operation { + if !iter.page.NotDone() { + return Operation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OperationListResultIterator type. +func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator { + return OperationListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (olr OperationListResult) IsEmpty() bool { + return olr.Value == nil || len(*olr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (olr OperationListResult) hasNextLink() bool { + return olr.NextLink != nil && len(*olr.NextLink) != 0 +} + +// operationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) { + if !olr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(olr.NextLink))) +} + +// OperationListResultPage contains a page of Operation values. +type OperationListResultPage struct { + fn func(context.Context, OperationListResult) (OperationListResult, error) + olr OperationListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *OperationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.olr) + if err != nil { + return err + } + page.olr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *OperationListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OperationListResultPage) NotDone() bool { + return !page.olr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OperationListResultPage) Response() OperationListResult { + return page.olr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OperationListResultPage) Values() []Operation { + if page.olr.IsEmpty() { + return nil + } + return *page.olr.Value +} + +// Creates a new instance of the OperationListResultPage type. +func NewOperationListResultPage(cur OperationListResult, getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { + return OperationListResultPage{ + fn: getNextPage, + olr: cur, + } +} + +// PivotProperties each pivot must contain a 'type' and 'name'. +type PivotProperties struct { + // Type - Data type to show in view. Possible values include: 'PivotTypeTypeDimension', 'PivotTypeTypeTagKey' + Type PivotTypeType `json:"type,omitempty"` + // Name - Data field to show in view. + Name *string `json:"name,omitempty"` +} + +// ProxyResource the Resource model definition. +type ProxyResource struct { + // ID - READ-ONLY; Resource Id. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` + // ETag - eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not. + ETag *string `json:"eTag,omitempty"` +} + +// MarshalJSON is the custom marshaler for ProxyResource. +func (pr ProxyResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pr.ETag != nil { + objectMap["eTag"] = pr.ETag + } + return json.Marshal(objectMap) +} + +// QueryAggregation the aggregation expression to be used in the query. +type QueryAggregation struct { + // Name - The name of the column to aggregate. + Name *string `json:"name,omitempty"` + // Function - The name of the aggregation function to use. + Function *string `json:"function,omitempty"` +} + +// QueryColumn ... +type QueryColumn struct { + // Name - The name of column. + Name *string `json:"name,omitempty"` + // Type - The type of column. + Type *string `json:"type,omitempty"` +} + +// QueryComparisonExpression the comparison expression to be used in the query. +type QueryComparisonExpression struct { + // Name - The name of the column to use in comparison. + Name *string `json:"name,omitempty"` + // Operator - The operator to use for comparison. + Operator *string `json:"operator,omitempty"` + // Values - Array of values to use for comparison + Values *[]string `json:"values,omitempty"` +} + +// QueryDataset the definition of data present in the query. +type QueryDataset struct { + // Granularity - The granularity of rows in the query. Possible values include: 'Daily' + Granularity GranularityType `json:"granularity,omitempty"` + // Configuration - Has configuration information for the data in the export. The configuration will be ignored if aggregation and grouping are provided. + Configuration *QueryDatasetConfiguration `json:"configuration,omitempty"` + // Aggregation - Dictionary of aggregation expression to use in the query. The key of each item in the dictionary is the alias for the aggregated column. Query can have up to 2 aggregation clauses. + Aggregation map[string]*QueryAggregation `json:"aggregation"` + // Grouping - Array of group by expression to use in the query. Query can have up to 2 group by clauses. + Grouping *[]QueryGrouping `json:"grouping,omitempty"` + // Filter - The filter expression to use in the query. Please reference our Query API REST documentation for how to properly format the filter. + Filter *QueryFilter `json:"filter,omitempty"` +} + +// MarshalJSON is the custom marshaler for QueryDataset. +func (qd QueryDataset) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if qd.Granularity != "" { + objectMap["granularity"] = qd.Granularity + } + if qd.Configuration != nil { + objectMap["configuration"] = qd.Configuration + } + if qd.Aggregation != nil { + objectMap["aggregation"] = qd.Aggregation + } + if qd.Grouping != nil { + objectMap["grouping"] = qd.Grouping + } + if qd.Filter != nil { + objectMap["filter"] = qd.Filter + } + return json.Marshal(objectMap) +} + +// QueryDatasetConfiguration the configuration of dataset in the query. +type QueryDatasetConfiguration struct { + // Columns - Array of column names to be included in the query. Any valid query column name is allowed. If not provided, then query includes all columns. + Columns *[]string `json:"columns,omitempty"` +} + +// QueryDefinition the definition of a query. +type QueryDefinition struct { + // Type - The type of the query. Possible values include: 'ExportTypeUsage', 'ExportTypeActualCost', 'ExportTypeAmortizedCost' + Type ExportType `json:"type,omitempty"` + // Timeframe - The time frame for pulling data for the query. If custom, then a specific time period must be provided. Possible values include: 'TimeframeTypeMonthToDate', 'TimeframeTypeBillingMonthToDate', 'TimeframeTypeTheLastMonth', 'TimeframeTypeTheLastBillingMonth', 'TimeframeTypeWeekToDate', 'TimeframeTypeCustom' + Timeframe TimeframeType `json:"timeframe,omitempty"` + // TimePeriod - Has time period for pulling data for the query. + TimePeriod *QueryTimePeriod `json:"timePeriod,omitempty"` + // Dataset - Has definition for data in this query. + Dataset *QueryDataset `json:"dataset,omitempty"` +} + +// QueryFilter the filter expression to be used in the export. +type QueryFilter struct { + // And - The logical "AND" expression. Must have at least 2 items. + And *[]QueryFilter `json:"and,omitempty"` + // Or - The logical "OR" expression. Must have at least 2 items. + Or *[]QueryFilter `json:"or,omitempty"` + // Not - The logical "NOT" expression. + Not *QueryFilter `json:"not,omitempty"` + // Dimension - Has comparison expression for a dimension + Dimension *QueryComparisonExpression `json:"dimension,omitempty"` + // Tag - Has comparison expression for a tag + Tag *QueryComparisonExpression `json:"tag,omitempty"` +} + +// QueryGrouping the group by expression to be used in the query. +type QueryGrouping struct { + // Type - Has type of the column to group. Possible values include: 'QueryColumnTypeTag', 'QueryColumnTypeDimension' + Type QueryColumnType `json:"type,omitempty"` + // Name - The name of the column to group. + Name *string `json:"name,omitempty"` +} + +// QueryProperties ... +type QueryProperties struct { + // NextLink - The link (url) to the next page of results. + NextLink *string `json:"nextLink,omitempty"` + // Columns - Array of columns + Columns *[]QueryColumn `json:"columns,omitempty"` + // Rows - Array of rows + Rows *[][]interface{} `json:"rows,omitempty"` +} + +// QueryResult result of query. It contains all columns listed under groupings and aggregation. +type QueryResult struct { + autorest.Response `json:"-"` + *QueryProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` + // Tags - READ-ONLY; Resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for QueryResult. +func (qr QueryResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if qr.QueryProperties != nil { + objectMap["properties"] = qr.QueryProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for QueryResult struct. +func (qr *QueryResult) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var queryProperties QueryProperties + err = json.Unmarshal(*v, &queryProperties) + if err != nil { + return err + } + qr.QueryProperties = &queryProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + qr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + qr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + qr.Type = &typeVar + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + qr.Tags = tags + } + } + } + + return nil +} + +// QueryTimePeriod the start and end date for pulling data for the query. +type QueryTimePeriod struct { + // From - The start date to pull data from. + From *date.Time `json:"from,omitempty"` + // To - The end date to pull data to. + To *date.Time `json:"to,omitempty"` +} + +// ReportConfigAggregation the aggregation expression to be used in the report. +type ReportConfigAggregation struct { + // Name - The name of the column to aggregate. + Name *string `json:"name,omitempty"` + // Function - The name of the aggregation function to use. + Function *string `json:"function,omitempty"` +} + +// ReportConfigComparisonExpression the comparison expression to be used in the report. +type ReportConfigComparisonExpression struct { + // Name - The name of the column to use in comparison. + Name *string `json:"name,omitempty"` + // Operator - The operator to use for comparison. Possible values include: 'In', 'Contains' + Operator OperatorType `json:"operator,omitempty"` + // Values - Array of values to use for comparison + Values *[]string `json:"values,omitempty"` +} + +// ReportConfigDataset the definition of data present in the report. +type ReportConfigDataset struct { + // Granularity - The granularity of rows in the report. Possible values include: 'ReportGranularityTypeDaily', 'ReportGranularityTypeMonthly' + Granularity ReportGranularityType `json:"granularity,omitempty"` + // Configuration - Has configuration information for the data in the report. The configuration will be ignored if aggregation and grouping are provided. + Configuration *ReportConfigDatasetConfiguration `json:"configuration,omitempty"` + // Aggregation - Dictionary of aggregation expression to use in the report. The key of each item in the dictionary is the alias for the aggregated column. Report can have up to 2 aggregation clauses. + Aggregation map[string]*ReportConfigAggregation `json:"aggregation"` + // Grouping - Array of group by expression to use in the report. Report can have up to 2 group by clauses. + Grouping *[]ReportConfigGrouping `json:"grouping,omitempty"` + // Sorting - Array of order by expression to use in the report. + Sorting *[]ReportConfigSorting `json:"sorting,omitempty"` + // Filter - Has filter expression to use in the report. + Filter *ReportConfigFilter `json:"filter,omitempty"` +} + +// MarshalJSON is the custom marshaler for ReportConfigDataset. +func (rcd ReportConfigDataset) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rcd.Granularity != "" { + objectMap["granularity"] = rcd.Granularity + } + if rcd.Configuration != nil { + objectMap["configuration"] = rcd.Configuration + } + if rcd.Aggregation != nil { + objectMap["aggregation"] = rcd.Aggregation + } + if rcd.Grouping != nil { + objectMap["grouping"] = rcd.Grouping + } + if rcd.Sorting != nil { + objectMap["sorting"] = rcd.Sorting + } + if rcd.Filter != nil { + objectMap["filter"] = rcd.Filter + } + return json.Marshal(objectMap) +} + +// ReportConfigDatasetConfiguration the configuration of dataset in the report. +type ReportConfigDatasetConfiguration struct { + // Columns - Array of column names to be included in the report. Any valid report column name is allowed. If not provided, then report includes all columns. + Columns *[]string `json:"columns,omitempty"` +} + +// ReportConfigDefinition the definition of a report config. +type ReportConfigDefinition struct { + // Type - The type of the report. Usage represents actual usage, forecast represents forecasted data and UsageAndForecast represents both usage and forecasted data. Actual usage and forecasted data can be differentiated based on dates. + Type *string `json:"type,omitempty"` + // Timeframe - The time frame for pulling data for the report. If custom, then a specific time period must be provided. Possible values include: 'ReportTimeframeTypeWeekToDate', 'ReportTimeframeTypeMonthToDate', 'ReportTimeframeTypeYearToDate', 'ReportTimeframeTypeCustom' + Timeframe ReportTimeframeType `json:"timeframe,omitempty"` + // TimePeriod - Has time period for pulling data for the report. + TimePeriod *ReportConfigTimePeriod `json:"timePeriod,omitempty"` + // Dataset - Has definition for data in this report config. + Dataset *ReportConfigDataset `json:"dataset,omitempty"` +} + +// ReportConfigFilter the filter expression to be used in the report. +type ReportConfigFilter struct { + // And - The logical "AND" expression. Must have at least 2 items. + And *[]ReportConfigFilter `json:"and,omitempty"` + // Or - The logical "OR" expression. Must have at least 2 items. + Or *[]ReportConfigFilter `json:"or,omitempty"` + // Not - The logical "NOT" expression. + Not *ReportConfigFilter `json:"not,omitempty"` + // Dimension - Has comparison expression for a dimension + Dimension *ReportConfigComparisonExpression `json:"dimension,omitempty"` + // Tag - Has comparison expression for a tag + Tag *ReportConfigComparisonExpression `json:"tag,omitempty"` +} + +// ReportConfigGrouping the group by expression to be used in the report. +type ReportConfigGrouping struct { + // Type - Has type of the column to group. Possible values include: 'ReportConfigColumnTypeTag', 'ReportConfigColumnTypeDimension' + Type ReportConfigColumnType `json:"type,omitempty"` + // Name - The name of the column to group. This version supports subscription lowest possible grain. + Name *string `json:"name,omitempty"` +} + +// ReportConfigSorting the order by expression to be used in the report. +type ReportConfigSorting struct { + // Direction - Direction of sort. Possible values include: 'Ascending', 'Descending' + Direction Direction `json:"direction,omitempty"` + // Name - The name of the column to sort. + Name *string `json:"name,omitempty"` +} + +// ReportConfigTimePeriod the start and end date for pulling data for the report. +type ReportConfigTimePeriod struct { + // From - The start date to pull data from. + From *date.Time `json:"from,omitempty"` + // To - The end date to pull data to. + To *date.Time `json:"to,omitempty"` +} + +// Resource the Resource model definition. +type Resource struct { + // ID - READ-ONLY; Resource Id. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` + // Tags - READ-ONLY; Resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// Status the status of the long running operation. +type Status struct { + // Status - The status of the long running operation. Possible values include: 'OperationStatusTypeInProgress', 'OperationStatusTypeCompleted', 'OperationStatusTypeFailed', 'OperationStatusTypeQueued', 'OperationStatusTypeNoDataFound', 'OperationStatusTypeReadyToDownload', 'OperationStatusTypeTimedOut' + Status OperationStatusType `json:"status,omitempty"` +} + +// View states and configurations of Cost Analysis. +type View struct { + autorest.Response `json:"-"` + *ViewProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` + // ETag - eTag of the resource. To handle concurrent update scenario, this field will be used to determine whether the user is updating the latest version or not. + ETag *string `json:"eTag,omitempty"` +} + +// MarshalJSON is the custom marshaler for View. +func (vVar View) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if vVar.ViewProperties != nil { + objectMap["properties"] = vVar.ViewProperties + } + if vVar.ETag != nil { + objectMap["eTag"] = vVar.ETag + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for View struct. +func (vVar *View) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var viewProperties ViewProperties + err = json.Unmarshal(*v, &viewProperties) + if err != nil { + return err + } + vVar.ViewProperties = &viewProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + vVar.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + vVar.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + vVar.Type = &typeVar + } + case "eTag": + if v != nil { + var eTag string + err = json.Unmarshal(*v, &eTag) + if err != nil { + return err + } + vVar.ETag = &eTag + } + } + } + + return nil +} + +// ViewListResult result of listing views. It contains a list of available views. +type ViewListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The list of views. + Value *[]View `json:"value,omitempty"` + // NextLink - READ-ONLY; The link (url) to the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON is the custom marshaler for ViewListResult. +func (vlr ViewListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + return json.Marshal(objectMap) +} + +// ViewListResultIterator provides access to a complete listing of View values. +type ViewListResultIterator struct { + i int + page ViewListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ViewListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ViewListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ViewListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ViewListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ViewListResultIterator) Response() ViewListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ViewListResultIterator) Value() View { + if !iter.page.NotDone() { + return View{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ViewListResultIterator type. +func NewViewListResultIterator(page ViewListResultPage) ViewListResultIterator { + return ViewListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (vlr ViewListResult) IsEmpty() bool { + return vlr.Value == nil || len(*vlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (vlr ViewListResult) hasNextLink() bool { + return vlr.NextLink != nil && len(*vlr.NextLink) != 0 +} + +// viewListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (vlr ViewListResult) viewListResultPreparer(ctx context.Context) (*http.Request, error) { + if !vlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(vlr.NextLink))) +} + +// ViewListResultPage contains a page of View values. +type ViewListResultPage struct { + fn func(context.Context, ViewListResult) (ViewListResult, error) + vlr ViewListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ViewListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ViewListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.vlr) + if err != nil { + return err + } + page.vlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ViewListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ViewListResultPage) NotDone() bool { + return !page.vlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ViewListResultPage) Response() ViewListResult { + return page.vlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ViewListResultPage) Values() []View { + if page.vlr.IsEmpty() { + return nil + } + return *page.vlr.Value +} + +// Creates a new instance of the ViewListResultPage type. +func NewViewListResultPage(cur ViewListResult, getNextPage func(context.Context, ViewListResult) (ViewListResult, error)) ViewListResultPage { + return ViewListResultPage{ + fn: getNextPage, + vlr: cur, + } +} + +// ViewProperties the properties of the view. +type ViewProperties struct { + // DisplayName - User input name of the view. Required. + DisplayName *string `json:"displayName,omitempty"` + // Scope - Cost Management scope to save the view on. This includes 'subscriptions/{subscriptionId}' for subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' for EnrollmentAccount scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for BillingProfile scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' for InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management Group scope, '/providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for ExternalBillingAccount scope, and '/providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for ExternalSubscription scope. + Scope *string `json:"scope,omitempty"` + // CreatedOn - READ-ONLY; Date the user created this view. + CreatedOn *date.Time `json:"createdOn,omitempty"` + // ModifiedOn - READ-ONLY; Date when the user last modified this view. + ModifiedOn *date.Time `json:"modifiedOn,omitempty"` + // ReportConfigDefinition - Query body configuration. Required. + *ReportConfigDefinition `json:"query,omitempty"` + // Chart - Chart type of the main view in Cost Analysis. Required. Possible values include: 'Area', 'Line', 'StackedColumn', 'GroupedColumn', 'Table' + Chart ChartType `json:"chart,omitempty"` + // Accumulated - Show costs accumulated over time. Possible values include: 'True', 'False' + Accumulated AccumulatedType `json:"accumulated,omitempty"` + // Metric - Metric to use when displaying costs. Possible values include: 'MetricTypeActualCost', 'MetricTypeAmortizedCost', 'MetricTypeAHUB' + Metric MetricType `json:"metric,omitempty"` + // Kpis - List of KPIs to show in Cost Analysis UI. + Kpis *[]KpiProperties `json:"kpis,omitempty"` + // Pivots - Configuration of 3 sub-views in the Cost Analysis UI. + Pivots *[]PivotProperties `json:"pivots,omitempty"` +} + +// MarshalJSON is the custom marshaler for ViewProperties. +func (vp ViewProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if vp.DisplayName != nil { + objectMap["displayName"] = vp.DisplayName + } + if vp.Scope != nil { + objectMap["scope"] = vp.Scope + } + if vp.ReportConfigDefinition != nil { + objectMap["query"] = vp.ReportConfigDefinition + } + if vp.Chart != "" { + objectMap["chart"] = vp.Chart + } + if vp.Accumulated != "" { + objectMap["accumulated"] = vp.Accumulated + } + if vp.Metric != "" { + objectMap["metric"] = vp.Metric + } + if vp.Kpis != nil { + objectMap["kpis"] = vp.Kpis + } + if vp.Pivots != nil { + objectMap["pivots"] = vp.Pivots + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ViewProperties struct. +func (vp *ViewProperties) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "displayName": + if v != nil { + var displayName string + err = json.Unmarshal(*v, &displayName) + if err != nil { + return err + } + vp.DisplayName = &displayName + } + case "scope": + if v != nil { + var scope string + err = json.Unmarshal(*v, &scope) + if err != nil { + return err + } + vp.Scope = &scope + } + case "createdOn": + if v != nil { + var createdOn date.Time + err = json.Unmarshal(*v, &createdOn) + if err != nil { + return err + } + vp.CreatedOn = &createdOn + } + case "modifiedOn": + if v != nil { + var modifiedOn date.Time + err = json.Unmarshal(*v, &modifiedOn) + if err != nil { + return err + } + vp.ModifiedOn = &modifiedOn + } + case "query": + if v != nil { + var reportConfigDefinition ReportConfigDefinition + err = json.Unmarshal(*v, &reportConfigDefinition) + if err != nil { + return err + } + vp.ReportConfigDefinition = &reportConfigDefinition + } + case "chart": + if v != nil { + var chart ChartType + err = json.Unmarshal(*v, &chart) + if err != nil { + return err + } + vp.Chart = chart + } + case "accumulated": + if v != nil { + var accumulated AccumulatedType + err = json.Unmarshal(*v, &accumulated) + if err != nil { + return err + } + vp.Accumulated = accumulated + } + case "metric": + if v != nil { + var metric MetricType + err = json.Unmarshal(*v, &metric) + if err != nil { + return err + } + vp.Metric = metric + } + case "kpis": + if v != nil { + var kpis []KpiProperties + err = json.Unmarshal(*v, &kpis) + if err != nil { + return err + } + vp.Kpis = &kpis + } + case "pivots": + if v != nil { + var pivots []PivotProperties + err = json.Unmarshal(*v, &pivots) + if err != nil { + return err + } + vp.Pivots = &pivots + } + } + } + + return nil +} diff --git a/services/costmanagement/mgmt/2021-01-01/costmanagement/operations.go b/services/costmanagement/mgmt/2021-01-01/costmanagement/operations.go new file mode 100644 index 000000000000..c70a4aac3fdc --- /dev/null +++ b/services/costmanagement/mgmt/2021-01-01/costmanagement/operations.go @@ -0,0 +1,140 @@ +package costmanagement + +// 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// OperationsClient is the client for the Operations methods of the Costmanagement service. +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available cost management REST API operations. +func (client OperationsClient) List(ctx context.Context) (result OperationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.olr.Response.Response != nil { + sc = result.olr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.olr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "costmanagement.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.olr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.OperationsClient", "List", resp, "Failure responding to request") + return + } + if result.olr.hasNextLink() && result.olr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2020-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.CostManagement/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client OperationsClient) listNextResults(ctx context.Context, lastResults OperationListResult) (result OperationListResult, err error) { + req, err := lastResults.operationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "costmanagement.OperationsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "costmanagement.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.OperationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OperationsClient) ListComplete(ctx context.Context) (result OperationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} diff --git a/services/costmanagement/mgmt/2021-01-01/costmanagement/query.go b/services/costmanagement/mgmt/2021-01-01/costmanagement/query.go new file mode 100644 index 000000000000..a81886b8cf54 --- /dev/null +++ b/services/costmanagement/mgmt/2021-01-01/costmanagement/query.go @@ -0,0 +1,267 @@ +package costmanagement + +// 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// QueryClient is the client for the Query methods of the Costmanagement service. +type QueryClient struct { + BaseClient +} + +// NewQueryClient creates an instance of the QueryClient client. +func NewQueryClient(subscriptionID string) QueryClient { + return NewQueryClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewQueryClientWithBaseURI creates an instance of the QueryClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewQueryClientWithBaseURI(baseURI string, subscriptionID string) QueryClient { + return QueryClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Usage query the usage data for scope defined. +// Parameters: +// scope - the scope associated with query and export operations. This includes +// '/subscriptions/{subscriptionId}/' for subscription scope, +// '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup scope, +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope and +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department +// scope, +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' +// for EnrollmentAccount scope, '/providers/Microsoft.Management/managementGroups/{managementGroupId} for +// Management Group scope, +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for +// billingProfile scope, +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}/invoiceSections/{invoiceSectionId}' +// for invoiceSection scope, and +// '/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/customers/{customerId}' specific for +// partners. +// parameters - parameters supplied to the CreateOrUpdate Query Config operation. +func (client QueryClient) Usage(ctx context.Context, scope string, parameters QueryDefinition) (result QueryResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/QueryClient.Usage") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.TimePeriod", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.TimePeriod.From", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.TimePeriod.To", Name: validation.Null, Rule: true, Chain: nil}, + }}, + {Target: "parameters.Dataset", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Grouping", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Grouping", Name: validation.MaxItems, Rule: 2, Chain: nil}}}, + {Target: "parameters.Dataset.Filter", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.And", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.And", Name: validation.MinItems, Rule: 2, Chain: nil}}}, + {Target: "parameters.Dataset.Filter.Or", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Or", Name: validation.MinItems, Rule: 2, Chain: nil}}}, + {Target: "parameters.Dataset.Filter.Not", Name: validation.Null, Rule: false, Chain: nil}, + {Target: "parameters.Dataset.Filter.Dimension", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Dimension.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Dataset.Filter.Dimension.Operator", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Dataset.Filter.Dimension.Values", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Dimension.Values", Name: validation.MinItems, Rule: 1, Chain: nil}}}, + }}, + {Target: "parameters.Dataset.Filter.Tag", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Tag.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Dataset.Filter.Tag.Operator", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Dataset.Filter.Tag.Values", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Tag.Values", Name: validation.MinItems, Rule: 1, Chain: nil}}}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewError("costmanagement.QueryClient", "Usage", err.Error()) + } + + req, err := client.UsagePreparer(ctx, scope, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.QueryClient", "Usage", nil, "Failure preparing request") + return + } + + resp, err := client.UsageSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "costmanagement.QueryClient", "Usage", resp, "Failure sending request") + return + } + + result, err = client.UsageResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.QueryClient", "Usage", resp, "Failure responding to request") + return + } + + return +} + +// UsagePreparer prepares the Usage request. +func (client QueryClient) UsagePreparer(ctx context.Context, scope string, parameters QueryDefinition) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "scope": scope, + } + + const APIVersion = "2020-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.CostManagement/query", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UsageSender sends the Usage request. The method will close the +// http.Response Body if it receives an error. +func (client QueryClient) UsageSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// UsageResponder handles the response to the Usage request. The method always +// closes the http.Response Body. +func (client QueryClient) UsageResponder(resp *http.Response) (result QueryResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UsageByExternalCloudProviderType query the usage data for external cloud provider type defined. +// Parameters: +// externalCloudProviderType - the external cloud provider type associated with dimension/query operations. +// This includes 'externalSubscriptions' for linked account and 'externalBillingAccounts' for consolidated +// account. +// externalCloudProviderID - this can be '{externalSubscriptionId}' for linked account or +// '{externalBillingAccountId}' for consolidated account used with dimension/query operations. +// parameters - parameters supplied to the CreateOrUpdate Query Config operation. +func (client QueryClient) UsageByExternalCloudProviderType(ctx context.Context, externalCloudProviderType ExternalCloudProviderType, externalCloudProviderID string, parameters QueryDefinition) (result QueryResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/QueryClient.UsageByExternalCloudProviderType") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.TimePeriod", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.TimePeriod.From", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.TimePeriod.To", Name: validation.Null, Rule: true, Chain: nil}, + }}, + {Target: "parameters.Dataset", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Grouping", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Grouping", Name: validation.MaxItems, Rule: 2, Chain: nil}}}, + {Target: "parameters.Dataset.Filter", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.And", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.And", Name: validation.MinItems, Rule: 2, Chain: nil}}}, + {Target: "parameters.Dataset.Filter.Or", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Or", Name: validation.MinItems, Rule: 2, Chain: nil}}}, + {Target: "parameters.Dataset.Filter.Not", Name: validation.Null, Rule: false, Chain: nil}, + {Target: "parameters.Dataset.Filter.Dimension", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Dimension.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Dataset.Filter.Dimension.Operator", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Dataset.Filter.Dimension.Values", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Dimension.Values", Name: validation.MinItems, Rule: 1, Chain: nil}}}, + }}, + {Target: "parameters.Dataset.Filter.Tag", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Tag.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Dataset.Filter.Tag.Operator", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Dataset.Filter.Tag.Values", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Tag.Values", Name: validation.MinItems, Rule: 1, Chain: nil}}}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewError("costmanagement.QueryClient", "UsageByExternalCloudProviderType", err.Error()) + } + + req, err := client.UsageByExternalCloudProviderTypePreparer(ctx, externalCloudProviderType, externalCloudProviderID, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.QueryClient", "UsageByExternalCloudProviderType", nil, "Failure preparing request") + return + } + + resp, err := client.UsageByExternalCloudProviderTypeSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "costmanagement.QueryClient", "UsageByExternalCloudProviderType", resp, "Failure sending request") + return + } + + result, err = client.UsageByExternalCloudProviderTypeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.QueryClient", "UsageByExternalCloudProviderType", resp, "Failure responding to request") + return + } + + return +} + +// UsageByExternalCloudProviderTypePreparer prepares the UsageByExternalCloudProviderType request. +func (client QueryClient) UsageByExternalCloudProviderTypePreparer(ctx context.Context, externalCloudProviderType ExternalCloudProviderType, externalCloudProviderID string, parameters QueryDefinition) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "externalCloudProviderId": autorest.Encode("path", externalCloudProviderID), + "externalCloudProviderType": autorest.Encode("path", externalCloudProviderType), + } + + const APIVersion = "2020-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.CostManagement/{externalCloudProviderType}/{externalCloudProviderId}/query", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UsageByExternalCloudProviderTypeSender sends the UsageByExternalCloudProviderType request. The method will close the +// http.Response Body if it receives an error. +func (client QueryClient) UsageByExternalCloudProviderTypeSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// UsageByExternalCloudProviderTypeResponder handles the response to the UsageByExternalCloudProviderType request. The method always +// closes the http.Response Body. +func (client QueryClient) UsageByExternalCloudProviderTypeResponder(resp *http.Response) (result QueryResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/costmanagement/mgmt/2021-01-01/costmanagement/version.go b/services/costmanagement/mgmt/2021-01-01/costmanagement/version.go new file mode 100644 index 000000000000..2eed6c4da705 --- /dev/null +++ b/services/costmanagement/mgmt/2021-01-01/costmanagement/version.go @@ -0,0 +1,19 @@ +package costmanagement + +import "github.com/Azure/azure-sdk-for-go/version" + +// 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. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + Version() + " costmanagement/2021-01-01" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +} diff --git a/services/costmanagement/mgmt/2021-01-01/costmanagement/views.go b/services/costmanagement/mgmt/2021-01-01/costmanagement/views.go new file mode 100644 index 000000000000..0d02fc01e558 --- /dev/null +++ b/services/costmanagement/mgmt/2021-01-01/costmanagement/views.go @@ -0,0 +1,832 @@ +package costmanagement + +// 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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ViewsClient is the client for the Views methods of the Costmanagement service. +type ViewsClient struct { + BaseClient +} + +// NewViewsClient creates an instance of the ViewsClient client. +func NewViewsClient(subscriptionID string) ViewsClient { + return NewViewsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewViewsClientWithBaseURI creates an instance of the ViewsClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewViewsClientWithBaseURI(baseURI string, subscriptionID string) ViewsClient { + return ViewsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate the operation to create or update a view. Update operation requires latest eTag to be set in the +// request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag. +// Parameters: +// viewName - view name +// parameters - parameters supplied to the CreateOrUpdate View operation. +func (client ViewsClient) CreateOrUpdate(ctx context.Context, viewName string, parameters View) (result View, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ViewsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ViewProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ViewProperties.ReportConfigDefinition", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ViewProperties.ReportConfigDefinition.Type", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ViewProperties.ReportConfigDefinition.TimePeriod", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ViewProperties.ReportConfigDefinition.TimePeriod.From", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ViewProperties.ReportConfigDefinition.TimePeriod.To", Name: validation.Null, Rule: true, Chain: nil}, + }}, + {Target: "parameters.ViewProperties.ReportConfigDefinition.Dataset", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ViewProperties.ReportConfigDefinition.Dataset.Grouping", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ViewProperties.ReportConfigDefinition.Dataset.Grouping", Name: validation.MaxItems, Rule: 2, Chain: nil}}}, + {Target: "parameters.ViewProperties.ReportConfigDefinition.Dataset.Filter", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ViewProperties.ReportConfigDefinition.Dataset.Filter.And", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ViewProperties.ReportConfigDefinition.Dataset.Filter.And", Name: validation.MinItems, Rule: 2, Chain: nil}}}, + {Target: "parameters.ViewProperties.ReportConfigDefinition.Dataset.Filter.Or", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ViewProperties.ReportConfigDefinition.Dataset.Filter.Or", Name: validation.MinItems, Rule: 2, Chain: nil}}}, + {Target: "parameters.ViewProperties.ReportConfigDefinition.Dataset.Filter.Not", Name: validation.Null, Rule: false, Chain: nil}, + {Target: "parameters.ViewProperties.ReportConfigDefinition.Dataset.Filter.Dimension", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ViewProperties.ReportConfigDefinition.Dataset.Filter.Dimension.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ViewProperties.ReportConfigDefinition.Dataset.Filter.Dimension.Values", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ViewProperties.ReportConfigDefinition.Dataset.Filter.Dimension.Values", Name: validation.MinItems, Rule: 1, Chain: nil}}}, + }}, + {Target: "parameters.ViewProperties.ReportConfigDefinition.Dataset.Filter.Tag", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ViewProperties.ReportConfigDefinition.Dataset.Filter.Tag.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ViewProperties.ReportConfigDefinition.Dataset.Filter.Tag.Values", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ViewProperties.ReportConfigDefinition.Dataset.Filter.Tag.Values", Name: validation.MinItems, Rule: 1, Chain: nil}}}, + }}, + }}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewError("costmanagement.ViewsClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, viewName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ViewsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "costmanagement.ViewsClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ViewsClient", "CreateOrUpdate", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ViewsClient) CreateOrUpdatePreparer(ctx context.Context, viewName string, parameters View) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "viewName": autorest.Encode("path", viewName), + } + + const APIVersion = "2020-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.CostManagement/views/{viewName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ViewsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ViewsClient) CreateOrUpdateResponder(resp *http.Response) (result View, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateOrUpdateByScope the operation to create or update a view. Update operation requires latest eTag to be set in +// the request. You may obtain the latest eTag by performing a get operation. Create operation does not require eTag. +// Parameters: +// scope - the scope associated with view operations. This includes 'subscriptions/{subscriptionId}' for +// subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup +// scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, +// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department +// scope, +// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' +// for EnrollmentAccount scope, +// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for +// BillingProfile scope, +// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' for +// InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management +// Group scope, 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for +// External Billing Account scope and +// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for External +// Subscription scope. +// viewName - view name +// parameters - parameters supplied to the CreateOrUpdate View operation. +func (client ViewsClient) CreateOrUpdateByScope(ctx context.Context, scope string, viewName string, parameters View) (result View, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ViewsClient.CreateOrUpdateByScope") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ViewProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ViewProperties.ReportConfigDefinition", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ViewProperties.ReportConfigDefinition.Type", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ViewProperties.ReportConfigDefinition.TimePeriod", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ViewProperties.ReportConfigDefinition.TimePeriod.From", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ViewProperties.ReportConfigDefinition.TimePeriod.To", Name: validation.Null, Rule: true, Chain: nil}, + }}, + {Target: "parameters.ViewProperties.ReportConfigDefinition.Dataset", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ViewProperties.ReportConfigDefinition.Dataset.Grouping", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ViewProperties.ReportConfigDefinition.Dataset.Grouping", Name: validation.MaxItems, Rule: 2, Chain: nil}}}, + {Target: "parameters.ViewProperties.ReportConfigDefinition.Dataset.Filter", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ViewProperties.ReportConfigDefinition.Dataset.Filter.And", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ViewProperties.ReportConfigDefinition.Dataset.Filter.And", Name: validation.MinItems, Rule: 2, Chain: nil}}}, + {Target: "parameters.ViewProperties.ReportConfigDefinition.Dataset.Filter.Or", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ViewProperties.ReportConfigDefinition.Dataset.Filter.Or", Name: validation.MinItems, Rule: 2, Chain: nil}}}, + {Target: "parameters.ViewProperties.ReportConfigDefinition.Dataset.Filter.Not", Name: validation.Null, Rule: false, Chain: nil}, + {Target: "parameters.ViewProperties.ReportConfigDefinition.Dataset.Filter.Dimension", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ViewProperties.ReportConfigDefinition.Dataset.Filter.Dimension.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ViewProperties.ReportConfigDefinition.Dataset.Filter.Dimension.Values", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ViewProperties.ReportConfigDefinition.Dataset.Filter.Dimension.Values", Name: validation.MinItems, Rule: 1, Chain: nil}}}, + }}, + {Target: "parameters.ViewProperties.ReportConfigDefinition.Dataset.Filter.Tag", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ViewProperties.ReportConfigDefinition.Dataset.Filter.Tag.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ViewProperties.ReportConfigDefinition.Dataset.Filter.Tag.Values", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ViewProperties.ReportConfigDefinition.Dataset.Filter.Tag.Values", Name: validation.MinItems, Rule: 1, Chain: nil}}}, + }}, + }}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewError("costmanagement.ViewsClient", "CreateOrUpdateByScope", err.Error()) + } + + req, err := client.CreateOrUpdateByScopePreparer(ctx, scope, viewName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ViewsClient", "CreateOrUpdateByScope", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateByScopeSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "costmanagement.ViewsClient", "CreateOrUpdateByScope", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateByScopeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ViewsClient", "CreateOrUpdateByScope", resp, "Failure responding to request") + return + } + + return +} + +// CreateOrUpdateByScopePreparer prepares the CreateOrUpdateByScope request. +func (client ViewsClient) CreateOrUpdateByScopePreparer(ctx context.Context, scope string, viewName string, parameters View) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "scope": autorest.Encode("path", scope), + "viewName": autorest.Encode("path", viewName), + } + + const APIVersion = "2020-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.CostManagement/views/{viewName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateByScopeSender sends the CreateOrUpdateByScope request. The method will close the +// http.Response Body if it receives an error. +func (client ViewsClient) CreateOrUpdateByScopeSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// CreateOrUpdateByScopeResponder handles the response to the CreateOrUpdateByScope request. The method always +// closes the http.Response Body. +func (client ViewsClient) CreateOrUpdateByScopeResponder(resp *http.Response) (result View, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete the operation to delete a view. +// Parameters: +// viewName - view name +func (client ViewsClient) Delete(ctx context.Context, viewName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ViewsClient.Delete") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, viewName) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ViewsClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "costmanagement.ViewsClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ViewsClient", "Delete", resp, "Failure responding to request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ViewsClient) DeletePreparer(ctx context.Context, viewName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "viewName": autorest.Encode("path", viewName), + } + + const APIVersion = "2020-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.CostManagement/views/{viewName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ViewsClient) DeleteSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ViewsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// DeleteByScope the operation to delete a view. +// Parameters: +// scope - the scope associated with view operations. This includes 'subscriptions/{subscriptionId}' for +// subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup +// scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, +// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department +// scope, +// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' +// for EnrollmentAccount scope, +// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for +// BillingProfile scope, +// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' for +// InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management +// Group scope, 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for +// External Billing Account scope and +// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for External +// Subscription scope. +// viewName - view name +func (client ViewsClient) DeleteByScope(ctx context.Context, scope string, viewName string) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ViewsClient.DeleteByScope") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeleteByScopePreparer(ctx, scope, viewName) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ViewsClient", "DeleteByScope", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteByScopeSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "costmanagement.ViewsClient", "DeleteByScope", resp, "Failure sending request") + return + } + + result, err = client.DeleteByScopeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ViewsClient", "DeleteByScope", resp, "Failure responding to request") + return + } + + return +} + +// DeleteByScopePreparer prepares the DeleteByScope request. +func (client ViewsClient) DeleteByScopePreparer(ctx context.Context, scope string, viewName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "scope": autorest.Encode("path", scope), + "viewName": autorest.Encode("path", viewName), + } + + const APIVersion = "2020-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.CostManagement/views/{viewName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteByScopeSender sends the DeleteByScope request. The method will close the +// http.Response Body if it receives an error. +func (client ViewsClient) DeleteByScopeSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// DeleteByScopeResponder handles the response to the DeleteByScope request. The method always +// closes the http.Response Body. +func (client ViewsClient) DeleteByScopeResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the view by view name. +// Parameters: +// viewName - view name +func (client ViewsClient) Get(ctx context.Context, viewName string) (result View, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ViewsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, viewName) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ViewsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "costmanagement.ViewsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ViewsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client ViewsClient) GetPreparer(ctx context.Context, viewName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "viewName": autorest.Encode("path", viewName), + } + + const APIVersion = "2020-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.CostManagement/views/{viewName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ViewsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ViewsClient) GetResponder(resp *http.Response) (result View, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetByScope gets the view for the defined scope by view name. +// Parameters: +// scope - the scope associated with view operations. This includes 'subscriptions/{subscriptionId}' for +// subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup +// scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, +// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department +// scope, +// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' +// for EnrollmentAccount scope, +// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for +// BillingProfile scope, +// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' for +// InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management +// Group scope, 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for +// External Billing Account scope and +// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for External +// Subscription scope. +// viewName - view name +func (client ViewsClient) GetByScope(ctx context.Context, scope string, viewName string) (result View, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ViewsClient.GetByScope") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetByScopePreparer(ctx, scope, viewName) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ViewsClient", "GetByScope", nil, "Failure preparing request") + return + } + + resp, err := client.GetByScopeSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "costmanagement.ViewsClient", "GetByScope", resp, "Failure sending request") + return + } + + result, err = client.GetByScopeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ViewsClient", "GetByScope", resp, "Failure responding to request") + return + } + + return +} + +// GetByScopePreparer prepares the GetByScope request. +func (client ViewsClient) GetByScopePreparer(ctx context.Context, scope string, viewName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "scope": autorest.Encode("path", scope), + "viewName": autorest.Encode("path", viewName), + } + + const APIVersion = "2020-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.CostManagement/views/{viewName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetByScopeSender sends the GetByScope request. The method will close the +// http.Response Body if it receives an error. +func (client ViewsClient) GetByScopeSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetByScopeResponder handles the response to the GetByScope request. The method always +// closes the http.Response Body. +func (client ViewsClient) GetByScopeResponder(resp *http.Response) (result View, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists all views by tenant and object. +func (client ViewsClient) List(ctx context.Context) (result ViewListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ViewsClient.List") + defer func() { + sc := -1 + if result.vlr.Response.Response != nil { + sc = result.vlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ViewsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.vlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "costmanagement.ViewsClient", "List", resp, "Failure sending request") + return + } + + result.vlr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ViewsClient", "List", resp, "Failure responding to request") + return + } + if result.vlr.hasNextLink() && result.vlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListPreparer prepares the List request. +func (client ViewsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2020-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.CostManagement/views"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ViewsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ViewsClient) ListResponder(resp *http.Response) (result ViewListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client ViewsClient) listNextResults(ctx context.Context, lastResults ViewListResult) (result ViewListResult, err error) { + req, err := lastResults.viewListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "costmanagement.ViewsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "costmanagement.ViewsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ViewsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client ViewsClient) ListComplete(ctx context.Context) (result ViewListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ViewsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} + +// ListByScope lists all views at the given scope. +// Parameters: +// scope - the scope associated with view operations. This includes 'subscriptions/{subscriptionId}' for +// subscription scope, 'subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}' for resourceGroup +// scope, 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}' for Billing Account scope, +// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/departments/{departmentId}' for Department +// scope, +// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/enrollmentAccounts/{enrollmentAccountId}' +// for EnrollmentAccount scope, +// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/billingProfiles/{billingProfileId}' for +// BillingProfile scope, +// 'providers/Microsoft.Billing/billingAccounts/{billingAccountId}/invoiceSections/{invoiceSectionId}' for +// InvoiceSection scope, 'providers/Microsoft.Management/managementGroups/{managementGroupId}' for Management +// Group scope, 'providers/Microsoft.CostManagement/externalBillingAccounts/{externalBillingAccountName}' for +// External Billing Account scope and +// 'providers/Microsoft.CostManagement/externalSubscriptions/{externalSubscriptionName}' for External +// Subscription scope. +func (client ViewsClient) ListByScope(ctx context.Context, scope string) (result ViewListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ViewsClient.ListByScope") + defer func() { + sc := -1 + if result.vlr.Response.Response != nil { + sc = result.vlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByScopeNextResults + req, err := client.ListByScopePreparer(ctx, scope) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ViewsClient", "ListByScope", nil, "Failure preparing request") + return + } + + resp, err := client.ListByScopeSender(req) + if err != nil { + result.vlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "costmanagement.ViewsClient", "ListByScope", resp, "Failure sending request") + return + } + + result.vlr, err = client.ListByScopeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ViewsClient", "ListByScope", resp, "Failure responding to request") + return + } + if result.vlr.hasNextLink() && result.vlr.IsEmpty() { + err = result.NextWithContext(ctx) + return + } + + return +} + +// ListByScopePreparer prepares the ListByScope request. +func (client ViewsClient) ListByScopePreparer(ctx context.Context, scope string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "scope": autorest.Encode("path", scope), + } + + const APIVersion = "2020-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/{scope}/providers/Microsoft.CostManagement/views", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByScopeSender sends the ListByScope request. The method will close the +// http.Response Body if it receives an error. +func (client ViewsClient) ListByScopeSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListByScopeResponder handles the response to the ListByScope request. The method always +// closes the http.Response Body. +func (client ViewsClient) ListByScopeResponder(resp *http.Response) (result ViewListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByScopeNextResults retrieves the next set of results, if any. +func (client ViewsClient) listByScopeNextResults(ctx context.Context, lastResults ViewListResult) (result ViewListResult, err error) { + req, err := lastResults.viewListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "costmanagement.ViewsClient", "listByScopeNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByScopeSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "costmanagement.ViewsClient", "listByScopeNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByScopeResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ViewsClient", "listByScopeNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByScopeComplete enumerates all values, automatically crossing page boundaries as required. +func (client ViewsClient) ListByScopeComplete(ctx context.Context, scope string) (result ViewListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ViewsClient.ListByScope") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByScope(ctx, scope) + return +} diff --git a/services/preview/costmanagement/mgmt/2018-08-01-preview/costmanagement/CHANGELOG.md b/services/preview/costmanagement/mgmt/2018-08-01-preview/costmanagement/CHANGELOG.md index 52911e4cc5e4..a1ecf841edb0 100644 --- a/services/preview/costmanagement/mgmt/2018-08-01-preview/costmanagement/CHANGELOG.md +++ b/services/preview/costmanagement/mgmt/2018-08-01-preview/costmanagement/CHANGELOG.md @@ -1,2 +1,2 @@ -# Change History +# Unreleased diff --git a/services/preview/costmanagement/mgmt/2018-08-01-preview/costmanagement/_meta.json b/services/preview/costmanagement/mgmt/2018-08-01-preview/costmanagement/_meta.json index 4087720a0c67..ab0297213c0c 100644 --- a/services/preview/costmanagement/mgmt/2018-08-01-preview/costmanagement/_meta.json +++ b/services/preview/costmanagement/mgmt/2018-08-01-preview/costmanagement/_meta.json @@ -1,5 +1,5 @@ { - "commit": "3c764635e7d442b3e74caf593029fcd440b3ef82", + "commit": "f92aaf88f4c9d1ffb9a014eba196d887a9288c3a", "readme": "/_/azure-rest-api-specs/specification/cost-management/resource-manager/readme.md", "tag": "package-2018-08-preview", "use": "@microsoft.azure/autorest.go@2.1.187", diff --git a/services/preview/costmanagement/mgmt/2019-03-01/costmanagement/CHANGELOG.md b/services/preview/costmanagement/mgmt/2019-03-01/costmanagement/CHANGELOG.md index 52911e4cc5e4..a1ecf841edb0 100644 --- a/services/preview/costmanagement/mgmt/2019-03-01/costmanagement/CHANGELOG.md +++ b/services/preview/costmanagement/mgmt/2019-03-01/costmanagement/CHANGELOG.md @@ -1,2 +1,2 @@ -# Change History +# Unreleased diff --git a/services/preview/costmanagement/mgmt/2019-03-01/costmanagement/_meta.json b/services/preview/costmanagement/mgmt/2019-03-01/costmanagement/_meta.json index 237e7e60532a..bd22a6a4a38c 100644 --- a/services/preview/costmanagement/mgmt/2019-03-01/costmanagement/_meta.json +++ b/services/preview/costmanagement/mgmt/2019-03-01/costmanagement/_meta.json @@ -1,5 +1,5 @@ { - "commit": "3c764635e7d442b3e74caf593029fcd440b3ef82", + "commit": "f92aaf88f4c9d1ffb9a014eba196d887a9288c3a", "readme": "/_/azure-rest-api-specs/specification/cost-management/resource-manager/readme.md", "tag": "package-preview-2019-03", "use": "@microsoft.azure/autorest.go@2.1.187",