From b7adc7b84686eb66329a7478b157552aba43483a Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Thu, 2 Aug 2018 13:29:55 -0700 Subject: [PATCH] Generated from 7d375b2ce4c679c5e3a1f63185925ca83422c098 (#2381) Add Connector resource type as preview to CostManagement RP * Initial commit for Microsoft.CostManagement 2018-09-01-preview * Add Connector resource type as preview to CostManagement RP --- .../mgmt/costmanagement/models.go | 30 +- .../billingaccountdimensions.go | 134 +++ .../costmanagement/client.go | 355 ++++++++ .../costmanagement/connector.go | 440 +++++++++ .../costmanagement/models.go | 846 ++++++++++++++++++ .../costmanagement/reportconfig.go | 666 ++++++++++++++ .../costmanagement/resourcegroupdimensions.go | 135 +++ .../costmanagement/subscriptiondimensions.go | 133 +++ .../costmanagement/version.go | 30 + 9 files changed, 2766 insertions(+), 3 deletions(-) create mode 100644 services/costmanagement/mgmt/2018-09-01-preview/costmanagement/billingaccountdimensions.go create mode 100644 services/costmanagement/mgmt/2018-09-01-preview/costmanagement/client.go create mode 100644 services/costmanagement/mgmt/2018-09-01-preview/costmanagement/connector.go create mode 100644 services/costmanagement/mgmt/2018-09-01-preview/costmanagement/models.go create mode 100644 services/costmanagement/mgmt/2018-09-01-preview/costmanagement/reportconfig.go create mode 100644 services/costmanagement/mgmt/2018-09-01-preview/costmanagement/resourcegroupdimensions.go create mode 100644 services/costmanagement/mgmt/2018-09-01-preview/costmanagement/subscriptiondimensions.go create mode 100644 services/costmanagement/mgmt/2018-09-01-preview/costmanagement/version.go diff --git a/profiles/preview/costmanagement/mgmt/costmanagement/models.go b/profiles/preview/costmanagement/mgmt/costmanagement/models.go index b16d97a81d58..93e8ba478e0c 100644 --- a/profiles/preview/costmanagement/mgmt/costmanagement/models.go +++ b/profiles/preview/costmanagement/mgmt/costmanagement/models.go @@ -19,7 +19,7 @@ package costmanagement -import original "github.com/Azure/azure-sdk-for-go/services/costmanagement/mgmt/2018-05-31/costmanagement" +import original "github.com/Azure/azure-sdk-for-go/services/costmanagement/mgmt/2018-09-01-preview/costmanagement" type BillingAccountDimensionsClient = original.BillingAccountDimensionsClient @@ -28,6 +28,15 @@ const ( ) type BaseClient = original.BaseClient +type ConnectorClient = original.ConnectorClient +type ConnectorStatus = original.ConnectorStatus + +const ( + Active ConnectorStatus = original.Active + Error ConnectorStatus = original.Error + Suspended ConnectorStatus = original.Suspended +) + type FormatType = original.FormatType const ( @@ -59,8 +68,8 @@ const ( type StatusType = original.StatusType const ( - Active StatusType = original.Active - Inactive StatusType = original.Inactive + StatusTypeActive StatusType = original.StatusTypeActive + StatusTypeInactive StatusType = original.StatusTypeInactive ) type TimeframeType = original.TimeframeType @@ -72,9 +81,15 @@ const ( YearToDate TimeframeType = original.YearToDate ) +type ConnectorCollectionErrorInfo = original.ConnectorCollectionErrorInfo +type ConnectorCollectionInfo = original.ConnectorCollectionInfo +type ConnectorDefinition = original.ConnectorDefinition +type ConnectorDefinitionListResult = original.ConnectorDefinitionListResult +type ConnectorProperties = original.ConnectorProperties type Dimension = original.Dimension type DimensionProperties = original.DimensionProperties type DimensionsListResult = original.DimensionsListResult +type ErrorBase = original.ErrorBase type ErrorDetails = original.ErrorDetails type ErrorResponse = original.ErrorResponse type Query = original.Query @@ -113,6 +128,15 @@ func New(subscriptionID string) BaseClient { func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { return original.NewWithBaseURI(baseURI, subscriptionID) } +func NewConnectorClient(subscriptionID string) ConnectorClient { + return original.NewConnectorClient(subscriptionID) +} +func NewConnectorClientWithBaseURI(baseURI string, subscriptionID string) ConnectorClient { + return original.NewConnectorClientWithBaseURI(baseURI, subscriptionID) +} +func PossibleConnectorStatusValues() []ConnectorStatus { + return original.PossibleConnectorStatusValues() +} func PossibleFormatTypeValues() []FormatType { return original.PossibleFormatTypeValues() } diff --git a/services/costmanagement/mgmt/2018-09-01-preview/costmanagement/billingaccountdimensions.go b/services/costmanagement/mgmt/2018-09-01-preview/costmanagement/billingaccountdimensions.go new file mode 100644 index 000000000000..b997f9577359 --- /dev/null +++ b/services/costmanagement/mgmt/2018-09-01-preview/costmanagement/billingaccountdimensions.go @@ -0,0 +1,134 @@ +package costmanagement + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// BillingAccountDimensionsClient is the client for the BillingAccountDimensions methods of the Costmanagement service. +type BillingAccountDimensionsClient struct { + BaseClient +} + +// NewBillingAccountDimensionsClient creates an instance of the BillingAccountDimensionsClient client. +func NewBillingAccountDimensionsClient(subscriptionID string) BillingAccountDimensionsClient { + return NewBillingAccountDimensionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewBillingAccountDimensionsClientWithBaseURI creates an instance of the BillingAccountDimensionsClient client. +func NewBillingAccountDimensionsClientWithBaseURI(baseURI string, subscriptionID string) BillingAccountDimensionsClient { + return BillingAccountDimensionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists the dimensions by billingAccount Id. +// Parameters: +// billingAccountID - billingAccount ID +// filter - may be used to filter dimensions by properties/category, properties/usageStart, +// properties/usageEnd. Supported operators are 'eq','lt', 'gt', 'le', 'ge'. +// expand - may be used to expand the properties/data within a dimension dategory. By default, data is not +// included when listing dimensions. +// skiptoken - skiptoken is only used if a previous operation returned a partial result. If a previous response +// contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that +// specifies a starting point to use for subsequent calls. +// top - may be used to limit the number of results to the most recent N dimension data. +func (client BillingAccountDimensionsClient) List(ctx context.Context, billingAccountID string, filter string, expand string, skiptoken string, top *int32) (result DimensionsListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMaximum, Rule: int64(1000), Chain: nil}, + {Target: "top", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("costmanagement.BillingAccountDimensionsClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, billingAccountID, filter, expand, skiptoken, top) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.BillingAccountDimensionsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "costmanagement.BillingAccountDimensionsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.BillingAccountDimensionsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client BillingAccountDimensionsClient) ListPreparer(ctx context.Context, billingAccountID string, filter string, expand string, skiptoken string, top *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountId": autorest.Encode("path", billingAccountID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + if len(skiptoken) > 0 { + queryParameters["$skiptoken"] = autorest.Encode("query", skiptoken) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.CostManagement/dimensions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client BillingAccountDimensionsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client BillingAccountDimensionsClient) ListResponder(resp *http.Response) (result DimensionsListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/costmanagement/mgmt/2018-09-01-preview/costmanagement/client.go b/services/costmanagement/mgmt/2018-09-01-preview/costmanagement/client.go new file mode 100644 index 000000000000..cfdec7df6bcf --- /dev/null +++ b/services/costmanagement/mgmt/2018-09-01-preview/costmanagement/client.go @@ -0,0 +1,355 @@ +// Package costmanagement implements the Azure ARM Costmanagement service API version 2018-09-01-preview. +// +// +package costmanagement + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +const ( + // DefaultBaseURI is the default URI used for the service Costmanagement + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Costmanagement. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient client. +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} + +// QueryBillingAccount lists the usage data for billing account. +// Parameters: +// billingAccountID - billingAccount ID +// parameters - parameters supplied to the CreateOrUpdate Report Config operation. +func (client BaseClient) QueryBillingAccount(ctx context.Context, billingAccountID string, parameters ReportConfigDefinition) (result QueryResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Type", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.TimePeriod", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.TimePeriod.From", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.TimePeriod.To", Name: validation.Null, Rule: true, Chain: nil}, + }}, + {Target: "parameters.Dataset", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Grouping", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Grouping", Name: validation.MaxItems, Rule: 2, Chain: nil}}}, + {Target: "parameters.Dataset.Filter", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.And", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.And", Name: validation.MinItems, Rule: 2, Chain: nil}}}, + {Target: "parameters.Dataset.Filter.Or", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Or", Name: validation.MinItems, Rule: 2, Chain: nil}}}, + {Target: "parameters.Dataset.Filter.Not", Name: validation.Null, Rule: false, Chain: nil}, + {Target: "parameters.Dataset.Filter.Dimension", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Dimension.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Dataset.Filter.Dimension.Operator", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Dataset.Filter.Dimension.Values", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Dimension.Values", Name: validation.MinItems, Rule: 1, Chain: nil}}}, + }}, + {Target: "parameters.Dataset.Filter.Tag", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Tag.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Dataset.Filter.Tag.Operator", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Dataset.Filter.Tag.Values", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Tag.Values", Name: validation.MinItems, Rule: 1, Chain: nil}}}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewError("costmanagement.BaseClient", "QueryBillingAccount", err.Error()) + } + + req, err := client.QueryBillingAccountPreparer(ctx, billingAccountID, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.BaseClient", "QueryBillingAccount", nil, "Failure preparing request") + return + } + + resp, err := client.QueryBillingAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "costmanagement.BaseClient", "QueryBillingAccount", resp, "Failure sending request") + return + } + + result, err = client.QueryBillingAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.BaseClient", "QueryBillingAccount", resp, "Failure responding to request") + } + + return +} + +// QueryBillingAccountPreparer prepares the QueryBillingAccount request. +func (client BaseClient) QueryBillingAccountPreparer(ctx context.Context, billingAccountID string, parameters ReportConfigDefinition) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountId": autorest.Encode("path", billingAccountID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountId}/providers/Microsoft.CostManagement/Query", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// QueryBillingAccountSender sends the QueryBillingAccount request. The method will close the +// http.Response Body if it receives an error. +func (client BaseClient) QueryBillingAccountSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// QueryBillingAccountResponder handles the response to the QueryBillingAccount request. The method always +// closes the http.Response Body. +func (client BaseClient) QueryBillingAccountResponder(resp *http.Response) (result QueryResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// QueryResourceGroup lists the usage data for subscriptionId and resource group. +// Parameters: +// resourceGroupName - azure Resource Group Name. +// parameters - parameters supplied to the CreateOrUpdate Report Config operation. +func (client BaseClient) QueryResourceGroup(ctx context.Context, resourceGroupName string, parameters ReportConfigDefinition) (result QueryResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Type", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.TimePeriod", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.TimePeriod.From", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.TimePeriod.To", Name: validation.Null, Rule: true, Chain: nil}, + }}, + {Target: "parameters.Dataset", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Grouping", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Grouping", Name: validation.MaxItems, Rule: 2, Chain: nil}}}, + {Target: "parameters.Dataset.Filter", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.And", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.And", Name: validation.MinItems, Rule: 2, Chain: nil}}}, + {Target: "parameters.Dataset.Filter.Or", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Or", Name: validation.MinItems, Rule: 2, Chain: nil}}}, + {Target: "parameters.Dataset.Filter.Not", Name: validation.Null, Rule: false, Chain: nil}, + {Target: "parameters.Dataset.Filter.Dimension", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Dimension.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Dataset.Filter.Dimension.Operator", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Dataset.Filter.Dimension.Values", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Dimension.Values", Name: validation.MinItems, Rule: 1, Chain: nil}}}, + }}, + {Target: "parameters.Dataset.Filter.Tag", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Tag.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Dataset.Filter.Tag.Operator", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Dataset.Filter.Tag.Values", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Tag.Values", Name: validation.MinItems, Rule: 1, Chain: nil}}}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewError("costmanagement.BaseClient", "QueryResourceGroup", err.Error()) + } + + req, err := client.QueryResourceGroupPreparer(ctx, resourceGroupName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.BaseClient", "QueryResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.QueryResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "costmanagement.BaseClient", "QueryResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.QueryResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.BaseClient", "QueryResourceGroup", resp, "Failure responding to request") + } + + return +} + +// QueryResourceGroupPreparer prepares the QueryResourceGroup request. +func (client BaseClient) QueryResourceGroupPreparer(ctx context.Context, resourceGroupName string, parameters ReportConfigDefinition) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.CostManagement/Query", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// QueryResourceGroupSender sends the QueryResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client BaseClient) QueryResourceGroupSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// QueryResourceGroupResponder handles the response to the QueryResourceGroup request. The method always +// closes the http.Response Body. +func (client BaseClient) QueryResourceGroupResponder(resp *http.Response) (result QueryResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// QuerySubscription lists the usage data for subscriptionId. +// Parameters: +// parameters - parameters supplied to the CreateOrUpdate Report Config operation. +func (client BaseClient) QuerySubscription(ctx context.Context, parameters ReportConfigDefinition) (result QueryResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Type", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.TimePeriod", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.TimePeriod.From", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.TimePeriod.To", Name: validation.Null, Rule: true, Chain: nil}, + }}, + {Target: "parameters.Dataset", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Grouping", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Grouping", Name: validation.MaxItems, Rule: 2, Chain: nil}}}, + {Target: "parameters.Dataset.Filter", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.And", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.And", Name: validation.MinItems, Rule: 2, Chain: nil}}}, + {Target: "parameters.Dataset.Filter.Or", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Or", Name: validation.MinItems, Rule: 2, Chain: nil}}}, + {Target: "parameters.Dataset.Filter.Not", Name: validation.Null, Rule: false, Chain: nil}, + {Target: "parameters.Dataset.Filter.Dimension", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Dimension.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Dataset.Filter.Dimension.Operator", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Dataset.Filter.Dimension.Values", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Dimension.Values", Name: validation.MinItems, Rule: 1, Chain: nil}}}, + }}, + {Target: "parameters.Dataset.Filter.Tag", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Tag.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Dataset.Filter.Tag.Operator", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.Dataset.Filter.Tag.Values", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.Dataset.Filter.Tag.Values", Name: validation.MinItems, Rule: 1, Chain: nil}}}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewError("costmanagement.BaseClient", "QuerySubscription", err.Error()) + } + + req, err := client.QuerySubscriptionPreparer(ctx, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.BaseClient", "QuerySubscription", nil, "Failure preparing request") + return + } + + resp, err := client.QuerySubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "costmanagement.BaseClient", "QuerySubscription", resp, "Failure sending request") + return + } + + result, err = client.QuerySubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.BaseClient", "QuerySubscription", resp, "Failure responding to request") + } + + return +} + +// QuerySubscriptionPreparer prepares the QuerySubscription request. +func (client BaseClient) QuerySubscriptionPreparer(ctx context.Context, parameters ReportConfigDefinition) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.CostManagement/Query", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// QuerySubscriptionSender sends the QuerySubscription request. The method will close the +// http.Response Body if it receives an error. +func (client BaseClient) QuerySubscriptionSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// QuerySubscriptionResponder handles the response to the QuerySubscription request. The method always +// closes the http.Response Body. +func (client BaseClient) QuerySubscriptionResponder(resp *http.Response) (result QueryResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/costmanagement/mgmt/2018-09-01-preview/costmanagement/connector.go b/services/costmanagement/mgmt/2018-09-01-preview/costmanagement/connector.go new file mode 100644 index 000000000000..de38326bc507 --- /dev/null +++ b/services/costmanagement/mgmt/2018-09-01-preview/costmanagement/connector.go @@ -0,0 +1,440 @@ +package costmanagement + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// ConnectorClient is the client for the Connector methods of the Costmanagement service. +type ConnectorClient struct { + BaseClient +} + +// NewConnectorClient creates an instance of the ConnectorClient client. +func NewConnectorClient(subscriptionID string) ConnectorClient { + return NewConnectorClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewConnectorClientWithBaseURI creates an instance of the ConnectorClient client. +func NewConnectorClientWithBaseURI(baseURI string, subscriptionID string) ConnectorClient { + return ConnectorClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate create or update a connector definition +// Parameters: +// resourceGroupName - azure Resource Group Name. +// connectorName - connector Name. +// connector - connector details +func (client ConnectorClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, connectorName string, connector ConnectorDefinition) (result ConnectorDefinition, err error) { + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, connectorName, connector) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ConnectorClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "costmanagement.ConnectorClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ConnectorClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ConnectorClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, connectorName string, connector ConnectorDefinition) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "connectorName": autorest.Encode("path", connectorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.CostManagement/connectors/{connectorName}", pathParameters), + autorest.WithJSON(connector), + 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 ConnectorClient) 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 ConnectorClient) CreateOrUpdateResponder(resp *http.Response) (result ConnectorDefinition, 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 delete a connector definition +// Parameters: +// resourceGroupName - azure Resource Group Name. +// connectorName - connector Name. +func (client ConnectorClient) Delete(ctx context.Context, resourceGroupName string, connectorName string) (result autorest.Response, err error) { + req, err := client.DeletePreparer(ctx, resourceGroupName, connectorName) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ConnectorClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "costmanagement.ConnectorClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ConnectorClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ConnectorClient) DeletePreparer(ctx context.Context, resourceGroupName string, connectorName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "connectorName": autorest.Encode("path", connectorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.CostManagement/connectors/{connectorName}", 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 ConnectorClient) 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 ConnectorClient) 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 +} + +// Get get a connector definition +// Parameters: +// resourceGroupName - azure Resource Group Name. +// connectorName - connector Name. +func (client ConnectorClient) Get(ctx context.Context, resourceGroupName string, connectorName string) (result ConnectorDefinition, err error) { + req, err := client.GetPreparer(ctx, resourceGroupName, connectorName) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ConnectorClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "costmanagement.ConnectorClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ConnectorClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ConnectorClient) GetPreparer(ctx context.Context, resourceGroupName string, connectorName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "connectorName": autorest.Encode("path", connectorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.CostManagement/connectors/{connectorName}", 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 ConnectorClient) 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 ConnectorClient) GetResponder(resp *http.Response) (result ConnectorDefinition, 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 list all connector definitions for a subscription +func (client ConnectorClient) List(ctx context.Context) (result ConnectorDefinitionListResult, err error) { + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ConnectorClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "costmanagement.ConnectorClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ConnectorClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ConnectorClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.CostManagement/connectors", 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 ConnectorClient) 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 ConnectorClient) ListResponder(resp *http.Response) (result ConnectorDefinitionListResult, 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 list all connector definitions for a resource group under a subscription. +// Parameters: +// resourceGroupName - azure Resource Group Name. +func (client ConnectorClient) ListByResourceGroupName(ctx context.Context, resourceGroupName string) (result ConnectorDefinitionListResult, err error) { + req, err := client.ListByResourceGroupNamePreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ConnectorClient", "ListByResourceGroupName", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupNameSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "costmanagement.ConnectorClient", "ListByResourceGroupName", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupNameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ConnectorClient", "ListByResourceGroupName", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupNamePreparer prepares the ListByResourceGroupName request. +func (client ConnectorClient) 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-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.CostManagement/connectors", 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 ConnectorClient) 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 ConnectorClient) ListByResourceGroupNameResponder(resp *http.Response) (result ConnectorDefinitionListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update update a connector definition +// Parameters: +// resourceGroupName - azure Resource Group Name. +// connectorName - connector Name. +// connector - connector details +func (client ConnectorClient) Update(ctx context.Context, resourceGroupName string, connectorName string, connector ConnectorDefinition) (result ConnectorDefinition, err error) { + req, err := client.UpdatePreparer(ctx, resourceGroupName, connectorName, connector) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ConnectorClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "costmanagement.ConnectorClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ConnectorClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ConnectorClient) UpdatePreparer(ctx context.Context, resourceGroupName string, connectorName string, connector ConnectorDefinition) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "connectorName": autorest.Encode("path", connectorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.CostManagement/connectors/{connectorName}", pathParameters), + autorest.WithJSON(connector), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ConnectorClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ConnectorClient) UpdateResponder(resp *http.Response) (result ConnectorDefinition, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/costmanagement/mgmt/2018-09-01-preview/costmanagement/models.go b/services/costmanagement/mgmt/2018-09-01-preview/costmanagement/models.go new file mode 100644 index 000000000000..a60ff4f432bb --- /dev/null +++ b/services/costmanagement/mgmt/2018-09-01-preview/costmanagement/models.go @@ -0,0 +1,846 @@ +package costmanagement + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/date" +) + +// ConnectorStatus enumerates the values for connector status. +type ConnectorStatus string + +const ( + // Active ... + Active ConnectorStatus = "active" + // Error ... + Error ConnectorStatus = "error" + // Suspended ... + Suspended ConnectorStatus = "suspended" +) + +// PossibleConnectorStatusValues returns an array of possible values for the ConnectorStatus const type. +func PossibleConnectorStatusValues() []ConnectorStatus { + return []ConnectorStatus{Active, Error, Suspended} +} + +// FormatType enumerates the values for format type. +type FormatType string + +const ( + // Csv ... + Csv FormatType = "Csv" +) + +// PossibleFormatTypeValues returns an array of possible values for the FormatType const type. +func PossibleFormatTypeValues() []FormatType { + return []FormatType{Csv} +} + +// GranularityType enumerates the values for granularity type. +type GranularityType string + +const ( + // Daily ... + Daily GranularityType = "Daily" +) + +// PossibleGranularityTypeValues returns an array of possible values for the GranularityType const type. +func PossibleGranularityTypeValues() []GranularityType { + return []GranularityType{Daily} +} + +// RecurrenceType enumerates the values for recurrence type. +type RecurrenceType string + +const ( + // RecurrenceTypeAnnually ... + RecurrenceTypeAnnually RecurrenceType = "Annually" + // RecurrenceTypeDaily ... + RecurrenceTypeDaily RecurrenceType = "Daily" + // RecurrenceTypeMonthly ... + RecurrenceTypeMonthly RecurrenceType = "Monthly" + // RecurrenceTypeWeekly ... + RecurrenceTypeWeekly RecurrenceType = "Weekly" +) + +// PossibleRecurrenceTypeValues returns an array of possible values for the RecurrenceType const type. +func PossibleRecurrenceTypeValues() []RecurrenceType { + return []RecurrenceType{RecurrenceTypeAnnually, RecurrenceTypeDaily, RecurrenceTypeMonthly, RecurrenceTypeWeekly} +} + +// ReportConfigColumnType enumerates the values for report config column type. +type ReportConfigColumnType string + +const ( + // ReportConfigColumnTypeDimension ... + ReportConfigColumnTypeDimension ReportConfigColumnType = "Dimension" + // ReportConfigColumnTypeTag ... + ReportConfigColumnTypeTag ReportConfigColumnType = "Tag" +) + +// PossibleReportConfigColumnTypeValues returns an array of possible values for the ReportConfigColumnType const type. +func PossibleReportConfigColumnTypeValues() []ReportConfigColumnType { + return []ReportConfigColumnType{ReportConfigColumnTypeDimension, ReportConfigColumnTypeTag} +} + +// StatusType enumerates the values for status type. +type StatusType string + +const ( + // StatusTypeActive ... + StatusTypeActive StatusType = "Active" + // StatusTypeInactive ... + StatusTypeInactive StatusType = "Inactive" +) + +// PossibleStatusTypeValues returns an array of possible values for the StatusType const type. +func PossibleStatusTypeValues() []StatusType { + return []StatusType{StatusTypeActive, StatusTypeInactive} +} + +// 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} +} + +// ConnectorCollectionErrorInfo details of any error encountered on last collection attempt +type ConnectorCollectionErrorInfo struct { + // ErrorMessage - Detailed error message + ErrorMessage *string `json:"errorMessage,omitempty"` + // ErrorCode - Short error message + ErrorCode *string `json:"errorCode,omitempty"` + // ErrorStartTime - Time the error started occuring (Last time error occurred in lastRun) + ErrorStartTime *date.Time `json:"errorStartTime,omitempty"` +} + +// ConnectorCollectionInfo collection and ingestion information +type ConnectorCollectionInfo struct { + // LastRun - Last time the data acquisition process completed (even if no new data was found) + LastRun *date.Time `json:"lastRun,omitempty"` + // SourceLastUpdated - Source timestamp of external data currently available in Azure (eg AWS last processed CUR file timestamp) + SourceLastUpdated *date.Time `json:"sourceLastUpdated,omitempty"` + // LastUpdated - Last time the external data was updated into Azure + LastUpdated *date.Time `json:"lastUpdated,omitempty"` + // Error - Error information of last collection + Error *ConnectorCollectionErrorInfo `json:"error,omitempty"` +} + +// ConnectorDefinition the Connector model definition +type ConnectorDefinition struct { + autorest.Response `json:"-"` + // Kind - Connector kind (eg aws) + Kind *string `json:"kind,omitempty"` + // ID - Connector id + ID *string `json:"id,omitempty"` + // Name - Connector name + Name *string `json:"name,omitempty"` + // Type - Connector type + Type *string `json:"type,omitempty"` + // Location - Connector location + Location *string `json:"location,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` + // ConnectorProperties - Connector properties + *ConnectorProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for ConnectorDefinition. +func (cd ConnectorDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cd.Kind != nil { + objectMap["kind"] = cd.Kind + } + if cd.ID != nil { + objectMap["id"] = cd.ID + } + if cd.Name != nil { + objectMap["name"] = cd.Name + } + if cd.Type != nil { + objectMap["type"] = cd.Type + } + if cd.Location != nil { + objectMap["location"] = cd.Location + } + if cd.Tags != nil { + objectMap["tags"] = cd.Tags + } + if cd.ConnectorProperties != nil { + objectMap["properties"] = cd.ConnectorProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ConnectorDefinition struct. +func (cd *ConnectorDefinition) 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 "kind": + if v != nil { + var kind string + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + cd.Kind = &kind + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + cd.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + cd.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + cd.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + cd.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + cd.Tags = tags + } + case "properties": + if v != nil { + var connectorProperties ConnectorProperties + err = json.Unmarshal(*v, &connectorProperties) + if err != nil { + return err + } + cd.ConnectorProperties = &connectorProperties + } + } + } + + return nil +} + +// ConnectorDefinitionListResult result of listing connector definitions. It contains a list of available connector +// definitions in the scope provided. +type ConnectorDefinitionListResult struct { + autorest.Response `json:"-"` + // Value - The list of connector definitions. + Value *[]ConnectorDefinition `json:"value,omitempty"` +} + +// ConnectorProperties the properties of a Connector +type ConnectorProperties struct { + // DisplayName - Connector DisplayName (defaults to Name) + DisplayName *string `json:"displayName,omitempty"` + // ProviderAccountID - Connector providerAccountId (determined from credentials) + ProviderAccountID *string `json:"providerAccountId,omitempty"` + // CredentialsKey - Credentials authentication key (eg AWS ARN) + CredentialsKey *string `json:"credentialsKey,omitempty"` + // CredentialsSecret - Credentials secret (eg AWS ExternalId) + CredentialsSecret *string `json:"credentialsSecret,omitempty"` + // ReportID - Identifying source report. (For AWS this is a CUR report name, defined with Daily and with Resources) + ReportID *string `json:"reportId,omitempty"` + // CreatedOn - Connector definition creation datetime + CreatedOn *date.Time `json:"createdOn,omitempty"` + // ModifiedOn - Connector last modified datetime + ModifiedOn *date.Time `json:"modifiedOn,omitempty"` + // Status - Connector status. Possible values include: 'Active', 'Error', 'Suspended' + Status ConnectorStatus `json:"status,omitempty"` + // Collection - Collection information + Collection *ConnectorCollectionInfo `json:"collection,omitempty"` +} + +// 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"` +} + +// ErrorBase the details of the error. +type ErrorBase struct { + // Code - A machine readable error code. + Code *string `json:"code,omitempty"` + // Message - A human readable error message. + Message *string `json:"message,omitempty"` + // Target - Indicates which property in the request is responsible for the error. + Target *string `json:"target,omitempty"` +} + +// ErrorDetails the details of the error. +type ErrorDetails struct { + // Code - A machine readable error code. + Code *string `json:"code,omitempty"` + // Message - A human readable error message. + Message *string `json:"message,omitempty"` + // Target - Indicates which property in the request is responsible for the error. + Target *string `json:"target,omitempty"` + // Details - error details. + Details *[]ErrorBase `json:"details,omitempty"` +} + +// ErrorResponse error response indicates that the service is not able to process the incoming request. The reason +// is provided in the error message. +type ErrorResponse struct { + // Error - The details of the error. + Error *ErrorDetails `json:"error,omitempty"` +} + +// Query ... +type Query struct { + *QueryProperties `json:"properties,omitempty"` + // ID - Resource Id. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for Query. +func (q Query) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if q.QueryProperties != nil { + objectMap["properties"] = q.QueryProperties + } + if q.ID != nil { + objectMap["id"] = q.ID + } + if q.Name != nil { + objectMap["name"] = q.Name + } + if q.Type != nil { + objectMap["type"] = q.Type + } + if q.Tags != nil { + objectMap["tags"] = q.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Query struct. +func (q *Query) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var queryProperties QueryProperties + err = json.Unmarshal(*v, &queryProperties) + if err != nil { + return err + } + q.QueryProperties = &queryProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + q.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + q.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + q.Type = &typeVar + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + q.Tags = tags + } + } + } + + return nil +} + +// QueryColumn ... +type QueryColumn struct { + Name *string `json:"name,omitempty"` + Type *string `json:"type,omitempty"` +} + +// QueryProperties ... +type QueryProperties struct { + NextLink *string `json:"nextLink,omitempty"` + // Columns - Array of columns + Columns *[]QueryColumn `json:"columns,omitempty"` + Rows *[][]interface{} `json:"rows,omitempty"` +} + +// QueryResult result of query. It contains all columns listed under groupings and aggregation. +type QueryResult struct { + autorest.Response `json:"-"` + // Value - The list of usage data. + Value *[]Query `json:"value,omitempty"` +} + +// ReportConfig a report config resource. +type ReportConfig struct { + autorest.Response `json:"-"` + *ReportConfigProperties `json:"properties,omitempty"` + // ID - Resource Id. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for ReportConfig. +func (rc ReportConfig) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rc.ReportConfigProperties != nil { + objectMap["properties"] = rc.ReportConfigProperties + } + if rc.ID != nil { + objectMap["id"] = rc.ID + } + if rc.Name != nil { + objectMap["name"] = rc.Name + } + if rc.Type != nil { + objectMap["type"] = rc.Type + } + if rc.Tags != nil { + objectMap["tags"] = rc.Tags + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for ReportConfig struct. +func (rc *ReportConfig) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var reportConfigProperties ReportConfigProperties + err = json.Unmarshal(*v, &reportConfigProperties) + if err != nil { + return err + } + rc.ReportConfigProperties = &reportConfigProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rc.Type = &typeVar + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + rc.Tags = tags + } + } + } + + return nil +} + +// ReportConfigAggregation the aggregation expression to be used in the report. +type ReportConfigAggregation struct { + // Name - The name of the column to aggregate. + Name *string `json:"name,omitempty"` + // Function - The name of the aggregation function to use. + Function *string `json:"function,omitempty"` +} + +// ReportConfigComparisonExpression the comparison expression to be used in the report. +type ReportConfigComparisonExpression struct { + // Name - The name of the column to use in comaprison. + Name *string `json:"name,omitempty"` + // Operator - The operator to use for comparison. + Operator *string `json:"operator,omitempty"` + // Values - Array of values to use for comparison + Values *[]string `json:"values,omitempty"` +} + +// ReportConfigDataset the definition of data present in the report. +type ReportConfigDataset struct { + // Granularity - The granularity of rows in the report. Possible values include: 'Daily' + Granularity GranularityType `json:"granularity,omitempty"` + // Configuration - Has configuration information for the data in the report. The configuration will be ignored if aggregation and grouping are provided. + Configuration *ReportConfigDatasetConfiguration `json:"configuration,omitempty"` + // Aggregation - Dictionary of aggregation expression to use in the report. The key of each item in the dictionary is the alias for the aggregated column. Report can have upto 2 aggregation clauses. + Aggregation map[string]*ReportConfigAggregation `json:"aggregation"` + // Grouping - Array of group by expression to use in the report. Report can have upto 2 group by clauses. + Grouping *[]ReportConfigGrouping `json:"grouping,omitempty"` + // Filter - Has filter expression to use in the report. + Filter *ReportConfigFilter `json:"filter,omitempty"` +} + +// MarshalJSON is the custom marshaler for ReportConfigDataset. +func (rcd ReportConfigDataset) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rcd.Granularity != "" { + objectMap["granularity"] = rcd.Granularity + } + if rcd.Configuration != nil { + objectMap["configuration"] = rcd.Configuration + } + if rcd.Aggregation != nil { + objectMap["aggregation"] = rcd.Aggregation + } + if rcd.Grouping != nil { + objectMap["grouping"] = rcd.Grouping + } + if rcd.Filter != nil { + objectMap["filter"] = rcd.Filter + } + return json.Marshal(objectMap) +} + +// ReportConfigDatasetConfiguration the configuration of dataset in the report. +type ReportConfigDatasetConfiguration struct { + // Columns - Array of column names to be included in the report. Any valid report column name is allowed. If not provided, then report includes all columns. + Columns *[]string `json:"columns,omitempty"` +} + +// ReportConfigDefinition the definition of a report config. +type ReportConfigDefinition struct { + // Type - The type of the report. + Type *string `json:"type,omitempty"` + // Timeframe - The time frame for pulling data for the report. If custom, then a specific time period must be provided. Possible values include: 'WeekToDate', 'MonthToDate', 'YearToDate', 'Custom' + Timeframe TimeframeType `json:"timeframe,omitempty"` + // TimePeriod - Has time period for pulling data for the report. + TimePeriod *ReportConfigTimePeriod `json:"timePeriod,omitempty"` + // Dataset - Has definition for data in this report config. + Dataset *ReportConfigDataset `json:"dataset,omitempty"` +} + +// ReportConfigDeliveryDestination the destination information for the delivery of the report. +type ReportConfigDeliveryDestination struct { + // ResourceID - The resource id of the storage account where reports will be delivered. + ResourceID *string `json:"resourceId,omitempty"` + // Container - The name of the container where reports will be uploaded. + Container *string `json:"container,omitempty"` + // RootFolderPath - The name of the directory where reports will be uploaded. + RootFolderPath *string `json:"rootFolderPath,omitempty"` +} + +// ReportConfigDeliveryInfo the delivery information associated with a report config. +type ReportConfigDeliveryInfo struct { + // Destination - Has destination for the report being delivered. + Destination *ReportConfigDeliveryDestination `json:"destination,omitempty"` +} + +// ReportConfigFilter the filter expression to be used in the report. +type ReportConfigFilter struct { + // And - The logical "AND" expression. Must have atleast 2 items. + And *[]ReportConfigFilter `json:"and,omitempty"` + // Or - The logical "OR" expression. Must have atleast 2 items. + Or *[]ReportConfigFilter `json:"or,omitempty"` + // Not - The logical "NOT" expression. + Not *ReportConfigFilter `json:"not,omitempty"` + // Dimension - Has comparison expression for a dimension + Dimension *ReportConfigComparisonExpression `json:"dimension,omitempty"` + // Tag - Has comparison expression for a tag + Tag *ReportConfigComparisonExpression `json:"tag,omitempty"` +} + +// ReportConfigGrouping the group by expression to be used in the report. +type ReportConfigGrouping struct { + // ColumnType - Has type of the column to group. Possible values include: 'ReportConfigColumnTypeTag', 'ReportConfigColumnTypeDimension' + ColumnType ReportConfigColumnType `json:"columnType,omitempty"` + // Name - The name of the column to group. + Name *string `json:"name,omitempty"` +} + +// ReportConfigListResult result of listing report configs. It contains a list of available report configurations +// in the scope provided. +type ReportConfigListResult struct { + autorest.Response `json:"-"` + // Value - The list of report configs. + Value *[]ReportConfig `json:"value,omitempty"` +} + +// ReportConfigProperties the properties of the report config. +type ReportConfigProperties struct { + // Schedule - Has schedule information for the report config. + Schedule *ReportConfigSchedule `json:"schedule,omitempty"` + // Format - The format of the report being delivered. Possible values include: 'Csv' + Format FormatType `json:"format,omitempty"` + // DeliveryInfo - Has delivery information for the report config. + DeliveryInfo *ReportConfigDeliveryInfo `json:"deliveryInfo,omitempty"` + // Definition - Has definition for the report config. + Definition *ReportConfigDefinition `json:"definition,omitempty"` +} + +// ReportConfigRecurrencePeriod the start and end date for recurrence schedule. +type ReportConfigRecurrencePeriod struct { + // From - The start date of recurrence. + From *date.Time `json:"from,omitempty"` + // To - The end date of recurrence. If not provided, we default this to 10 years from the start date. + To *date.Time `json:"to,omitempty"` +} + +// ReportConfigSchedule the schedule associated with a report config. +type ReportConfigSchedule struct { + // Status - The status of the schedule. Whether active or not. If inactive, the report's scheduled execution is paused. Possible values include: 'StatusTypeActive', 'StatusTypeInactive' + Status StatusType `json:"status,omitempty"` + // Recurrence - The schedule recurrence. Possible values include: 'RecurrenceTypeDaily', 'RecurrenceTypeWeekly', 'RecurrenceTypeMonthly', 'RecurrenceTypeAnnually' + Recurrence RecurrenceType `json:"recurrence,omitempty"` + // RecurrencePeriod - Has start and end date of the recurrence. The start date must be in future. If present, the end date must be greater than start date. + RecurrencePeriod *ReportConfigRecurrencePeriod `json:"recurrencePeriod,omitempty"` +} + +// ReportConfigTimePeriod the start and end date for pulling data for the report. +type ReportConfigTimePeriod struct { + // From - The start date to pull data from. + From *date.Time `json:"from,omitempty"` + // To - The end date to pull data to. + To *date.Time `json:"to,omitempty"` +} + +// Resource the Resource model definition. +type Resource struct { + // ID - Resource Id. + ID *string `json:"id,omitempty"` + // Name - Resource name. + Name *string `json:"name,omitempty"` + // Type - Resource type. + Type *string `json:"type,omitempty"` + // Tags - Resource tags. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if r.ID != nil { + objectMap["id"] = r.ID + } + if r.Name != nil { + objectMap["name"] = r.Name + } + if r.Type != nil { + objectMap["type"] = r.Type + } + if r.Tags != nil { + objectMap["tags"] = r.Tags + } + return json.Marshal(objectMap) +} diff --git a/services/costmanagement/mgmt/2018-09-01-preview/costmanagement/reportconfig.go b/services/costmanagement/mgmt/2018-09-01-preview/costmanagement/reportconfig.go new file mode 100644 index 000000000000..91172c6468e0 --- /dev/null +++ b/services/costmanagement/mgmt/2018-09-01-preview/costmanagement/reportconfig.go @@ -0,0 +1,666 @@ +package costmanagement + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// ReportConfigClient is the client for the ReportConfig methods of the Costmanagement service. +type ReportConfigClient struct { + BaseClient +} + +// NewReportConfigClient creates an instance of the ReportConfigClient client. +func NewReportConfigClient(subscriptionID string) ReportConfigClient { + return NewReportConfigClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewReportConfigClientWithBaseURI creates an instance of the ReportConfigClient client. +func NewReportConfigClientWithBaseURI(baseURI string, subscriptionID string) ReportConfigClient { + return ReportConfigClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate the operation to create or update a report config. Update operation requires latest eTag to be set in +// the request mandatorily. You may obtain the latest eTag by performing a get operation. Create operation does not +// require eTag. +// Parameters: +// reportConfigName - report Config Name. +// parameters - parameters supplied to the CreateOrUpdate Report Config operation. +func (client ReportConfigClient) CreateOrUpdate(ctx context.Context, reportConfigName string, parameters ReportConfig) (result ReportConfig, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ReportConfigProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Schedule", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Schedule.RecurrencePeriod", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Schedule.RecurrencePeriod.From", Name: validation.Null, Rule: true, Chain: nil}}}, + }}, + {Target: "parameters.ReportConfigProperties.DeliveryInfo", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.DeliveryInfo.Destination", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.DeliveryInfo.Destination.ResourceID", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ReportConfigProperties.DeliveryInfo.Destination.Container", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}, + {Target: "parameters.ReportConfigProperties.Definition", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Type", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ReportConfigProperties.Definition.TimePeriod", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.TimePeriod.From", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ReportConfigProperties.Definition.TimePeriod.To", Name: validation.Null, Rule: true, Chain: nil}, + }}, + {Target: "parameters.ReportConfigProperties.Definition.Dataset", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Grouping", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Grouping", Name: validation.MaxItems, Rule: 2, Chain: nil}}}, + {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.And", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.And", Name: validation.MinItems, Rule: 2, Chain: nil}}}, + {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Or", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Or", Name: validation.MinItems, Rule: 2, Chain: nil}}}, + {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Not", Name: validation.Null, Rule: false, Chain: nil}, + {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Dimension", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Dimension.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Dimension.Operator", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Dimension.Values", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Dimension.Values", Name: validation.MinItems, Rule: 1, Chain: nil}}}, + }}, + {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Tag", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Tag.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Tag.Operator", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Tag.Values", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Tag.Values", Name: validation.MinItems, Rule: 1, Chain: nil}}}, + }}, + }}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewError("costmanagement.ReportConfigClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, reportConfigName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ReportConfigClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "costmanagement.ReportConfigClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ReportConfigClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ReportConfigClient) CreateOrUpdatePreparer(ctx context.Context, reportConfigName string, parameters ReportConfig) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "reportConfigName": autorest.Encode("path", reportConfigName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.CostManagement/reportconfigs/{reportConfigName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client ReportConfigClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ReportConfigClient) CreateOrUpdateResponder(resp *http.Response) (result ReportConfig, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// CreateOrUpdateByResourceGroupName the operation to create or update a report config. Update operation requires +// latest eTag to be set in the request mandatorily. You may obtain the latest eTag by performing a get operation. +// Create operation does not require eTag. +// Parameters: +// resourceGroupName - azure Resource Group Name. +// reportConfigName - report Config Name. +// parameters - parameters supplied to the CreateOrUpdate Report Config operation. +func (client ReportConfigClient) CreateOrUpdateByResourceGroupName(ctx context.Context, resourceGroupName string, reportConfigName string, parameters ReportConfig) (result ReportConfig, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ReportConfigProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Schedule", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Schedule.RecurrencePeriod", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Schedule.RecurrencePeriod.From", Name: validation.Null, Rule: true, Chain: nil}}}, + }}, + {Target: "parameters.ReportConfigProperties.DeliveryInfo", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.DeliveryInfo.Destination", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.DeliveryInfo.Destination.ResourceID", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ReportConfigProperties.DeliveryInfo.Destination.Container", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}, + {Target: "parameters.ReportConfigProperties.Definition", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Type", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ReportConfigProperties.Definition.TimePeriod", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.TimePeriod.From", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ReportConfigProperties.Definition.TimePeriod.To", Name: validation.Null, Rule: true, Chain: nil}, + }}, + {Target: "parameters.ReportConfigProperties.Definition.Dataset", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Grouping", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Grouping", Name: validation.MaxItems, Rule: 2, Chain: nil}}}, + {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.And", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.And", Name: validation.MinItems, Rule: 2, Chain: nil}}}, + {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Or", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Or", Name: validation.MinItems, Rule: 2, Chain: nil}}}, + {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Not", Name: validation.Null, Rule: false, Chain: nil}, + {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Dimension", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Dimension.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Dimension.Operator", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Dimension.Values", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Dimension.Values", Name: validation.MinItems, Rule: 1, Chain: nil}}}, + }}, + {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Tag", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Tag.Name", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Tag.Operator", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Tag.Values", Name: validation.Null, Rule: true, + Chain: []validation.Constraint{{Target: "parameters.ReportConfigProperties.Definition.Dataset.Filter.Tag.Values", Name: validation.MinItems, Rule: 1, Chain: nil}}}, + }}, + }}, + }}, + }}, + }}}}}); err != nil { + return result, validation.NewError("costmanagement.ReportConfigClient", "CreateOrUpdateByResourceGroupName", err.Error()) + } + + req, err := client.CreateOrUpdateByResourceGroupNamePreparer(ctx, resourceGroupName, reportConfigName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ReportConfigClient", "CreateOrUpdateByResourceGroupName", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateByResourceGroupNameSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "costmanagement.ReportConfigClient", "CreateOrUpdateByResourceGroupName", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateByResourceGroupNameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ReportConfigClient", "CreateOrUpdateByResourceGroupName", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdateByResourceGroupNamePreparer prepares the CreateOrUpdateByResourceGroupName request. +func (client ReportConfigClient) CreateOrUpdateByResourceGroupNamePreparer(ctx context.Context, resourceGroupName string, reportConfigName string, parameters ReportConfig) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "reportConfigName": autorest.Encode("path", reportConfigName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CostManagement/reportconfigs/{reportConfigName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateByResourceGroupNameSender sends the CreateOrUpdateByResourceGroupName request. The method will close the +// http.Response Body if it receives an error. +func (client ReportConfigClient) CreateOrUpdateByResourceGroupNameSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateByResourceGroupNameResponder handles the response to the CreateOrUpdateByResourceGroupName request. The method always +// closes the http.Response Body. +func (client ReportConfigClient) CreateOrUpdateByResourceGroupNameResponder(resp *http.Response) (result ReportConfig, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete the operation to delete a report. +// Parameters: +// reportConfigName - report Config Name. +func (client ReportConfigClient) Delete(ctx context.Context, reportConfigName string) (result autorest.Response, err error) { + req, err := client.DeletePreparer(ctx, reportConfigName) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ReportConfigClient", "Delete", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "costmanagement.ReportConfigClient", "Delete", resp, "Failure sending request") + return + } + + result, err = client.DeleteResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ReportConfigClient", "Delete", resp, "Failure responding to request") + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ReportConfigClient) DeletePreparer(ctx context.Context, reportConfigName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "reportConfigName": autorest.Encode("path", reportConfigName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.CostManagement/reportconfigs/{reportConfigName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client ReportConfigClient) DeleteSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client ReportConfigClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// DeleteByResourceGroupName the operation to delete a report config. +// Parameters: +// resourceGroupName - azure Resource Group Name. +// reportConfigName - report Config Name. +func (client ReportConfigClient) DeleteByResourceGroupName(ctx context.Context, resourceGroupName string, reportConfigName string) (result autorest.Response, err error) { + req, err := client.DeleteByResourceGroupNamePreparer(ctx, resourceGroupName, reportConfigName) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ReportConfigClient", "DeleteByResourceGroupName", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteByResourceGroupNameSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "costmanagement.ReportConfigClient", "DeleteByResourceGroupName", resp, "Failure sending request") + return + } + + result, err = client.DeleteByResourceGroupNameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ReportConfigClient", "DeleteByResourceGroupName", resp, "Failure responding to request") + } + + return +} + +// DeleteByResourceGroupNamePreparer prepares the DeleteByResourceGroupName request. +func (client ReportConfigClient) DeleteByResourceGroupNamePreparer(ctx context.Context, resourceGroupName string, reportConfigName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "reportConfigName": autorest.Encode("path", reportConfigName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CostManagement/reportconfigs/{reportConfigName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteByResourceGroupNameSender sends the DeleteByResourceGroupName request. The method will close the +// http.Response Body if it receives an error. +func (client ReportConfigClient) DeleteByResourceGroupNameSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// DeleteByResourceGroupNameResponder handles the response to the DeleteByResourceGroupName request. The method always +// closes the http.Response Body. +func (client ReportConfigClient) DeleteByResourceGroupNameResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets the report config for a subscription by report config name. +// Parameters: +// reportConfigName - report Config Name. +func (client ReportConfigClient) Get(ctx context.Context, reportConfigName string) (result ReportConfig, err error) { + req, err := client.GetPreparer(ctx, reportConfigName) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ReportConfigClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "costmanagement.ReportConfigClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ReportConfigClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ReportConfigClient) GetPreparer(ctx context.Context, reportConfigName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "reportConfigName": autorest.Encode("path", reportConfigName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.CostManagement/reportconfigs/{reportConfigName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client ReportConfigClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ReportConfigClient) GetResponder(resp *http.Response) (result ReportConfig, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetByResourceGroupName gets the report config for a resource group under a subscription by report config name. +// Parameters: +// resourceGroupName - azure Resource Group Name. +// reportConfigName - report Config Name. +func (client ReportConfigClient) GetByResourceGroupName(ctx context.Context, resourceGroupName string, reportConfigName string) (result ReportConfig, err error) { + req, err := client.GetByResourceGroupNamePreparer(ctx, resourceGroupName, reportConfigName) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ReportConfigClient", "GetByResourceGroupName", nil, "Failure preparing request") + return + } + + resp, err := client.GetByResourceGroupNameSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "costmanagement.ReportConfigClient", "GetByResourceGroupName", resp, "Failure sending request") + return + } + + result, err = client.GetByResourceGroupNameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ReportConfigClient", "GetByResourceGroupName", resp, "Failure responding to request") + } + + return +} + +// GetByResourceGroupNamePreparer prepares the GetByResourceGroupName request. +func (client ReportConfigClient) GetByResourceGroupNamePreparer(ctx context.Context, resourceGroupName string, reportConfigName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "reportConfigName": autorest.Encode("path", reportConfigName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CostManagement/reportconfigs/{reportConfigName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetByResourceGroupNameSender sends the GetByResourceGroupName request. The method will close the +// http.Response Body if it receives an error. +func (client ReportConfigClient) GetByResourceGroupNameSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetByResourceGroupNameResponder handles the response to the GetByResourceGroupName request. The method always +// closes the http.Response Body. +func (client ReportConfigClient) GetByResourceGroupNameResponder(resp *http.Response) (result ReportConfig, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists all report configs for a subscription. +func (client ReportConfigClient) List(ctx context.Context) (result ReportConfigListResult, err error) { + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ReportConfigClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "costmanagement.ReportConfigClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ReportConfigClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ReportConfigClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.CostManagement/reportconfigs", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ReportConfigClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ReportConfigClient) ListResponder(resp *http.Response) (result ReportConfigListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroupName lists all report configs for a resource group under a subscription. +// Parameters: +// resourceGroupName - azure Resource Group Name. +func (client ReportConfigClient) ListByResourceGroupName(ctx context.Context, resourceGroupName string) (result ReportConfigListResult, err error) { + req, err := client.ListByResourceGroupNamePreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ReportConfigClient", "ListByResourceGroupName", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupNameSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "costmanagement.ReportConfigClient", "ListByResourceGroupName", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupNameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ReportConfigClient", "ListByResourceGroupName", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupNamePreparer prepares the ListByResourceGroupName request. +func (client ReportConfigClient) ListByResourceGroupNamePreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CostManagement/reportconfigs", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupNameSender sends the ListByResourceGroupName request. The method will close the +// http.Response Body if it receives an error. +func (client ReportConfigClient) ListByResourceGroupNameSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupNameResponder handles the response to the ListByResourceGroupName request. The method always +// closes the http.Response Body. +func (client ReportConfigClient) ListByResourceGroupNameResponder(resp *http.Response) (result ReportConfigListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/costmanagement/mgmt/2018-09-01-preview/costmanagement/resourcegroupdimensions.go b/services/costmanagement/mgmt/2018-09-01-preview/costmanagement/resourcegroupdimensions.go new file mode 100644 index 000000000000..c9bdcd6a2358 --- /dev/null +++ b/services/costmanagement/mgmt/2018-09-01-preview/costmanagement/resourcegroupdimensions.go @@ -0,0 +1,135 @@ +package costmanagement + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// ResourceGroupDimensionsClient is the client for the ResourceGroupDimensions methods of the Costmanagement service. +type ResourceGroupDimensionsClient struct { + BaseClient +} + +// NewResourceGroupDimensionsClient creates an instance of the ResourceGroupDimensionsClient client. +func NewResourceGroupDimensionsClient(subscriptionID string) ResourceGroupDimensionsClient { + return NewResourceGroupDimensionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewResourceGroupDimensionsClientWithBaseURI creates an instance of the ResourceGroupDimensionsClient client. +func NewResourceGroupDimensionsClientWithBaseURI(baseURI string, subscriptionID string) ResourceGroupDimensionsClient { + return ResourceGroupDimensionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists the dimensions by resource group Id. +// Parameters: +// resourceGroupName - azure Resource Group Name. +// filter - may be used to filter dimensions by properties/category, properties/usageStart, +// properties/usageEnd. Supported operators are 'eq','lt', 'gt', 'le', 'ge'. +// expand - may be used to expand the properties/data within a dimension dategory. By default, data is not +// included when listing dimensions. +// skiptoken - skiptoken is only used if a previous operation returned a partial result. If a previous response +// contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that +// specifies a starting point to use for subsequent calls. +// top - may be used to limit the number of results to the most recent N dimension data. +func (client ResourceGroupDimensionsClient) List(ctx context.Context, resourceGroupName string, filter string, expand string, skiptoken string, top *int32) (result DimensionsListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMaximum, Rule: int64(1000), Chain: nil}, + {Target: "top", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("costmanagement.ResourceGroupDimensionsClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, resourceGroupName, filter, expand, skiptoken, top) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ResourceGroupDimensionsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "costmanagement.ResourceGroupDimensionsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.ResourceGroupDimensionsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client ResourceGroupDimensionsClient) ListPreparer(ctx context.Context, resourceGroupName string, filter string, expand string, skiptoken string, top *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + if len(skiptoken) > 0 { + queryParameters["$skiptoken"] = autorest.Encode("query", skiptoken) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.CostManagement/dimensions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client ResourceGroupDimensionsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client ResourceGroupDimensionsClient) ListResponder(resp *http.Response) (result DimensionsListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/costmanagement/mgmt/2018-09-01-preview/costmanagement/subscriptiondimensions.go b/services/costmanagement/mgmt/2018-09-01-preview/costmanagement/subscriptiondimensions.go new file mode 100644 index 000000000000..331c48eed829 --- /dev/null +++ b/services/costmanagement/mgmt/2018-09-01-preview/costmanagement/subscriptiondimensions.go @@ -0,0 +1,133 @@ +package costmanagement + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "net/http" +) + +// SubscriptionDimensionsClient is the client for the SubscriptionDimensions methods of the Costmanagement service. +type SubscriptionDimensionsClient struct { + BaseClient +} + +// NewSubscriptionDimensionsClient creates an instance of the SubscriptionDimensionsClient client. +func NewSubscriptionDimensionsClient(subscriptionID string) SubscriptionDimensionsClient { + return NewSubscriptionDimensionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewSubscriptionDimensionsClientWithBaseURI creates an instance of the SubscriptionDimensionsClient client. +func NewSubscriptionDimensionsClientWithBaseURI(baseURI string, subscriptionID string) SubscriptionDimensionsClient { + return SubscriptionDimensionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists the dimensions by subscription Id. +// Parameters: +// filter - may be used to filter dimensions by properties/category, properties/usageStart, +// properties/usageEnd. Supported operators are 'eq','lt', 'gt', 'le', 'ge'. +// expand - may be used to expand the properties/data within a dimension dategory. By default, data is not +// included when listing dimensions. +// skiptoken - skiptoken is only used if a previous operation returned a partial result. If a previous response +// contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that +// specifies a starting point to use for subsequent calls. +// top - may be used to limit the number of results to the most recent N dimension data. +func (client SubscriptionDimensionsClient) List(ctx context.Context, filter string, expand string, skiptoken string, top *int32) (result DimensionsListResult, err error) { + if err := validation.Validate([]validation.Validation{ + {TargetValue: top, + Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMaximum, Rule: int64(1000), Chain: nil}, + {Target: "top", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("costmanagement.SubscriptionDimensionsClient", "List", err.Error()) + } + + req, err := client.ListPreparer(ctx, filter, expand, skiptoken, top) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.SubscriptionDimensionsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "costmanagement.SubscriptionDimensionsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "costmanagement.SubscriptionDimensionsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client SubscriptionDimensionsClient) ListPreparer(ctx context.Context, filter string, expand string, skiptoken string, top *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-09-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + if len(skiptoken) > 0 { + queryParameters["$skiptoken"] = autorest.Encode("query", skiptoken) + } + if top != nil { + queryParameters["$top"] = autorest.Encode("query", *top) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.CostManagement/dimensions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client SubscriptionDimensionsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client SubscriptionDimensionsClient) ListResponder(resp *http.Response) (result DimensionsListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/costmanagement/mgmt/2018-09-01-preview/costmanagement/version.go b/services/costmanagement/mgmt/2018-09-01-preview/costmanagement/version.go new file mode 100644 index 000000000000..c83b1fd1c819 --- /dev/null +++ b/services/costmanagement/mgmt/2018-09-01-preview/costmanagement/version.go @@ -0,0 +1,30 @@ +package costmanagement + +import "github.com/Azure/azure-sdk-for-go/version" + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + version.Number + " costmanagement/2018-09-01-preview" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +}