diff --git a/profiles/preview/consumption/mgmt/consumption/models.go b/profiles/preview/consumption/mgmt/consumption/models.go index d993fc41e923..16d982e4e48d 100644 --- a/profiles/preview/consumption/mgmt/consumption/models.go +++ b/profiles/preview/consumption/mgmt/consumption/models.go @@ -21,8 +21,6 @@ package consumption import original "github.com/Azure/azure-sdk-for-go/services/consumption/mgmt/2018-05-31/consumption" -type BillingAccountDimensionsClient = original.BillingAccountDimensionsClient - const ( DefaultBaseURI = original.DefaultBaseURI ) @@ -43,12 +41,6 @@ const ( ChargeTypeForecast ChargeType = original.ChargeTypeForecast ) -type FormatType = original.FormatType - -const ( - Csv FormatType = original.Csv -) - type Grain = original.Grain const ( @@ -57,47 +49,6 @@ const ( Yearly Grain = original.Yearly ) -type GranularityType = original.GranularityType - -const ( - GranularityTypeDaily GranularityType = original.GranularityTypeDaily -) - -type RecurrenceType = original.RecurrenceType - -const ( - RecurrenceTypeAnnually RecurrenceType = original.RecurrenceTypeAnnually - RecurrenceTypeDaily RecurrenceType = original.RecurrenceTypeDaily - RecurrenceTypeMonthly RecurrenceType = original.RecurrenceTypeMonthly - RecurrenceTypeWeekly RecurrenceType = original.RecurrenceTypeWeekly -) - -type ReportConfigColumnType = original.ReportConfigColumnType - -const ( - ReportConfigColumnTypeDimension ReportConfigColumnType = original.ReportConfigColumnTypeDimension - ReportConfigColumnTypeTag ReportConfigColumnType = original.ReportConfigColumnTypeTag -) - -type StatusType = original.StatusType - -const ( - Active StatusType = original.Active - Inactive StatusType = original.Inactive -) - -type TimeframeType = original.TimeframeType - -const ( - Custom TimeframeType = original.Custom - MonthToDate TimeframeType = original.MonthToDate - WeekToDate TimeframeType = original.WeekToDate - YearToDate TimeframeType = original.YearToDate -) - -type Dimension = original.Dimension -type DimensionProperties = original.DimensionProperties -type DimensionsListResult = original.DimensionsListResult type ErrorDetails = original.ErrorDetails type ErrorResponse = original.ErrorResponse type Forecast = original.Forecast @@ -113,26 +64,7 @@ type OperationListResultPage = original.OperationListResultPage type PriceSheetModel = original.PriceSheetModel type PriceSheetProperties = original.PriceSheetProperties type PriceSheetResult = original.PriceSheetResult -type ReportConfig = original.ReportConfig -type ReportConfigAggregation = original.ReportConfigAggregation -type ReportConfigComparisonExpression = original.ReportConfigComparisonExpression -type ReportConfigDataset = original.ReportConfigDataset -type ReportConfigDatasetConfiguration = original.ReportConfigDatasetConfiguration -type ReportConfigDefinition = original.ReportConfigDefinition -type ReportConfigDeliveryDestination = original.ReportConfigDeliveryDestination -type ReportConfigDeliveryInfo = original.ReportConfigDeliveryInfo -type ReportConfigFilter = original.ReportConfigFilter -type ReportConfigGrouping = original.ReportConfigGrouping -type ReportConfigListResult = original.ReportConfigListResult -type ReportConfigProperties = original.ReportConfigProperties -type ReportConfigRecurrencePeriod = original.ReportConfigRecurrencePeriod -type ReportConfigSchedule = original.ReportConfigSchedule -type ReportConfigTimePeriod = original.ReportConfigTimePeriod type Resource = original.Resource -type UsageAnalysis = original.UsageAnalysis -type UsageAnalysisColumn = original.UsageAnalysisColumn -type UsageAnalysisProperties = original.UsageAnalysisProperties -type UsageAnalysisResult = original.UsageAnalysisResult type UsageDetail = original.UsageDetail type UsageDetailProperties = original.UsageDetailProperties type UsageDetailsListResult = original.UsageDetailsListResult @@ -140,17 +72,8 @@ type UsageDetailsListResultIterator = original.UsageDetailsListResultIterator type UsageDetailsListResultPage = original.UsageDetailsListResultPage type OperationsClient = original.OperationsClient type PriceSheetClient = original.PriceSheetClient -type ReportConfigClient = original.ReportConfigClient -type ResourceGroupDimensionsClient = original.ResourceGroupDimensionsClient -type SubscriptionDimensionsClient = original.SubscriptionDimensionsClient type UsageDetailsClient = original.UsageDetailsClient -func NewBillingAccountDimensionsClient(subscriptionID string) BillingAccountDimensionsClient { - return original.NewBillingAccountDimensionsClient(subscriptionID) -} -func NewBillingAccountDimensionsClientWithBaseURI(baseURI string, subscriptionID string) BillingAccountDimensionsClient { - return original.NewBillingAccountDimensionsClientWithBaseURI(baseURI, subscriptionID) -} func New(subscriptionID string) BaseClient { return original.New(subscriptionID) } @@ -169,27 +92,9 @@ func PossibleBoundValues() []Bound { func PossibleChargeTypeValues() []ChargeType { return original.PossibleChargeTypeValues() } -func PossibleFormatTypeValues() []FormatType { - return original.PossibleFormatTypeValues() -} func PossibleGrainValues() []Grain { return original.PossibleGrainValues() } -func PossibleGranularityTypeValues() []GranularityType { - return original.PossibleGranularityTypeValues() -} -func PossibleRecurrenceTypeValues() []RecurrenceType { - return original.PossibleRecurrenceTypeValues() -} -func PossibleReportConfigColumnTypeValues() []ReportConfigColumnType { - return original.PossibleReportConfigColumnTypeValues() -} -func PossibleStatusTypeValues() []StatusType { - return original.PossibleStatusTypeValues() -} -func PossibleTimeframeTypeValues() []TimeframeType { - return original.PossibleTimeframeTypeValues() -} func NewOperationsClient(subscriptionID string) OperationsClient { return original.NewOperationsClient(subscriptionID) } @@ -202,24 +107,6 @@ func NewPriceSheetClient(subscriptionID string) PriceSheetClient { func NewPriceSheetClientWithBaseURI(baseURI string, subscriptionID string) PriceSheetClient { return original.NewPriceSheetClientWithBaseURI(baseURI, subscriptionID) } -func NewReportConfigClient(subscriptionID string) ReportConfigClient { - return original.NewReportConfigClient(subscriptionID) -} -func NewReportConfigClientWithBaseURI(baseURI string, subscriptionID string) ReportConfigClient { - return original.NewReportConfigClientWithBaseURI(baseURI, subscriptionID) -} -func NewResourceGroupDimensionsClient(subscriptionID string) ResourceGroupDimensionsClient { - return original.NewResourceGroupDimensionsClient(subscriptionID) -} -func NewResourceGroupDimensionsClientWithBaseURI(baseURI string, subscriptionID string) ResourceGroupDimensionsClient { - return original.NewResourceGroupDimensionsClientWithBaseURI(baseURI, subscriptionID) -} -func NewSubscriptionDimensionsClient(subscriptionID string) SubscriptionDimensionsClient { - return original.NewSubscriptionDimensionsClient(subscriptionID) -} -func NewSubscriptionDimensionsClientWithBaseURI(baseURI string, subscriptionID string) SubscriptionDimensionsClient { - return original.NewSubscriptionDimensionsClientWithBaseURI(baseURI, subscriptionID) -} func NewUsageDetailsClient(subscriptionID string) UsageDetailsClient { return original.NewUsageDetailsClient(subscriptionID) } diff --git a/services/consumption/mgmt/2018-05-31/consumption/billingaccountdimensions.go b/services/consumption/mgmt/2018-05-31/consumption/billingaccountdimensions.go deleted file mode 100644 index f4a7d85749d4..000000000000 --- a/services/consumption/mgmt/2018-05-31/consumption/billingaccountdimensions.go +++ /dev/null @@ -1,135 +0,0 @@ -package consumption - -// Copyright (c) Microsoft and contributors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// -// See the License for the specific language governing permissions and -// limitations under the License. -// -// 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" - "net/http" -) - -// BillingAccountDimensionsClient is the consumption management client provides access to consumption resources for -// Azure Enterprise Subscriptions. -type BillingAccountDimensionsClient struct { - BaseClient -} - -// NewBillingAccountDimensionsClient creates an instance of the BillingAccountDimensionsClient client. -func NewBillingAccountDimensionsClient(subscriptionID string) BillingAccountDimensionsClient { - return NewBillingAccountDimensionsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewBillingAccountDimensionsClientWithBaseURI creates an instance of the BillingAccountDimensionsClient client. -func NewBillingAccountDimensionsClientWithBaseURI(baseURI string, subscriptionID string) BillingAccountDimensionsClient { - return BillingAccountDimensionsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// List lists the dimensions by billingAccount Id. -// Parameters: -// billingAccountID - billingAccount ID -// 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 dategory. 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 BillingAccountDimensionsClient) List(ctx context.Context, billingAccountID string, filter string, expand string, skiptoken string, top *int32) (result DimensionsListResult, err error) { - 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: 1, Chain: nil}, - }}}}}); err != nil { - return result, validation.NewError("consumption.BillingAccountDimensionsClient", "List", err.Error()) - } - - req, err := client.ListPreparer(ctx, billingAccountID, filter, expand, skiptoken, top) - if err != nil { - err = autorest.NewErrorWithError(err, "consumption.BillingAccountDimensionsClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "consumption.BillingAccountDimensionsClient", "List", resp, "Failure sending request") - return - } - - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "consumption.BillingAccountDimensionsClient", "List", resp, "Failure responding to request") - } - - return -} - -// ListPreparer prepares the List request. -func (client BillingAccountDimensionsClient) ListPreparer(ctx context.Context, billingAccountID string, filter string, expand string, skiptoken string, top *int32) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "billingAccountId": autorest.Encode("path", billingAccountID), - } - - const APIVersion = "2018-05-31" - 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.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/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 BillingAccountDimensionsClient) ListSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, 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 BillingAccountDimensionsClient) ListResponder(resp *http.Response) (result DimensionsListResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/services/consumption/mgmt/2018-05-31/consumption/client.go b/services/consumption/mgmt/2018-05-31/consumption/client.go index 65c8aa13725f..1bd8c604a8f5 100644 --- a/services/consumption/mgmt/2018-05-31/consumption/client.go +++ b/services/consumption/mgmt/2018-05-31/consumption/client.go @@ -21,11 +21,7 @@ package consumption // 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" - "net/http" ) const ( @@ -53,303 +49,3 @@ func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { SubscriptionID: subscriptionID, } } - -// AnalyzeBillingAccountUsage lists the usage data for billing account. -// Parameters: -// billingAccountID - billingAccount ID -// parameters - parameters supplied to the CreateOrUpdate Report Config operation. -func (client BaseClient) AnalyzeBillingAccountUsage(ctx context.Context, billingAccountID string, parameters ReportConfigDefinition) (result UsageAnalysisResult, err error) { - if err := validation.Validate([]validation.Validation{ - {TargetValue: parameters, - Constraints: []validation.Constraint{{Target: "parameters.Type", Name: validation.Null, Rule: true, Chain: nil}, - {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: false, - 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("consumption.BaseClient", "AnalyzeBillingAccountUsage", err.Error()) - } - - req, err := client.AnalyzeBillingAccountUsagePreparer(ctx, billingAccountID, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "consumption.BaseClient", "AnalyzeBillingAccountUsage", nil, "Failure preparing request") - return - } - - resp, err := client.AnalyzeBillingAccountUsageSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "consumption.BaseClient", "AnalyzeBillingAccountUsage", resp, "Failure sending request") - return - } - - result, err = client.AnalyzeBillingAccountUsageResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "consumption.BaseClient", "AnalyzeBillingAccountUsage", resp, "Failure responding to request") - } - - return -} - -// AnalyzeBillingAccountUsagePreparer prepares the AnalyzeBillingAccountUsage request. -func (client BaseClient) AnalyzeBillingAccountUsagePreparer(ctx context.Context, billingAccountID string, parameters ReportConfigDefinition) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "billingAccountId": autorest.Encode("path", billingAccountID), - } - - const APIVersion = "2018-05-31" - 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.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/AnalyzeUsage", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// AnalyzeBillingAccountUsageSender sends the AnalyzeBillingAccountUsage request. The method will close the -// http.Response Body if it receives an error. -func (client BaseClient) AnalyzeBillingAccountUsageSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// AnalyzeBillingAccountUsageResponder handles the response to the AnalyzeBillingAccountUsage request. The method always -// closes the http.Response Body. -func (client BaseClient) AnalyzeBillingAccountUsageResponder(resp *http.Response) (result UsageAnalysisResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// AnalyzeResourceGroupUsage lists the usage data for subscriptionId and resource group. -// Parameters: -// resourceGroupName - azure Resource Group Name. -// parameters - parameters supplied to the CreateOrUpdate Report Config operation. -func (client BaseClient) AnalyzeResourceGroupUsage(ctx context.Context, resourceGroupName string, parameters ReportConfigDefinition) (result UsageAnalysisResult, err error) { - if err := validation.Validate([]validation.Validation{ - {TargetValue: parameters, - Constraints: []validation.Constraint{{Target: "parameters.Type", Name: validation.Null, Rule: true, Chain: nil}, - {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: false, - 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("consumption.BaseClient", "AnalyzeResourceGroupUsage", err.Error()) - } - - req, err := client.AnalyzeResourceGroupUsagePreparer(ctx, resourceGroupName, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "consumption.BaseClient", "AnalyzeResourceGroupUsage", nil, "Failure preparing request") - return - } - - resp, err := client.AnalyzeResourceGroupUsageSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "consumption.BaseClient", "AnalyzeResourceGroupUsage", resp, "Failure sending request") - return - } - - result, err = client.AnalyzeResourceGroupUsageResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "consumption.BaseClient", "AnalyzeResourceGroupUsage", resp, "Failure responding to request") - } - - return -} - -// AnalyzeResourceGroupUsagePreparer prepares the AnalyzeResourceGroupUsage request. -func (client BaseClient) AnalyzeResourceGroupUsagePreparer(ctx context.Context, resourceGroupName string, parameters ReportConfigDefinition) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2018-05-31" - 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("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Consumption/AnalyzeUsage", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// AnalyzeResourceGroupUsageSender sends the AnalyzeResourceGroupUsage request. The method will close the -// http.Response Body if it receives an error. -func (client BaseClient) AnalyzeResourceGroupUsageSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// AnalyzeResourceGroupUsageResponder handles the response to the AnalyzeResourceGroupUsage request. The method always -// closes the http.Response Body. -func (client BaseClient) AnalyzeResourceGroupUsageResponder(resp *http.Response) (result UsageAnalysisResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// AnalyzeSubscriptionUsage lists the usage data for subscriptionId. -// Parameters: -// parameters - parameters supplied to the CreateOrUpdate Report Config operation. -func (client BaseClient) AnalyzeSubscriptionUsage(ctx context.Context, parameters ReportConfigDefinition) (result UsageAnalysisResult, err error) { - if err := validation.Validate([]validation.Validation{ - {TargetValue: parameters, - Constraints: []validation.Constraint{{Target: "parameters.Type", Name: validation.Null, Rule: true, Chain: nil}, - {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: false, - 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("consumption.BaseClient", "AnalyzeSubscriptionUsage", err.Error()) - } - - req, err := client.AnalyzeSubscriptionUsagePreparer(ctx, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "consumption.BaseClient", "AnalyzeSubscriptionUsage", nil, "Failure preparing request") - return - } - - resp, err := client.AnalyzeSubscriptionUsageSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "consumption.BaseClient", "AnalyzeSubscriptionUsage", resp, "Failure sending request") - return - } - - result, err = client.AnalyzeSubscriptionUsageResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "consumption.BaseClient", "AnalyzeSubscriptionUsage", resp, "Failure responding to request") - } - - return -} - -// AnalyzeSubscriptionUsagePreparer prepares the AnalyzeSubscriptionUsage request. -func (client BaseClient) AnalyzeSubscriptionUsagePreparer(ctx context.Context, parameters ReportConfigDefinition) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2018-05-31" - 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("/subscriptions/{subscriptionId}/providers/Microsoft.Consumption/AnalyzeUsage", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// AnalyzeSubscriptionUsageSender sends the AnalyzeSubscriptionUsage request. The method will close the -// http.Response Body if it receives an error. -func (client BaseClient) AnalyzeSubscriptionUsageSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// AnalyzeSubscriptionUsageResponder handles the response to the AnalyzeSubscriptionUsage request. The method always -// closes the http.Response Body. -func (client BaseClient) AnalyzeSubscriptionUsageResponder(resp *http.Response) (result UsageAnalysisResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/services/consumption/mgmt/2018-05-31/consumption/models.go b/services/consumption/mgmt/2018-05-31/consumption/models.go index 1c530fd466f2..e59303b8885a 100644 --- a/services/consumption/mgmt/2018-05-31/consumption/models.go +++ b/services/consumption/mgmt/2018-05-31/consumption/models.go @@ -57,19 +57,6 @@ func PossibleChargeTypeValues() []ChargeType { return []ChargeType{ChargeTypeActual, ChargeTypeForecast} } -// 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} -} - // Grain enumerates the values for grain. type Grain string @@ -87,198 +74,6 @@ func PossibleGrainValues() []Grain { return []Grain{Daily, Monthly, Yearly} } -// GranularityType enumerates the values for granularity type. -type GranularityType string - -const ( - // GranularityTypeDaily ... - GranularityTypeDaily GranularityType = "Daily" -) - -// PossibleGranularityTypeValues returns an array of possible values for the GranularityType const type. -func PossibleGranularityTypeValues() []GranularityType { - return []GranularityType{GranularityTypeDaily} -} - -// 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} -} - -// 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 ( - // Custom ... - Custom TimeframeType = "Custom" - // MonthToDate ... - MonthToDate TimeframeType = "MonthToDate" - // WeekToDate ... - WeekToDate TimeframeType = "WeekToDate" - // YearToDate ... - YearToDate TimeframeType = "YearToDate" -) - -// PossibleTimeframeTypeValues returns an array of possible values for the TimeframeType const type. -func PossibleTimeframeTypeValues() []TimeframeType { - return []TimeframeType{Custom, MonthToDate, WeekToDate, YearToDate} -} - -// Dimension ... -type Dimension struct { - *DimensionProperties `json:"properties,omitempty"` - // ID - Resource Id. - ID *string `json:"id,omitempty"` - // Name - Resource name. - Name *string `json:"name,omitempty"` - // Type - Resource type. - Type *string `json:"type,omitempty"` - // Tags - 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 - } - if d.ID != nil { - objectMap["id"] = d.ID - } - if d.Name != nil { - objectMap["name"] = d.Name - } - if d.Type != nil { - objectMap["type"] = d.Type - } - if d.Tags != nil { - objectMap["tags"] = d.Tags - } - 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 { - Data *[]string `json:"data,omitempty"` - Total *int32 `json:"total,omitempty"` - Category *string `json:"category,omitempty"` - UsageStart *date.Time `json:"usageStart,omitempty"` - UsageEnd *date.Time `json:"usageEnd,omitempty"` - NextLink *string `json:"nextLink,omitempty"` -} - -// DimensionsListResult result of listing dimensions. It contains a list of available dimensions. -type DimensionsListResult struct { - autorest.Response `json:"-"` - // Value - The list of dimensions. - Value *[]Dimension `json:"value,omitempty"` -} - // ErrorDetails the details of the error. type ErrorDetails struct { // Code - Error code. @@ -685,256 +480,6 @@ func (psr *PriceSheetResult) UnmarshalJSON(body []byte) error { return nil } -// ReportConfig a report config resource. -type ReportConfig struct { - autorest.Response `json:"-"` - *ReportConfigProperties `json:"properties,omitempty"` - // ID - Resource Id. - ID *string `json:"id,omitempty"` - // Name - Resource name. - Name *string `json:"name,omitempty"` - // Type - Resource type. - Type *string `json:"type,omitempty"` - // Tags - Resource tags. - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for ReportConfig. -func (rc ReportConfig) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if rc.ReportConfigProperties != nil { - objectMap["properties"] = rc.ReportConfigProperties - } - if rc.ID != nil { - objectMap["id"] = rc.ID - } - if rc.Name != nil { - objectMap["name"] = rc.Name - } - if rc.Type != nil { - objectMap["type"] = rc.Type - } - if rc.Tags != nil { - objectMap["tags"] = rc.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for ReportConfig struct. -func (rc *ReportConfig) 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 reportConfigProperties ReportConfigProperties - err = json.Unmarshal(*v, &reportConfigProperties) - if err != nil { - return err - } - rc.ReportConfigProperties = &reportConfigProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - rc.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - rc.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - rc.Type = &typeVar - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - rc.Tags = tags - } - } - } - - return nil -} - -// 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 comaprison. - 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"` -} - -// ReportConfigDataset the definition of data present in the report. -type ReportConfigDataset struct { - // Granularity - The granularity of rows in the report. Possible values include: 'GranularityTypeDaily' - Granularity GranularityType `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 upto 2 aggregation clauses. - Aggregation map[string]*ReportConfigAggregation `json:"aggregation"` - // Grouping - Array of group by expression to use in the report. Report can have upto 2 group by clauses. - Grouping *[]ReportConfigGrouping `json:"grouping,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.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. - 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: 'WeekToDate', 'MonthToDate', 'YearToDate', 'Custom' - Timeframe TimeframeType `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"` -} - -// ReportConfigDeliveryDestination the destination information for the delivery of the report. -type ReportConfigDeliveryDestination struct { - // ResourceID - The resource id of the storage account where reports will be delivered. - ResourceID *string `json:"resourceId,omitempty"` - // Container - The name of the container where reports will be uploaded. - Container *string `json:"container,omitempty"` - // RootFolderPath - The name of the directory where reports will be uploaded. - RootFolderPath *string `json:"rootFolderPath,omitempty"` -} - -// ReportConfigDeliveryInfo the delivery information associated with a report config. -type ReportConfigDeliveryInfo struct { - // Destination - Has destination for the report being delivered. - Destination *ReportConfigDeliveryDestination `json:"destination,omitempty"` -} - -// ReportConfigFilter the filter expression to be used in the report. -type ReportConfigFilter struct { - // And - The logical "AND" expression. Must have atleast 2 items. - And *[]ReportConfigFilter `json:"and,omitempty"` - // Or - The logical "OR" expression. Must have atleast 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 { - // ColumnType - Has type of the column to group. Possible values include: 'ReportConfigColumnTypeTag', 'ReportConfigColumnTypeDimension' - ColumnType ReportConfigColumnType `json:"columnType,omitempty"` - // Name - The name of the column to group. - Name *string `json:"name,omitempty"` -} - -// ReportConfigListResult result of listing report configs. It contains a list of available report configurations -// in the scope provided. -type ReportConfigListResult struct { - autorest.Response `json:"-"` - // Value - The list of report configs. - Value *[]ReportConfig `json:"value,omitempty"` -} - -// ReportConfigProperties the properties of the report config. -type ReportConfigProperties struct { - // Schedule - Has schedule information for the report config. - Schedule *ReportConfigSchedule `json:"schedule,omitempty"` - // Format - The format of the report being delivered. Possible values include: 'Csv' - Format FormatType `json:"format,omitempty"` - // DeliveryInfo - Has delivery information for the report config. - DeliveryInfo *ReportConfigDeliveryInfo `json:"deliveryInfo,omitempty"` - // Definition - Has definition for the report config. - Definition *ReportConfigDefinition `json:"definition,omitempty"` -} - -// ReportConfigRecurrencePeriod the start and end date for recurrence schedule. -type ReportConfigRecurrencePeriod struct { - // From - The start date of recurrence. - From *date.Time `json:"from,omitempty"` - // To - The end date of recurrence. If not provided, we default this to 10 years from the start date. - To *date.Time `json:"to,omitempty"` -} - -// ReportConfigSchedule the schedule associated with a report config. -type ReportConfigSchedule struct { - // Status - The status of the schedule. Whether active or not. If inactive, the report's scheduled execution 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 *ReportConfigRecurrencePeriod `json:"recurrencePeriod,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 - Resource Id. @@ -965,121 +510,6 @@ func (r Resource) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } -// UsageAnalysis ... -type UsageAnalysis struct { - *UsageAnalysisProperties `json:"properties,omitempty"` - // ID - Resource Id. - ID *string `json:"id,omitempty"` - // Name - Resource name. - Name *string `json:"name,omitempty"` - // Type - Resource type. - Type *string `json:"type,omitempty"` - // Tags - Resource tags. - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for UsageAnalysis. -func (ua UsageAnalysis) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if ua.UsageAnalysisProperties != nil { - objectMap["properties"] = ua.UsageAnalysisProperties - } - if ua.ID != nil { - objectMap["id"] = ua.ID - } - if ua.Name != nil { - objectMap["name"] = ua.Name - } - if ua.Type != nil { - objectMap["type"] = ua.Type - } - if ua.Tags != nil { - objectMap["tags"] = ua.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for UsageAnalysis struct. -func (ua *UsageAnalysis) 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 usageAnalysisProperties UsageAnalysisProperties - err = json.Unmarshal(*v, &usageAnalysisProperties) - if err != nil { - return err - } - ua.UsageAnalysisProperties = &usageAnalysisProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - ua.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - ua.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - ua.Type = &typeVar - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - ua.Tags = tags - } - } - } - - return nil -} - -// UsageAnalysisColumn ... -type UsageAnalysisColumn struct { - Name *string `json:"name,omitempty"` - Type *string `json:"type,omitempty"` -} - -// UsageAnalysisProperties ... -type UsageAnalysisProperties struct { - NextLink *string `json:"nextLink,omitempty"` - // Columns - Array of columns - Columns *[]UsageAnalysisColumn `json:"columns,omitempty"` - Rows *[][]interface{} `json:"rows,omitempty"` -} - -// UsageAnalysisResult result of listing usages. It contains all columns listed under groupings and aggregation. -type UsageAnalysisResult struct { - autorest.Response `json:"-"` - // Value - The list of usage data. - Value *[]UsageAnalysis `json:"value,omitempty"` -} - // UsageDetail an usage detail resource. type UsageDetail struct { *UsageDetailProperties `json:"properties,omitempty"` diff --git a/services/consumption/mgmt/2018-05-31/consumption/reportconfig.go b/services/consumption/mgmt/2018-05-31/consumption/reportconfig.go deleted file mode 100644 index 3cf62d42d421..000000000000 --- a/services/consumption/mgmt/2018-05-31/consumption/reportconfig.go +++ /dev/null @@ -1,667 +0,0 @@ -package consumption - -// Copyright (c) Microsoft and contributors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// -// See the License for the specific language governing permissions and -// limitations under the License. -// -// 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" - "net/http" -) - -// ReportConfigClient is the consumption management client provides access to consumption resources for Azure -// Enterprise Subscriptions. -type ReportConfigClient struct { - BaseClient -} - -// NewReportConfigClient creates an instance of the ReportConfigClient client. -func NewReportConfigClient(subscriptionID string) ReportConfigClient { - return NewReportConfigClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewReportConfigClientWithBaseURI creates an instance of the ReportConfigClient client. -func NewReportConfigClientWithBaseURI(baseURI string, subscriptionID string) ReportConfigClient { - return ReportConfigClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// CreateOrUpdate the operation to create or update a report config. Update operation requires latest eTag to be set in -// the request mandatorily. You may obtain the latest eTag by performing a get operation. Create operation does not -// require eTag. -// Parameters: -// reportConfigName - report Config Name. -// parameters - parameters supplied to the CreateOrUpdate Report Config operation. -func (client ReportConfigClient) CreateOrUpdate(ctx context.Context, reportConfigName string, parameters ReportConfig) (result ReportConfig, err error) { - if err := validation.Validate([]validation.Validation{ - {TargetValue: parameters, - Constraints: []validation.Constraint{{Target: "parameters.ReportConfigProperties", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Schedule", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Schedule.RecurrencePeriod", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Schedule.RecurrencePeriod.From", Name: validation.Null, Rule: true, Chain: nil}}}, - }}, - {Target: "parameters.ReportConfigProperties.DeliveryInfo", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.DeliveryInfo.Destination", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.DeliveryInfo.Destination.ResourceID", Name: validation.Null, Rule: true, Chain: nil}, - {Target: "parameters.ReportConfigProperties.DeliveryInfo.Destination.Container", Name: validation.Null, Rule: true, Chain: nil}, - }}, - }}, - {Target: "parameters.ReportConfigProperties.Definition", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Type", Name: validation.Null, Rule: true, Chain: nil}, - {Target: "parameters.ReportConfigProperties.Definition.TimePeriod", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.TimePeriod.From", Name: validation.Null, Rule: true, Chain: nil}, - {Target: "parameters.ReportConfigProperties.Definition.TimePeriod.To", Name: validation.Null, Rule: true, Chain: nil}, - }}, - {Target: "parameters.ReportConfigProperties.Definition.Dataset", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Grouping", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Grouping", Name: validation.MaxItems, Rule: 2, Chain: nil}}}, - {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.And", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.And", Name: validation.MinItems, Rule: 2, Chain: nil}}}, - {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Or", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Or", Name: validation.MinItems, Rule: 2, Chain: nil}}}, - {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Not", Name: validation.Null, Rule: false, Chain: nil}, - {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Dimension", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Dimension.Name", Name: validation.Null, Rule: true, Chain: nil}, - {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Dimension.Operator", Name: validation.Null, Rule: true, Chain: nil}, - {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Dimension.Values", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Dimension.Values", Name: validation.MinItems, Rule: 1, Chain: nil}}}, - }}, - {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Tag", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Tag.Name", Name: validation.Null, Rule: true, Chain: nil}, - {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Tag.Operator", Name: validation.Null, Rule: true, Chain: nil}, - {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Tag.Values", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Tag.Values", Name: validation.MinItems, Rule: 1, Chain: nil}}}, - }}, - }}, - }}, - }}, - }}}}}); err != nil { - return result, validation.NewError("consumption.ReportConfigClient", "CreateOrUpdate", err.Error()) - } - - req, err := client.CreateOrUpdatePreparer(ctx, reportConfigName, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "CreateOrUpdate", nil, "Failure preparing request") - return - } - - resp, err := client.CreateOrUpdateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "CreateOrUpdate", resp, "Failure sending request") - return - } - - result, err = client.CreateOrUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "CreateOrUpdate", resp, "Failure responding to request") - } - - return -} - -// CreateOrUpdatePreparer prepares the CreateOrUpdate request. -func (client ReportConfigClient) CreateOrUpdatePreparer(ctx context.Context, reportConfigName string, parameters ReportConfig) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "reportConfigName": autorest.Encode("path", reportConfigName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2018-05-31" - 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("/subscriptions/{subscriptionId}/providers/Microsoft.Consumption/reportconfigs/{reportConfigName}", 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 ReportConfigClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always -// closes the http.Response Body. -func (client ReportConfigClient) CreateOrUpdateResponder(resp *http.Response) (result ReportConfig, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// CreateOrUpdateByResourceGroupName the operation to create or update a report config. Update operation requires -// latest eTag to be set in the request mandatorily. You may obtain the latest eTag by performing a get operation. -// Create operation does not require eTag. -// Parameters: -// resourceGroupName - azure Resource Group Name. -// reportConfigName - report Config Name. -// parameters - parameters supplied to the CreateOrUpdate Report Config operation. -func (client ReportConfigClient) CreateOrUpdateByResourceGroupName(ctx context.Context, resourceGroupName string, reportConfigName string, parameters ReportConfig) (result ReportConfig, err error) { - if err := validation.Validate([]validation.Validation{ - {TargetValue: parameters, - Constraints: []validation.Constraint{{Target: "parameters.ReportConfigProperties", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Schedule", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Schedule.RecurrencePeriod", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Schedule.RecurrencePeriod.From", Name: validation.Null, Rule: true, Chain: nil}}}, - }}, - {Target: "parameters.ReportConfigProperties.DeliveryInfo", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.DeliveryInfo.Destination", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.DeliveryInfo.Destination.ResourceID", Name: validation.Null, Rule: true, Chain: nil}, - {Target: "parameters.ReportConfigProperties.DeliveryInfo.Destination.Container", Name: validation.Null, Rule: true, Chain: nil}, - }}, - }}, - {Target: "parameters.ReportConfigProperties.Definition", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Type", Name: validation.Null, Rule: true, Chain: nil}, - {Target: "parameters.ReportConfigProperties.Definition.TimePeriod", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.TimePeriod.From", Name: validation.Null, Rule: true, Chain: nil}, - {Target: "parameters.ReportConfigProperties.Definition.TimePeriod.To", Name: validation.Null, Rule: true, Chain: nil}, - }}, - {Target: "parameters.ReportConfigProperties.Definition.Dataset", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Grouping", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Grouping", Name: validation.MaxItems, Rule: 2, Chain: nil}}}, - {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.And", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.And", Name: validation.MinItems, Rule: 2, Chain: nil}}}, - {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Or", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Or", Name: validation.MinItems, Rule: 2, Chain: nil}}}, - {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Not", Name: validation.Null, Rule: false, Chain: nil}, - {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Dimension", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Dimension.Name", Name: validation.Null, Rule: true, Chain: nil}, - {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Dimension.Operator", Name: validation.Null, Rule: true, Chain: nil}, - {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Dimension.Values", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Dimension.Values", Name: validation.MinItems, Rule: 1, Chain: nil}}}, - }}, - {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Tag", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Tag.Name", Name: validation.Null, Rule: true, Chain: nil}, - {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Tag.Operator", Name: validation.Null, Rule: true, Chain: nil}, - {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Tag.Values", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Tag.Values", Name: validation.MinItems, Rule: 1, Chain: nil}}}, - }}, - }}, - }}, - }}, - }}}}}); err != nil { - return result, validation.NewError("consumption.ReportConfigClient", "CreateOrUpdateByResourceGroupName", err.Error()) - } - - req, err := client.CreateOrUpdateByResourceGroupNamePreparer(ctx, resourceGroupName, reportConfigName, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "CreateOrUpdateByResourceGroupName", nil, "Failure preparing request") - return - } - - resp, err := client.CreateOrUpdateByResourceGroupNameSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "CreateOrUpdateByResourceGroupName", resp, "Failure sending request") - return - } - - result, err = client.CreateOrUpdateByResourceGroupNameResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "CreateOrUpdateByResourceGroupName", resp, "Failure responding to request") - } - - return -} - -// CreateOrUpdateByResourceGroupNamePreparer prepares the CreateOrUpdateByResourceGroupName request. -func (client ReportConfigClient) CreateOrUpdateByResourceGroupNamePreparer(ctx context.Context, resourceGroupName string, reportConfigName string, parameters ReportConfig) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "reportConfigName": autorest.Encode("path", reportConfigName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2018-05-31" - 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("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Consumption/reportconfigs/{reportConfigName}", pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateOrUpdateByResourceGroupNameSender sends the CreateOrUpdateByResourceGroupName request. The method will close the -// http.Response Body if it receives an error. -func (client ReportConfigClient) CreateOrUpdateByResourceGroupNameSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// CreateOrUpdateByResourceGroupNameResponder handles the response to the CreateOrUpdateByResourceGroupName request. The method always -// closes the http.Response Body. -func (client ReportConfigClient) CreateOrUpdateByResourceGroupNameResponder(resp *http.Response) (result ReportConfig, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// Delete the operation to delete a report. -// Parameters: -// reportConfigName - report Config Name. -func (client ReportConfigClient) Delete(ctx context.Context, reportConfigName string) (result autorest.Response, err error) { - req, err := client.DeletePreparer(ctx, reportConfigName) - if err != nil { - err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "Delete", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "Delete", resp, "Failure sending request") - return - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "Delete", resp, "Failure responding to request") - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client ReportConfigClient) DeletePreparer(ctx context.Context, reportConfigName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "reportConfigName": autorest.Encode("path", reportConfigName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2018-05-31" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Consumption/reportconfigs/{reportConfigName}", 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 ReportConfigClient) DeleteSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client ReportConfigClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.Response = resp - return -} - -// DeleteByResourceGroupName the operation to delete a report config. -// Parameters: -// resourceGroupName - azure Resource Group Name. -// reportConfigName - report Config Name. -func (client ReportConfigClient) DeleteByResourceGroupName(ctx context.Context, resourceGroupName string, reportConfigName string) (result autorest.Response, err error) { - req, err := client.DeleteByResourceGroupNamePreparer(ctx, resourceGroupName, reportConfigName) - if err != nil { - err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "DeleteByResourceGroupName", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteByResourceGroupNameSender(req) - if err != nil { - result.Response = resp - err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "DeleteByResourceGroupName", resp, "Failure sending request") - return - } - - result, err = client.DeleteByResourceGroupNameResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "DeleteByResourceGroupName", resp, "Failure responding to request") - } - - return -} - -// DeleteByResourceGroupNamePreparer prepares the DeleteByResourceGroupName request. -func (client ReportConfigClient) DeleteByResourceGroupNamePreparer(ctx context.Context, resourceGroupName string, reportConfigName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "reportConfigName": autorest.Encode("path", reportConfigName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2018-05-31" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Consumption/reportconfigs/{reportConfigName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteByResourceGroupNameSender sends the DeleteByResourceGroupName request. The method will close the -// http.Response Body if it receives an error. -func (client ReportConfigClient) DeleteByResourceGroupNameSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// DeleteByResourceGroupNameResponder handles the response to the DeleteByResourceGroupName request. The method always -// closes the http.Response Body. -func (client ReportConfigClient) DeleteByResourceGroupNameResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.Response = resp - return -} - -// Get gets the report config for a subscription by report config name. -// Parameters: -// reportConfigName - report Config Name. -func (client ReportConfigClient) Get(ctx context.Context, reportConfigName string) (result ReportConfig, err error) { - req, err := client.GetPreparer(ctx, reportConfigName) - if err != nil { - err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "Get", resp, "Failure responding to request") - } - - return -} - -// GetPreparer prepares the Get request. -func (client ReportConfigClient) GetPreparer(ctx context.Context, reportConfigName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "reportConfigName": autorest.Encode("path", reportConfigName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2018-05-31" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Consumption/reportconfigs/{reportConfigName}", 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 ReportConfigClient) GetSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client ReportConfigClient) GetResponder(resp *http.Response) (result ReportConfig, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// GetByResourceGroupName gets the report config for a resource group under a subscription by report config name. -// Parameters: -// resourceGroupName - azure Resource Group Name. -// reportConfigName - report Config Name. -func (client ReportConfigClient) GetByResourceGroupName(ctx context.Context, resourceGroupName string, reportConfigName string) (result ReportConfig, err error) { - req, err := client.GetByResourceGroupNamePreparer(ctx, resourceGroupName, reportConfigName) - if err != nil { - err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "GetByResourceGroupName", nil, "Failure preparing request") - return - } - - resp, err := client.GetByResourceGroupNameSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "GetByResourceGroupName", resp, "Failure sending request") - return - } - - result, err = client.GetByResourceGroupNameResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "GetByResourceGroupName", resp, "Failure responding to request") - } - - return -} - -// GetByResourceGroupNamePreparer prepares the GetByResourceGroupName request. -func (client ReportConfigClient) GetByResourceGroupNamePreparer(ctx context.Context, resourceGroupName string, reportConfigName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "reportConfigName": autorest.Encode("path", reportConfigName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2018-05-31" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Consumption/reportconfigs/{reportConfigName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetByResourceGroupNameSender sends the GetByResourceGroupName request. The method will close the -// http.Response Body if it receives an error. -func (client ReportConfigClient) GetByResourceGroupNameSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// GetByResourceGroupNameResponder handles the response to the GetByResourceGroupName request. The method always -// closes the http.Response Body. -func (client ReportConfigClient) GetByResourceGroupNameResponder(resp *http.Response) (result ReportConfig, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// List lists all report configs for a subscription. -func (client ReportConfigClient) List(ctx context.Context) (result ReportConfigListResult, err error) { - req, err := client.ListPreparer(ctx) - if err != nil { - err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "List", resp, "Failure sending request") - return - } - - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "List", resp, "Failure responding to request") - } - - return -} - -// ListPreparer prepares the List request. -func (client ReportConfigClient) ListPreparer(ctx context.Context) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2018-05-31" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Consumption/reportconfigs", 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 ReportConfigClient) ListSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client ReportConfigClient) ListResponder(resp *http.Response) (result ReportConfigListResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// ListByResourceGroupName lists all report configs for a resource group under a subscription. -// Parameters: -// resourceGroupName - azure Resource Group Name. -func (client ReportConfigClient) ListByResourceGroupName(ctx context.Context, resourceGroupName string) (result ReportConfigListResult, err error) { - req, err := client.ListByResourceGroupNamePreparer(ctx, resourceGroupName) - if err != nil { - err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "ListByResourceGroupName", nil, "Failure preparing request") - return - } - - resp, err := client.ListByResourceGroupNameSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "ListByResourceGroupName", resp, "Failure sending request") - return - } - - result, err = client.ListByResourceGroupNameResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "ListByResourceGroupName", resp, "Failure responding to request") - } - - return -} - -// ListByResourceGroupNamePreparer prepares the ListByResourceGroupName request. -func (client ReportConfigClient) ListByResourceGroupNamePreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2018-05-31" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Consumption/reportconfigs", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListByResourceGroupNameSender sends the ListByResourceGroupName request. The method will close the -// http.Response Body if it receives an error. -func (client ReportConfigClient) ListByResourceGroupNameSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// ListByResourceGroupNameResponder handles the response to the ListByResourceGroupName request. The method always -// closes the http.Response Body. -func (client ReportConfigClient) ListByResourceGroupNameResponder(resp *http.Response) (result ReportConfigListResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/services/consumption/mgmt/2018-05-31/consumption/resourcegroupdimensions.go b/services/consumption/mgmt/2018-05-31/consumption/resourcegroupdimensions.go deleted file mode 100644 index 652e2f80c655..000000000000 --- a/services/consumption/mgmt/2018-05-31/consumption/resourcegroupdimensions.go +++ /dev/null @@ -1,136 +0,0 @@ -package consumption - -// Copyright (c) Microsoft and contributors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// -// See the License for the specific language governing permissions and -// limitations under the License. -// -// 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" - "net/http" -) - -// ResourceGroupDimensionsClient is the consumption management client provides access to consumption resources for -// Azure Enterprise Subscriptions. -type ResourceGroupDimensionsClient struct { - BaseClient -} - -// NewResourceGroupDimensionsClient creates an instance of the ResourceGroupDimensionsClient client. -func NewResourceGroupDimensionsClient(subscriptionID string) ResourceGroupDimensionsClient { - return NewResourceGroupDimensionsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewResourceGroupDimensionsClientWithBaseURI creates an instance of the ResourceGroupDimensionsClient client. -func NewResourceGroupDimensionsClientWithBaseURI(baseURI string, subscriptionID string) ResourceGroupDimensionsClient { - return ResourceGroupDimensionsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// List lists the dimensions by resource group Id. -// Parameters: -// resourceGroupName - azure Resource Group Name. -// 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 dategory. 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 ResourceGroupDimensionsClient) List(ctx context.Context, resourceGroupName string, filter string, expand string, skiptoken string, top *int32) (result DimensionsListResult, err error) { - 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: 1, Chain: nil}, - }}}}}); err != nil { - return result, validation.NewError("consumption.ResourceGroupDimensionsClient", "List", err.Error()) - } - - req, err := client.ListPreparer(ctx, resourceGroupName, filter, expand, skiptoken, top) - if err != nil { - err = autorest.NewErrorWithError(err, "consumption.ResourceGroupDimensionsClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "consumption.ResourceGroupDimensionsClient", "List", resp, "Failure sending request") - return - } - - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "consumption.ResourceGroupDimensionsClient", "List", resp, "Failure responding to request") - } - - return -} - -// ListPreparer prepares the List request. -func (client ResourceGroupDimensionsClient) ListPreparer(ctx context.Context, resourceGroupName string, filter string, expand string, skiptoken string, top *int32) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2018-05-31" - 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("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Consumption/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 ResourceGroupDimensionsClient) ListSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client ResourceGroupDimensionsClient) ListResponder(resp *http.Response) (result DimensionsListResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/services/consumption/mgmt/2018-05-31/consumption/subscriptiondimensions.go b/services/consumption/mgmt/2018-05-31/consumption/subscriptiondimensions.go deleted file mode 100644 index 45d0dd7aa1df..000000000000 --- a/services/consumption/mgmt/2018-05-31/consumption/subscriptiondimensions.go +++ /dev/null @@ -1,134 +0,0 @@ -package consumption - -// Copyright (c) Microsoft and contributors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// -// See the License for the specific language governing permissions and -// limitations under the License. -// -// 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" - "net/http" -) - -// SubscriptionDimensionsClient is the consumption management client provides access to consumption resources for Azure -// Enterprise Subscriptions. -type SubscriptionDimensionsClient struct { - BaseClient -} - -// NewSubscriptionDimensionsClient creates an instance of the SubscriptionDimensionsClient client. -func NewSubscriptionDimensionsClient(subscriptionID string) SubscriptionDimensionsClient { - return NewSubscriptionDimensionsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewSubscriptionDimensionsClientWithBaseURI creates an instance of the SubscriptionDimensionsClient client. -func NewSubscriptionDimensionsClientWithBaseURI(baseURI string, subscriptionID string) SubscriptionDimensionsClient { - return SubscriptionDimensionsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// List lists the dimensions by subscription Id. -// Parameters: -// 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 dategory. 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 SubscriptionDimensionsClient) List(ctx context.Context, filter string, expand string, skiptoken string, top *int32) (result DimensionsListResult, err error) { - 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: 1, Chain: nil}, - }}}}}); err != nil { - return result, validation.NewError("consumption.SubscriptionDimensionsClient", "List", err.Error()) - } - - req, err := client.ListPreparer(ctx, filter, expand, skiptoken, top) - if err != nil { - err = autorest.NewErrorWithError(err, "consumption.SubscriptionDimensionsClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "consumption.SubscriptionDimensionsClient", "List", resp, "Failure sending request") - return - } - - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "consumption.SubscriptionDimensionsClient", "List", resp, "Failure responding to request") - } - - return -} - -// ListPreparer prepares the List request. -func (client SubscriptionDimensionsClient) ListPreparer(ctx context.Context, filter string, expand string, skiptoken string, top *int32) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2018-05-31" - 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("/subscriptions/{subscriptionId}/providers/Microsoft.Consumption/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 SubscriptionDimensionsClient) ListSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client SubscriptionDimensionsClient) ListResponder(resp *http.Response) (result DimensionsListResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -}