diff --git a/profiles/preview/costmanagement/mgmt/costmanagement/models.go b/profiles/preview/costmanagement/mgmt/costmanagement/models.go new file mode 100644 index 000000000000..b16d97a81d58 --- /dev/null +++ b/profiles/preview/costmanagement/mgmt/costmanagement/models.go @@ -0,0 +1,157 @@ +// +build go1.9 + +// Copyright 2018 Microsoft Corporation +// +// 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. + +// This code was auto-generated by: +// github.com/Azure/azure-sdk-for-go/tools/profileBuilder + +package costmanagement + +import original "github.com/Azure/azure-sdk-for-go/services/costmanagement/mgmt/2018-05-31/costmanagement" + +type BillingAccountDimensionsClient = original.BillingAccountDimensionsClient + +const ( + DefaultBaseURI = original.DefaultBaseURI +) + +type BaseClient = original.BaseClient +type FormatType = original.FormatType + +const ( + Csv FormatType = original.Csv +) + +type GranularityType = original.GranularityType + +const ( + Daily GranularityType = original.Daily +) + +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 Query = original.Query +type QueryColumn = original.QueryColumn +type QueryProperties = original.QueryProperties +type QueryResult = original.QueryResult +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 ReportConfigClient = original.ReportConfigClient +type ResourceGroupDimensionsClient = original.ResourceGroupDimensionsClient +type SubscriptionDimensionsClient = original.SubscriptionDimensionsClient + +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) +} +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return original.NewWithBaseURI(baseURI, subscriptionID) +} +func PossibleFormatTypeValues() []FormatType { + return original.PossibleFormatTypeValues() +} +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 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 UserAgent() string { + return original.UserAgent() + " profiles/preview" +} +func Version() string { + return original.Version() +} diff --git a/services/costmanagement/mgmt/2018-05-31/costmanagement/billingaccountdimensions.go b/services/costmanagement/mgmt/2018-05-31/costmanagement/billingaccountdimensions.go new file mode 100644 index 000000000000..b162e4d19ad8 --- /dev/null +++ b/services/costmanagement/mgmt/2018-05-31/costmanagement/billingaccountdimensions.go @@ -0,0 +1,134 @@ +package costmanagement + +// 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 client for the BillingAccountDimensions methods of the Costmanagement service. +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("costmanagement.BillingAccountDimensionsClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, billingAccountID, filter, expand, skiptoken, top) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.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, "costmanagement.BillingAccountDimensionsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.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.CostManagement/dimensions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client 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/costmanagement/mgmt/2018-05-31/costmanagement/client.go b/services/costmanagement/mgmt/2018-05-31/costmanagement/client.go new file mode 100644 index 000000000000..a43db626d54a --- /dev/null +++ b/services/costmanagement/mgmt/2018-05-31/costmanagement/client.go @@ -0,0 +1,355 @@ +// Package costmanagement implements the Azure ARM Costmanagement service API version 2018-05-31. +// +// +package costmanagement + +// 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" +) + +const ( + // DefaultBaseURI is the default URI used for the service Costmanagement + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Costmanagement. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient client. +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} + +// QueryBillingAccount lists the usage data for billing account. +// Parameters: +// billingAccountID - billingAccount ID +// parameters - parameters supplied to the CreateOrUpdate Report Config operation. +func (client BaseClient) QueryBillingAccount(ctx context.Context, billingAccountID string, parameters ReportConfigDefinition) (result QueryResult, 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("costmanagement.BaseClient", "QueryBillingAccount", err.Error()) + } + + req, err := client.QueryBillingAccountPreparer(ctx, billingAccountID, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.BaseClient", "QueryBillingAccount", nil, "Failure preparing request") + return + } + + resp, err := client.QueryBillingAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "costmanagement.BaseClient", "QueryBillingAccount", resp, "Failure sending request") + return + } + + result, err = client.QueryBillingAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.BaseClient", "QueryBillingAccount", resp, "Failure responding to request") + } + + return +} + +// QueryBillingAccountPreparer prepares the QueryBillingAccount request. +func (client BaseClient) QueryBillingAccountPreparer(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.CostManagement/Query", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// QueryBillingAccountSender sends the QueryBillingAccount request. The method will close the +// http.Response Body if it receives an error. +func (client BaseClient) QueryBillingAccountSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// QueryBillingAccountResponder handles the response to the QueryBillingAccount request. The method always +// closes the http.Response Body. +func (client BaseClient) QueryBillingAccountResponder(resp *http.Response) (result QueryResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// QueryResourceGroup 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) QueryResourceGroup(ctx context.Context, resourceGroupName string, parameters ReportConfigDefinition) (result QueryResult, 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("costmanagement.BaseClient", "QueryResourceGroup", err.Error()) + } + + req, err := client.QueryResourceGroupPreparer(ctx, resourceGroupName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.BaseClient", "QueryResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.QueryResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "costmanagement.BaseClient", "QueryResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.QueryResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.BaseClient", "QueryResourceGroup", resp, "Failure responding to request") + } + + return +} + +// QueryResourceGroupPreparer prepares the QueryResourceGroup request. +func (client BaseClient) QueryResourceGroupPreparer(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.CostManagement/Query", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// QueryResourceGroupSender sends the QueryResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client BaseClient) QueryResourceGroupSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// QueryResourceGroupResponder handles the response to the QueryResourceGroup request. The method always +// closes the http.Response Body. +func (client BaseClient) QueryResourceGroupResponder(resp *http.Response) (result QueryResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// QuerySubscription lists the usage data for subscriptionId. +// Parameters: +// parameters - parameters supplied to the CreateOrUpdate Report Config operation. +func (client BaseClient) QuerySubscription(ctx context.Context, parameters ReportConfigDefinition) (result QueryResult, 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("costmanagement.BaseClient", "QuerySubscription", err.Error()) + } + + req, err := client.QuerySubscriptionPreparer(ctx, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.BaseClient", "QuerySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.QuerySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "costmanagement.BaseClient", "QuerySubscription", resp, "Failure sending request") + return + } + + result, err = client.QuerySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.BaseClient", "QuerySubscription", resp, "Failure responding to request") + } + + return +} + +// QuerySubscriptionPreparer prepares the QuerySubscription request. +func (client BaseClient) QuerySubscriptionPreparer(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.CostManagement/Query", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// QuerySubscriptionSender sends the QuerySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client BaseClient) QuerySubscriptionSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// QuerySubscriptionResponder handles the response to the QuerySubscription request. The method always +// closes the http.Response Body. +func (client BaseClient) QuerySubscriptionResponder(resp *http.Response) (result QueryResult, 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/costmanagement/mgmt/2018-05-31/costmanagement/models.go b/services/costmanagement/mgmt/2018-05-31/costmanagement/models.go new file mode 100644 index 000000000000..2f9f3b4ed498 --- /dev/null +++ b/services/costmanagement/mgmt/2018-05-31/costmanagement/models.go @@ -0,0 +1,639 @@ +package costmanagement + +// 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 ( + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/date" +) + +// 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} +} + +// GranularityType enumerates the values for granularity type. +type GranularityType string + +const ( + // Daily ... + Daily GranularityType = "Daily" +) + +// PossibleGranularityTypeValues returns an array of possible values for the GranularityType const type. +func PossibleGranularityTypeValues() []GranularityType { + return []GranularityType{Daily} +} + +// 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. + Code *string `json:"code,omitempty"` + // Message - Error message indicating why the operation failed. + Message *string `json:"message,omitempty"` +} + +// ErrorResponse error response indicates that the service is not able to process the incoming request. The reason +// is provided in the error message. +type ErrorResponse struct { + // Error - The details of the error. + Error *ErrorDetails `json:"error,omitempty"` +} + +// Query ... +type Query struct { + *QueryProperties `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 Query. +func (q Query) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if q.QueryProperties != nil { + objectMap["properties"] = q.QueryProperties + } + if q.ID != nil { + objectMap["id"] = q.ID + } + if q.Name != nil { + objectMap["name"] = q.Name + } + if q.Type != nil { + objectMap["type"] = q.Type + } + if q.Tags != nil { + objectMap["tags"] = q.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Query struct. +func (q *Query) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var queryProperties QueryProperties + err = json.Unmarshal(*v, &queryProperties) + if err != nil { + return err + } + q.QueryProperties = &queryProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + q.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + q.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + q.Type = &typeVar + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + q.Tags = tags + } + } + } + + return nil +} + +// QueryColumn ... +type QueryColumn struct { + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} + +// QueryProperties ... +type QueryProperties struct { + NextLink *string `json:"nextLink,omitempty"` + // Columns - Array of columns + Columns *[]QueryColumn `json:"columns,omitempty"` + Rows *[][]interface{} `json:"rows,omitempty"` +} + +// QueryResult result of query. It contains all columns listed under groupings and aggregation. +type QueryResult struct { + autorest.Response `json:"-"` + // Value - The list of usage data. + Value *[]Query `json:"value,omitempty"` +} + +// 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: 'Daily' + 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. + 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 Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if r.ID != nil { + objectMap["id"] = r.ID + } + if r.Name != nil { + objectMap["name"] = r.Name + } + if r.Type != nil { + objectMap["type"] = r.Type + } + if r.Tags != nil { + objectMap["tags"] = r.Tags + } + return json.Marshal(objectMap) +} diff --git a/services/costmanagement/mgmt/2018-05-31/costmanagement/reportconfig.go b/services/costmanagement/mgmt/2018-05-31/costmanagement/reportconfig.go new file mode 100644 index 000000000000..c1b6ceb9430e --- /dev/null +++ b/services/costmanagement/mgmt/2018-05-31/costmanagement/reportconfig.go @@ -0,0 +1,666 @@ +package costmanagement + +// 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 client for the ReportConfig methods of the Costmanagement service. +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("costmanagement.ReportConfigClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, reportConfigName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.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, "costmanagement.ReportConfigClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.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.CostManagement/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("costmanagement.ReportConfigClient", "CreateOrUpdateByResourceGroupName", err.Error()) + } + + req, err := client.CreateOrUpdateByResourceGroupNamePreparer(ctx, resourceGroupName, reportConfigName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.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, "costmanagement.ReportConfigClient", "CreateOrUpdateByResourceGroupName", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateByResourceGroupNameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.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.CostManagement/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, "costmanagement.ReportConfigClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "costmanagement.ReportConfigClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.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.CostManagement/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, "costmanagement.ReportConfigClient", "DeleteByResourceGroupName", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteByResourceGroupNameSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "costmanagement.ReportConfigClient", "DeleteByResourceGroupName", resp, "Failure sending request") + return + } + + result, err = client.DeleteByResourceGroupNameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.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.CostManagement/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, "costmanagement.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, "costmanagement.ReportConfigClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.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.CostManagement/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, "costmanagement.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, "costmanagement.ReportConfigClient", "GetByResourceGroupName", resp, "Failure sending request") + return + } + + result, err = client.GetByResourceGroupNameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.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.CostManagement/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, "costmanagement.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, "costmanagement.ReportConfigClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.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.CostManagement/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, "costmanagement.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, "costmanagement.ReportConfigClient", "ListByResourceGroupName", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupNameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.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.CostManagement/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/costmanagement/mgmt/2018-05-31/costmanagement/resourcegroupdimensions.go b/services/costmanagement/mgmt/2018-05-31/costmanagement/resourcegroupdimensions.go new file mode 100644 index 000000000000..c88e4c90daa1 --- /dev/null +++ b/services/costmanagement/mgmt/2018-05-31/costmanagement/resourcegroupdimensions.go @@ -0,0 +1,135 @@ +package costmanagement + +// 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 client for the ResourceGroupDimensions methods of the Costmanagement service. +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("costmanagement.ResourceGroupDimensionsClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceGroupName, filter, expand, skiptoken, top) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.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, "costmanagement.ResourceGroupDimensionsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.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.CostManagement/dimensions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client 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/costmanagement/mgmt/2018-05-31/costmanagement/subscriptiondimensions.go b/services/costmanagement/mgmt/2018-05-31/costmanagement/subscriptiondimensions.go new file mode 100644 index 000000000000..d63b4dadb70a --- /dev/null +++ b/services/costmanagement/mgmt/2018-05-31/costmanagement/subscriptiondimensions.go @@ -0,0 +1,133 @@ +package costmanagement + +// 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 client for the SubscriptionDimensions methods of the Costmanagement service. +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("costmanagement.SubscriptionDimensionsClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, filter, expand, skiptoken, top) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.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, "costmanagement.SubscriptionDimensionsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.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.CostManagement/dimensions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client 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 +} diff --git a/services/costmanagement/mgmt/2018-05-31/costmanagement/version.go b/services/costmanagement/mgmt/2018-05-31/costmanagement/version.go new file mode 100644 index 000000000000..6ae8d8a9a433 --- /dev/null +++ b/services/costmanagement/mgmt/2018-05-31/costmanagement/version.go @@ -0,0 +1,30 @@ +package costmanagement + +import "github.com/Azure/azure-sdk-for-go/version" + +// 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. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + version.Number + " costmanagement/2018-05-31" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +}