diff --git a/profiles/preview/consumption/mgmt/consumption/models.go b/profiles/preview/consumption/mgmt/consumption/models.go index cf86760f7a86..2cce26ecac65 100644 --- a/profiles/preview/consumption/mgmt/consumption/models.go +++ b/profiles/preview/consumption/mgmt/consumption/models.go @@ -21,6 +21,9 @@ package consumption import original "github.com/Azure/azure-sdk-for-go/services/consumption/mgmt/2018-05-31/consumption" +type BillingAccountClient = original.BillingAccountClient +type BillingAccountInsightsClient = original.BillingAccountInsightsClient + const ( DefaultBaseURI = original.DefaultBaseURI ) @@ -41,6 +44,12 @@ const ( ChargeTypeForecast ChargeType = original.ChargeTypeForecast ) +type FormatType = original.FormatType + +const ( + Csv FormatType = original.Csv +) + type Grain = original.Grain const ( @@ -49,20 +58,97 @@ const ( Yearly Grain = original.Yearly ) +type GranularityType = original.GranularityType + +const ( + GranularityTypeDaily GranularityType = original.GranularityTypeDaily +) + +type RecurrenceType = original.RecurrenceType + +const ( + RecurrenceTypeAnnually RecurrenceType = original.RecurrenceTypeAnnually + RecurrenceTypeDaily RecurrenceType = original.RecurrenceTypeDaily + RecurrenceTypeMonthly RecurrenceType = original.RecurrenceTypeMonthly + RecurrenceTypeWeekly RecurrenceType = original.RecurrenceTypeWeekly +) + +type ReportConfigColumnType = original.ReportConfigColumnType + +const ( + ReportConfigColumnTypeDimension ReportConfigColumnType = original.ReportConfigColumnTypeDimension + ReportConfigColumnTypeTag ReportConfigColumnType = original.ReportConfigColumnTypeTag +) + +type StatusType = original.StatusType + +const ( + Active StatusType = original.Active + Inactive StatusType = original.Inactive +) + +type TimeframeType = original.TimeframeType + +const ( + Custom TimeframeType = original.Custom + MonthToDate TimeframeType = original.MonthToDate + WeekToDate TimeframeType = original.WeekToDate + YearToDate TimeframeType = original.YearToDate +) + +type Dimension = original.Dimension +type DimensionProperties = original.DimensionProperties +type DimensionsListResult = original.DimensionsListResult type ErrorDetails = original.ErrorDetails type ErrorResponse = original.ErrorResponse type Forecast = original.Forecast type ForecastProperties = original.ForecastProperties type ForecastPropertiesConfidenceLevelsItem = original.ForecastPropertiesConfidenceLevelsItem type ForecastsListResult = original.ForecastsListResult +type Insight = original.Insight +type InsightColumn = original.InsightColumn +type InsightProperties = original.InsightProperties +type InsightsListResult = original.InsightsListResult type Operation = original.Operation type OperationDisplay = original.OperationDisplay type OperationListResult = original.OperationListResult type OperationListResultIterator = original.OperationListResultIterator type OperationListResultPage = original.OperationListResultPage +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 OperationsClient = original.OperationsClient +type ReportConfigClient = original.ReportConfigClient +type ResourceGroupClient = original.ResourceGroupClient +type ResourceGroupInsightsClient = original.ResourceGroupInsightsClient +type SubscriptionClient = original.SubscriptionClient +type SubscriptionInsightsClient = original.SubscriptionInsightsClient +func NewBillingAccountClient(subscriptionID string) BillingAccountClient { + return original.NewBillingAccountClient(subscriptionID) +} +func NewBillingAccountClientWithBaseURI(baseURI string, subscriptionID string) BillingAccountClient { + return original.NewBillingAccountClientWithBaseURI(baseURI, subscriptionID) +} +func NewBillingAccountInsightsClient(subscriptionID string) BillingAccountInsightsClient { + return original.NewBillingAccountInsightsClient(subscriptionID) +} +func NewBillingAccountInsightsClientWithBaseURI(baseURI string, subscriptionID string) BillingAccountInsightsClient { + return original.NewBillingAccountInsightsClientWithBaseURI(baseURI, subscriptionID) +} func New(subscriptionID string) BaseClient { return original.New(subscriptionID) } @@ -81,15 +167,63 @@ func PossibleBoundValues() []Bound { func PossibleChargeTypeValues() []ChargeType { return original.PossibleChargeTypeValues() } +func PossibleFormatTypeValues() []FormatType { + return original.PossibleFormatTypeValues() +} func PossibleGrainValues() []Grain { return original.PossibleGrainValues() } +func PossibleGranularityTypeValues() []GranularityType { + return original.PossibleGranularityTypeValues() +} +func PossibleRecurrenceTypeValues() []RecurrenceType { + return original.PossibleRecurrenceTypeValues() +} +func PossibleReportConfigColumnTypeValues() []ReportConfigColumnType { + return original.PossibleReportConfigColumnTypeValues() +} +func PossibleStatusTypeValues() []StatusType { + return original.PossibleStatusTypeValues() +} +func PossibleTimeframeTypeValues() []TimeframeType { + return original.PossibleTimeframeTypeValues() +} func NewOperationsClient(subscriptionID string) OperationsClient { return original.NewOperationsClient(subscriptionID) } func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { return original.NewOperationsClientWithBaseURI(baseURI, subscriptionID) } +func NewReportConfigClient(subscriptionID string) ReportConfigClient { + return original.NewReportConfigClient(subscriptionID) +} +func NewReportConfigClientWithBaseURI(baseURI string, subscriptionID string) ReportConfigClient { + return original.NewReportConfigClientWithBaseURI(baseURI, subscriptionID) +} +func NewResourceGroupClient(subscriptionID string) ResourceGroupClient { + return original.NewResourceGroupClient(subscriptionID) +} +func NewResourceGroupClientWithBaseURI(baseURI string, subscriptionID string) ResourceGroupClient { + return original.NewResourceGroupClientWithBaseURI(baseURI, subscriptionID) +} +func NewResourceGroupInsightsClient(subscriptionID string) ResourceGroupInsightsClient { + return original.NewResourceGroupInsightsClient(subscriptionID) +} +func NewResourceGroupInsightsClientWithBaseURI(baseURI string, subscriptionID string) ResourceGroupInsightsClient { + return original.NewResourceGroupInsightsClientWithBaseURI(baseURI, subscriptionID) +} +func NewSubscriptionClient(subscriptionID string) SubscriptionClient { + return original.NewSubscriptionClient(subscriptionID) +} +func NewSubscriptionClientWithBaseURI(baseURI string, subscriptionID string) SubscriptionClient { + return original.NewSubscriptionClientWithBaseURI(baseURI, subscriptionID) +} +func NewSubscriptionInsightsClient(subscriptionID string) SubscriptionInsightsClient { + return original.NewSubscriptionInsightsClient(subscriptionID) +} +func NewSubscriptionInsightsClientWithBaseURI(baseURI string, subscriptionID string) SubscriptionInsightsClient { + return original.NewSubscriptionInsightsClientWithBaseURI(baseURI, subscriptionID) +} func UserAgent() string { return original.UserAgent() + " profiles/preview" } diff --git a/services/consumption/mgmt/2018-05-31/consumption/billingaccount.go b/services/consumption/mgmt/2018-05-31/consumption/billingaccount.go new file mode 100644 index 000000000000..c825cb0e24b5 --- /dev/null +++ b/services/consumption/mgmt/2018-05-31/consumption/billingaccount.go @@ -0,0 +1,135 @@ +package consumption + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// BillingAccountClient is the consumption management client provides access to consumption resources for Azure +// Enterprise Subscriptions. +type BillingAccountClient struct { + BaseClient +} + +// NewBillingAccountClient creates an instance of the BillingAccountClient client. +func NewBillingAccountClient(subscriptionID string) BillingAccountClient { + return NewBillingAccountClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewBillingAccountClientWithBaseURI creates an instance of the BillingAccountClient client. +func NewBillingAccountClientWithBaseURI(baseURI string, subscriptionID string) BillingAccountClient { + return BillingAccountClient{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 BillingAccountClient) 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: 1000, Chain: nil}, + {Target: "top", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("consumption.BillingAccountClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, billingAccountID, filter, expand, skiptoken, top) + if err != nil { + err = autorest.NewErrorWithError(err, "consumption.BillingAccountClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "consumption.BillingAccountClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "consumption.BillingAccountClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client BillingAccountClient) ListPreparer(ctx context.Context, billingAccountID string, filter string, expand string, skiptoken string, top *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountId": autorest.Encode("path", billingAccountID), + } + + const APIVersion = "2018-05-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + if len(skiptoken) > 0 { + queryParameters["$skiptoken"] = autorest.Encode("query", skiptoken) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/dimensions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client BillingAccountClient) 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 BillingAccountClient) ListResponder(resp *http.Response) (result DimensionsListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/consumption/mgmt/2018-05-31/consumption/billingaccountinsights.go b/services/consumption/mgmt/2018-05-31/consumption/billingaccountinsights.go new file mode 100644 index 000000000000..92a793e1d30a --- /dev/null +++ b/services/consumption/mgmt/2018-05-31/consumption/billingaccountinsights.go @@ -0,0 +1,142 @@ +package consumption + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// BillingAccountInsightsClient is the consumption management client provides access to consumption resources for Azure +// Enterprise Subscriptions. +type BillingAccountInsightsClient struct { + BaseClient +} + +// NewBillingAccountInsightsClient creates an instance of the BillingAccountInsightsClient client. +func NewBillingAccountInsightsClient(subscriptionID string) BillingAccountInsightsClient { + return NewBillingAccountInsightsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewBillingAccountInsightsClientWithBaseURI creates an instance of the BillingAccountInsightsClient client. +func NewBillingAccountInsightsClientWithBaseURI(baseURI string, subscriptionID string) BillingAccountInsightsClient { + return BillingAccountInsightsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Post lists the consumption data for billing account. +// Parameters: +// billingAccountID - billingAccount ID +// parameters - parameters supplied to the CreateOrUpdate Report Config operation. +func (client BillingAccountInsightsClient) Post(ctx context.Context, billingAccountID string, parameters ReportConfigDefinition) (result InsightsListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Type", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.TimePeriod", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.TimePeriod.From", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.TimePeriod.To", Name: validation.Null, Rule: true, Chain: nil}, + }}, + {Target: "parameters.Dataset", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Grouping", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Grouping", Name: validation.MaxItems, Rule: 2, Chain: nil}}}, + {Target: "parameters.Dataset.Filter", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.And", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.And", Name: validation.MinItems, Rule: 2, Chain: nil}}}, + {Target: "parameters.Dataset.Filter.Or", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Or", Name: validation.MinItems, Rule: 2, Chain: nil}}}, + {Target: "parameters.Dataset.Filter.Not", Name: validation.Null, Rule: false, Chain: nil}, + {Target: "parameters.Dataset.Filter.Dimension", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Dimension.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Dataset.Filter.Dimension.Operator", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Dataset.Filter.Dimension.Values", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Dimension.Values", Name: validation.MinItems, Rule: 1, Chain: nil}}}, + }}, + {Target: "parameters.Dataset.Filter.Tag", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Tag.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Dataset.Filter.Tag.Operator", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Dataset.Filter.Tag.Values", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Tag.Values", Name: validation.MinItems, Rule: 1, Chain: nil}}}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewError("consumption.BillingAccountInsightsClient", "Post", err.Error()) + } + + req, err := client.PostPreparer(ctx, billingAccountID, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "consumption.BillingAccountInsightsClient", "Post", nil, "Failure preparing request") + return + } + + resp, err := client.PostSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "consumption.BillingAccountInsightsClient", "Post", resp, "Failure sending request") + return + } + + result, err = client.PostResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "consumption.BillingAccountInsightsClient", "Post", resp, "Failure responding to request") + } + + return +} + +// PostPreparer prepares the Post request. +func (client BillingAccountInsightsClient) PostPreparer(ctx context.Context, billingAccountID string, parameters ReportConfigDefinition) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountId": autorest.Encode("path", billingAccountID), + } + + const APIVersion = "2018-05-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.Consumption/insights", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// PostSender sends the Post request. The method will close the +// http.Response Body if it receives an error. +func (client BillingAccountInsightsClient) PostSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// PostResponder handles the response to the Post request. The method always +// closes the http.Response Body. +func (client BillingAccountInsightsClient) PostResponder(resp *http.Response) (result InsightsListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/consumption/mgmt/2018-05-31/consumption/models.go b/services/consumption/mgmt/2018-05-31/consumption/models.go index 9b5909d7c724..373e7ebb40a9 100644 --- a/services/consumption/mgmt/2018-05-31/consumption/models.go +++ b/services/consumption/mgmt/2018-05-31/consumption/models.go @@ -20,6 +20,7 @@ package consumption import ( "encoding/json" "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/date" "github.com/Azure/go-autorest/autorest/to" "github.com/shopspring/decimal" "net/http" @@ -55,6 +56,19 @@ func PossibleChargeTypeValues() []ChargeType { return []ChargeType{ChargeTypeActual, ChargeTypeForecast} } +// FormatType enumerates the values for format type. +type FormatType string + +const ( + // Csv ... + Csv FormatType = "Csv" +) + +// PossibleFormatTypeValues returns an array of possible values for the FormatType const type. +func PossibleFormatTypeValues() []FormatType { + return []FormatType{Csv} +} + // Grain enumerates the values for grain. type Grain string @@ -72,6 +86,198 @@ func PossibleGrainValues() []Grain { return []Grain{Daily, Monthly, Yearly} } +// GranularityType enumerates the values for granularity type. +type GranularityType string + +const ( + // GranularityTypeDaily ... + GranularityTypeDaily GranularityType = "Daily" +) + +// PossibleGranularityTypeValues returns an array of possible values for the GranularityType const type. +func PossibleGranularityTypeValues() []GranularityType { + return []GranularityType{GranularityTypeDaily} +} + +// RecurrenceType enumerates the values for recurrence type. +type RecurrenceType string + +const ( + // RecurrenceTypeAnnually ... + RecurrenceTypeAnnually RecurrenceType = "Annually" + // RecurrenceTypeDaily ... + RecurrenceTypeDaily RecurrenceType = "Daily" + // RecurrenceTypeMonthly ... + RecurrenceTypeMonthly RecurrenceType = "Monthly" + // RecurrenceTypeWeekly ... + RecurrenceTypeWeekly RecurrenceType = "Weekly" +) + +// PossibleRecurrenceTypeValues returns an array of possible values for the RecurrenceType const type. +func PossibleRecurrenceTypeValues() []RecurrenceType { + return []RecurrenceType{RecurrenceTypeAnnually, RecurrenceTypeDaily, RecurrenceTypeMonthly, RecurrenceTypeWeekly} +} + +// ReportConfigColumnType enumerates the values for report config column type. +type ReportConfigColumnType string + +const ( + // ReportConfigColumnTypeDimension ... + ReportConfigColumnTypeDimension ReportConfigColumnType = "Dimension" + // ReportConfigColumnTypeTag ... + ReportConfigColumnTypeTag ReportConfigColumnType = "Tag" +) + +// PossibleReportConfigColumnTypeValues returns an array of possible values for the ReportConfigColumnType const type. +func PossibleReportConfigColumnTypeValues() []ReportConfigColumnType { + return []ReportConfigColumnType{ReportConfigColumnTypeDimension, ReportConfigColumnTypeTag} +} + +// StatusType enumerates the values for status type. +type StatusType string + +const ( + // Active ... + Active StatusType = "Active" + // Inactive ... + Inactive StatusType = "Inactive" +) + +// PossibleStatusTypeValues returns an array of possible values for the StatusType const type. +func PossibleStatusTypeValues() []StatusType { + return []StatusType{Active, Inactive} +} + +// TimeframeType enumerates the values for timeframe type. +type TimeframeType string + +const ( + // Custom ... + Custom TimeframeType = "Custom" + // MonthToDate ... + MonthToDate TimeframeType = "MonthToDate" + // WeekToDate ... + WeekToDate TimeframeType = "WeekToDate" + // YearToDate ... + YearToDate TimeframeType = "YearToDate" +) + +// PossibleTimeframeTypeValues returns an array of possible values for the TimeframeType const type. +func PossibleTimeframeTypeValues() []TimeframeType { + return []TimeframeType{Custom, MonthToDate, WeekToDate, YearToDate} +} + +// Dimension ... +type Dimension struct { + *DimensionProperties `json:"properties,omitempty"` + // ID - Resource Id. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for Dimension. +func (d Dimension) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if d.DimensionProperties != nil { + objectMap["properties"] = d.DimensionProperties + } + if d.ID != nil { + objectMap["id"] = d.ID + } + if d.Name != nil { + objectMap["name"] = d.Name + } + if d.Type != nil { + objectMap["type"] = d.Type + } + if d.Tags != nil { + objectMap["tags"] = d.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Dimension struct. +func (d *Dimension) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var dimensionProperties DimensionProperties + err = json.Unmarshal(*v, &dimensionProperties) + if err != nil { + return err + } + d.DimensionProperties = &dimensionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + d.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + d.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + d.Type = &typeVar + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + d.Tags = tags + } + } + } + + return nil +} + +// DimensionProperties ... +type DimensionProperties struct { + Data *[]string `json:"data,omitempty"` + Total *int32 `json:"total,omitempty"` + Category *string `json:"category,omitempty"` + UsageStart *date.Time `json:"usageStart,omitempty"` + UsageEnd *date.Time `json:"usageEnd,omitempty"` + NextLink *string `json:"nextLink,omitempty"` +} + +// DimensionsListResult result of listing dimensions. It contains a list of available dimensions. +type DimensionsListResult struct { + autorest.Response `json:"-"` + // Value - The list of dimensions. + Value *[]Dimension `json:"value,omitempty"` +} + // ErrorDetails the details of the error. type ErrorDetails struct { // Code - Error code. @@ -214,6 +420,121 @@ type ForecastsListResult struct { Value *[]Forecast `json:"value,omitempty"` } +// Insight ... +type Insight struct { + *InsightProperties `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 Insight. +func (i Insight) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if i.InsightProperties != nil { + objectMap["properties"] = i.InsightProperties + } + if i.ID != nil { + objectMap["id"] = i.ID + } + if i.Name != nil { + objectMap["name"] = i.Name + } + if i.Type != nil { + objectMap["type"] = i.Type + } + if i.Tags != nil { + objectMap["tags"] = i.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Insight struct. +func (i *Insight) 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 insightProperties InsightProperties + err = json.Unmarshal(*v, &insightProperties) + if err != nil { + return err + } + i.InsightProperties = &insightProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + i.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + i.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + i.Type = &typeVar + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + i.Tags = tags + } + } + } + + return nil +} + +// InsightColumn ... +type InsightColumn struct { + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} + +// InsightProperties ... +type InsightProperties struct { + NextLink *string `json:"nextLink,omitempty"` + // Columns - Array of columns + Columns *[]InsightColumn `json:"columns,omitempty"` + Rows *[][]interface{} `json:"rows,omitempty"` +} + +// InsightsListResult result of listing insights. It contains all columns listed under groupings and aggregation. +type InsightsListResult struct { + autorest.Response `json:"-"` + // Value - The list of insights. + Value *[]Insight `json:"value,omitempty"` +} + // Operation a Consumption REST API operation. type Operation struct { // Name - Operation name: {provider}/{resource}/{operation}. @@ -335,6 +656,262 @@ func (page OperationListResultPage) Values() []Operation { return *page.olr.Value } +// ReportConfig a report config resource. +type ReportConfig struct { + autorest.Response `json:"-"` + *ReportConfigProperties `json:"properties,omitempty"` + // ID - Resource Id. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ReportConfig. +func (rc ReportConfig) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rc.ReportConfigProperties != nil { + objectMap["properties"] = rc.ReportConfigProperties + } + if rc.ID != nil { + objectMap["id"] = rc.ID + } + if rc.Name != nil { + objectMap["name"] = rc.Name + } + if rc.Type != nil { + objectMap["type"] = rc.Type + } + if rc.Tags != nil { + objectMap["tags"] = rc.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ReportConfig struct. +func (rc *ReportConfig) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var reportConfigProperties ReportConfigProperties + err = json.Unmarshal(*v, &reportConfigProperties) + if err != nil { + return err + } + rc.ReportConfigProperties = &reportConfigProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rc.Type = &typeVar + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + rc.Tags = tags + } + } + } + + return nil +} + +// ReportConfigAggregation the aggregation expression to be used in the report. +type ReportConfigAggregation struct { + // Name - The name of the column to aggregate. + Name *string `json:"name,omitempty"` + // Function - The name of the aggregation function to use. + Function *string `json:"function,omitempty"` +} + +// ReportConfigComparisonExpression the comparison expression to be used in the report. +type ReportConfigComparisonExpression struct { + // Name - The name of the column to use in comaprison. + Name *string `json:"name,omitempty"` + // Operator - The operator to use for comparison. + Operator *string `json:"operator,omitempty"` + // Values - Array of values to use for comparison + Values *[]string `json:"values,omitempty"` +} + +// ReportConfigDataset the definition of data present in the report. +type ReportConfigDataset struct { + // Granularity - The granularity of rows in the report. Possible values include: 'GranularityTypeDaily' + Granularity GranularityType `json:"granularity,omitempty"` + // Configuration - Has configuration information for the data in the report. The configuration will be ignored if aggregation and grouping are provided. + Configuration *ReportConfigDatasetConfiguration `json:"configuration,omitempty"` + // Aggregation - Dictionary of aggregation expression to use in the report. The key of each item in the dictionary is the alias for the aggregated column. Report can have upto 2 aggregation clauses. + Aggregation map[string]*ReportConfigAggregation `json:"aggregation"` + // Grouping - Array of group by expression to use in the report. Report can have upto 2 group by clauses. + Grouping *[]ReportConfigGrouping `json:"grouping,omitempty"` + // Filter - Has filter expression to use in the report. + Filter *ReportConfigFilter `json:"filter,omitempty"` +} + +// MarshalJSON is the custom marshaler for ReportConfigDataset. +func (rcd ReportConfigDataset) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rcd.Granularity != "" { + objectMap["granularity"] = rcd.Granularity + } + if rcd.Configuration != nil { + objectMap["configuration"] = rcd.Configuration + } + if rcd.Aggregation != nil { + objectMap["aggregation"] = rcd.Aggregation + } + if rcd.Grouping != nil { + objectMap["grouping"] = rcd.Grouping + } + if rcd.Filter != nil { + objectMap["filter"] = rcd.Filter + } + return json.Marshal(objectMap) +} + +// ReportConfigDatasetConfiguration the configuration of dataset in the report. +type ReportConfigDatasetConfiguration struct { + // Columns - Array of column names to be included in the report. Any valid report column name is allowed. If not provided, then report includes all columns. + Columns *[]string `json:"columns,omitempty"` +} + +// ReportConfigDefinition the definition of a report config. +type ReportConfigDefinition struct { + // Type - The type of the report. + Type *string `json:"type,omitempty"` + // Timeframe - The time frame for pulling data for the report. If custom, then a specific time period must be provided. Possible values include: 'WeekToDate', 'MonthToDate', 'YearToDate', 'Custom' + Timeframe TimeframeType `json:"timeframe,omitempty"` + // TimePeriod - Has time period for pulling data for the report. + TimePeriod *ReportConfigTimePeriod `json:"timePeriod,omitempty"` + // Dataset - Has definition for data in this report config. + Dataset *ReportConfigDataset `json:"dataset,omitempty"` +} + +// ReportConfigDeliveryDestination the destination information for the delivery of the report. +type ReportConfigDeliveryDestination struct { + // SubscriptionID - The subscription id of the storage account where reports will be delivered. + SubscriptionID *string `json:"subscriptionId,omitempty"` + // ResourceGroup - The resource group of the storage account here reports will be delivered. + ResourceGroup *string `json:"resourceGroup,omitempty"` + // StorageAccount - The storage account here reports will be delivered. + StorageAccount *string `json:"storageAccount,omitempty"` + // Endpoint - The endpoint of the storage service where reports will be delivered. + Endpoint *string `json:"endpoint,omitempty"` + // Container - The name of the container where reports will be uploaded. + Container *string `json:"container,omitempty"` + // Category - The name of the directory where reports will be uploaded. + Category *string `json:"category,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. diff --git a/services/consumption/mgmt/2018-05-31/consumption/reportconfig.go b/services/consumption/mgmt/2018-05-31/consumption/reportconfig.go new file mode 100644 index 000000000000..bfa14259b005 --- /dev/null +++ b/services/consumption/mgmt/2018-05-31/consumption/reportconfig.go @@ -0,0 +1,675 @@ +package consumption + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// ReportConfigClient is the consumption management client provides access to consumption resources for Azure +// Enterprise Subscriptions. +type ReportConfigClient struct { + BaseClient +} + +// NewReportConfigClient creates an instance of the ReportConfigClient client. +func NewReportConfigClient(subscriptionID string) ReportConfigClient { + return NewReportConfigClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewReportConfigClientWithBaseURI creates an instance of the ReportConfigClient client. +func NewReportConfigClientWithBaseURI(baseURI string, subscriptionID string) ReportConfigClient { + return ReportConfigClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate the operation to create or update a report config. Update operation requires latest eTag to be set in +// the request mandatorily. You may obtain the latest eTag by performing a get operation. Create operation does not +// require eTag. +// Parameters: +// reportConfigName - report Config Name. +// parameters - parameters supplied to the CreateOrUpdate Report Config operation. +func (client ReportConfigClient) CreateOrUpdate(ctx context.Context, reportConfigName string, parameters ReportConfig) (result ReportConfig, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ReportConfigProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Schedule", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Schedule.RecurrencePeriod", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Schedule.RecurrencePeriod.From", Name: validation.Null, Rule: true, Chain: nil}}}, + }}, + {Target: "parameters.ReportConfigProperties.DeliveryInfo", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.DeliveryInfo.Destination", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.DeliveryInfo.Destination.SubscriptionID", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ReportConfigProperties.DeliveryInfo.Destination.ResourceGroup", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ReportConfigProperties.DeliveryInfo.Destination.StorageAccount", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ReportConfigProperties.DeliveryInfo.Destination.Endpoint", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ReportConfigProperties.DeliveryInfo.Destination.Container", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ReportConfigProperties.DeliveryInfo.Destination.Category", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}, + {Target: "parameters.ReportConfigProperties.Definition", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Type", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ReportConfigProperties.Definition.TimePeriod", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.TimePeriod.From", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ReportConfigProperties.Definition.TimePeriod.To", Name: validation.Null, Rule: true, Chain: nil}, + }}, + {Target: "parameters.ReportConfigProperties.Definition.Dataset", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Grouping", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Grouping", Name: validation.MaxItems, Rule: 2, Chain: nil}}}, + {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.And", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.And", Name: validation.MinItems, Rule: 2, Chain: nil}}}, + {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Or", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Or", Name: validation.MinItems, Rule: 2, Chain: nil}}}, + {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Not", Name: validation.Null, Rule: false, Chain: nil}, + {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Dimension", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Dimension.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Dimension.Operator", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Dimension.Values", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Dimension.Values", Name: validation.MinItems, Rule: 1, Chain: nil}}}, + }}, + {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Tag", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Tag.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Tag.Operator", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Tag.Values", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Tag.Values", Name: validation.MinItems, Rule: 1, Chain: nil}}}, + }}, + }}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewError("consumption.ReportConfigClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, reportConfigName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ReportConfigClient) CreateOrUpdatePreparer(ctx context.Context, reportConfigName string, parameters ReportConfig) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "reportConfigName": autorest.Encode("path", reportConfigName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-05-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Consumption/reportconfigs/{reportConfigName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ReportConfigClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ReportConfigClient) CreateOrUpdateResponder(resp *http.Response) (result ReportConfig, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateOrUpdateByResourceGroupName the operation to create or update a report config. Update operation requires +// latest eTag to be set in the request mandatorily. You may obtain the latest eTag by performing a get operation. +// Create operation does not require eTag. +// Parameters: +// resourceGroupName - azure Resource Group Name. +// reportConfigName - report Config Name. +// parameters - parameters supplied to the CreateOrUpdate Report Config operation. +func (client ReportConfigClient) CreateOrUpdateByResourceGroupName(ctx context.Context, resourceGroupName string, reportConfigName string, parameters ReportConfig) (result ReportConfig, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ReportConfigProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Schedule", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Schedule.RecurrencePeriod", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Schedule.RecurrencePeriod.From", Name: validation.Null, Rule: true, Chain: nil}}}, + }}, + {Target: "parameters.ReportConfigProperties.DeliveryInfo", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.DeliveryInfo.Destination", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.DeliveryInfo.Destination.SubscriptionID", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ReportConfigProperties.DeliveryInfo.Destination.ResourceGroup", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ReportConfigProperties.DeliveryInfo.Destination.StorageAccount", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ReportConfigProperties.DeliveryInfo.Destination.Endpoint", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ReportConfigProperties.DeliveryInfo.Destination.Container", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ReportConfigProperties.DeliveryInfo.Destination.Category", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}, + {Target: "parameters.ReportConfigProperties.Definition", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Type", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ReportConfigProperties.Definition.TimePeriod", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.TimePeriod.From", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ReportConfigProperties.Definition.TimePeriod.To", Name: validation.Null, Rule: true, Chain: nil}, + }}, + {Target: "parameters.ReportConfigProperties.Definition.Dataset", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Grouping", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Grouping", Name: validation.MaxItems, Rule: 2, Chain: nil}}}, + {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.And", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.And", Name: validation.MinItems, Rule: 2, Chain: nil}}}, + {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Or", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Or", Name: validation.MinItems, Rule: 2, Chain: nil}}}, + {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Not", Name: validation.Null, Rule: false, Chain: nil}, + {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Dimension", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Dimension.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Dimension.Operator", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Dimension.Values", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Dimension.Values", Name: validation.MinItems, Rule: 1, Chain: nil}}}, + }}, + {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Tag", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Tag.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Tag.Operator", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Tag.Values", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Tag.Values", Name: validation.MinItems, Rule: 1, Chain: nil}}}, + }}, + }}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewError("consumption.ReportConfigClient", "CreateOrUpdateByResourceGroupName", err.Error()) + } + + req, err := client.CreateOrUpdateByResourceGroupNamePreparer(ctx, resourceGroupName, reportConfigName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "CreateOrUpdateByResourceGroupName", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateByResourceGroupNameSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "CreateOrUpdateByResourceGroupName", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateByResourceGroupNameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "CreateOrUpdateByResourceGroupName", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdateByResourceGroupNamePreparer prepares the CreateOrUpdateByResourceGroupName request. +func (client ReportConfigClient) CreateOrUpdateByResourceGroupNamePreparer(ctx context.Context, resourceGroupName string, reportConfigName string, parameters ReportConfig) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "reportConfigName": autorest.Encode("path", reportConfigName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-05-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Consumption/reportconfigs/{reportConfigName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateByResourceGroupNameSender sends the CreateOrUpdateByResourceGroupName request. The method will close the +// http.Response Body if it receives an error. +func (client ReportConfigClient) CreateOrUpdateByResourceGroupNameSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateByResourceGroupNameResponder handles the response to the CreateOrUpdateByResourceGroupName request. The method always +// closes the http.Response Body. +func (client ReportConfigClient) CreateOrUpdateByResourceGroupNameResponder(resp *http.Response) (result ReportConfig, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete the operation to delete a report. +// Parameters: +// reportConfigName - report Config Name. +func (client ReportConfigClient) Delete(ctx context.Context, reportConfigName string) (result autorest.Response, err error) { + req, err := client.DeletePreparer(ctx, reportConfigName) + if err != nil { + err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ReportConfigClient) DeletePreparer(ctx context.Context, reportConfigName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "reportConfigName": autorest.Encode("path", reportConfigName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-05-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Consumption/reportconfigs/{reportConfigName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ReportConfigClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ReportConfigClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// DeleteByResourceGroupName the operation to delete a report config. +// Parameters: +// resourceGroupName - azure Resource Group Name. +// reportConfigName - report Config Name. +func (client ReportConfigClient) DeleteByResourceGroupName(ctx context.Context, resourceGroupName string, reportConfigName string) (result autorest.Response, err error) { + req, err := client.DeleteByResourceGroupNamePreparer(ctx, resourceGroupName, reportConfigName) + if err != nil { + err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "DeleteByResourceGroupName", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteByResourceGroupNameSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "DeleteByResourceGroupName", resp, "Failure sending request") + return + } + + result, err = client.DeleteByResourceGroupNameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "DeleteByResourceGroupName", resp, "Failure responding to request") + } + + return +} + +// DeleteByResourceGroupNamePreparer prepares the DeleteByResourceGroupName request. +func (client ReportConfigClient) DeleteByResourceGroupNamePreparer(ctx context.Context, resourceGroupName string, reportConfigName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "reportConfigName": autorest.Encode("path", reportConfigName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-05-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Consumption/reportconfigs/{reportConfigName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteByResourceGroupNameSender sends the DeleteByResourceGroupName request. The method will close the +// http.Response Body if it receives an error. +func (client ReportConfigClient) DeleteByResourceGroupNameSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteByResourceGroupNameResponder handles the response to the DeleteByResourceGroupName request. The method always +// closes the http.Response Body. +func (client ReportConfigClient) DeleteByResourceGroupNameResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the report config for a subscription by report config name. +// Parameters: +// reportConfigName - report Config Name. +func (client ReportConfigClient) Get(ctx context.Context, reportConfigName string) (result ReportConfig, err error) { + req, err := client.GetPreparer(ctx, reportConfigName) + if err != nil { + err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ReportConfigClient) GetPreparer(ctx context.Context, reportConfigName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "reportConfigName": autorest.Encode("path", reportConfigName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-05-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Consumption/reportconfigs/{reportConfigName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ReportConfigClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ReportConfigClient) GetResponder(resp *http.Response) (result ReportConfig, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetByResourceGroupName gets the report config for a resource group under a subscription by report config name. +// Parameters: +// resourceGroupName - azure Resource Group Name. +// reportConfigName - report Config Name. +func (client ReportConfigClient) GetByResourceGroupName(ctx context.Context, resourceGroupName string, reportConfigName string) (result ReportConfig, err error) { + req, err := client.GetByResourceGroupNamePreparer(ctx, resourceGroupName, reportConfigName) + if err != nil { + err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "GetByResourceGroupName", nil, "Failure preparing request") + return + } + + resp, err := client.GetByResourceGroupNameSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "GetByResourceGroupName", resp, "Failure sending request") + return + } + + result, err = client.GetByResourceGroupNameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "GetByResourceGroupName", resp, "Failure responding to request") + } + + return +} + +// GetByResourceGroupNamePreparer prepares the GetByResourceGroupName request. +func (client ReportConfigClient) GetByResourceGroupNamePreparer(ctx context.Context, resourceGroupName string, reportConfigName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "reportConfigName": autorest.Encode("path", reportConfigName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-05-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Consumption/reportconfigs/{reportConfigName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetByResourceGroupNameSender sends the GetByResourceGroupName request. The method will close the +// http.Response Body if it receives an error. +func (client ReportConfigClient) GetByResourceGroupNameSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetByResourceGroupNameResponder handles the response to the GetByResourceGroupName request. The method always +// closes the http.Response Body. +func (client ReportConfigClient) GetByResourceGroupNameResponder(resp *http.Response) (result ReportConfig, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists all report configs for a subscription. +func (client ReportConfigClient) List(ctx context.Context) (result ReportConfigListResult, err error) { + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ReportConfigClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-05-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Consumption/reportconfigs", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ReportConfigClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ReportConfigClient) ListResponder(resp *http.Response) (result ReportConfigListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroupName lists all report configs for a resource group under a subscription. +// Parameters: +// resourceGroupName - azure Resource Group Name. +func (client ReportConfigClient) ListByResourceGroupName(ctx context.Context, resourceGroupName string) (result ReportConfigListResult, err error) { + req, err := client.ListByResourceGroupNamePreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "ListByResourceGroupName", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupNameSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "ListByResourceGroupName", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupNameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "consumption.ReportConfigClient", "ListByResourceGroupName", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupNamePreparer prepares the ListByResourceGroupName request. +func (client ReportConfigClient) ListByResourceGroupNamePreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-05-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Consumption/reportconfigs", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupNameSender sends the ListByResourceGroupName request. The method will close the +// http.Response Body if it receives an error. +func (client ReportConfigClient) ListByResourceGroupNameSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupNameResponder handles the response to the ListByResourceGroupName request. The method always +// closes the http.Response Body. +func (client ReportConfigClient) ListByResourceGroupNameResponder(resp *http.Response) (result ReportConfigListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/consumption/mgmt/2018-05-31/consumption/resourcegroup.go b/services/consumption/mgmt/2018-05-31/consumption/resourcegroup.go new file mode 100644 index 000000000000..321672dff572 --- /dev/null +++ b/services/consumption/mgmt/2018-05-31/consumption/resourcegroup.go @@ -0,0 +1,136 @@ +package consumption + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// ResourceGroupClient is the consumption management client provides access to consumption resources for Azure +// Enterprise Subscriptions. +type ResourceGroupClient struct { + BaseClient +} + +// NewResourceGroupClient creates an instance of the ResourceGroupClient client. +func NewResourceGroupClient(subscriptionID string) ResourceGroupClient { + return NewResourceGroupClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewResourceGroupClientWithBaseURI creates an instance of the ResourceGroupClient client. +func NewResourceGroupClientWithBaseURI(baseURI string, subscriptionID string) ResourceGroupClient { + return ResourceGroupClient{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 ResourceGroupClient) 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: 1000, Chain: nil}, + {Target: "top", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("consumption.ResourceGroupClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceGroupName, filter, expand, skiptoken, top) + if err != nil { + err = autorest.NewErrorWithError(err, "consumption.ResourceGroupClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "consumption.ResourceGroupClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "consumption.ResourceGroupClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ResourceGroupClient) ListPreparer(ctx context.Context, resourceGroupName string, filter string, expand string, skiptoken string, top *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-05-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + if len(skiptoken) > 0 { + queryParameters["$skiptoken"] = autorest.Encode("query", skiptoken) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Consumption/dimensions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ResourceGroupClient) 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 ResourceGroupClient) ListResponder(resp *http.Response) (result DimensionsListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/consumption/mgmt/2018-05-31/consumption/resourcegroupinsights.go b/services/consumption/mgmt/2018-05-31/consumption/resourcegroupinsights.go new file mode 100644 index 000000000000..2bf247c1397d --- /dev/null +++ b/services/consumption/mgmt/2018-05-31/consumption/resourcegroupinsights.go @@ -0,0 +1,143 @@ +package consumption + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// ResourceGroupInsightsClient is the consumption management client provides access to consumption resources for Azure +// Enterprise Subscriptions. +type ResourceGroupInsightsClient struct { + BaseClient +} + +// NewResourceGroupInsightsClient creates an instance of the ResourceGroupInsightsClient client. +func NewResourceGroupInsightsClient(subscriptionID string) ResourceGroupInsightsClient { + return NewResourceGroupInsightsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewResourceGroupInsightsClientWithBaseURI creates an instance of the ResourceGroupInsightsClient client. +func NewResourceGroupInsightsClientWithBaseURI(baseURI string, subscriptionID string) ResourceGroupInsightsClient { + return ResourceGroupInsightsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Post lists the consumption data for subscriptionId and resource group. +// Parameters: +// resourceGroupName - azure Resource Group Name. +// parameters - parameters supplied to the CreateOrUpdate Report Config operation. +func (client ResourceGroupInsightsClient) Post(ctx context.Context, resourceGroupName string, parameters ReportConfigDefinition) (result InsightsListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Type", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.TimePeriod", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.TimePeriod.From", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.TimePeriod.To", Name: validation.Null, Rule: true, Chain: nil}, + }}, + {Target: "parameters.Dataset", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Grouping", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Grouping", Name: validation.MaxItems, Rule: 2, Chain: nil}}}, + {Target: "parameters.Dataset.Filter", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.And", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.And", Name: validation.MinItems, Rule: 2, Chain: nil}}}, + {Target: "parameters.Dataset.Filter.Or", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Or", Name: validation.MinItems, Rule: 2, Chain: nil}}}, + {Target: "parameters.Dataset.Filter.Not", Name: validation.Null, Rule: false, Chain: nil}, + {Target: "parameters.Dataset.Filter.Dimension", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Dimension.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Dataset.Filter.Dimension.Operator", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Dataset.Filter.Dimension.Values", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Dimension.Values", Name: validation.MinItems, Rule: 1, Chain: nil}}}, + }}, + {Target: "parameters.Dataset.Filter.Tag", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Tag.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Dataset.Filter.Tag.Operator", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Dataset.Filter.Tag.Values", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Tag.Values", Name: validation.MinItems, Rule: 1, Chain: nil}}}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewError("consumption.ResourceGroupInsightsClient", "Post", err.Error()) + } + + req, err := client.PostPreparer(ctx, resourceGroupName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "consumption.ResourceGroupInsightsClient", "Post", nil, "Failure preparing request") + return + } + + resp, err := client.PostSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "consumption.ResourceGroupInsightsClient", "Post", resp, "Failure sending request") + return + } + + result, err = client.PostResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "consumption.ResourceGroupInsightsClient", "Post", resp, "Failure responding to request") + } + + return +} + +// PostPreparer prepares the Post request. +func (client ResourceGroupInsightsClient) PostPreparer(ctx context.Context, resourceGroupName string, parameters ReportConfigDefinition) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-05-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Consumption/Insights", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// PostSender sends the Post request. The method will close the +// http.Response Body if it receives an error. +func (client ResourceGroupInsightsClient) PostSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// PostResponder handles the response to the Post request. The method always +// closes the http.Response Body. +func (client ResourceGroupInsightsClient) PostResponder(resp *http.Response) (result InsightsListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/consumption/mgmt/2018-05-31/consumption/subscription.go b/services/consumption/mgmt/2018-05-31/consumption/subscription.go new file mode 100644 index 000000000000..bcdb830b7da0 --- /dev/null +++ b/services/consumption/mgmt/2018-05-31/consumption/subscription.go @@ -0,0 +1,134 @@ +package consumption + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// SubscriptionClient is the consumption management client provides access to consumption resources for Azure +// Enterprise Subscriptions. +type SubscriptionClient struct { + BaseClient +} + +// NewSubscriptionClient creates an instance of the SubscriptionClient client. +func NewSubscriptionClient(subscriptionID string) SubscriptionClient { + return NewSubscriptionClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewSubscriptionClientWithBaseURI creates an instance of the SubscriptionClient client. +func NewSubscriptionClientWithBaseURI(baseURI string, subscriptionID string) SubscriptionClient { + return SubscriptionClient{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 SubscriptionClient) 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: 1000, Chain: nil}, + {Target: "top", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("consumption.SubscriptionClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, filter, expand, skiptoken, top) + if err != nil { + err = autorest.NewErrorWithError(err, "consumption.SubscriptionClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "consumption.SubscriptionClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "consumption.SubscriptionClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client SubscriptionClient) ListPreparer(ctx context.Context, filter string, expand string, skiptoken string, top *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-05-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + if len(skiptoken) > 0 { + queryParameters["$skiptoken"] = autorest.Encode("query", skiptoken) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Consumption/dimensions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client SubscriptionClient) 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 SubscriptionClient) ListResponder(resp *http.Response) (result DimensionsListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/consumption/mgmt/2018-05-31/consumption/subscriptioninsights.go b/services/consumption/mgmt/2018-05-31/consumption/subscriptioninsights.go new file mode 100644 index 000000000000..054024210ce9 --- /dev/null +++ b/services/consumption/mgmt/2018-05-31/consumption/subscriptioninsights.go @@ -0,0 +1,141 @@ +package consumption + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// SubscriptionInsightsClient is the consumption management client provides access to consumption resources for Azure +// Enterprise Subscriptions. +type SubscriptionInsightsClient struct { + BaseClient +} + +// NewSubscriptionInsightsClient creates an instance of the SubscriptionInsightsClient client. +func NewSubscriptionInsightsClient(subscriptionID string) SubscriptionInsightsClient { + return NewSubscriptionInsightsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewSubscriptionInsightsClientWithBaseURI creates an instance of the SubscriptionInsightsClient client. +func NewSubscriptionInsightsClientWithBaseURI(baseURI string, subscriptionID string) SubscriptionInsightsClient { + return SubscriptionInsightsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Post lists the consumption data for subscriptionId. +// Parameters: +// parameters - parameters supplied to the CreateOrUpdate Report Config operation. +func (client SubscriptionInsightsClient) Post(ctx context.Context, parameters ReportConfigDefinition) (result InsightsListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Type", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.TimePeriod", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.TimePeriod.From", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.TimePeriod.To", Name: validation.Null, Rule: true, Chain: nil}, + }}, + {Target: "parameters.Dataset", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Grouping", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Grouping", Name: validation.MaxItems, Rule: 2, Chain: nil}}}, + {Target: "parameters.Dataset.Filter", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.And", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.And", Name: validation.MinItems, Rule: 2, Chain: nil}}}, + {Target: "parameters.Dataset.Filter.Or", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Or", Name: validation.MinItems, Rule: 2, Chain: nil}}}, + {Target: "parameters.Dataset.Filter.Not", Name: validation.Null, Rule: false, Chain: nil}, + {Target: "parameters.Dataset.Filter.Dimension", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Dimension.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Dataset.Filter.Dimension.Operator", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Dataset.Filter.Dimension.Values", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Dimension.Values", Name: validation.MinItems, Rule: 1, Chain: nil}}}, + }}, + {Target: "parameters.Dataset.Filter.Tag", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Tag.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Dataset.Filter.Tag.Operator", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Dataset.Filter.Tag.Values", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Tag.Values", Name: validation.MinItems, Rule: 1, Chain: nil}}}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewError("consumption.SubscriptionInsightsClient", "Post", err.Error()) + } + + req, err := client.PostPreparer(ctx, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "consumption.SubscriptionInsightsClient", "Post", nil, "Failure preparing request") + return + } + + resp, err := client.PostSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "consumption.SubscriptionInsightsClient", "Post", resp, "Failure sending request") + return + } + + result, err = client.PostResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "consumption.SubscriptionInsightsClient", "Post", resp, "Failure responding to request") + } + + return +} + +// PostPreparer prepares the Post request. +func (client SubscriptionInsightsClient) PostPreparer(ctx context.Context, parameters ReportConfigDefinition) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-05-31" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Consumption/Insights", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// PostSender sends the Post request. The method will close the +// http.Response Body if it receives an error. +func (client SubscriptionInsightsClient) PostSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// PostResponder handles the response to the Post request. The method always +// closes the http.Response Body. +func (client SubscriptionInsightsClient) PostResponder(resp *http.Response) (result InsightsListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +}