diff --git a/services/preview/billing/mgmt/2020-05-01-preview/billing/accounts.go b/services/preview/billing/mgmt/2020-05-01-preview/billing/accounts.go new file mode 100644 index 000000000000..5ba5d79c5287 --- /dev/null +++ b/services/preview/billing/mgmt/2020-05-01-preview/billing/accounts.go @@ -0,0 +1,415 @@ +package billing + +// 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/tracing" + "net/http" +) + +// AccountsClient is the billing client provides access to billing resources for Azure subscriptions. +type AccountsClient struct { + BaseClient +} + +// NewAccountsClient creates an instance of the AccountsClient client. +func NewAccountsClient(subscriptionID string) AccountsClient { + return NewAccountsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAccountsClientWithBaseURI creates an instance of the AccountsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewAccountsClientWithBaseURI(baseURI string, subscriptionID string) AccountsClient { + return AccountsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a billing account by its ID. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// expand - may be used to expand the soldTo, invoice sections and billing profiles. +func (client AccountsClient) Get(ctx context.Context, billingAccountName string, expand string) (result Account, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, billingAccountName, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AccountsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.AccountsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AccountsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client AccountsClient) GetPreparer(ctx context.Context, billingAccountName string, expand string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}", 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 AccountsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AccountsClient) GetResponder(resp *http.Response) (result Account, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists the billing accounts that a user has access to. +// Parameters: +// expand - may be used to expand the soldTo, invoice sections and billing profiles. +func (client AccountsClient) List(ctx context.Context, expand string) (result AccountListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.List") + defer func() { + sc := -1 + if result.alr.Response.Response != nil { + sc = result.alr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AccountsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.alr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.AccountsClient", "List", resp, "Failure sending request") + return + } + + result.alr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AccountsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client AccountsClient) ListPreparer(ctx context.Context, expand string) (*http.Request, error) { + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Billing/billingAccounts"), + 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 AccountsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client AccountsClient) ListResponder(resp *http.Response) (result AccountListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client AccountsClient) listNextResults(ctx context.Context, lastResults AccountListResult) (result AccountListResult, err error) { + req, err := lastResults.accountListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.AccountsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.AccountsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AccountsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client AccountsClient) ListComplete(ctx context.Context, expand string) (result AccountListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, expand) + return +} + +// ListInvoiceSectionsByCreateSubscriptionPermission lists the invoice sections for which the user has permission to +// create Azure subscriptions. The operation is supported only for billing accounts with agreement type Microsoft +// Customer Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +func (client AccountsClient) ListInvoiceSectionsByCreateSubscriptionPermission(ctx context.Context, billingAccountName string) (result InvoiceSectionListWithCreateSubPermissionResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.ListInvoiceSectionsByCreateSubscriptionPermission") + defer func() { + sc := -1 + if result.islwcspr.Response.Response != nil { + sc = result.islwcspr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listInvoiceSectionsByCreateSubscriptionPermissionNextResults + req, err := client.ListInvoiceSectionsByCreateSubscriptionPermissionPreparer(ctx, billingAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AccountsClient", "ListInvoiceSectionsByCreateSubscriptionPermission", nil, "Failure preparing request") + return + } + + resp, err := client.ListInvoiceSectionsByCreateSubscriptionPermissionSender(req) + if err != nil { + result.islwcspr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.AccountsClient", "ListInvoiceSectionsByCreateSubscriptionPermission", resp, "Failure sending request") + return + } + + result.islwcspr, err = client.ListInvoiceSectionsByCreateSubscriptionPermissionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AccountsClient", "ListInvoiceSectionsByCreateSubscriptionPermission", resp, "Failure responding to request") + } + + return +} + +// ListInvoiceSectionsByCreateSubscriptionPermissionPreparer prepares the ListInvoiceSectionsByCreateSubscriptionPermission request. +func (client AccountsClient) ListInvoiceSectionsByCreateSubscriptionPermissionPreparer(ctx context.Context, billingAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/listInvoiceSectionsWithCreateSubscriptionPermission", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListInvoiceSectionsByCreateSubscriptionPermissionSender sends the ListInvoiceSectionsByCreateSubscriptionPermission request. The method will close the +// http.Response Body if it receives an error. +func (client AccountsClient) ListInvoiceSectionsByCreateSubscriptionPermissionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListInvoiceSectionsByCreateSubscriptionPermissionResponder handles the response to the ListInvoiceSectionsByCreateSubscriptionPermission request. The method always +// closes the http.Response Body. +func (client AccountsClient) ListInvoiceSectionsByCreateSubscriptionPermissionResponder(resp *http.Response) (result InvoiceSectionListWithCreateSubPermissionResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listInvoiceSectionsByCreateSubscriptionPermissionNextResults retrieves the next set of results, if any. +func (client AccountsClient) listInvoiceSectionsByCreateSubscriptionPermissionNextResults(ctx context.Context, lastResults InvoiceSectionListWithCreateSubPermissionResult) (result InvoiceSectionListWithCreateSubPermissionResult, err error) { + req, err := lastResults.invoiceSectionListWithCreateSubPermissionResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.AccountsClient", "listInvoiceSectionsByCreateSubscriptionPermissionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListInvoiceSectionsByCreateSubscriptionPermissionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.AccountsClient", "listInvoiceSectionsByCreateSubscriptionPermissionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListInvoiceSectionsByCreateSubscriptionPermissionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AccountsClient", "listInvoiceSectionsByCreateSubscriptionPermissionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListInvoiceSectionsByCreateSubscriptionPermissionComplete enumerates all values, automatically crossing page boundaries as required. +func (client AccountsClient) ListInvoiceSectionsByCreateSubscriptionPermissionComplete(ctx context.Context, billingAccountName string) (result InvoiceSectionListWithCreateSubPermissionResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.ListInvoiceSectionsByCreateSubscriptionPermission") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListInvoiceSectionsByCreateSubscriptionPermission(ctx, billingAccountName) + return +} + +// Update updates the properties of a billing account. Currently, displayName and address can be updated. The operation +// is supported only for billing accounts with agreement type Microsoft Customer Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// parameters - request parameters that are provided to the update billing account operation. +func (client AccountsClient) Update(ctx context.Context, billingAccountName string, parameters AccountUpdateRequest) (result AccountsUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.Update") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, billingAccountName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AccountsClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AccountsClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client AccountsClient) UpdatePreparer(ctx context.Context, billingAccountName string, parameters AccountUpdateRequest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}", pathParameters), + autorest.WithJSON(parameters), + 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 AccountsClient) UpdateSender(req *http.Request) (future AccountsUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client AccountsClient) UpdateResponder(resp *http.Response) (result Account, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/billing/mgmt/2020-05-01-preview/billing/address.go b/services/preview/billing/mgmt/2020-05-01-preview/billing/address.go new file mode 100644 index 000000000000..bc411463c3be --- /dev/null +++ b/services/preview/billing/mgmt/2020-05-01-preview/billing/address.go @@ -0,0 +1,119 @@ +package billing + +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// AddressClient is the billing client provides access to billing resources for Azure subscriptions. +type AddressClient struct { + BaseClient +} + +// NewAddressClient creates an instance of the AddressClient client. +func NewAddressClient(subscriptionID string) AddressClient { + return NewAddressClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAddressClientWithBaseURI creates an instance of the AddressClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewAddressClientWithBaseURI(baseURI string, subscriptionID string) AddressClient { + return AddressClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Validate validates an address. Use the operation to validate an address before using it as soldTo or a billTo +// address. +func (client AddressClient) Validate(ctx context.Context, address AddressDetails) (result ValidateAddressResponse, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AddressClient.Validate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: address, + Constraints: []validation.Constraint{{Target: "address.AddressLine1", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "address.Country", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("billing.AddressClient", "Validate", err.Error()) + } + + req, err := client.ValidatePreparer(ctx, address) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AddressClient", "Validate", nil, "Failure preparing request") + return + } + + resp, err := client.ValidateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.AddressClient", "Validate", resp, "Failure sending request") + return + } + + result, err = client.ValidateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AddressClient", "Validate", resp, "Failure responding to request") + } + + return +} + +// ValidatePreparer prepares the Validate request. +func (client AddressClient) ValidatePreparer(ctx context.Context, address AddressDetails) (*http.Request, error) { + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Billing/validateAddress"), + autorest.WithJSON(address), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ValidateSender sends the Validate request. The method will close the +// http.Response Body if it receives an error. +func (client AddressClient) ValidateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ValidateResponder handles the response to the Validate request. The method always +// closes the http.Response Body. +func (client AddressClient) ValidateResponder(resp *http.Response) (result ValidateAddressResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/billing/mgmt/2020-05-01-preview/billing/agreements.go b/services/preview/billing/mgmt/2020-05-01-preview/billing/agreements.go new file mode 100644 index 000000000000..c0b9353b4a7c --- /dev/null +++ b/services/preview/billing/mgmt/2020-05-01-preview/billing/agreements.go @@ -0,0 +1,234 @@ +package billing + +// 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/tracing" + "net/http" +) + +// AgreementsClient is the billing client provides access to billing resources for Azure subscriptions. +type AgreementsClient struct { + BaseClient +} + +// NewAgreementsClient creates an instance of the AgreementsClient client. +func NewAgreementsClient(subscriptionID string) AgreementsClient { + return NewAgreementsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAgreementsClientWithBaseURI creates an instance of the AgreementsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewAgreementsClientWithBaseURI(baseURI string, subscriptionID string) AgreementsClient { + return AgreementsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets an agreement by ID. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// agreementName - the ID that uniquely identifies an agreement. +// expand - may be used to expand the participants. +func (client AgreementsClient) Get(ctx context.Context, billingAccountName string, agreementName string, expand string) (result Agreement, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AgreementsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, billingAccountName, agreementName, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AgreementsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.AgreementsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AgreementsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client AgreementsClient) GetPreparer(ctx context.Context, billingAccountName string, agreementName string, expand string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "agreementName": autorest.Encode("path", agreementName), + "billingAccountName": autorest.Encode("path", billingAccountName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/agreements/{agreementName}", 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 AgreementsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AgreementsClient) GetResponder(resp *http.Response) (result Agreement, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByBillingAccount lists the agreements for a billing account. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// expand - may be used to expand the participants. +func (client AgreementsClient) ListByBillingAccount(ctx context.Context, billingAccountName string, expand string) (result AgreementListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AgreementsClient.ListByBillingAccount") + defer func() { + sc := -1 + if result.alr.Response.Response != nil { + sc = result.alr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByBillingAccountNextResults + req, err := client.ListByBillingAccountPreparer(ctx, billingAccountName, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AgreementsClient", "ListByBillingAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByBillingAccountSender(req) + if err != nil { + result.alr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.AgreementsClient", "ListByBillingAccount", resp, "Failure sending request") + return + } + + result.alr, err = client.ListByBillingAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AgreementsClient", "ListByBillingAccount", resp, "Failure responding to request") + } + + return +} + +// ListByBillingAccountPreparer prepares the ListByBillingAccount request. +func (client AgreementsClient) ListByBillingAccountPreparer(ctx context.Context, billingAccountName string, expand string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/agreements", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByBillingAccountSender sends the ListByBillingAccount request. The method will close the +// http.Response Body if it receives an error. +func (client AgreementsClient) ListByBillingAccountSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListByBillingAccountResponder handles the response to the ListByBillingAccount request. The method always +// closes the http.Response Body. +func (client AgreementsClient) ListByBillingAccountResponder(resp *http.Response) (result AgreementListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByBillingAccountNextResults retrieves the next set of results, if any. +func (client AgreementsClient) listByBillingAccountNextResults(ctx context.Context, lastResults AgreementListResult) (result AgreementListResult, err error) { + req, err := lastResults.agreementListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.AgreementsClient", "listByBillingAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByBillingAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.AgreementsClient", "listByBillingAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByBillingAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AgreementsClient", "listByBillingAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByBillingAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client AgreementsClient) ListByBillingAccountComplete(ctx context.Context, billingAccountName string, expand string) (result AgreementListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AgreementsClient.ListByBillingAccount") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByBillingAccount(ctx, billingAccountName, expand) + return +} diff --git a/services/preview/billing/mgmt/2020-05-01-preview/billing/availablebalances.go b/services/preview/billing/mgmt/2020-05-01-preview/billing/availablebalances.go new file mode 100644 index 000000000000..9e7029db721c --- /dev/null +++ b/services/preview/billing/mgmt/2020-05-01-preview/billing/availablebalances.go @@ -0,0 +1,119 @@ +package billing + +// 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/tracing" + "net/http" +) + +// AvailableBalancesClient is the billing client provides access to billing resources for Azure subscriptions. +type AvailableBalancesClient struct { + BaseClient +} + +// NewAvailableBalancesClient creates an instance of the AvailableBalancesClient client. +func NewAvailableBalancesClient(subscriptionID string) AvailableBalancesClient { + return NewAvailableBalancesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAvailableBalancesClientWithBaseURI creates an instance of the AvailableBalancesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewAvailableBalancesClientWithBaseURI(baseURI string, subscriptionID string) AvailableBalancesClient { + return AvailableBalancesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get the available credit balance for a billing profile. This is the balance that can be used for pay now to settle +// due or past due invoices. The operation is supported only for billing accounts with agreement type Microsoft +// Customer Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// billingProfileName - the ID that uniquely identifies a billing profile. +func (client AvailableBalancesClient) Get(ctx context.Context, billingAccountName string, billingProfileName string) (result AvailableBalance, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AvailableBalancesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, billingAccountName, billingProfileName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AvailableBalancesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.AvailableBalancesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AvailableBalancesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client AvailableBalancesClient) GetPreparer(ctx context.Context, billingAccountName string, billingProfileName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingProfileName": autorest.Encode("path", billingProfileName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/availableBalance/default", 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 AvailableBalancesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client AvailableBalancesClient) GetResponder(resp *http.Response) (result AvailableBalance, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/billing/mgmt/2020-05-01-preview/billing/billingapi/interfaces.go b/services/preview/billing/mgmt/2020-05-01-preview/billing/billingapi/interfaces.go new file mode 100644 index 000000000000..884ae6a1fde6 --- /dev/null +++ b/services/preview/billing/mgmt/2020-05-01-preview/billing/billingapi/interfaces.go @@ -0,0 +1,233 @@ +package billingapi + +// 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/azure-sdk-for-go/services/preview/billing/mgmt/2020-05-01-preview/billing" +) + +// AccountsClientAPI contains the set of methods on the AccountsClient type. +type AccountsClientAPI interface { + Get(ctx context.Context, billingAccountName string, expand string) (result billing.Account, err error) + List(ctx context.Context, expand string) (result billing.AccountListResultPage, err error) + ListComplete(ctx context.Context, expand string) (result billing.AccountListResultIterator, err error) + ListInvoiceSectionsByCreateSubscriptionPermission(ctx context.Context, billingAccountName string) (result billing.InvoiceSectionListWithCreateSubPermissionResultPage, err error) + ListInvoiceSectionsByCreateSubscriptionPermissionComplete(ctx context.Context, billingAccountName string) (result billing.InvoiceSectionListWithCreateSubPermissionResultIterator, err error) + Update(ctx context.Context, billingAccountName string, parameters billing.AccountUpdateRequest) (result billing.AccountsUpdateFuture, err error) +} + +var _ AccountsClientAPI = (*billing.AccountsClient)(nil) + +// AddressClientAPI contains the set of methods on the AddressClient type. +type AddressClientAPI interface { + Validate(ctx context.Context, address billing.AddressDetails) (result billing.ValidateAddressResponse, err error) +} + +var _ AddressClientAPI = (*billing.AddressClient)(nil) + +// AvailableBalancesClientAPI contains the set of methods on the AvailableBalancesClient type. +type AvailableBalancesClientAPI interface { + Get(ctx context.Context, billingAccountName string, billingProfileName string) (result billing.AvailableBalance, err error) +} + +var _ AvailableBalancesClientAPI = (*billing.AvailableBalancesClient)(nil) + +// InstructionsClientAPI contains the set of methods on the InstructionsClient type. +type InstructionsClientAPI interface { + Get(ctx context.Context, billingAccountName string, billingProfileName string, instructionName string) (result billing.Instruction, err error) + ListByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string) (result billing.InstructionListResultPage, err error) + ListByBillingProfileComplete(ctx context.Context, billingAccountName string, billingProfileName string) (result billing.InstructionListResultIterator, err error) + Put(ctx context.Context, billingAccountName string, billingProfileName string, instructionName string, parameters billing.Instruction) (result billing.Instruction, err error) +} + +var _ InstructionsClientAPI = (*billing.InstructionsClient)(nil) + +// ProfilesClientAPI contains the set of methods on the ProfilesClient type. +type ProfilesClientAPI interface { + CreateOrUpdate(ctx context.Context, billingAccountName string, billingProfileName string, parameters billing.Profile) (result billing.ProfilesCreateOrUpdateFuture, err error) + Get(ctx context.Context, billingAccountName string, billingProfileName string, expand string) (result billing.Profile, err error) + ListByBillingAccount(ctx context.Context, billingAccountName string, expand string) (result billing.ProfileListResultPage, err error) + ListByBillingAccountComplete(ctx context.Context, billingAccountName string, expand string) (result billing.ProfileListResultIterator, err error) +} + +var _ ProfilesClientAPI = (*billing.ProfilesClient)(nil) + +// CustomersClientAPI contains the set of methods on the CustomersClient type. +type CustomersClientAPI interface { + Get(ctx context.Context, billingAccountName string, customerName string, expand string) (result billing.Customer, err error) + ListByBillingAccount(ctx context.Context, billingAccountName string, search string, filter string) (result billing.CustomerListResultPage, err error) + ListByBillingAccountComplete(ctx context.Context, billingAccountName string, search string, filter string) (result billing.CustomerListResultIterator, err error) + ListByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string, search string, filter string) (result billing.CustomerListResultPage, err error) + ListByBillingProfileComplete(ctx context.Context, billingAccountName string, billingProfileName string, search string, filter string) (result billing.CustomerListResultIterator, err error) +} + +var _ CustomersClientAPI = (*billing.CustomersClient)(nil) + +// InvoiceSectionsClientAPI contains the set of methods on the InvoiceSectionsClient type. +type InvoiceSectionsClientAPI interface { + CreateOrUpdate(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, parameters billing.InvoiceSection) (result billing.InvoiceSectionsCreateOrUpdateFuture, err error) + Get(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string) (result billing.InvoiceSection, err error) + ListByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string) (result billing.InvoiceSectionListResultPage, err error) + ListByBillingProfileComplete(ctx context.Context, billingAccountName string, billingProfileName string) (result billing.InvoiceSectionListResultIterator, err error) +} + +var _ InvoiceSectionsClientAPI = (*billing.InvoiceSectionsClient)(nil) + +// PermissionsClientAPI contains the set of methods on the PermissionsClient type. +type PermissionsClientAPI interface { + ListByBillingAccount(ctx context.Context, billingAccountName string) (result billing.PermissionsListResultPage, err error) + ListByBillingAccountComplete(ctx context.Context, billingAccountName string) (result billing.PermissionsListResultIterator, err error) + ListByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string) (result billing.PermissionsListResultPage, err error) + ListByBillingProfileComplete(ctx context.Context, billingAccountName string, billingProfileName string) (result billing.PermissionsListResultIterator, err error) + ListByCustomer(ctx context.Context, billingAccountName string, customerName string) (result billing.PermissionsListResultPage, err error) + ListByCustomerComplete(ctx context.Context, billingAccountName string, customerName string) (result billing.PermissionsListResultIterator, err error) + ListByInvoiceSections(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string) (result billing.PermissionsListResultPage, err error) + ListByInvoiceSectionsComplete(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string) (result billing.PermissionsListResultIterator, err error) +} + +var _ PermissionsClientAPI = (*billing.PermissionsClient)(nil) + +// SubscriptionsClientAPI contains the set of methods on the SubscriptionsClient type. +type SubscriptionsClientAPI interface { + Get(ctx context.Context, billingAccountName string) (result billing.Subscription, err error) + ListByBillingAccount(ctx context.Context, billingAccountName string) (result billing.SubscriptionsListResultPage, err error) + ListByBillingAccountComplete(ctx context.Context, billingAccountName string) (result billing.SubscriptionsListResultIterator, err error) + ListByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string) (result billing.SubscriptionsListResultPage, err error) + ListByBillingProfileComplete(ctx context.Context, billingAccountName string, billingProfileName string) (result billing.SubscriptionsListResultIterator, err error) + ListByCustomer(ctx context.Context, billingAccountName string, customerName string) (result billing.SubscriptionsListResultPage, err error) + ListByCustomerComplete(ctx context.Context, billingAccountName string, customerName string) (result billing.SubscriptionsListResultIterator, err error) + ListByInvoiceSection(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string) (result billing.SubscriptionsListResultPage, err error) + ListByInvoiceSectionComplete(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string) (result billing.SubscriptionsListResultIterator, err error) + Move(ctx context.Context, billingAccountName string, parameters billing.TransferBillingSubscriptionRequestProperties) (result billing.SubscriptionsMoveFuture, err error) + Update(ctx context.Context, billingAccountName string, parameters billing.Subscription) (result billing.Subscription, err error) + ValidateMove(ctx context.Context, billingAccountName string, parameters billing.TransferBillingSubscriptionRequestProperties) (result billing.ValidateSubscriptionTransferEligibilityResult, err error) +} + +var _ SubscriptionsClientAPI = (*billing.SubscriptionsClient)(nil) + +// ProductsClientAPI contains the set of methods on the ProductsClient type. +type ProductsClientAPI interface { + Get(ctx context.Context, billingAccountName string, productName string) (result billing.Product, err error) + ListByBillingAccount(ctx context.Context, billingAccountName string, filter string) (result billing.ProductsListResultPage, err error) + ListByBillingAccountComplete(ctx context.Context, billingAccountName string, filter string) (result billing.ProductsListResultIterator, err error) + ListByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string, filter string) (result billing.ProductsListResultPage, err error) + ListByBillingProfileComplete(ctx context.Context, billingAccountName string, billingProfileName string, filter string) (result billing.ProductsListResultIterator, err error) + ListByCustomer(ctx context.Context, billingAccountName string, customerName string) (result billing.ProductsListResultPage, err error) + ListByCustomerComplete(ctx context.Context, billingAccountName string, customerName string) (result billing.ProductsListResultIterator, err error) + ListByInvoiceSection(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, filter string) (result billing.ProductsListResultPage, err error) + ListByInvoiceSectionComplete(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, filter string) (result billing.ProductsListResultIterator, err error) + Move(ctx context.Context, billingAccountName string, productName string, parameters billing.TransferProductRequestProperties) (result billing.Product, err error) + Update(ctx context.Context, billingAccountName string, productName string, parameters billing.Product) (result billing.Product, err error) + ValidateMove(ctx context.Context, billingAccountName string, productName string, parameters billing.TransferProductRequestProperties) (result billing.ValidateProductTransferEligibilityResult, err error) +} + +var _ ProductsClientAPI = (*billing.ProductsClient)(nil) + +// InvoicesClientAPI contains the set of methods on the InvoicesClient type. +type InvoicesClientAPI interface { + DownloadBillingSubscriptionInvoice(ctx context.Context, invoiceName string, downloadToken string) (result billing.InvoicesDownloadBillingSubscriptionInvoiceFuture, err error) + DownloadInvoice(ctx context.Context, billingAccountName string, invoiceName string, downloadToken string) (result billing.InvoicesDownloadInvoiceFuture, err error) + Get(ctx context.Context, billingAccountName string, invoiceName string) (result billing.Invoice, err error) + GetByID(ctx context.Context, invoiceName string) (result billing.Invoice, err error) + GetBySubscriptionAndInvoiceID(ctx context.Context, invoiceName string) (result billing.Invoice, err error) + ListByBillingAccount(ctx context.Context, billingAccountName string, periodStartDate string, periodEndDate string) (result billing.InvoiceListResultPage, err error) + ListByBillingAccountComplete(ctx context.Context, billingAccountName string, periodStartDate string, periodEndDate string) (result billing.InvoiceListResultIterator, err error) + ListByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string, periodStartDate string, periodEndDate string) (result billing.InvoiceListResultPage, err error) + ListByBillingProfileComplete(ctx context.Context, billingAccountName string, billingProfileName string, periodStartDate string, periodEndDate string) (result billing.InvoiceListResultIterator, err error) + ListByBillingSubscription(ctx context.Context, periodStartDate string, periodEndDate string) (result billing.InvoiceListResultPage, err error) + ListByBillingSubscriptionComplete(ctx context.Context, periodStartDate string, periodEndDate string) (result billing.InvoiceListResultIterator, err error) +} + +var _ InvoicesClientAPI = (*billing.InvoicesClient)(nil) + +// TransactionsClientAPI contains the set of methods on the TransactionsClient type. +type TransactionsClientAPI interface { + ListByInvoice(ctx context.Context, billingAccountName string, invoiceName string) (result billing.TransactionListResultPage, err error) + ListByInvoiceComplete(ctx context.Context, billingAccountName string, invoiceName string) (result billing.TransactionListResultIterator, err error) +} + +var _ TransactionsClientAPI = (*billing.TransactionsClient)(nil) + +// PoliciesClientAPI contains the set of methods on the PoliciesClient type. +type PoliciesClientAPI interface { + GetByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string) (result billing.Policy, err error) + GetByCustomer(ctx context.Context, billingAccountName string, customerName string) (result billing.CustomerPolicy, err error) + Update(ctx context.Context, billingAccountName string, billingProfileName string, parameters billing.Policy) (result billing.Policy, err error) + UpdateCustomer(ctx context.Context, billingAccountName string, customerName string, parameters billing.CustomerPolicy) (result billing.CustomerPolicy, err error) +} + +var _ PoliciesClientAPI = (*billing.PoliciesClient)(nil) + +// PropertyClientAPI contains the set of methods on the PropertyClient type. +type PropertyClientAPI interface { + Get(ctx context.Context) (result billing.Property, err error) + Update(ctx context.Context, parameters billing.Property) (result billing.Property, err error) +} + +var _ PropertyClientAPI = (*billing.PropertyClient)(nil) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result billing.OperationListResultPage, err error) + ListComplete(ctx context.Context) (result billing.OperationListResultIterator, err error) +} + +var _ OperationsClientAPI = (*billing.OperationsClient)(nil) + +// RoleDefinitionsClientAPI contains the set of methods on the RoleDefinitionsClient type. +type RoleDefinitionsClientAPI interface { + GetByBillingAccount(ctx context.Context, billingAccountName string, billingRoleDefinitionName string) (result billing.RoleDefinition, err error) + GetByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string, billingRoleDefinitionName string) (result billing.RoleDefinition, err error) + GetByInvoiceSection(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, billingRoleDefinitionName string) (result billing.RoleDefinition, err error) + ListByBillingAccount(ctx context.Context, billingAccountName string) (result billing.RoleDefinitionListResultPage, err error) + ListByBillingAccountComplete(ctx context.Context, billingAccountName string) (result billing.RoleDefinitionListResultIterator, err error) + ListByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string) (result billing.RoleDefinitionListResultPage, err error) + ListByBillingProfileComplete(ctx context.Context, billingAccountName string, billingProfileName string) (result billing.RoleDefinitionListResultIterator, err error) + ListByInvoiceSection(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string) (result billing.RoleDefinitionListResultPage, err error) + ListByInvoiceSectionComplete(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string) (result billing.RoleDefinitionListResultIterator, err error) +} + +var _ RoleDefinitionsClientAPI = (*billing.RoleDefinitionsClient)(nil) + +// RoleAssignmentsClientAPI contains the set of methods on the RoleAssignmentsClient type. +type RoleAssignmentsClientAPI interface { + DeleteByBillingAccount(ctx context.Context, billingAccountName string, billingRoleAssignmentName string) (result billing.RoleAssignment, err error) + DeleteByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string, billingRoleAssignmentName string) (result billing.RoleAssignment, err error) + DeleteByInvoiceSection(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, billingRoleAssignmentName string) (result billing.RoleAssignment, err error) + GetByBillingAccount(ctx context.Context, billingAccountName string, billingRoleAssignmentName string) (result billing.RoleAssignment, err error) + GetByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string, billingRoleAssignmentName string) (result billing.RoleAssignment, err error) + GetByInvoiceSection(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, billingRoleAssignmentName string) (result billing.RoleAssignment, err error) + ListByBillingAccount(ctx context.Context, billingAccountName string) (result billing.RoleAssignmentListResultPage, err error) + ListByBillingAccountComplete(ctx context.Context, billingAccountName string) (result billing.RoleAssignmentListResultIterator, err error) + ListByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string) (result billing.RoleAssignmentListResultPage, err error) + ListByBillingProfileComplete(ctx context.Context, billingAccountName string, billingProfileName string) (result billing.RoleAssignmentListResultIterator, err error) + ListByInvoiceSection(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string) (result billing.RoleAssignmentListResultPage, err error) + ListByInvoiceSectionComplete(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string) (result billing.RoleAssignmentListResultIterator, err error) +} + +var _ RoleAssignmentsClientAPI = (*billing.RoleAssignmentsClient)(nil) + +// AgreementsClientAPI contains the set of methods on the AgreementsClient type. +type AgreementsClientAPI interface { + Get(ctx context.Context, billingAccountName string, agreementName string, expand string) (result billing.Agreement, err error) + ListByBillingAccount(ctx context.Context, billingAccountName string, expand string) (result billing.AgreementListResultPage, err error) + ListByBillingAccountComplete(ctx context.Context, billingAccountName string, expand string) (result billing.AgreementListResultIterator, err error) +} + +var _ AgreementsClientAPI = (*billing.AgreementsClient)(nil) diff --git a/services/preview/billing/mgmt/2020-05-01-preview/billing/client.go b/services/preview/billing/mgmt/2020-05-01-preview/billing/client.go new file mode 100644 index 000000000000..ee477d8660c5 --- /dev/null +++ b/services/preview/billing/mgmt/2020-05-01-preview/billing/client.go @@ -0,0 +1,52 @@ +// Package billing implements the Azure ARM Billing service API version 2020-05-01. +// +// Billing client provides access to billing resources for Azure subscriptions. +package billing + +// 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 ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Billing + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Billing. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with +// an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/services/preview/billing/mgmt/2020-05-01-preview/billing/customers.go b/services/preview/billing/mgmt/2020-05-01-preview/billing/customers.go new file mode 100644 index 000000000000..de360a26a5a4 --- /dev/null +++ b/services/preview/billing/mgmt/2020-05-01-preview/billing/customers.go @@ -0,0 +1,363 @@ +package billing + +// 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/tracing" + "net/http" +) + +// CustomersClient is the billing client provides access to billing resources for Azure subscriptions. +type CustomersClient struct { + BaseClient +} + +// NewCustomersClient creates an instance of the CustomersClient client. +func NewCustomersClient(subscriptionID string) CustomersClient { + return NewCustomersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewCustomersClientWithBaseURI creates an instance of the CustomersClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewCustomersClientWithBaseURI(baseURI string, subscriptionID string) CustomersClient { + return CustomersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a customer by its ID. The operation is supported only for billing accounts with agreement type Microsoft +// Partner Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// customerName - the ID that uniquely identifies a customer. +// expand - may be used to expand enabledAzurePlans and resellers +func (client CustomersClient) Get(ctx context.Context, billingAccountName string, customerName string, expand string) (result Customer, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CustomersClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, billingAccountName, customerName, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.CustomersClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.CustomersClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.CustomersClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client CustomersClient) GetPreparer(ctx context.Context, billingAccountName string, customerName string, expand string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "customerName": autorest.Encode("path", customerName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}", 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 CustomersClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client CustomersClient) GetResponder(resp *http.Response) (result Customer, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByBillingAccount lists the customers that are billed to a billing account. The operation is supported only for +// billing accounts with agreement type Microsoft Partner Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// search - used for searching customers by their name. Any customer with name containing the search text will +// be included in the response +// filter - may be used to filter the list of customers. +func (client CustomersClient) ListByBillingAccount(ctx context.Context, billingAccountName string, search string, filter string) (result CustomerListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CustomersClient.ListByBillingAccount") + defer func() { + sc := -1 + if result.clr.Response.Response != nil { + sc = result.clr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByBillingAccountNextResults + req, err := client.ListByBillingAccountPreparer(ctx, billingAccountName, search, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.CustomersClient", "ListByBillingAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByBillingAccountSender(req) + if err != nil { + result.clr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.CustomersClient", "ListByBillingAccount", resp, "Failure sending request") + return + } + + result.clr, err = client.ListByBillingAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.CustomersClient", "ListByBillingAccount", resp, "Failure responding to request") + } + + return +} + +// ListByBillingAccountPreparer prepares the ListByBillingAccount request. +func (client CustomersClient) ListByBillingAccountPreparer(ctx context.Context, billingAccountName string, search string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(search) > 0 { + queryParameters["$search"] = autorest.Encode("query", search) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByBillingAccountSender sends the ListByBillingAccount request. The method will close the +// http.Response Body if it receives an error. +func (client CustomersClient) ListByBillingAccountSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListByBillingAccountResponder handles the response to the ListByBillingAccount request. The method always +// closes the http.Response Body. +func (client CustomersClient) ListByBillingAccountResponder(resp *http.Response) (result CustomerListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByBillingAccountNextResults retrieves the next set of results, if any. +func (client CustomersClient) listByBillingAccountNextResults(ctx context.Context, lastResults CustomerListResult) (result CustomerListResult, err error) { + req, err := lastResults.customerListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.CustomersClient", "listByBillingAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByBillingAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.CustomersClient", "listByBillingAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByBillingAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.CustomersClient", "listByBillingAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByBillingAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client CustomersClient) ListByBillingAccountComplete(ctx context.Context, billingAccountName string, search string, filter string) (result CustomerListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CustomersClient.ListByBillingAccount") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByBillingAccount(ctx, billingAccountName, search, filter) + return +} + +// ListByBillingProfile lists the customers that are billed to a billing profile. The operation is supported only for +// billing accounts with agreement type Microsoft Partner Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// billingProfileName - the ID that uniquely identifies a billing profile. +// search - used for searching customers by their name. Any customer with name containing the search text will +// be included in the response +// filter - may be used to filter the list of customers. +func (client CustomersClient) ListByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string, search string, filter string) (result CustomerListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CustomersClient.ListByBillingProfile") + defer func() { + sc := -1 + if result.clr.Response.Response != nil { + sc = result.clr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByBillingProfileNextResults + req, err := client.ListByBillingProfilePreparer(ctx, billingAccountName, billingProfileName, search, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.CustomersClient", "ListByBillingProfile", nil, "Failure preparing request") + return + } + + resp, err := client.ListByBillingProfileSender(req) + if err != nil { + result.clr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.CustomersClient", "ListByBillingProfile", resp, "Failure sending request") + return + } + + result.clr, err = client.ListByBillingProfileResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.CustomersClient", "ListByBillingProfile", resp, "Failure responding to request") + } + + return +} + +// ListByBillingProfilePreparer prepares the ListByBillingProfile request. +func (client CustomersClient) ListByBillingProfilePreparer(ctx context.Context, billingAccountName string, billingProfileName string, search string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingProfileName": autorest.Encode("path", billingProfileName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(search) > 0 { + queryParameters["$search"] = autorest.Encode("query", search) + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByBillingProfileSender sends the ListByBillingProfile request. The method will close the +// http.Response Body if it receives an error. +func (client CustomersClient) ListByBillingProfileSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListByBillingProfileResponder handles the response to the ListByBillingProfile request. The method always +// closes the http.Response Body. +func (client CustomersClient) ListByBillingProfileResponder(resp *http.Response) (result CustomerListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByBillingProfileNextResults retrieves the next set of results, if any. +func (client CustomersClient) listByBillingProfileNextResults(ctx context.Context, lastResults CustomerListResult) (result CustomerListResult, err error) { + req, err := lastResults.customerListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.CustomersClient", "listByBillingProfileNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByBillingProfileSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.CustomersClient", "listByBillingProfileNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByBillingProfileResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.CustomersClient", "listByBillingProfileNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByBillingProfileComplete enumerates all values, automatically crossing page boundaries as required. +func (client CustomersClient) ListByBillingProfileComplete(ctx context.Context, billingAccountName string, billingProfileName string, search string, filter string) (result CustomerListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CustomersClient.ListByBillingProfile") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByBillingProfile(ctx, billingAccountName, billingProfileName, search, filter) + return +} diff --git a/services/preview/billing/mgmt/2020-05-01-preview/billing/instructions.go b/services/preview/billing/mgmt/2020-05-01-preview/billing/instructions.go new file mode 100644 index 000000000000..4237890a28c7 --- /dev/null +++ b/services/preview/billing/mgmt/2020-05-01-preview/billing/instructions.go @@ -0,0 +1,322 @@ +package billing + +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// InstructionsClient is the billing client provides access to billing resources for Azure subscriptions. +type InstructionsClient struct { + BaseClient +} + +// NewInstructionsClient creates an instance of the InstructionsClient client. +func NewInstructionsClient(subscriptionID string) InstructionsClient { + return NewInstructionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewInstructionsClientWithBaseURI creates an instance of the InstructionsClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewInstructionsClientWithBaseURI(baseURI string, subscriptionID string) InstructionsClient { + return InstructionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get get the instruction by name. These are custom billing instructions and are only applicable for certain +// customers. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// billingProfileName - the ID that uniquely identifies a billing profile. +// instructionName - instruction Name. +func (client InstructionsClient) Get(ctx context.Context, billingAccountName string, billingProfileName string, instructionName string) (result Instruction, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstructionsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, billingAccountName, billingProfileName, instructionName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InstructionsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.InstructionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InstructionsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client InstructionsClient) GetPreparer(ctx context.Context, billingAccountName string, billingProfileName string, instructionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingProfileName": autorest.Encode("path", billingProfileName), + "instructionName": autorest.Encode("path", instructionName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/instructions/{instructionName}", 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 InstructionsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client InstructionsClient) GetResponder(resp *http.Response) (result Instruction, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByBillingProfile lists the instructions by billing profile id. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// billingProfileName - the ID that uniquely identifies a billing profile. +func (client InstructionsClient) ListByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string) (result InstructionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstructionsClient.ListByBillingProfile") + defer func() { + sc := -1 + if result.ilr.Response.Response != nil { + sc = result.ilr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByBillingProfileNextResults + req, err := client.ListByBillingProfilePreparer(ctx, billingAccountName, billingProfileName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InstructionsClient", "ListByBillingProfile", nil, "Failure preparing request") + return + } + + resp, err := client.ListByBillingProfileSender(req) + if err != nil { + result.ilr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.InstructionsClient", "ListByBillingProfile", resp, "Failure sending request") + return + } + + result.ilr, err = client.ListByBillingProfileResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InstructionsClient", "ListByBillingProfile", resp, "Failure responding to request") + } + + return +} + +// ListByBillingProfilePreparer prepares the ListByBillingProfile request. +func (client InstructionsClient) ListByBillingProfilePreparer(ctx context.Context, billingAccountName string, billingProfileName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingProfileName": autorest.Encode("path", billingProfileName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/instructions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByBillingProfileSender sends the ListByBillingProfile request. The method will close the +// http.Response Body if it receives an error. +func (client InstructionsClient) ListByBillingProfileSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListByBillingProfileResponder handles the response to the ListByBillingProfile request. The method always +// closes the http.Response Body. +func (client InstructionsClient) ListByBillingProfileResponder(resp *http.Response) (result InstructionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByBillingProfileNextResults retrieves the next set of results, if any. +func (client InstructionsClient) listByBillingProfileNextResults(ctx context.Context, lastResults InstructionListResult) (result InstructionListResult, err error) { + req, err := lastResults.instructionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.InstructionsClient", "listByBillingProfileNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByBillingProfileSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.InstructionsClient", "listByBillingProfileNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByBillingProfileResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InstructionsClient", "listByBillingProfileNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByBillingProfileComplete enumerates all values, automatically crossing page boundaries as required. +func (client InstructionsClient) ListByBillingProfileComplete(ctx context.Context, billingAccountName string, billingProfileName string) (result InstructionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstructionsClient.ListByBillingProfile") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByBillingProfile(ctx, billingAccountName, billingProfileName) + return +} + +// Put creates or updates an instruction. These are custom billing instructions and are only applicable for certain +// customers. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// billingProfileName - the ID that uniquely identifies a billing profile. +// instructionName - instruction Name. +// parameters - the new instruction. +func (client InstructionsClient) Put(ctx context.Context, billingAccountName string, billingProfileName string, instructionName string, parameters Instruction) (result Instruction, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstructionsClient.Put") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.InstructionProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.InstructionProperties.Amount", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.InstructionProperties.StartDate", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.InstructionProperties.EndDate", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("billing.InstructionsClient", "Put", err.Error()) + } + + req, err := client.PutPreparer(ctx, billingAccountName, billingProfileName, instructionName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InstructionsClient", "Put", nil, "Failure preparing request") + return + } + + resp, err := client.PutSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.InstructionsClient", "Put", resp, "Failure sending request") + return + } + + result, err = client.PutResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InstructionsClient", "Put", resp, "Failure responding to request") + } + + return +} + +// PutPreparer prepares the Put request. +func (client InstructionsClient) PutPreparer(ctx context.Context, billingAccountName string, billingProfileName string, instructionName string, parameters Instruction) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingProfileName": autorest.Encode("path", billingProfileName), + "instructionName": autorest.Encode("path", instructionName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/instructions/{instructionName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// PutSender sends the Put request. The method will close the +// http.Response Body if it receives an error. +func (client InstructionsClient) PutSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// PutResponder handles the response to the Put request. The method always +// closes the http.Response Body. +func (client InstructionsClient) PutResponder(resp *http.Response) (result Instruction, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/billing/mgmt/2020-05-01-preview/billing/invoices.go b/services/preview/billing/mgmt/2020-05-01-preview/billing/invoices.go new file mode 100644 index 000000000000..9e8161d9abb9 --- /dev/null +++ b/services/preview/billing/mgmt/2020-05-01-preview/billing/invoices.go @@ -0,0 +1,760 @@ +package billing + +// 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/tracing" + "net/http" +) + +// InvoicesClient is the billing client provides access to billing resources for Azure subscriptions. +type InvoicesClient struct { + BaseClient +} + +// NewInvoicesClient creates an instance of the InvoicesClient client. +func NewInvoicesClient(subscriptionID string) InvoicesClient { + return NewInvoicesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewInvoicesClientWithBaseURI creates an instance of the InvoicesClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewInvoicesClientWithBaseURI(baseURI string, subscriptionID string) InvoicesClient { + return InvoicesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// DownloadBillingSubscriptionInvoice gets a URL to download an invoice. +// Parameters: +// invoiceName - the ID that uniquely identifies an invoice. +// downloadToken - download token with document source and document ID. +func (client InvoicesClient) DownloadBillingSubscriptionInvoice(ctx context.Context, invoiceName string, downloadToken string) (result InvoicesDownloadBillingSubscriptionInvoiceFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InvoicesClient.DownloadBillingSubscriptionInvoice") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DownloadBillingSubscriptionInvoicePreparer(ctx, invoiceName, downloadToken) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "DownloadBillingSubscriptionInvoice", nil, "Failure preparing request") + return + } + + result, err = client.DownloadBillingSubscriptionInvoiceSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "DownloadBillingSubscriptionInvoice", result.Response(), "Failure sending request") + return + } + + return +} + +// DownloadBillingSubscriptionInvoicePreparer prepares the DownloadBillingSubscriptionInvoice request. +func (client InvoicesClient) DownloadBillingSubscriptionInvoicePreparer(ctx context.Context, invoiceName string, downloadToken string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "invoiceName": autorest.Encode("path", invoiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + "downloadToken": autorest.Encode("query", downloadToken), + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/{subscriptionId}/invoices/{invoiceName}/download", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DownloadBillingSubscriptionInvoiceSender sends the DownloadBillingSubscriptionInvoice request. The method will close the +// http.Response Body if it receives an error. +func (client InvoicesClient) DownloadBillingSubscriptionInvoiceSender(req *http.Request) (future InvoicesDownloadBillingSubscriptionInvoiceFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// DownloadBillingSubscriptionInvoiceResponder handles the response to the DownloadBillingSubscriptionInvoice request. The method always +// closes the http.Response Body. +func (client InvoicesClient) DownloadBillingSubscriptionInvoiceResponder(resp *http.Response) (result DownloadURL, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// DownloadInvoice gets a URL to download an invoice. The operation is supported for billing accounts with agreement +// type Microsoft Partner Agreement or Microsoft Customer Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// invoiceName - the ID that uniquely identifies an invoice. +// downloadToken - download token with document source and document ID. +func (client InvoicesClient) DownloadInvoice(ctx context.Context, billingAccountName string, invoiceName string, downloadToken string) (result InvoicesDownloadInvoiceFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InvoicesClient.DownloadInvoice") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DownloadInvoicePreparer(ctx, billingAccountName, invoiceName, downloadToken) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "DownloadInvoice", nil, "Failure preparing request") + return + } + + result, err = client.DownloadInvoiceSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "DownloadInvoice", result.Response(), "Failure sending request") + return + } + + return +} + +// DownloadInvoicePreparer prepares the DownloadInvoice request. +func (client InvoicesClient) DownloadInvoicePreparer(ctx context.Context, billingAccountName string, invoiceName string, downloadToken string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "invoiceName": autorest.Encode("path", invoiceName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + "downloadToken": autorest.Encode("query", downloadToken), + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/{invoiceName}/download", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DownloadInvoiceSender sends the DownloadInvoice request. The method will close the +// http.Response Body if it receives an error. +func (client InvoicesClient) DownloadInvoiceSender(req *http.Request) (future InvoicesDownloadInvoiceFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// DownloadInvoiceResponder handles the response to the DownloadInvoice request. The method always +// closes the http.Response Body. +func (client InvoicesClient) DownloadInvoiceResponder(resp *http.Response) (result DownloadURL, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets an invoice by billing account name and ID. The operation is supported for billing accounts with agreement +// type Microsoft Partner Agreement or Microsoft Customer Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// invoiceName - the ID that uniquely identifies an invoice. +func (client InvoicesClient) Get(ctx context.Context, billingAccountName string, invoiceName string) (result Invoice, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InvoicesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, billingAccountName, invoiceName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client InvoicesClient) GetPreparer(ctx context.Context, billingAccountName string, invoiceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "invoiceName": autorest.Encode("path", invoiceName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/{invoiceName}", 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 InvoicesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client InvoicesClient) GetResponder(resp *http.Response) (result Invoice, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetByID gets an invoice by ID. The operation is supported for billing accounts with agreement type Microsoft Partner +// Agreement or Microsoft Customer Agreement. +// Parameters: +// invoiceName - the ID that uniquely identifies an invoice. +func (client InvoicesClient) GetByID(ctx context.Context, invoiceName string) (result Invoice, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InvoicesClient.GetByID") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetByIDPreparer(ctx, invoiceName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "GetByID", nil, "Failure preparing request") + return + } + + resp, err := client.GetByIDSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "GetByID", resp, "Failure sending request") + return + } + + result, err = client.GetByIDResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "GetByID", resp, "Failure responding to request") + } + + return +} + +// GetByIDPreparer prepares the GetByID request. +func (client InvoicesClient) GetByIDPreparer(ctx context.Context, invoiceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "invoiceName": autorest.Encode("path", invoiceName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/default/invoices/{invoiceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetByIDSender sends the GetByID request. The method will close the +// http.Response Body if it receives an error. +func (client InvoicesClient) GetByIDSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetByIDResponder handles the response to the GetByID request. The method always +// closes the http.Response Body. +func (client InvoicesClient) GetByIDResponder(resp *http.Response) (result Invoice, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetBySubscriptionAndInvoiceID gets an invoice by subscription ID and invoice ID. +// Parameters: +// invoiceName - the ID that uniquely identifies an invoice. +func (client InvoicesClient) GetBySubscriptionAndInvoiceID(ctx context.Context, invoiceName string) (result Invoice, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InvoicesClient.GetBySubscriptionAndInvoiceID") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetBySubscriptionAndInvoiceIDPreparer(ctx, invoiceName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "GetBySubscriptionAndInvoiceID", nil, "Failure preparing request") + return + } + + resp, err := client.GetBySubscriptionAndInvoiceIDSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "GetBySubscriptionAndInvoiceID", resp, "Failure sending request") + return + } + + result, err = client.GetBySubscriptionAndInvoiceIDResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "GetBySubscriptionAndInvoiceID", resp, "Failure responding to request") + } + + return +} + +// GetBySubscriptionAndInvoiceIDPreparer prepares the GetBySubscriptionAndInvoiceID request. +func (client InvoicesClient) GetBySubscriptionAndInvoiceIDPreparer(ctx context.Context, invoiceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "invoiceName": autorest.Encode("path", invoiceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/{subscriptionId}/invoices/{invoiceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetBySubscriptionAndInvoiceIDSender sends the GetBySubscriptionAndInvoiceID request. The method will close the +// http.Response Body if it receives an error. +func (client InvoicesClient) GetBySubscriptionAndInvoiceIDSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetBySubscriptionAndInvoiceIDResponder handles the response to the GetBySubscriptionAndInvoiceID request. The method always +// closes the http.Response Body. +func (client InvoicesClient) GetBySubscriptionAndInvoiceIDResponder(resp *http.Response) (result Invoice, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByBillingAccount lists the invoices for a billing account for a given start date and end date. The operation is +// supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// periodStartDate - the start date to fetch the invoices. The date should be specified in MM-DD-YYYY format. +// periodEndDate - the end date to fetch the invoices. The date should be specified in MM-DD-YYYY format. +func (client InvoicesClient) ListByBillingAccount(ctx context.Context, billingAccountName string, periodStartDate string, periodEndDate string) (result InvoiceListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InvoicesClient.ListByBillingAccount") + defer func() { + sc := -1 + if result.ilr.Response.Response != nil { + sc = result.ilr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByBillingAccountNextResults + req, err := client.ListByBillingAccountPreparer(ctx, billingAccountName, periodStartDate, periodEndDate) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "ListByBillingAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByBillingAccountSender(req) + if err != nil { + result.ilr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "ListByBillingAccount", resp, "Failure sending request") + return + } + + result.ilr, err = client.ListByBillingAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "ListByBillingAccount", resp, "Failure responding to request") + } + + return +} + +// ListByBillingAccountPreparer prepares the ListByBillingAccount request. +func (client InvoicesClient) ListByBillingAccountPreparer(ctx context.Context, billingAccountName string, periodStartDate string, periodEndDate string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + "periodEndDate": autorest.Encode("query", periodEndDate), + "periodStartDate": autorest.Encode("query", periodStartDate), + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByBillingAccountSender sends the ListByBillingAccount request. The method will close the +// http.Response Body if it receives an error. +func (client InvoicesClient) ListByBillingAccountSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListByBillingAccountResponder handles the response to the ListByBillingAccount request. The method always +// closes the http.Response Body. +func (client InvoicesClient) ListByBillingAccountResponder(resp *http.Response) (result InvoiceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByBillingAccountNextResults retrieves the next set of results, if any. +func (client InvoicesClient) listByBillingAccountNextResults(ctx context.Context, lastResults InvoiceListResult) (result InvoiceListResult, err error) { + req, err := lastResults.invoiceListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.InvoicesClient", "listByBillingAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByBillingAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.InvoicesClient", "listByBillingAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByBillingAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "listByBillingAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByBillingAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client InvoicesClient) ListByBillingAccountComplete(ctx context.Context, billingAccountName string, periodStartDate string, periodEndDate string) (result InvoiceListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InvoicesClient.ListByBillingAccount") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByBillingAccount(ctx, billingAccountName, periodStartDate, periodEndDate) + return +} + +// ListByBillingProfile lists the invoices for a billing profile for a given start date and end date. The operation is +// supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// billingProfileName - the ID that uniquely identifies a billing profile. +// periodStartDate - the start date to fetch the invoices. The date should be specified in MM-DD-YYYY format. +// periodEndDate - the end date to fetch the invoices. The date should be specified in MM-DD-YYYY format. +func (client InvoicesClient) ListByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string, periodStartDate string, periodEndDate string) (result InvoiceListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InvoicesClient.ListByBillingProfile") + defer func() { + sc := -1 + if result.ilr.Response.Response != nil { + sc = result.ilr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByBillingProfileNextResults + req, err := client.ListByBillingProfilePreparer(ctx, billingAccountName, billingProfileName, periodStartDate, periodEndDate) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "ListByBillingProfile", nil, "Failure preparing request") + return + } + + resp, err := client.ListByBillingProfileSender(req) + if err != nil { + result.ilr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "ListByBillingProfile", resp, "Failure sending request") + return + } + + result.ilr, err = client.ListByBillingProfileResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "ListByBillingProfile", resp, "Failure responding to request") + } + + return +} + +// ListByBillingProfilePreparer prepares the ListByBillingProfile request. +func (client InvoicesClient) ListByBillingProfilePreparer(ctx context.Context, billingAccountName string, billingProfileName string, periodStartDate string, periodEndDate string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingProfileName": autorest.Encode("path", billingProfileName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + "periodEndDate": autorest.Encode("query", periodEndDate), + "periodStartDate": autorest.Encode("query", periodStartDate), + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoices", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByBillingProfileSender sends the ListByBillingProfile request. The method will close the +// http.Response Body if it receives an error. +func (client InvoicesClient) ListByBillingProfileSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListByBillingProfileResponder handles the response to the ListByBillingProfile request. The method always +// closes the http.Response Body. +func (client InvoicesClient) ListByBillingProfileResponder(resp *http.Response) (result InvoiceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByBillingProfileNextResults retrieves the next set of results, if any. +func (client InvoicesClient) listByBillingProfileNextResults(ctx context.Context, lastResults InvoiceListResult) (result InvoiceListResult, err error) { + req, err := lastResults.invoiceListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.InvoicesClient", "listByBillingProfileNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByBillingProfileSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.InvoicesClient", "listByBillingProfileNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByBillingProfileResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "listByBillingProfileNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByBillingProfileComplete enumerates all values, automatically crossing page boundaries as required. +func (client InvoicesClient) ListByBillingProfileComplete(ctx context.Context, billingAccountName string, billingProfileName string, periodStartDate string, periodEndDate string) (result InvoiceListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InvoicesClient.ListByBillingProfile") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByBillingProfile(ctx, billingAccountName, billingProfileName, periodStartDate, periodEndDate) + return +} + +// ListByBillingSubscription lists the invoices for a subscription. +// Parameters: +// periodStartDate - invoice period start date. +// periodEndDate - invoice period end date. +func (client InvoicesClient) ListByBillingSubscription(ctx context.Context, periodStartDate string, periodEndDate string) (result InvoiceListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InvoicesClient.ListByBillingSubscription") + defer func() { + sc := -1 + if result.ilr.Response.Response != nil { + sc = result.ilr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByBillingSubscriptionNextResults + req, err := client.ListByBillingSubscriptionPreparer(ctx, periodStartDate, periodEndDate) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "ListByBillingSubscription", nil, "Failure preparing request") + return + } + + resp, err := client.ListByBillingSubscriptionSender(req) + if err != nil { + result.ilr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "ListByBillingSubscription", resp, "Failure sending request") + return + } + + result.ilr, err = client.ListByBillingSubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "ListByBillingSubscription", resp, "Failure responding to request") + } + + return +} + +// ListByBillingSubscriptionPreparer prepares the ListByBillingSubscription request. +func (client InvoicesClient) ListByBillingSubscriptionPreparer(ctx context.Context, periodStartDate string, periodEndDate string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + "periodEndDate": autorest.Encode("query", periodEndDate), + "periodStartDate": autorest.Encode("query", periodStartDate), + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/{subscriptionId}/invoices", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByBillingSubscriptionSender sends the ListByBillingSubscription request. The method will close the +// http.Response Body if it receives an error. +func (client InvoicesClient) ListByBillingSubscriptionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListByBillingSubscriptionResponder handles the response to the ListByBillingSubscription request. The method always +// closes the http.Response Body. +func (client InvoicesClient) ListByBillingSubscriptionResponder(resp *http.Response) (result InvoiceListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByBillingSubscriptionNextResults retrieves the next set of results, if any. +func (client InvoicesClient) listByBillingSubscriptionNextResults(ctx context.Context, lastResults InvoiceListResult) (result InvoiceListResult, err error) { + req, err := lastResults.invoiceListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.InvoicesClient", "listByBillingSubscriptionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByBillingSubscriptionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.InvoicesClient", "listByBillingSubscriptionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByBillingSubscriptionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "listByBillingSubscriptionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByBillingSubscriptionComplete enumerates all values, automatically crossing page boundaries as required. +func (client InvoicesClient) ListByBillingSubscriptionComplete(ctx context.Context, periodStartDate string, periodEndDate string) (result InvoiceListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InvoicesClient.ListByBillingSubscription") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByBillingSubscription(ctx, periodStartDate, periodEndDate) + return +} diff --git a/services/preview/billing/mgmt/2020-05-01-preview/billing/invoicesections.go b/services/preview/billing/mgmt/2020-05-01-preview/billing/invoicesections.go new file mode 100644 index 000000000000..088a9e1f7cac --- /dev/null +++ b/services/preview/billing/mgmt/2020-05-01-preview/billing/invoicesections.go @@ -0,0 +1,312 @@ +package billing + +// 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/tracing" + "net/http" +) + +// InvoiceSectionsClient is the billing client provides access to billing resources for Azure subscriptions. +type InvoiceSectionsClient struct { + BaseClient +} + +// NewInvoiceSectionsClient creates an instance of the InvoiceSectionsClient client. +func NewInvoiceSectionsClient(subscriptionID string) InvoiceSectionsClient { + return NewInvoiceSectionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewInvoiceSectionsClientWithBaseURI creates an instance of the InvoiceSectionsClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewInvoiceSectionsClientWithBaseURI(baseURI string, subscriptionID string) InvoiceSectionsClient { + return InvoiceSectionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates an invoice section. The operation is supported only for billing accounts with +// agreement type Microsoft Customer Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// billingProfileName - the ID that uniquely identifies a billing profile. +// invoiceSectionName - the ID that uniquely identifies an invoice section. +// parameters - the new or updated invoice section. +func (client InvoiceSectionsClient) CreateOrUpdate(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, parameters InvoiceSection) (result InvoiceSectionsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InvoiceSectionsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, billingAccountName, billingProfileName, invoiceSectionName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client InvoiceSectionsClient) CreateOrUpdatePreparer(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, parameters InvoiceSection) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingProfileName": autorest.Encode("path", billingProfileName), + "invoiceSectionName": autorest.Encode("path", invoiceSectionName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}", 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 InvoiceSectionsClient) CreateOrUpdateSender(req *http.Request) (future InvoiceSectionsCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client InvoiceSectionsClient) CreateOrUpdateResponder(resp *http.Response) (result InvoiceSection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets an invoice section by its ID. The operation is supported only for billing accounts with agreement type +// Microsoft Customer Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// billingProfileName - the ID that uniquely identifies a billing profile. +// invoiceSectionName - the ID that uniquely identifies an invoice section. +func (client InvoiceSectionsClient) Get(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string) (result InvoiceSection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InvoiceSectionsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, billingAccountName, billingProfileName, invoiceSectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client InvoiceSectionsClient) GetPreparer(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingProfileName": autorest.Encode("path", billingProfileName), + "invoiceSectionName": autorest.Encode("path", invoiceSectionName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}", 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 InvoiceSectionsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client InvoiceSectionsClient) GetResponder(resp *http.Response) (result InvoiceSection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByBillingProfile lists the invoice sections that a user has access to. The operation is supported only for +// billing accounts with agreement type Microsoft Customer Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// billingProfileName - the ID that uniquely identifies a billing profile. +func (client InvoiceSectionsClient) ListByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string) (result InvoiceSectionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InvoiceSectionsClient.ListByBillingProfile") + defer func() { + sc := -1 + if result.islr.Response.Response != nil { + sc = result.islr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByBillingProfileNextResults + req, err := client.ListByBillingProfilePreparer(ctx, billingAccountName, billingProfileName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "ListByBillingProfile", nil, "Failure preparing request") + return + } + + resp, err := client.ListByBillingProfileSender(req) + if err != nil { + result.islr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "ListByBillingProfile", resp, "Failure sending request") + return + } + + result.islr, err = client.ListByBillingProfileResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "ListByBillingProfile", resp, "Failure responding to request") + } + + return +} + +// ListByBillingProfilePreparer prepares the ListByBillingProfile request. +func (client InvoiceSectionsClient) ListByBillingProfilePreparer(ctx context.Context, billingAccountName string, billingProfileName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingProfileName": autorest.Encode("path", billingProfileName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByBillingProfileSender sends the ListByBillingProfile request. The method will close the +// http.Response Body if it receives an error. +func (client InvoiceSectionsClient) ListByBillingProfileSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListByBillingProfileResponder handles the response to the ListByBillingProfile request. The method always +// closes the http.Response Body. +func (client InvoiceSectionsClient) ListByBillingProfileResponder(resp *http.Response) (result InvoiceSectionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByBillingProfileNextResults retrieves the next set of results, if any. +func (client InvoiceSectionsClient) listByBillingProfileNextResults(ctx context.Context, lastResults InvoiceSectionListResult) (result InvoiceSectionListResult, err error) { + req, err := lastResults.invoiceSectionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "listByBillingProfileNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByBillingProfileSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "listByBillingProfileNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByBillingProfileResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "listByBillingProfileNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByBillingProfileComplete enumerates all values, automatically crossing page boundaries as required. +func (client InvoiceSectionsClient) ListByBillingProfileComplete(ctx context.Context, billingAccountName string, billingProfileName string) (result InvoiceSectionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InvoiceSectionsClient.ListByBillingProfile") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByBillingProfile(ctx, billingAccountName, billingProfileName) + return +} diff --git a/services/preview/billing/mgmt/2020-05-01-preview/billing/models.go b/services/preview/billing/mgmt/2020-05-01-preview/billing/models.go new file mode 100644 index 000000000000..0bfb27c44127 --- /dev/null +++ b/services/preview/billing/mgmt/2020-05-01-preview/billing/models.go @@ -0,0 +1,5052 @@ +package billing + +// 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" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "github.com/satori/go.uuid" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/billing/mgmt/2020-05-01-preview/billing" + +// AcceptanceMode enumerates the values for acceptance mode. +type AcceptanceMode string + +const ( + // ClickToAccept ... + ClickToAccept AcceptanceMode = "ClickToAccept" + // ESignEmbedded ... + ESignEmbedded AcceptanceMode = "ESignEmbedded" + // ESignOffline ... + ESignOffline AcceptanceMode = "ESignOffline" +) + +// PossibleAcceptanceModeValues returns an array of possible values for the AcceptanceMode const type. +func PossibleAcceptanceModeValues() []AcceptanceMode { + return []AcceptanceMode{ClickToAccept, ESignEmbedded, ESignOffline} +} + +// AccountStatus enumerates the values for account status. +type AccountStatus string + +const ( + // Active ... + Active AccountStatus = "Active" + // Deleted ... + Deleted AccountStatus = "Deleted" + // Disabled ... + Disabled AccountStatus = "Disabled" + // Expired ... + Expired AccountStatus = "Expired" + // Extended ... + Extended AccountStatus = "Extended" + // Terminated ... + Terminated AccountStatus = "Terminated" + // Transferred ... + Transferred AccountStatus = "Transferred" +) + +// PossibleAccountStatusValues returns an array of possible values for the AccountStatus const type. +func PossibleAccountStatusValues() []AccountStatus { + return []AccountStatus{Active, Deleted, Disabled, Expired, Extended, Terminated, Transferred} +} + +// AccountType enumerates the values for account type. +type AccountType string + +const ( + // Enterprise ... + Enterprise AccountType = "Enterprise" + // Individual ... + Individual AccountType = "Individual" + // Partner ... + Partner AccountType = "Partner" +) + +// PossibleAccountTypeValues returns an array of possible values for the AccountType const type. +func PossibleAccountTypeValues() []AccountType { + return []AccountType{Enterprise, Individual, Partner} +} + +// AddressValidationStatus enumerates the values for address validation status. +type AddressValidationStatus string + +const ( + // Invalid ... + Invalid AddressValidationStatus = "Invalid" + // Valid ... + Valid AddressValidationStatus = "Valid" +) + +// PossibleAddressValidationStatusValues returns an array of possible values for the AddressValidationStatus const type. +func PossibleAddressValidationStatusValues() []AddressValidationStatus { + return []AddressValidationStatus{Invalid, Valid} +} + +// AgreementType enumerates the values for agreement type. +type AgreementType string + +const ( + // EnterpriseAgreement ... + EnterpriseAgreement AgreementType = "EnterpriseAgreement" + // MicrosoftCustomerAgreement ... + MicrosoftCustomerAgreement AgreementType = "MicrosoftCustomerAgreement" + // MicrosoftOnlineServicesProgram ... + MicrosoftOnlineServicesProgram AgreementType = "MicrosoftOnlineServicesProgram" + // MicrosoftPartnerAgreement ... + MicrosoftPartnerAgreement AgreementType = "MicrosoftPartnerAgreement" +) + +// PossibleAgreementTypeValues returns an array of possible values for the AgreementType const type. +func PossibleAgreementTypeValues() []AgreementType { + return []AgreementType{EnterpriseAgreement, MicrosoftCustomerAgreement, MicrosoftOnlineServicesProgram, MicrosoftPartnerAgreement} +} + +// AutoRenew enumerates the values for auto renew. +type AutoRenew string + +const ( + // Off ... + Off AutoRenew = "Off" + // On ... + On AutoRenew = "On" +) + +// PossibleAutoRenewValues returns an array of possible values for the AutoRenew const type. +func PossibleAutoRenewValues() []AutoRenew { + return []AutoRenew{Off, On} +} + +// Category enumerates the values for category. +type Category string + +const ( + // CategoryAffiliatePurchaseTerms ... + CategoryAffiliatePurchaseTerms Category = "AffiliatePurchaseTerms" + // CategoryMicrosoftCustomerAgreement ... + CategoryMicrosoftCustomerAgreement Category = "MicrosoftCustomerAgreement" + // CategoryOther ... + CategoryOther Category = "Other" +) + +// PossibleCategoryValues returns an array of possible values for the Category const type. +func PossibleCategoryValues() []Category { + return []Category{CategoryAffiliatePurchaseTerms, CategoryMicrosoftCustomerAgreement, CategoryOther} +} + +// DocumentSource enumerates the values for document source. +type DocumentSource string + +const ( + // DRS ... + DRS DocumentSource = "DRS" + // ENF ... + ENF DocumentSource = "ENF" +) + +// PossibleDocumentSourceValues returns an array of possible values for the DocumentSource const type. +func PossibleDocumentSourceValues() []DocumentSource { + return []DocumentSource{DRS, ENF} +} + +// DocumentType enumerates the values for document type. +type DocumentType string + +const ( + // DocumentTypeCreditNote ... + DocumentTypeCreditNote DocumentType = "CreditNote" + // DocumentTypeInvoice ... + DocumentTypeInvoice DocumentType = "Invoice" + // DocumentTypeTaxReceipt ... + DocumentTypeTaxReceipt DocumentType = "TaxReceipt" + // DocumentTypeVoidNote ... + DocumentTypeVoidNote DocumentType = "VoidNote" +) + +// PossibleDocumentTypeValues returns an array of possible values for the DocumentType const type. +func PossibleDocumentTypeValues() []DocumentType { + return []DocumentType{DocumentTypeCreditNote, DocumentTypeInvoice, DocumentTypeTaxReceipt, DocumentTypeVoidNote} +} + +// Frequency enumerates the values for frequency. +type Frequency string + +const ( + // Monthly ... + Monthly Frequency = "Monthly" + // OneTime ... + OneTime Frequency = "OneTime" + // UsageBased ... + UsageBased Frequency = "UsageBased" +) + +// PossibleFrequencyValues returns an array of possible values for the Frequency const type. +func PossibleFrequencyValues() []Frequency { + return []Frequency{Monthly, OneTime, UsageBased} +} + +// InvoiceStatus enumerates the values for invoice status. +type InvoiceStatus string + +const ( + // Due ... + Due InvoiceStatus = "Due" + // OverDue ... + OverDue InvoiceStatus = "OverDue" + // Paid ... + Paid InvoiceStatus = "Paid" +) + +// PossibleInvoiceStatusValues returns an array of possible values for the InvoiceStatus const type. +func PossibleInvoiceStatusValues() []InvoiceStatus { + return []InvoiceStatus{Due, OverDue, Paid} +} + +// InvoiceType enumerates the values for invoice type. +type InvoiceType string + +const ( + // AzureMarketplace ... + AzureMarketplace InvoiceType = "AzureMarketplace" + // AzureService ... + AzureService InvoiceType = "AzureService" + // AzureSupport ... + AzureSupport InvoiceType = "AzureSupport" +) + +// PossibleInvoiceTypeValues returns an array of possible values for the InvoiceType const type. +func PossibleInvoiceTypeValues() []InvoiceType { + return []InvoiceType{AzureMarketplace, AzureService, AzureSupport} +} + +// MarketplacePurchasesPolicy enumerates the values for marketplace purchases policy. +type MarketplacePurchasesPolicy string + +const ( + // AllAllowed ... + AllAllowed MarketplacePurchasesPolicy = "AllAllowed" + // NotAllowed ... + NotAllowed MarketplacePurchasesPolicy = "NotAllowed" + // OnlyFreeAllowed ... + OnlyFreeAllowed MarketplacePurchasesPolicy = "OnlyFreeAllowed" +) + +// PossibleMarketplacePurchasesPolicyValues returns an array of possible values for the MarketplacePurchasesPolicy const type. +func PossibleMarketplacePurchasesPolicyValues() []MarketplacePurchasesPolicy { + return []MarketplacePurchasesPolicy{AllAllowed, NotAllowed, OnlyFreeAllowed} +} + +// PaymentMethodFamily enumerates the values for payment method family. +type PaymentMethodFamily string + +const ( + // CheckWire ... + CheckWire PaymentMethodFamily = "CheckWire" + // CreditCard ... + CreditCard PaymentMethodFamily = "CreditCard" + // Credits ... + Credits PaymentMethodFamily = "Credits" + // None ... + None PaymentMethodFamily = "None" +) + +// PossiblePaymentMethodFamilyValues returns an array of possible values for the PaymentMethodFamily const type. +func PossiblePaymentMethodFamilyValues() []PaymentMethodFamily { + return []PaymentMethodFamily{CheckWire, CreditCard, Credits, None} +} + +// ProductStatusType enumerates the values for product status type. +type ProductStatusType string + +const ( + // ProductStatusTypeActive ... + ProductStatusTypeActive ProductStatusType = "Active" + // ProductStatusTypeAutoRenew ... + ProductStatusTypeAutoRenew ProductStatusType = "AutoRenew" + // ProductStatusTypeCancelled ... + ProductStatusTypeCancelled ProductStatusType = "Cancelled" + // ProductStatusTypeDisabled ... + ProductStatusTypeDisabled ProductStatusType = "Disabled" + // ProductStatusTypeExpired ... + ProductStatusTypeExpired ProductStatusType = "Expired" + // ProductStatusTypeExpiring ... + ProductStatusTypeExpiring ProductStatusType = "Expiring" + // ProductStatusTypeInactive ... + ProductStatusTypeInactive ProductStatusType = "Inactive" + // ProductStatusTypePastDue ... + ProductStatusTypePastDue ProductStatusType = "PastDue" +) + +// PossibleProductStatusTypeValues returns an array of possible values for the ProductStatusType const type. +func PossibleProductStatusTypeValues() []ProductStatusType { + return []ProductStatusType{ProductStatusTypeActive, ProductStatusTypeAutoRenew, ProductStatusTypeCancelled, ProductStatusTypeDisabled, ProductStatusTypeExpired, ProductStatusTypeExpiring, ProductStatusTypeInactive, ProductStatusTypePastDue} +} + +// ProductTransferValidationErrorCode enumerates the values for product transfer validation error code. +type ProductTransferValidationErrorCode string + +const ( + // CrossBillingAccountNotAllowed ... + CrossBillingAccountNotAllowed ProductTransferValidationErrorCode = "CrossBillingAccountNotAllowed" + // DestinationBillingProfilePastDue ... + DestinationBillingProfilePastDue ProductTransferValidationErrorCode = "DestinationBillingProfilePastDue" + // InsufficientPermissionOnDestination ... + InsufficientPermissionOnDestination ProductTransferValidationErrorCode = "InsufficientPermissionOnDestination" + // InsufficientPermissionOnSource ... + InsufficientPermissionOnSource ProductTransferValidationErrorCode = "InsufficientPermissionOnSource" + // InvalidSource ... + InvalidSource ProductTransferValidationErrorCode = "InvalidSource" + // NotAvailableForDestinationMarket ... + NotAvailableForDestinationMarket ProductTransferValidationErrorCode = "NotAvailableForDestinationMarket" + // OneTimePurchaseProductTransferNotAllowed ... + OneTimePurchaseProductTransferNotAllowed ProductTransferValidationErrorCode = "OneTimePurchaseProductTransferNotAllowed" + // ProductNotActive ... + ProductNotActive ProductTransferValidationErrorCode = "ProductNotActive" + // ProductTypeNotSupported ... + ProductTypeNotSupported ProductTransferValidationErrorCode = "ProductTypeNotSupported" +) + +// PossibleProductTransferValidationErrorCodeValues returns an array of possible values for the ProductTransferValidationErrorCode const type. +func PossibleProductTransferValidationErrorCodeValues() []ProductTransferValidationErrorCode { + return []ProductTransferValidationErrorCode{CrossBillingAccountNotAllowed, DestinationBillingProfilePastDue, InsufficientPermissionOnDestination, InsufficientPermissionOnSource, InvalidSource, NotAvailableForDestinationMarket, OneTimePurchaseProductTransferNotAllowed, ProductNotActive, ProductTypeNotSupported} +} + +// ProfileSpendingLimit enumerates the values for profile spending limit. +type ProfileSpendingLimit string + +const ( + // ProfileSpendingLimitOff ... + ProfileSpendingLimitOff ProfileSpendingLimit = "Off" + // ProfileSpendingLimitOn ... + ProfileSpendingLimitOn ProfileSpendingLimit = "On" +) + +// PossibleProfileSpendingLimitValues returns an array of possible values for the ProfileSpendingLimit const type. +func PossibleProfileSpendingLimitValues() []ProfileSpendingLimit { + return []ProfileSpendingLimit{ProfileSpendingLimitOff, ProfileSpendingLimitOn} +} + +// ProfileStatus enumerates the values for profile status. +type ProfileStatus string + +const ( + // ProfileStatusActive ... + ProfileStatusActive ProfileStatus = "Active" + // ProfileStatusDisabled ... + ProfileStatusDisabled ProfileStatus = "Disabled" + // ProfileStatusWarned ... + ProfileStatusWarned ProfileStatus = "Warned" +) + +// PossibleProfileStatusValues returns an array of possible values for the ProfileStatus const type. +func PossibleProfileStatusValues() []ProfileStatus { + return []ProfileStatus{ProfileStatusActive, ProfileStatusDisabled, ProfileStatusWarned} +} + +// ProfileStatusReasonCode enumerates the values for profile status reason code. +type ProfileStatusReasonCode string + +const ( + // PastDue ... + PastDue ProfileStatusReasonCode = "PastDue" + // SpendingLimitExpired ... + SpendingLimitExpired ProfileStatusReasonCode = "SpendingLimitExpired" + // SpendingLimitReached ... + SpendingLimitReached ProfileStatusReasonCode = "SpendingLimitReached" +) + +// PossibleProfileStatusReasonCodeValues returns an array of possible values for the ProfileStatusReasonCode const type. +func PossibleProfileStatusReasonCodeValues() []ProfileStatusReasonCode { + return []ProfileStatusReasonCode{PastDue, SpendingLimitExpired, SpendingLimitReached} +} + +// ReservationPurchasesPolicy enumerates the values for reservation purchases policy. +type ReservationPurchasesPolicy string + +const ( + // ReservationPurchasesPolicyAllowed ... + ReservationPurchasesPolicyAllowed ReservationPurchasesPolicy = "Allowed" + // ReservationPurchasesPolicyNotAllowed ... + ReservationPurchasesPolicyNotAllowed ReservationPurchasesPolicy = "NotAllowed" +) + +// PossibleReservationPurchasesPolicyValues returns an array of possible values for the ReservationPurchasesPolicy const type. +func PossibleReservationPurchasesPolicyValues() []ReservationPurchasesPolicy { + return []ReservationPurchasesPolicy{ReservationPurchasesPolicyAllowed, ReservationPurchasesPolicyNotAllowed} +} + +// ReservationType enumerates the values for reservation type. +type ReservationType string + +const ( + // Purchase ... + Purchase ReservationType = "Purchase" + // UsageCharge ... + UsageCharge ReservationType = "Usage Charge" +) + +// PossibleReservationTypeValues returns an array of possible values for the ReservationType const type. +func PossibleReservationTypeValues() []ReservationType { + return []ReservationType{Purchase, UsageCharge} +} + +// SpendingLimit enumerates the values for spending limit. +type SpendingLimit string + +const ( + // SpendingLimitOff ... + SpendingLimitOff SpendingLimit = "Off" + // SpendingLimitOn ... + SpendingLimitOn SpendingLimit = "On" +) + +// PossibleSpendingLimitValues returns an array of possible values for the SpendingLimit const type. +func PossibleSpendingLimitValues() []SpendingLimit { + return []SpendingLimit{SpendingLimitOff, SpendingLimitOn} +} + +// SpendingLimitForBillingProfile enumerates the values for spending limit for billing profile. +type SpendingLimitForBillingProfile string + +const ( + // SpendingLimitForBillingProfileOff ... + SpendingLimitForBillingProfileOff SpendingLimitForBillingProfile = "Off" + // SpendingLimitForBillingProfileOn ... + SpendingLimitForBillingProfileOn SpendingLimitForBillingProfile = "On" +) + +// PossibleSpendingLimitForBillingProfileValues returns an array of possible values for the SpendingLimitForBillingProfile const type. +func PossibleSpendingLimitForBillingProfileValues() []SpendingLimitForBillingProfile { + return []SpendingLimitForBillingProfile{SpendingLimitForBillingProfileOff, SpendingLimitForBillingProfileOn} +} + +// StatusReasonCode enumerates the values for status reason code. +type StatusReasonCode string + +const ( + // StatusReasonCodePastDue ... + StatusReasonCodePastDue StatusReasonCode = "PastDue" + // StatusReasonCodeSpendingLimitExpired ... + StatusReasonCodeSpendingLimitExpired StatusReasonCode = "SpendingLimitExpired" + // StatusReasonCodeSpendingLimitReached ... + StatusReasonCodeSpendingLimitReached StatusReasonCode = "SpendingLimitReached" +) + +// PossibleStatusReasonCodeValues returns an array of possible values for the StatusReasonCode const type. +func PossibleStatusReasonCodeValues() []StatusReasonCode { + return []StatusReasonCode{StatusReasonCodePastDue, StatusReasonCodeSpendingLimitExpired, StatusReasonCodeSpendingLimitReached} +} + +// StatusReasonCodeForBillingProfile enumerates the values for status reason code for billing profile. +type StatusReasonCodeForBillingProfile string + +const ( + // StatusReasonCodeForBillingProfilePastDue ... + StatusReasonCodeForBillingProfilePastDue StatusReasonCodeForBillingProfile = "PastDue" + // StatusReasonCodeForBillingProfileSpendingLimitExpired ... + StatusReasonCodeForBillingProfileSpendingLimitExpired StatusReasonCodeForBillingProfile = "SpendingLimitExpired" + // StatusReasonCodeForBillingProfileSpendingLimitReached ... + StatusReasonCodeForBillingProfileSpendingLimitReached StatusReasonCodeForBillingProfile = "SpendingLimitReached" +) + +// PossibleStatusReasonCodeForBillingProfileValues returns an array of possible values for the StatusReasonCodeForBillingProfile const type. +func PossibleStatusReasonCodeForBillingProfileValues() []StatusReasonCodeForBillingProfile { + return []StatusReasonCodeForBillingProfile{StatusReasonCodeForBillingProfilePastDue, StatusReasonCodeForBillingProfileSpendingLimitExpired, StatusReasonCodeForBillingProfileSpendingLimitReached} +} + +// SubscriptionStatusType enumerates the values for subscription status type. +type SubscriptionStatusType string + +const ( + // SubscriptionStatusTypeAbandoned ... + SubscriptionStatusTypeAbandoned SubscriptionStatusType = "Abandoned" + // SubscriptionStatusTypeActive ... + SubscriptionStatusTypeActive SubscriptionStatusType = "Active" + // SubscriptionStatusTypeDeleted ... + SubscriptionStatusTypeDeleted SubscriptionStatusType = "Deleted" + // SubscriptionStatusTypeInactive ... + SubscriptionStatusTypeInactive SubscriptionStatusType = "Inactive" + // SubscriptionStatusTypeWarning ... + SubscriptionStatusTypeWarning SubscriptionStatusType = "Warning" +) + +// PossibleSubscriptionStatusTypeValues returns an array of possible values for the SubscriptionStatusType const type. +func PossibleSubscriptionStatusTypeValues() []SubscriptionStatusType { + return []SubscriptionStatusType{SubscriptionStatusTypeAbandoned, SubscriptionStatusTypeActive, SubscriptionStatusTypeDeleted, SubscriptionStatusTypeInactive, SubscriptionStatusTypeWarning} +} + +// SubscriptionTransferValidationErrorCode enumerates the values for subscription transfer validation error +// code. +type SubscriptionTransferValidationErrorCode string + +const ( + // SubscriptionTransferValidationErrorCodeCrossBillingAccountNotAllowed ... + SubscriptionTransferValidationErrorCodeCrossBillingAccountNotAllowed SubscriptionTransferValidationErrorCode = "CrossBillingAccountNotAllowed" + // SubscriptionTransferValidationErrorCodeDestinationBillingProfilePastDue ... + SubscriptionTransferValidationErrorCodeDestinationBillingProfilePastDue SubscriptionTransferValidationErrorCode = "DestinationBillingProfilePastDue" + // SubscriptionTransferValidationErrorCodeInsufficientPermissionOnDestination ... + SubscriptionTransferValidationErrorCodeInsufficientPermissionOnDestination SubscriptionTransferValidationErrorCode = "InsufficientPermissionOnDestination" + // SubscriptionTransferValidationErrorCodeInsufficientPermissionOnSource ... + SubscriptionTransferValidationErrorCodeInsufficientPermissionOnSource SubscriptionTransferValidationErrorCode = "InsufficientPermissionOnSource" + // SubscriptionTransferValidationErrorCodeInvalidSource ... + SubscriptionTransferValidationErrorCodeInvalidSource SubscriptionTransferValidationErrorCode = "InvalidSource" + // SubscriptionTransferValidationErrorCodeNotAvailableForDestinationMarket ... + SubscriptionTransferValidationErrorCodeNotAvailableForDestinationMarket SubscriptionTransferValidationErrorCode = "NotAvailableForDestinationMarket" + // SubscriptionTransferValidationErrorCodeSubscriptionNotActive ... + SubscriptionTransferValidationErrorCodeSubscriptionNotActive SubscriptionTransferValidationErrorCode = "SubscriptionNotActive" + // SubscriptionTransferValidationErrorCodeSubscriptionTypeNotSupported ... + SubscriptionTransferValidationErrorCodeSubscriptionTypeNotSupported SubscriptionTransferValidationErrorCode = "SubscriptionTypeNotSupported" +) + +// PossibleSubscriptionTransferValidationErrorCodeValues returns an array of possible values for the SubscriptionTransferValidationErrorCode const type. +func PossibleSubscriptionTransferValidationErrorCodeValues() []SubscriptionTransferValidationErrorCode { + return []SubscriptionTransferValidationErrorCode{SubscriptionTransferValidationErrorCodeCrossBillingAccountNotAllowed, SubscriptionTransferValidationErrorCodeDestinationBillingProfilePastDue, SubscriptionTransferValidationErrorCodeInsufficientPermissionOnDestination, SubscriptionTransferValidationErrorCodeInsufficientPermissionOnSource, SubscriptionTransferValidationErrorCodeInvalidSource, SubscriptionTransferValidationErrorCodeNotAvailableForDestinationMarket, SubscriptionTransferValidationErrorCodeSubscriptionNotActive, SubscriptionTransferValidationErrorCodeSubscriptionTypeNotSupported} +} + +// TransactionTypeKind enumerates the values for transaction type kind. +type TransactionTypeKind string + +const ( + // All ... + All TransactionTypeKind = "all" + // Reservation ... + Reservation TransactionTypeKind = "reservation" +) + +// PossibleTransactionTypeKindValues returns an array of possible values for the TransactionTypeKind const type. +func PossibleTransactionTypeKindValues() []TransactionTypeKind { + return []TransactionTypeKind{All, Reservation} +} + +// ViewCharges enumerates the values for view charges. +type ViewCharges string + +const ( + // ViewChargesAllowed ... + ViewChargesAllowed ViewCharges = "Allowed" + // ViewChargesNotAllowed ... + ViewChargesNotAllowed ViewCharges = "NotAllowed" +) + +// PossibleViewChargesValues returns an array of possible values for the ViewCharges const type. +func PossibleViewChargesValues() []ViewCharges { + return []ViewCharges{ViewChargesAllowed, ViewChargesNotAllowed} +} + +// ViewChargesPolicy enumerates the values for view charges policy. +type ViewChargesPolicy string + +const ( + // ViewChargesPolicyAllowed ... + ViewChargesPolicyAllowed ViewChargesPolicy = "Allowed" + // ViewChargesPolicyNotAllowed ... + ViewChargesPolicyNotAllowed ViewChargesPolicy = "NotAllowed" +) + +// PossibleViewChargesPolicyValues returns an array of possible values for the ViewChargesPolicy const type. +func PossibleViewChargesPolicyValues() []ViewChargesPolicy { + return []ViewChargesPolicy{ViewChargesPolicyAllowed, ViewChargesPolicyNotAllowed} +} + +// Account a billing account. +type Account struct { + autorest.Response `json:"-"` + // AccountProperties - The properties of the billing account. + *AccountProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Account. +func (a Account) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if a.AccountProperties != nil { + objectMap["properties"] = a.AccountProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Account struct. +func (a *Account) 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 accountProperties AccountProperties + err = json.Unmarshal(*v, &accountProperties) + if err != nil { + return err + } + a.AccountProperties = &accountProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + a.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + a.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + a.Type = &typeVar + } + } + } + + return nil +} + +// AccountListResult the list of billing accounts. +type AccountListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The list of billing accounts. + Value *[]Account `json:"value,omitempty"` + // NextLink - READ-ONLY; The link (url) to the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// AccountListResultIterator provides access to a complete listing of Account values. +type AccountListResultIterator struct { + i int + page AccountListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *AccountListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccountListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *AccountListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter AccountListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter AccountListResultIterator) Response() AccountListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter AccountListResultIterator) Value() Account { + if !iter.page.NotDone() { + return Account{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the AccountListResultIterator type. +func NewAccountListResultIterator(page AccountListResultPage) AccountListResultIterator { + return AccountListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (alr AccountListResult) IsEmpty() bool { + return alr.Value == nil || len(*alr.Value) == 0 +} + +// accountListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (alr AccountListResult) accountListResultPreparer(ctx context.Context) (*http.Request, error) { + if alr.NextLink == nil || len(to.String(alr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(alr.NextLink))) +} + +// AccountListResultPage contains a page of Account values. +type AccountListResultPage struct { + fn func(context.Context, AccountListResult) (AccountListResult, error) + alr AccountListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *AccountListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccountListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.alr) + if err != nil { + return err + } + page.alr = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *AccountListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page AccountListResultPage) NotDone() bool { + return !page.alr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page AccountListResultPage) Response() AccountListResult { + return page.alr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page AccountListResultPage) Values() []Account { + if page.alr.IsEmpty() { + return nil + } + return *page.alr.Value +} + +// Creates a new instance of the AccountListResultPage type. +func NewAccountListResultPage(getNextPage func(context.Context, AccountListResult) (AccountListResult, error)) AccountListResultPage { + return AccountListResultPage{fn: getNextPage} +} + +// AccountProperties the properties of the billing account. +type AccountProperties struct { + // DisplayName - The billing account name. + DisplayName *string `json:"displayName,omitempty"` + // SoldTo - The address of the individual or organization that is responsible for the billing account. + SoldTo *AddressDetails `json:"soldTo,omitempty"` + // AgreementType - READ-ONLY; The type of agreement. Possible values include: 'MicrosoftCustomerAgreement', 'EnterpriseAgreement', 'MicrosoftOnlineServicesProgram', 'MicrosoftPartnerAgreement' + AgreementType AgreementType `json:"agreementType,omitempty"` + // AccountType - READ-ONLY; The type of customer. Possible values include: 'Enterprise', 'Individual', 'Partner' + AccountType AccountType `json:"accountType,omitempty"` + // AccountStatus - READ-ONLY; The current status of the billing account. Possible values include: 'Active', 'Deleted', 'Disabled', 'Expired', 'Transferred', 'Extended', 'Terminated' + AccountStatus AccountStatus `json:"accountStatus,omitempty"` + // BillingProfiles - The billing profiles associated with the billing account. By default this is not populated, unless it's specified in $expand. + BillingProfiles *ProfilesOnExpand `json:"billingProfiles,omitempty"` + // EnrollmentDetails - READ-ONLY; The details about the associated legacy enrollment. By default this is not populated, unless it's specified in $expand. + EnrollmentDetails *Enrollment `json:"enrollmentDetails,omitempty"` + // Departments - The departments associated to the enrollment. + Departments *[]Department `json:"departments,omitempty"` + // EnrollmentAccounts - The accounts associated to the enrollment. + EnrollmentAccounts *[]EnrollmentAccount `json:"enrollmentAccounts,omitempty"` + // HasReadAccess - READ-ONLY; Indicates whether user has read access to the billing account. + HasReadAccess *bool `json:"hasReadAccess,omitempty"` +} + +// AccountsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type AccountsUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *AccountsUpdateFuture) Result(client AccountsClient) (a Account, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AccountsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("billing.AccountsUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if a.Response.Response, err = future.GetResult(sender); err == nil && a.Response.Response.StatusCode != http.StatusNoContent { + a, err = client.UpdateResponder(a.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AccountsUpdateFuture", "Result", a.Response.Response, "Failure responding to request") + } + } + return +} + +// AccountUpdateRequest the request properties of the billing account that can be updated. +type AccountUpdateRequest struct { + // AccountProperties - A billing property. + *AccountProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for AccountUpdateRequest. +func (aur AccountUpdateRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if aur.AccountProperties != nil { + objectMap["properties"] = aur.AccountProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AccountUpdateRequest struct. +func (aur *AccountUpdateRequest) 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 accountProperties AccountProperties + err = json.Unmarshal(*v, &accountProperties) + if err != nil { + return err + } + aur.AccountProperties = &accountProperties + } + } + } + + return nil +} + +// AddressDetails address details. +type AddressDetails struct { + // FirstName - First name. + FirstName *string `json:"firstName,omitempty"` + // LastName - Last name. + LastName *string `json:"lastName,omitempty"` + // CompanyName - Company name. + CompanyName *string `json:"companyName,omitempty"` + // AddressLine1 - Address line 1. + AddressLine1 *string `json:"addressLine1,omitempty"` + // AddressLine2 - Address line 2. + AddressLine2 *string `json:"addressLine2,omitempty"` + // AddressLine3 - Address line 3. + AddressLine3 *string `json:"addressLine3,omitempty"` + // City - Address city. + City *string `json:"city,omitempty"` + // District - Address district. + District *string `json:"district,omitempty"` + // Region - Address region. + Region *string `json:"region,omitempty"` + // Country - Country code uses ISO2, 2-digit format. + Country *string `json:"country,omitempty"` + // PostalCode - Postal code. + PostalCode *string `json:"postalCode,omitempty"` + // Email - Email address. + Email *string `json:"email,omitempty"` + // PhoneNumber - Phone number. + PhoneNumber *string `json:"phoneNumber,omitempty"` +} + +// Agreement an agreement. +type Agreement struct { + autorest.Response `json:"-"` + // AgreementProperties - The properties of an agreement. + *AgreementProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Agreement. +func (a Agreement) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if a.AgreementProperties != nil { + objectMap["properties"] = a.AgreementProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Agreement struct. +func (a *Agreement) 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 agreementProperties AgreementProperties + err = json.Unmarshal(*v, &agreementProperties) + if err != nil { + return err + } + a.AgreementProperties = &agreementProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + a.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + a.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + a.Type = &typeVar + } + } + } + + return nil +} + +// AgreementListResult result of listing agreements. +type AgreementListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The list of agreements. + Value *[]Agreement `json:"value,omitempty"` + // NextLink - READ-ONLY; The link (url) to the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// AgreementListResultIterator provides access to a complete listing of Agreement values. +type AgreementListResultIterator struct { + i int + page AgreementListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *AgreementListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AgreementListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *AgreementListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter AgreementListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter AgreementListResultIterator) Response() AgreementListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter AgreementListResultIterator) Value() Agreement { + if !iter.page.NotDone() { + return Agreement{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the AgreementListResultIterator type. +func NewAgreementListResultIterator(page AgreementListResultPage) AgreementListResultIterator { + return AgreementListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (alr AgreementListResult) IsEmpty() bool { + return alr.Value == nil || len(*alr.Value) == 0 +} + +// agreementListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (alr AgreementListResult) agreementListResultPreparer(ctx context.Context) (*http.Request, error) { + if alr.NextLink == nil || len(to.String(alr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(alr.NextLink))) +} + +// AgreementListResultPage contains a page of Agreement values. +type AgreementListResultPage struct { + fn func(context.Context, AgreementListResult) (AgreementListResult, error) + alr AgreementListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *AgreementListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AgreementListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.alr) + if err != nil { + return err + } + page.alr = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *AgreementListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page AgreementListResultPage) NotDone() bool { + return !page.alr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page AgreementListResultPage) Response() AgreementListResult { + return page.alr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page AgreementListResultPage) Values() []Agreement { + if page.alr.IsEmpty() { + return nil + } + return *page.alr.Value +} + +// Creates a new instance of the AgreementListResultPage type. +func NewAgreementListResultPage(getNextPage func(context.Context, AgreementListResult) (AgreementListResult, error)) AgreementListResultPage { + return AgreementListResultPage{fn: getNextPage} +} + +// AgreementProperties the properties of an agreement. +type AgreementProperties struct { + // AgreementLink - READ-ONLY; The URL to download the agreement. + AgreementLink *string `json:"agreementLink,omitempty"` + // Category - READ-ONLY; The category of the agreement signed by a customer. Possible values include: 'CategoryMicrosoftCustomerAgreement', 'CategoryAffiliatePurchaseTerms', 'CategoryOther' + Category Category `json:"category,omitempty"` + // AcceptanceMode - READ-ONLY; The mode of acceptance for an agreement. Possible values include: 'ClickToAccept', 'ESignEmbedded', 'ESignOffline' + AcceptanceMode AcceptanceMode `json:"acceptanceMode,omitempty"` + // EffectiveDate - READ-ONLY; The date from which the agreement is effective. + EffectiveDate *date.Time `json:"effectiveDate,omitempty"` + // ExpirationDate - READ-ONLY; The date when the agreement expires. + ExpirationDate *date.Time `json:"expirationDate,omitempty"` + // Participants - The list of participants that participates in acceptance of an agreement. + Participants *[]Participants `json:"participants,omitempty"` + // Status - READ-ONLY; The current status of the agreement. + Status *string `json:"status,omitempty"` +} + +// Amount the amount. +type Amount struct { + // Currency - READ-ONLY; The currency for the amount value. + Currency *string `json:"currency,omitempty"` + // Value - Amount value. + Value *float64 `json:"value,omitempty"` +} + +// AvailableBalance the latest Azure credit balance. This is the balance available for pay now. +type AvailableBalance struct { + autorest.Response `json:"-"` + *AvailableBalanceProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for AvailableBalance. +func (ab AvailableBalance) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ab.AvailableBalanceProperties != nil { + objectMap["properties"] = ab.AvailableBalanceProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AvailableBalance struct. +func (ab *AvailableBalance) 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 availableBalanceProperties AvailableBalanceProperties + err = json.Unmarshal(*v, &availableBalanceProperties) + if err != nil { + return err + } + ab.AvailableBalanceProperties = &availableBalanceProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ab.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ab.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ab.Type = &typeVar + } + } + } + + return nil +} + +// AvailableBalanceProperties the properties of available balance. +type AvailableBalanceProperties struct { + // Amount - READ-ONLY; Balance amount. + Amount *Amount `json:"amount,omitempty"` +} + +// AzurePlan details of the Azure plan. +type AzurePlan struct { + // SkuID - The sku id. + SkuID *string `json:"skuId,omitempty"` + // SkuDescription - READ-ONLY; The sku description. + SkuDescription *string `json:"skuDescription,omitempty"` +} + +// Customer a partner's customer. +type Customer struct { + autorest.Response `json:"-"` + // CustomerProperties - The customer. + *CustomerProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Customer. +func (c Customer) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if c.CustomerProperties != nil { + objectMap["properties"] = c.CustomerProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Customer struct. +func (c *Customer) 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 customerProperties CustomerProperties + err = json.Unmarshal(*v, &customerProperties) + if err != nil { + return err + } + c.CustomerProperties = &customerProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + c.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + c.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + c.Type = &typeVar + } + } + } + + return nil +} + +// CustomerListResult the list of customers. +type CustomerListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The list of customers. + Value *[]Customer `json:"value,omitempty"` + // NextLink - READ-ONLY; The link (url) to the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// CustomerListResultIterator provides access to a complete listing of Customer values. +type CustomerListResultIterator struct { + i int + page CustomerListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *CustomerListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CustomerListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *CustomerListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter CustomerListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter CustomerListResultIterator) Response() CustomerListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter CustomerListResultIterator) Value() Customer { + if !iter.page.NotDone() { + return Customer{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the CustomerListResultIterator type. +func NewCustomerListResultIterator(page CustomerListResultPage) CustomerListResultIterator { + return CustomerListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (clr CustomerListResult) IsEmpty() bool { + return clr.Value == nil || len(*clr.Value) == 0 +} + +// customerListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (clr CustomerListResult) customerListResultPreparer(ctx context.Context) (*http.Request, error) { + if clr.NextLink == nil || len(to.String(clr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(clr.NextLink))) +} + +// CustomerListResultPage contains a page of Customer values. +type CustomerListResultPage struct { + fn func(context.Context, CustomerListResult) (CustomerListResult, error) + clr CustomerListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *CustomerListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CustomerListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.clr) + if err != nil { + return err + } + page.clr = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *CustomerListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page CustomerListResultPage) NotDone() bool { + return !page.clr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page CustomerListResultPage) Response() CustomerListResult { + return page.clr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page CustomerListResultPage) Values() []Customer { + if page.clr.IsEmpty() { + return nil + } + return *page.clr.Value +} + +// Creates a new instance of the CustomerListResultPage type. +func NewCustomerListResultPage(getNextPage func(context.Context, CustomerListResult) (CustomerListResult, error)) CustomerListResultPage { + return CustomerListResultPage{fn: getNextPage} +} + +// CustomerPolicy the customer's Policy. +type CustomerPolicy struct { + autorest.Response `json:"-"` + *CustomerPolicyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for CustomerPolicy. +func (cp CustomerPolicy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if cp.CustomerPolicyProperties != nil { + objectMap["properties"] = cp.CustomerPolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for CustomerPolicy struct. +func (cp *CustomerPolicy) 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 customerPolicyProperties CustomerPolicyProperties + err = json.Unmarshal(*v, &customerPolicyProperties) + if err != nil { + return err + } + cp.CustomerPolicyProperties = &customerPolicyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + cp.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + cp.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + cp.Type = &typeVar + } + } + } + + return nil +} + +// CustomerPolicyProperties the properties of a customer's policy. +type CustomerPolicyProperties struct { + // ViewCharges - The policy that controls whether the users in customer's organization can view charges at pay-as-you-go prices. Possible values include: 'ViewChargesAllowed', 'ViewChargesNotAllowed' + ViewCharges ViewCharges `json:"viewCharges,omitempty"` +} + +// CustomerProperties the properties of a customer. +type CustomerProperties struct { + // BillingProfileID - READ-ONLY; The ID of the billing profile for the invoice section. + BillingProfileID *string `json:"billingProfileId,omitempty"` + // BillingProfileDisplayName - READ-ONLY; The name of the billing profile for the invoice section. + BillingProfileDisplayName *string `json:"billingProfileDisplayName,omitempty"` + // DisplayName - The name of the customer. + DisplayName *string `json:"displayName,omitempty"` + // EnabledAzurePlans - Azure plans enabled for the customer. + EnabledAzurePlans *[]AzurePlan `json:"enabledAzurePlans,omitempty"` + // Resellers - The list of resellers for which an Azure plan is enabled for the customer. + Resellers *[]Reseller `json:"resellers,omitempty"` +} + +// Department a department. +type Department struct { + // DepartmentProperties - A department. + *DepartmentProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Department. +func (d Department) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if d.DepartmentProperties != nil { + objectMap["properties"] = d.DepartmentProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Department struct. +func (d *Department) 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 departmentProperties DepartmentProperties + err = json.Unmarshal(*v, &departmentProperties) + if err != nil { + return err + } + d.DepartmentProperties = &departmentProperties + } + 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 + } + } + } + + return nil +} + +// DepartmentProperties the properties of a department. +type DepartmentProperties struct { + // DepartmentName - The name of the department. + DepartmentName *string `json:"departmentName,omitempty"` + // CostCenter - The cost center associated with the department. + CostCenter *string `json:"costCenter,omitempty"` + // Status - The status of the department. + Status *string `json:"status,omitempty"` + // EnrollmentAccounts - Associated enrollment accounts. By default this is not populated, unless it's specified in $expand. + EnrollmentAccounts *[]EnrollmentAccount `json:"enrollmentAccounts,omitempty"` +} + +// Document the properties of a document. +type Document struct { + // Kind - READ-ONLY; The type of the document. Possible values include: 'DocumentTypeInvoice', 'DocumentTypeVoidNote', 'DocumentTypeTaxReceipt', 'DocumentTypeCreditNote' + Kind DocumentType `json:"kind,omitempty"` + // URL - READ-ONLY; Document URL. + URL *string `json:"url,omitempty"` + // Source - READ-ONLY; The source of the document. ENF for Brazil and DRS for rest of the world. Possible values include: 'DRS', 'ENF' + Source DocumentSource `json:"source,omitempty"` +} + +// DownloadURL a secure URL that can be used to download a an entity until the URL expires. +type DownloadURL struct { + autorest.Response `json:"-"` + // ExpiryTime - READ-ONLY; The time in UTC when the download URL will expire. + ExpiryTime *date.Time `json:"expiryTime,omitempty"` + // URL - READ-ONLY; The URL to the PDF file. + URL *string `json:"url,omitempty"` +} + +// Enrollment the properties of an enrollment. +type Enrollment struct { + // StartDate - The start date of the enrollment. + StartDate *date.Time `json:"startDate,omitempty"` + // EndDate - The end date of the enrollment. + EndDate *date.Time `json:"endDate,omitempty"` + // Currency - READ-ONLY; The billing currency for the enrollment. + Currency *string `json:"currency,omitempty"` + // Channel - READ-ONLY; The channel type of the enrollment. + Channel *string `json:"channel,omitempty"` + // Policies - READ-ONLY; The policies for Enterprise Agreement enrollments. + Policies *EnrollmentPolicies `json:"policies,omitempty"` + // Language - READ-ONLY; The language for the enrollment. + Language *string `json:"language,omitempty"` + // CountryCode - READ-ONLY; The country code of the enrollment. + CountryCode *string `json:"countryCode,omitempty"` + // Status - READ-ONLY; The current status of the enrollment. + Status *string `json:"status,omitempty"` + // BillingCycle - READ-ONLY; The billing cycle for the enrollment. + BillingCycle *string `json:"billingCycle,omitempty"` +} + +// EnrollmentAccount an enrollment account. +type EnrollmentAccount struct { + // EnrollmentAccountProperties - The properties of an enrollment account. + *EnrollmentAccountProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for EnrollmentAccount. +func (ea EnrollmentAccount) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ea.EnrollmentAccountProperties != nil { + objectMap["properties"] = ea.EnrollmentAccountProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for EnrollmentAccount struct. +func (ea *EnrollmentAccount) 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 enrollmentAccountProperties EnrollmentAccountProperties + err = json.Unmarshal(*v, &enrollmentAccountProperties) + if err != nil { + return err + } + ea.EnrollmentAccountProperties = &enrollmentAccountProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ea.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ea.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ea.Type = &typeVar + } + } + } + + return nil +} + +// EnrollmentAccountContext the enrollment account context +type EnrollmentAccountContext struct { + // CostCenter - The cost center associated with the enrollment account. + CostCenter *string `json:"costCenter,omitempty"` + // StartDate - The start date of the enrollment account. + StartDate *date.Time `json:"startDate,omitempty"` + // EndDate - The end date of the enrollment account. + EndDate *date.Time `json:"endDate,omitempty"` + // EnrollmentAccountName - The ID of the enrollment account. + EnrollmentAccountName *string `json:"enrollmentAccountName,omitempty"` +} + +// EnrollmentAccountProperties the properties of an enrollment account. +type EnrollmentAccountProperties struct { + // AccountName - The name of the enrollment account. + AccountName *string `json:"accountName,omitempty"` + // CostCenter - The cost center associated with the enrollment account. + CostCenter *string `json:"costCenter,omitempty"` + // AccountOwner - The owner of the enrollment account. + AccountOwner *string `json:"accountOwner,omitempty"` + // Status - The status of the enrollment account. + Status *string `json:"status,omitempty"` + // StartDate - The start date of the enrollment account. + StartDate *date.Time `json:"startDate,omitempty"` + // EndDate - The end date of the enrollment account. + EndDate *date.Time `json:"endDate,omitempty"` + // Department - Associated department. By default this is not populated, unless it's specified in $expand. + Department *Department `json:"department,omitempty"` +} + +// EnrollmentPolicies the policies for Enterprise Agreement enrollments. +type EnrollmentPolicies struct { + // AccountOwnerViewCharges - READ-ONLY; The policy that controls whether Account Owners can view charges. + AccountOwnerViewCharges *bool `json:"accountOwnerViewCharges,omitempty"` + // DepartmentAdminViewCharges - READ-ONLY; The policy that controls whether Department Administrators can view charges. + DepartmentAdminViewCharges *bool `json:"departmentAdminViewCharges,omitempty"` + // MarketplacesEnabled - READ-ONLY; The policy that controls whether Azure marketplace purchases are allowed in the enrollment. + MarketplacesEnabled *bool `json:"marketplacesEnabled,omitempty"` + // ReservedInstancesEnabled - READ-ONLY; The policy that controls whether Azure reservation purchases are allowed in the enrollment. + ReservedInstancesEnabled *bool `json:"reservedInstancesEnabled,omitempty"` +} + +// ErrorDetails the details of the error. +type ErrorDetails struct { + // Code - READ-ONLY; Error code. + Code *string `json:"code,omitempty"` + // Message - READ-ONLY; Error message indicating why the operation failed. + Message *string `json:"message,omitempty"` + // Target - READ-ONLY; The target of the particular error. + Target *string `json:"target,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"` +} + +// Instruction an instruction. +type Instruction struct { + autorest.Response `json:"-"` + // InstructionProperties - A billing instruction used during invoice generation. + *InstructionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Instruction. +func (i Instruction) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if i.InstructionProperties != nil { + objectMap["properties"] = i.InstructionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Instruction struct. +func (i *Instruction) 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 instructionProperties InstructionProperties + err = json.Unmarshal(*v, &instructionProperties) + if err != nil { + return err + } + i.InstructionProperties = &instructionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + i.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + i.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + i.Type = &typeVar + } + } + } + + return nil +} + +// InstructionListResult the list of billing instructions used during invoice generation. +type InstructionListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The list of billing instructions used during invoice generation. + Value *[]Instruction `json:"value,omitempty"` + // NextLink - READ-ONLY; The link (url) to the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// InstructionListResultIterator provides access to a complete listing of Instruction values. +type InstructionListResultIterator struct { + i int + page InstructionListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *InstructionListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstructionListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *InstructionListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter InstructionListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter InstructionListResultIterator) Response() InstructionListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter InstructionListResultIterator) Value() Instruction { + if !iter.page.NotDone() { + return Instruction{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the InstructionListResultIterator type. +func NewInstructionListResultIterator(page InstructionListResultPage) InstructionListResultIterator { + return InstructionListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ilr InstructionListResult) IsEmpty() bool { + return ilr.Value == nil || len(*ilr.Value) == 0 +} + +// instructionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ilr InstructionListResult) instructionListResultPreparer(ctx context.Context) (*http.Request, error) { + if ilr.NextLink == nil || len(to.String(ilr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ilr.NextLink))) +} + +// InstructionListResultPage contains a page of Instruction values. +type InstructionListResultPage struct { + fn func(context.Context, InstructionListResult) (InstructionListResult, error) + ilr InstructionListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *InstructionListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InstructionListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.ilr) + if err != nil { + return err + } + page.ilr = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *InstructionListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page InstructionListResultPage) NotDone() bool { + return !page.ilr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page InstructionListResultPage) Response() InstructionListResult { + return page.ilr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page InstructionListResultPage) Values() []Instruction { + if page.ilr.IsEmpty() { + return nil + } + return *page.ilr.Value +} + +// Creates a new instance of the InstructionListResultPage type. +func NewInstructionListResultPage(getNextPage func(context.Context, InstructionListResult) (InstructionListResult, error)) InstructionListResultPage { + return InstructionListResultPage{fn: getNextPage} +} + +// InstructionProperties a billing instruction used during invoice generation. +type InstructionProperties struct { + // Amount - The amount budgeted for this billing instruction. + Amount *float64 `json:"amount,omitempty"` + // StartDate - The date this billing instruction goes into effect. + StartDate *date.Time `json:"startDate,omitempty"` + // EndDate - The date this billing instruction is no longer in effect. + EndDate *date.Time `json:"endDate,omitempty"` + // CreationDate - The date this billing instruction was created. + CreationDate *date.Time `json:"creationDate,omitempty"` +} + +// Invoice an invoice. +type Invoice struct { + autorest.Response `json:"-"` + // InvoiceProperties - An invoice. + *InvoiceProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Invoice. +func (i Invoice) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if i.InvoiceProperties != nil { + objectMap["properties"] = i.InvoiceProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Invoice struct. +func (i *Invoice) 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 invoiceProperties InvoiceProperties + err = json.Unmarshal(*v, &invoiceProperties) + if err != nil { + return err + } + i.InvoiceProperties = &invoiceProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + i.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + i.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + i.Type = &typeVar + } + } + } + + return nil +} + +// InvoiceListResult the list of invoices. +type InvoiceListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The list of invoices. + Value *[]Invoice `json:"value,omitempty"` + // NextLink - READ-ONLY; The link (url) to the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// InvoiceListResultIterator provides access to a complete listing of Invoice values. +type InvoiceListResultIterator struct { + i int + page InvoiceListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *InvoiceListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InvoiceListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *InvoiceListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter InvoiceListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter InvoiceListResultIterator) Response() InvoiceListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter InvoiceListResultIterator) Value() Invoice { + if !iter.page.NotDone() { + return Invoice{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the InvoiceListResultIterator type. +func NewInvoiceListResultIterator(page InvoiceListResultPage) InvoiceListResultIterator { + return InvoiceListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ilr InvoiceListResult) IsEmpty() bool { + return ilr.Value == nil || len(*ilr.Value) == 0 +} + +// invoiceListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ilr InvoiceListResult) invoiceListResultPreparer(ctx context.Context) (*http.Request, error) { + if ilr.NextLink == nil || len(to.String(ilr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ilr.NextLink))) +} + +// InvoiceListResultPage contains a page of Invoice values. +type InvoiceListResultPage struct { + fn func(context.Context, InvoiceListResult) (InvoiceListResult, error) + ilr InvoiceListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *InvoiceListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InvoiceListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.ilr) + if err != nil { + return err + } + page.ilr = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *InvoiceListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page InvoiceListResultPage) NotDone() bool { + return !page.ilr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page InvoiceListResultPage) Response() InvoiceListResult { + return page.ilr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page InvoiceListResultPage) Values() []Invoice { + if page.ilr.IsEmpty() { + return nil + } + return *page.ilr.Value +} + +// Creates a new instance of the InvoiceListResultPage type. +func NewInvoiceListResultPage(getNextPage func(context.Context, InvoiceListResult) (InvoiceListResult, error)) InvoiceListResultPage { + return InvoiceListResultPage{fn: getNextPage} +} + +// InvoiceProperties the properties of the invoice. +type InvoiceProperties struct { + // DueDate - READ-ONLY; The due date for the invoice. + DueDate *date.Time `json:"dueDate,omitempty"` + // InvoiceDate - READ-ONLY; The date when the invoice was generated. + InvoiceDate *date.Time `json:"invoiceDate,omitempty"` + // Status - READ-ONLY; The current status of the invoice. Possible values include: 'Due', 'OverDue', 'Paid' + Status InvoiceStatus `json:"status,omitempty"` + // AmountDue - READ-ONLY; The amount due as of now. + AmountDue *Amount `json:"amountDue,omitempty"` + // AzurePrepaymentApplied - READ-ONLY; The amount of Azure prepayment applied to the charges. This field is applicable to billing accounts with agreement type Microsoft Customer Agreement. + AzurePrepaymentApplied *Amount `json:"azurePrepaymentApplied,omitempty"` + // BilledAmount - READ-ONLY; The total charges for the invoice billing period. + BilledAmount *Amount `json:"billedAmount,omitempty"` + // CreditAmount - READ-ONLY; The total refund for returns and cancellations during the invoice billing period. This field is applicable to billing accounts with agreement type Microsoft Customer Agreement. + CreditAmount *Amount `json:"creditAmount,omitempty"` + // FreeAzureCreditApplied - READ-ONLY; The amount of free Azure credits applied to the charges. This field is applicable to billing accounts with agreement type Microsoft Customer Agreement. + FreeAzureCreditApplied *Amount `json:"freeAzureCreditApplied,omitempty"` + // SubTotal - READ-ONLY; The pre-tax amount due. This field is applicable to billing accounts with agreement type Microsoft Customer Agreement. + SubTotal *Amount `json:"subTotal,omitempty"` + // TaxAmount - READ-ONLY; The amount of tax charged for the billing period. This field is applicable to billing accounts with agreement type Microsoft Customer Agreement. + TaxAmount *Amount `json:"taxAmount,omitempty"` + // TotalAmount - READ-ONLY; The amount due when the invoice was generated. This field is applicable to billing accounts with agreement type Microsoft Customer Agreement. + TotalAmount *Amount `json:"totalAmount,omitempty"` + // InvoicePeriodStartDate - READ-ONLY; The start date of the billing period for which the invoice is generated. + InvoicePeriodStartDate *date.Time `json:"invoicePeriodStartDate,omitempty"` + // InvoicePeriodEndDate - READ-ONLY; The end date of the billing period for which the invoice is generated. + InvoicePeriodEndDate *date.Time `json:"invoicePeriodEndDate,omitempty"` + // InvoiceType - READ-ONLY; Invoice type. Possible values include: 'AzureService', 'AzureMarketplace', 'AzureSupport' + InvoiceType InvoiceType `json:"invoiceType,omitempty"` + // IsMonthlyInvoice - READ-ONLY; Specifies if the invoice is generated as part of monthly invoicing cycle or not. This field is applicable to billing accounts with agreement type Microsoft Customer Agreement. + IsMonthlyInvoice *bool `json:"isMonthlyInvoice,omitempty"` + // BillingProfileID - READ-ONLY; The ID of the billing profile for which the invoice is generated. + BillingProfileID *string `json:"billingProfileId,omitempty"` + // BillingProfileDisplayName - READ-ONLY; The name of the billing profile for which the invoice is generated. + BillingProfileDisplayName *string `json:"billingProfileDisplayName,omitempty"` + // PurchaseOrderNumber - READ-ONLY; An optional purchase order number for the invoice. + PurchaseOrderNumber *string `json:"purchaseOrderNumber,omitempty"` + // Documents - READ-ONLY; List of documents available to download such as invoice and tax receipt. + Documents *[]Document `json:"documents,omitempty"` + // Payments - READ-ONLY; List of payments. + Payments *[]PaymentProperties `json:"payments,omitempty"` + // SubscriptionID - READ-ONLY; The ID of the subscription for which the invoice is generated. + SubscriptionID *string `json:"subscriptionId,omitempty"` +} + +// InvoicesDownloadBillingSubscriptionInvoiceFuture an abstraction for monitoring and retrieving the +// results of a long-running operation. +type InvoicesDownloadBillingSubscriptionInvoiceFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *InvoicesDownloadBillingSubscriptionInvoiceFuture) Result(client InvoicesClient) (du DownloadURL, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoicesDownloadBillingSubscriptionInvoiceFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("billing.InvoicesDownloadBillingSubscriptionInvoiceFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if du.Response.Response, err = future.GetResult(sender); err == nil && du.Response.Response.StatusCode != http.StatusNoContent { + du, err = client.DownloadBillingSubscriptionInvoiceResponder(du.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoicesDownloadBillingSubscriptionInvoiceFuture", "Result", du.Response.Response, "Failure responding to request") + } + } + return +} + +// InvoicesDownloadInvoiceFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type InvoicesDownloadInvoiceFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *InvoicesDownloadInvoiceFuture) Result(client InvoicesClient) (du DownloadURL, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoicesDownloadInvoiceFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("billing.InvoicesDownloadInvoiceFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if du.Response.Response, err = future.GetResult(sender); err == nil && du.Response.Response.StatusCode != http.StatusNoContent { + du, err = client.DownloadInvoiceResponder(du.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoicesDownloadInvoiceFuture", "Result", du.Response.Response, "Failure responding to request") + } + } + return +} + +// InvoiceSection an invoice section. +type InvoiceSection struct { + autorest.Response `json:"-"` + // InvoiceSectionProperties - The properties of an invoice section. + *InvoiceSectionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for InvoiceSection. +func (is InvoiceSection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if is.InvoiceSectionProperties != nil { + objectMap["properties"] = is.InvoiceSectionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for InvoiceSection struct. +func (is *InvoiceSection) 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 invoiceSectionProperties InvoiceSectionProperties + err = json.Unmarshal(*v, &invoiceSectionProperties) + if err != nil { + return err + } + is.InvoiceSectionProperties = &invoiceSectionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + is.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + is.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + is.Type = &typeVar + } + } + } + + return nil +} + +// InvoiceSectionCreationRequest the properties of the invoice section. +type InvoiceSectionCreationRequest struct { + // DisplayName - The name of the invoice section. + DisplayName *string `json:"displayName,omitempty"` +} + +// InvoiceSectionListResult the list of invoice sections. +type InvoiceSectionListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The list of invoice sections. + Value *[]InvoiceSection `json:"value,omitempty"` + // NextLink - READ-ONLY; The link (url) to the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// InvoiceSectionListResultIterator provides access to a complete listing of InvoiceSection values. +type InvoiceSectionListResultIterator struct { + i int + page InvoiceSectionListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *InvoiceSectionListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InvoiceSectionListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *InvoiceSectionListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter InvoiceSectionListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter InvoiceSectionListResultIterator) Response() InvoiceSectionListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter InvoiceSectionListResultIterator) Value() InvoiceSection { + if !iter.page.NotDone() { + return InvoiceSection{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the InvoiceSectionListResultIterator type. +func NewInvoiceSectionListResultIterator(page InvoiceSectionListResultPage) InvoiceSectionListResultIterator { + return InvoiceSectionListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (islr InvoiceSectionListResult) IsEmpty() bool { + return islr.Value == nil || len(*islr.Value) == 0 +} + +// invoiceSectionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (islr InvoiceSectionListResult) invoiceSectionListResultPreparer(ctx context.Context) (*http.Request, error) { + if islr.NextLink == nil || len(to.String(islr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(islr.NextLink))) +} + +// InvoiceSectionListResultPage contains a page of InvoiceSection values. +type InvoiceSectionListResultPage struct { + fn func(context.Context, InvoiceSectionListResult) (InvoiceSectionListResult, error) + islr InvoiceSectionListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *InvoiceSectionListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InvoiceSectionListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.islr) + if err != nil { + return err + } + page.islr = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *InvoiceSectionListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page InvoiceSectionListResultPage) NotDone() bool { + return !page.islr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page InvoiceSectionListResultPage) Response() InvoiceSectionListResult { + return page.islr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page InvoiceSectionListResultPage) Values() []InvoiceSection { + if page.islr.IsEmpty() { + return nil + } + return *page.islr.Value +} + +// Creates a new instance of the InvoiceSectionListResultPage type. +func NewInvoiceSectionListResultPage(getNextPage func(context.Context, InvoiceSectionListResult) (InvoiceSectionListResult, error)) InvoiceSectionListResultPage { + return InvoiceSectionListResultPage{fn: getNextPage} +} + +// InvoiceSectionListWithCreateSubPermissionResult the list of invoice section properties with create +// subscription permission. +type InvoiceSectionListWithCreateSubPermissionResult struct { + autorest.Response `json:"-"` + // Value - The list of invoice section properties with create subscription permission. + Value *[]InvoiceSectionWithCreateSubPermission `json:"value,omitempty"` + // NextLink - READ-ONLY; The link (url) to the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// InvoiceSectionListWithCreateSubPermissionResultIterator provides access to a complete listing of +// InvoiceSectionWithCreateSubPermission values. +type InvoiceSectionListWithCreateSubPermissionResultIterator struct { + i int + page InvoiceSectionListWithCreateSubPermissionResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *InvoiceSectionListWithCreateSubPermissionResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InvoiceSectionListWithCreateSubPermissionResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *InvoiceSectionListWithCreateSubPermissionResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter InvoiceSectionListWithCreateSubPermissionResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter InvoiceSectionListWithCreateSubPermissionResultIterator) Response() InvoiceSectionListWithCreateSubPermissionResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter InvoiceSectionListWithCreateSubPermissionResultIterator) Value() InvoiceSectionWithCreateSubPermission { + if !iter.page.NotDone() { + return InvoiceSectionWithCreateSubPermission{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the InvoiceSectionListWithCreateSubPermissionResultIterator type. +func NewInvoiceSectionListWithCreateSubPermissionResultIterator(page InvoiceSectionListWithCreateSubPermissionResultPage) InvoiceSectionListWithCreateSubPermissionResultIterator { + return InvoiceSectionListWithCreateSubPermissionResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (islwcspr InvoiceSectionListWithCreateSubPermissionResult) IsEmpty() bool { + return islwcspr.Value == nil || len(*islwcspr.Value) == 0 +} + +// invoiceSectionListWithCreateSubPermissionResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (islwcspr InvoiceSectionListWithCreateSubPermissionResult) invoiceSectionListWithCreateSubPermissionResultPreparer(ctx context.Context) (*http.Request, error) { + if islwcspr.NextLink == nil || len(to.String(islwcspr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(islwcspr.NextLink))) +} + +// InvoiceSectionListWithCreateSubPermissionResultPage contains a page of +// InvoiceSectionWithCreateSubPermission values. +type InvoiceSectionListWithCreateSubPermissionResultPage struct { + fn func(context.Context, InvoiceSectionListWithCreateSubPermissionResult) (InvoiceSectionListWithCreateSubPermissionResult, error) + islwcspr InvoiceSectionListWithCreateSubPermissionResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *InvoiceSectionListWithCreateSubPermissionResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InvoiceSectionListWithCreateSubPermissionResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.islwcspr) + if err != nil { + return err + } + page.islwcspr = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *InvoiceSectionListWithCreateSubPermissionResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page InvoiceSectionListWithCreateSubPermissionResultPage) NotDone() bool { + return !page.islwcspr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page InvoiceSectionListWithCreateSubPermissionResultPage) Response() InvoiceSectionListWithCreateSubPermissionResult { + return page.islwcspr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page InvoiceSectionListWithCreateSubPermissionResultPage) Values() []InvoiceSectionWithCreateSubPermission { + if page.islwcspr.IsEmpty() { + return nil + } + return *page.islwcspr.Value +} + +// Creates a new instance of the InvoiceSectionListWithCreateSubPermissionResultPage type. +func NewInvoiceSectionListWithCreateSubPermissionResultPage(getNextPage func(context.Context, InvoiceSectionListWithCreateSubPermissionResult) (InvoiceSectionListWithCreateSubPermissionResult, error)) InvoiceSectionListWithCreateSubPermissionResultPage { + return InvoiceSectionListWithCreateSubPermissionResultPage{fn: getNextPage} +} + +// InvoiceSectionProperties the properties of an invoice section. +type InvoiceSectionProperties struct { + // DisplayName - The name of the invoice section. + DisplayName *string `json:"displayName,omitempty"` + // Labels - Dictionary of metadata associated with the invoice section. + Labels map[string]*string `json:"labels"` + // SystemID - READ-ONLY; The system generated unique identifier for an invoice section. + SystemID *string `json:"systemId,omitempty"` +} + +// MarshalJSON is the custom marshaler for InvoiceSectionProperties. +func (isp InvoiceSectionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if isp.DisplayName != nil { + objectMap["displayName"] = isp.DisplayName + } + if isp.Labels != nil { + objectMap["labels"] = isp.Labels + } + return json.Marshal(objectMap) +} + +// InvoiceSectionsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type InvoiceSectionsCreateOrUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *InvoiceSectionsCreateOrUpdateFuture) Result(client InvoiceSectionsClient) (is InvoiceSection, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("billing.InvoiceSectionsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if is.Response.Response, err = future.GetResult(sender); err == nil && is.Response.Response.StatusCode != http.StatusNoContent { + is, err = client.CreateOrUpdateResponder(is.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsCreateOrUpdateFuture", "Result", is.Response.Response, "Failure responding to request") + } + } + return +} + +// InvoiceSectionsOnExpand the invoice sections associated to the billing profile. By default this is not +// populated, unless it's specified in $expand. +type InvoiceSectionsOnExpand struct { + // HasMoreResults - READ-ONLY; Indicates whether there are more invoice sections than the ones listed in this collection. The collection lists a maximum of 50 invoice sections. To get all invoice sections, use the list invoice sections API. + HasMoreResults *bool `json:"hasMoreResults,omitempty"` + // Value - The invoice sections associated to the billing profile. + Value *[]InvoiceSection `json:"value,omitempty"` +} + +// InvoiceSectionWithCreateSubPermission invoice section properties with create subscription permission. +type InvoiceSectionWithCreateSubPermission struct { + // InvoiceSectionID - READ-ONLY; The ID of the invoice section. + InvoiceSectionID *string `json:"invoiceSectionId,omitempty"` + // InvoiceSectionDisplayName - READ-ONLY; The name of the invoice section. + InvoiceSectionDisplayName *string `json:"invoiceSectionDisplayName,omitempty"` + // InvoiceSectionSystemID - READ-ONLY; The system generated unique identifier for an invoice section. + InvoiceSectionSystemID *string `json:"invoiceSectionSystemId,omitempty"` + // BillingProfileID - READ-ONLY; The ID of the billing profile for the invoice section. + BillingProfileID *string `json:"billingProfileId,omitempty"` + // BillingProfileDisplayName - READ-ONLY; The name of the billing profile for the invoice section. + BillingProfileDisplayName *string `json:"billingProfileDisplayName,omitempty"` + // BillingProfileStatus - READ-ONLY; The status of the billing profile. Possible values include: 'ProfileStatusActive', 'ProfileStatusDisabled', 'ProfileStatusWarned' + BillingProfileStatus ProfileStatus `json:"billingProfileStatus,omitempty"` + // BillingProfileStatusReasonCode - READ-ONLY; Reason for the specified billing profile status. Possible values include: 'StatusReasonCodeForBillingProfilePastDue', 'StatusReasonCodeForBillingProfileSpendingLimitReached', 'StatusReasonCodeForBillingProfileSpendingLimitExpired' + BillingProfileStatusReasonCode StatusReasonCodeForBillingProfile `json:"billingProfileStatusReasonCode,omitempty"` + // BillingProfileSpendingLimit - READ-ONLY; The billing profile spending limit. Possible values include: 'SpendingLimitForBillingProfileOff', 'SpendingLimitForBillingProfileOn' + BillingProfileSpendingLimit SpendingLimitForBillingProfile `json:"billingProfileSpendingLimit,omitempty"` + // BillingProfileSystemID - READ-ONLY; The system generated unique identifier for a billing profile. + BillingProfileSystemID *string `json:"billingProfileSystemId,omitempty"` + // EnabledAzurePlans - Enabled azure plans for the associated billing profile. + EnabledAzurePlans *[]AzurePlan `json:"enabledAzurePlans,omitempty"` +} + +// Operation a Billing REST API operation. +type Operation struct { + // Name - READ-ONLY; Operation name: {provider}/{resource}/{operation}. + Name *string `json:"name,omitempty"` + // Display - The object that represents the operation. + Display *OperationDisplay `json:"display,omitempty"` +} + +// OperationDisplay the object that represents the operation. +type OperationDisplay struct { + // Provider - READ-ONLY; Service provider: Microsoft.Billing. + Provider *string `json:"provider,omitempty"` + // Resource - READ-ONLY; Resource on which the operation is performed such as invoice and billing subscription. + Resource *string `json:"resource,omitempty"` + // Operation - READ-ONLY; Operation type such as read, write and delete. + Operation *string `json:"operation,omitempty"` +} + +// OperationListResult the list of billing operations and a URL link to get the next set of results. +type OperationListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The list of billing operations supported by the Microsoft.Billing resource provider. + Value *[]Operation `json:"value,omitempty"` + // NextLink - READ-ONLY; URL to get the next set of operation list results if there are any. + NextLink *string `json:"nextLink,omitempty"` +} + +// OperationListResultIterator provides access to a complete listing of Operation values. +type OperationListResultIterator struct { + i int + page OperationListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *OperationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OperationListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter OperationListResultIterator) Response() OperationListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter OperationListResultIterator) Value() Operation { + if !iter.page.NotDone() { + return Operation{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OperationListResultIterator type. +func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator { + return OperationListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (olr OperationListResult) IsEmpty() bool { + return olr.Value == nil || len(*olr.Value) == 0 +} + +// operationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) { + if olr.NextLink == nil || len(to.String(olr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(olr.NextLink))) +} + +// OperationListResultPage contains a page of Operation values. +type OperationListResultPage struct { + fn func(context.Context, OperationListResult) (OperationListResult, error) + olr OperationListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *OperationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.olr) + if err != nil { + return err + } + page.olr = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *OperationListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OperationListResultPage) NotDone() bool { + return !page.olr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OperationListResultPage) Response() OperationListResult { + return page.olr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OperationListResultPage) Values() []Operation { + if page.olr.IsEmpty() { + return nil + } + return *page.olr.Value +} + +// Creates a new instance of the OperationListResultPage type. +func NewOperationListResultPage(getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { + return OperationListResultPage{fn: getNextPage} +} + +// Participants the details about a participant. +type Participants struct { + // Status - READ-ONLY; The acceptance status of the participant. + Status *string `json:"status,omitempty"` + // StatusDate - READ-ONLY; The date when the status got changed. + StatusDate *date.Time `json:"statusDate,omitempty"` + // Email - READ-ONLY; The email address of the participant. + Email *string `json:"email,omitempty"` +} + +// PaymentProperties the properties of a payment. +type PaymentProperties struct { + // PaymentType - READ-ONLY; The type of payment. + PaymentType *string `json:"paymentType,omitempty"` + // Amount - READ-ONLY; The paid amount. + Amount *Amount `json:"amount,omitempty"` + // Date - READ-ONLY; The date when the payment was made. + Date *date.Time `json:"date,omitempty"` + // PaymentMethodFamily - The family of payment method. Possible values include: 'Credits', 'CheckWire', 'CreditCard', 'None' + PaymentMethodFamily PaymentMethodFamily `json:"paymentMethodFamily,omitempty"` + // PaymentMethodType - READ-ONLY; The type of payment method. + PaymentMethodType *string `json:"paymentMethodType,omitempty"` +} + +// PermissionsListResult result of list billingPermissions a caller has on a billing account. +type PermissionsListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The list of billingPermissions a caller has on a billing account. + Value *[]PermissionsProperties `json:"value,omitempty"` + // NextLink - READ-ONLY; The link (url) to the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// PermissionsListResultIterator provides access to a complete listing of PermissionsProperties values. +type PermissionsListResultIterator struct { + i int + page PermissionsListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *PermissionsListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PermissionsListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *PermissionsListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter PermissionsListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter PermissionsListResultIterator) Response() PermissionsListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter PermissionsListResultIterator) Value() PermissionsProperties { + if !iter.page.NotDone() { + return PermissionsProperties{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the PermissionsListResultIterator type. +func NewPermissionsListResultIterator(page PermissionsListResultPage) PermissionsListResultIterator { + return PermissionsListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (plr PermissionsListResult) IsEmpty() bool { + return plr.Value == nil || len(*plr.Value) == 0 +} + +// permissionsListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (plr PermissionsListResult) permissionsListResultPreparer(ctx context.Context) (*http.Request, error) { + if plr.NextLink == nil || len(to.String(plr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(plr.NextLink))) +} + +// PermissionsListResultPage contains a page of PermissionsProperties values. +type PermissionsListResultPage struct { + fn func(context.Context, PermissionsListResult) (PermissionsListResult, error) + plr PermissionsListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *PermissionsListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PermissionsListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.plr) + if err != nil { + return err + } + page.plr = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *PermissionsListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page PermissionsListResultPage) NotDone() bool { + return !page.plr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page PermissionsListResultPage) Response() PermissionsListResult { + return page.plr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page PermissionsListResultPage) Values() []PermissionsProperties { + if page.plr.IsEmpty() { + return nil + } + return *page.plr.Value +} + +// Creates a new instance of the PermissionsListResultPage type. +func NewPermissionsListResultPage(getNextPage func(context.Context, PermissionsListResult) (PermissionsListResult, error)) PermissionsListResultPage { + return PermissionsListResultPage{fn: getNextPage} +} + +// PermissionsProperties the set of allowed action and not allowed actions a caller has on a billing +// account +type PermissionsProperties struct { + // Actions - READ-ONLY; The set of actions that the caller is allowed to perform. + Actions *[]string `json:"actions,omitempty"` + // NotActions - READ-ONLY; The set of actions that the caller is not allowed to perform. + NotActions *[]string `json:"notActions,omitempty"` +} + +// Policy a policy. +type Policy struct { + autorest.Response `json:"-"` + *PolicyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Policy. +func (p Policy) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if p.PolicyProperties != nil { + objectMap["properties"] = p.PolicyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Policy struct. +func (p *Policy) 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 policyProperties PolicyProperties + err = json.Unmarshal(*v, &policyProperties) + if err != nil { + return err + } + p.PolicyProperties = &policyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + p.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + p.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + p.Type = &typeVar + } + } + } + + return nil +} + +// PolicyProperties the properties of a policy. +type PolicyProperties struct { + // MarketplacePurchases - The policy that controls whether Azure marketplace purchases are allowed for a billing profile. Possible values include: 'AllAllowed', 'OnlyFreeAllowed', 'NotAllowed' + MarketplacePurchases MarketplacePurchasesPolicy `json:"marketplacePurchases,omitempty"` + // ReservationPurchases - The policy that controls whether Azure reservation purchases are allowed for a billing profile. Possible values include: 'ReservationPurchasesPolicyAllowed', 'ReservationPurchasesPolicyNotAllowed' + ReservationPurchases ReservationPurchasesPolicy `json:"reservationPurchases,omitempty"` + // ViewCharges - The policy that controls whether users with Azure RBAC access to a subscription can view its charges. Possible values include: 'ViewChargesPolicyAllowed', 'ViewChargesPolicyNotAllowed' + ViewCharges ViewChargesPolicy `json:"viewCharges,omitempty"` +} + +// Product a product. +type Product struct { + autorest.Response `json:"-"` + *ProductProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Product. +func (p Product) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if p.ProductProperties != nil { + objectMap["properties"] = p.ProductProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Product struct. +func (p *Product) 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 productProperties ProductProperties + err = json.Unmarshal(*v, &productProperties) + if err != nil { + return err + } + p.ProductProperties = &productProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + p.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + p.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + p.Type = &typeVar + } + } + } + + return nil +} + +// ProductProperties the properties of a product. +type ProductProperties struct { + // AutoRenew - Indicates whether auto renewal is turned on or off for a product. Possible values include: 'Off', 'On' + AutoRenew AutoRenew `json:"autoRenew,omitempty"` + // DisplayName - READ-ONLY; The display name of the product. + DisplayName *string `json:"displayName,omitempty"` + // PurchaseDate - READ-ONLY; The date when the product was purchased. + PurchaseDate *date.Time `json:"purchaseDate,omitempty"` + // ProductTypeID - READ-ONLY; The ID of the type of product. + ProductTypeID *string `json:"productTypeId,omitempty"` + // ProductType - READ-ONLY; The description of the type of product. + ProductType *string `json:"productType,omitempty"` + // Status - The current status of the product. Possible values include: 'ProductStatusTypeActive', 'ProductStatusTypeInactive', 'ProductStatusTypePastDue', 'ProductStatusTypeExpiring', 'ProductStatusTypeExpired', 'ProductStatusTypeDisabled', 'ProductStatusTypeCancelled', 'ProductStatusTypeAutoRenew' + Status ProductStatusType `json:"status,omitempty"` + // EndDate - READ-ONLY; The date when the product will be renewed or canceled. + EndDate *date.Time `json:"endDate,omitempty"` + // BillingFrequency - The frequency at which the product will be billed. Possible values include: 'OneTime', 'Monthly', 'UsageBased' + BillingFrequency Frequency `json:"billingFrequency,omitempty"` + // LastCharge - READ-ONLY; The last month charges. + LastCharge *Amount `json:"lastCharge,omitempty"` + // LastChargeDate - READ-ONLY; The date of the last charge. + LastChargeDate *date.Time `json:"lastChargeDate,omitempty"` + // Quantity - READ-ONLY; The quantity purchased for the product. + Quantity *float64 `json:"quantity,omitempty"` + // SkuID - READ-ONLY; The sku ID of the product. + SkuID *string `json:"skuId,omitempty"` + // SkuDescription - READ-ONLY; The sku description of the product. + SkuDescription *string `json:"skuDescription,omitempty"` + // TenantID - READ-ONLY; The id of the tenant in which the product is used. + TenantID *string `json:"tenantId,omitempty"` + // AvailabilityID - READ-ONLY; The availability of the product. + AvailabilityID *string `json:"availabilityId,omitempty"` + // InvoiceSectionID - READ-ONLY; The ID of the invoice section to which the product is billed. + InvoiceSectionID *string `json:"invoiceSectionId,omitempty"` + // InvoiceSectionDisplayName - READ-ONLY; The name of the invoice section to which the product is billed. + InvoiceSectionDisplayName *string `json:"invoiceSectionDisplayName,omitempty"` + // BillingProfileID - READ-ONLY; The ID of the billing profile to which the product is billed. + BillingProfileID *string `json:"billingProfileId,omitempty"` + // BillingProfileDisplayName - READ-ONLY; The name of the billing profile to which the product is billed. + BillingProfileDisplayName *string `json:"billingProfileDisplayName,omitempty"` + // CustomerID - READ-ONLY; The ID of the customer for whom the product was purchased. The field is applicable only for Microsoft Partner Agreement billing account. + CustomerID *string `json:"customerId,omitempty"` + // CustomerDisplayName - READ-ONLY; The name of the customer for whom the product was purchased. The field is applicable only for Microsoft Partner Agreement billing account. + CustomerDisplayName *string `json:"customerDisplayName,omitempty"` + // Reseller - READ-ONLY; Reseller for this product. + Reseller *Reseller `json:"reseller,omitempty"` +} + +// ProductsListResult the list of products. It contains a list of available product summaries in reverse +// chronological order by purchase date. +type ProductsListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The list of products. + Value *[]Product `json:"value,omitempty"` + // NextLink - READ-ONLY; The link (url) to the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// ProductsListResultIterator provides access to a complete listing of Product values. +type ProductsListResultIterator struct { + i int + page ProductsListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ProductsListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductsListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ProductsListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ProductsListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ProductsListResultIterator) Response() ProductsListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ProductsListResultIterator) Value() Product { + if !iter.page.NotDone() { + return Product{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ProductsListResultIterator type. +func NewProductsListResultIterator(page ProductsListResultPage) ProductsListResultIterator { + return ProductsListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (plr ProductsListResult) IsEmpty() bool { + return plr.Value == nil || len(*plr.Value) == 0 +} + +// productsListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (plr ProductsListResult) productsListResultPreparer(ctx context.Context) (*http.Request, error) { + if plr.NextLink == nil || len(to.String(plr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(plr.NextLink))) +} + +// ProductsListResultPage contains a page of Product values. +type ProductsListResultPage struct { + fn func(context.Context, ProductsListResult) (ProductsListResult, error) + plr ProductsListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ProductsListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductsListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.plr) + if err != nil { + return err + } + page.plr = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ProductsListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ProductsListResultPage) NotDone() bool { + return !page.plr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ProductsListResultPage) Response() ProductsListResult { + return page.plr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ProductsListResultPage) Values() []Product { + if page.plr.IsEmpty() { + return nil + } + return *page.plr.Value +} + +// Creates a new instance of the ProductsListResultPage type. +func NewProductsListResultPage(getNextPage func(context.Context, ProductsListResult) (ProductsListResult, error)) ProductsListResultPage { + return ProductsListResultPage{fn: getNextPage} +} + +// Profile a billing profile. +type Profile struct { + autorest.Response `json:"-"` + // ProfileProperties - The properties of the billing profile. + *ProfileProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Profile. +func (p Profile) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if p.ProfileProperties != nil { + objectMap["properties"] = p.ProfileProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Profile struct. +func (p *Profile) 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 profileProperties ProfileProperties + err = json.Unmarshal(*v, &profileProperties) + if err != nil { + return err + } + p.ProfileProperties = &profileProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + p.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + p.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + p.Type = &typeVar + } + } + } + + return nil +} + +// ProfileCreationRequest the request parameters for creating a new billing profile. +type ProfileCreationRequest struct { + // DisplayName - The name of the billing profile. + DisplayName *string `json:"displayName,omitempty"` + // PoNumber - The purchase order name that will appear on the invoices generated for the billing profile. + PoNumber *string `json:"poNumber,omitempty"` + // BillTo - The address of the individual or organization that is responsible for the billing profile. + BillTo *AddressDetails `json:"billTo,omitempty"` + // InvoiceEmailOptIn - Flag controlling whether the invoices for the billing profile are sent through email. + InvoiceEmailOptIn *bool `json:"invoiceEmailOptIn,omitempty"` + // EnabledAzurePlans - Enabled azure plans for the billing profile. + EnabledAzurePlans *[]AzurePlan `json:"enabledAzurePlans,omitempty"` +} + +// ProfileListResult the list of billing profiles. +type ProfileListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The list of billing profiles. + Value *[]Profile `json:"value,omitempty"` + // NextLink - READ-ONLY; The link (url) to the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// ProfileListResultIterator provides access to a complete listing of Profile values. +type ProfileListResultIterator struct { + i int + page ProfileListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *ProfileListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProfileListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *ProfileListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter ProfileListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter ProfileListResultIterator) Response() ProfileListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter ProfileListResultIterator) Value() Profile { + if !iter.page.NotDone() { + return Profile{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the ProfileListResultIterator type. +func NewProfileListResultIterator(page ProfileListResultPage) ProfileListResultIterator { + return ProfileListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (plr ProfileListResult) IsEmpty() bool { + return plr.Value == nil || len(*plr.Value) == 0 +} + +// profileListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (plr ProfileListResult) profileListResultPreparer(ctx context.Context) (*http.Request, error) { + if plr.NextLink == nil || len(to.String(plr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(plr.NextLink))) +} + +// ProfileListResultPage contains a page of Profile values. +type ProfileListResultPage struct { + fn func(context.Context, ProfileListResult) (ProfileListResult, error) + plr ProfileListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *ProfileListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProfileListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.plr) + if err != nil { + return err + } + page.plr = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *ProfileListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page ProfileListResultPage) NotDone() bool { + return !page.plr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page ProfileListResultPage) Response() ProfileListResult { + return page.plr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page ProfileListResultPage) Values() []Profile { + if page.plr.IsEmpty() { + return nil + } + return *page.plr.Value +} + +// Creates a new instance of the ProfileListResultPage type. +func NewProfileListResultPage(getNextPage func(context.Context, ProfileListResult) (ProfileListResult, error)) ProfileListResultPage { + return ProfileListResultPage{fn: getNextPage} +} + +// ProfileProperties the properties of the billing profile. +type ProfileProperties struct { + // DisplayName - The name of the billing profile. + DisplayName *string `json:"displayName,omitempty"` + // PoNumber - The purchase order name that will appear on the invoices generated for the billing profile. + PoNumber *string `json:"poNumber,omitempty"` + // BillTo - Billing address. + BillTo *AddressDetails `json:"billTo,omitempty"` + // InvoiceEmailOptIn - Flag controlling whether the invoices for the billing profile are sent through email. + InvoiceEmailOptIn *bool `json:"invoiceEmailOptIn,omitempty"` + // InvoiceDay - READ-ONLY; The day of the month when the invoice for the billing profile is generated. + InvoiceDay *int32 `json:"invoiceDay,omitempty"` + // Currency - READ-ONLY; The currency in which the charges for the billing profile are billed. + Currency *string `json:"currency,omitempty"` + // EnabledAzurePlans - Information about the enabled azure plans. + EnabledAzurePlans *[]AzurePlan `json:"enabledAzurePlans,omitempty"` + // InvoiceSections - The invoice sections associated to the billing profile. By default this is not populated, unless it's specified in $expand. + InvoiceSections *InvoiceSectionsOnExpand `json:"invoiceSections,omitempty"` + // HasReadAccess - READ-ONLY; Indicates whether user has read access to the billing profile. + HasReadAccess *bool `json:"hasReadAccess,omitempty"` + // SystemID - READ-ONLY; The system generated unique identifier for a billing profile. + SystemID *string `json:"systemId,omitempty"` + // Status - READ-ONLY; The status of the billing profile. Possible values include: 'ProfileStatusActive', 'ProfileStatusDisabled', 'ProfileStatusWarned' + Status ProfileStatus `json:"status,omitempty"` + // StatusReasonCode - READ-ONLY; Reason for the specified billing profile status. Possible values include: 'StatusReasonCodePastDue', 'StatusReasonCodeSpendingLimitReached', 'StatusReasonCodeSpendingLimitExpired' + StatusReasonCode StatusReasonCode `json:"statusReasonCode,omitempty"` + // SpendingLimit - READ-ONLY; The billing profile spending limit. Possible values include: 'SpendingLimitOff', 'SpendingLimitOn' + SpendingLimit SpendingLimit `json:"spendingLimit,omitempty"` +} + +// ProfilesCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ProfilesCreateOrUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ProfilesCreateOrUpdateFuture) Result(client ProfilesClient) (p Profile, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProfilesCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("billing.ProfilesCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if p.Response.Response, err = future.GetResult(sender); err == nil && p.Response.Response.StatusCode != http.StatusNoContent { + p, err = client.CreateOrUpdateResponder(p.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProfilesCreateOrUpdateFuture", "Result", p.Response.Response, "Failure responding to request") + } + } + return +} + +// ProfilesOnExpand the billing profiles associated with the billing account. By default this is not +// populated, unless it's specified in $expand. +type ProfilesOnExpand struct { + // HasMoreResults - READ-ONLY; Indicates whether there are more billing profiles than the ones listed in this collection. The collection lists a maximum of 50 billing profiles. To get all billing profiles, use the list billing profiles API. + HasMoreResults *bool `json:"hasMoreResults,omitempty"` + // Value - The billing profiles associated with the billing account. + Value *[]Profile `json:"value,omitempty"` +} + +// Property a billing property. +type Property struct { + autorest.Response `json:"-"` + // PropertyProperties - A billing property. + *PropertyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Property. +func (p Property) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if p.PropertyProperties != nil { + objectMap["properties"] = p.PropertyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Property struct. +func (p *Property) 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 propertyProperties PropertyProperties + err = json.Unmarshal(*v, &propertyProperties) + if err != nil { + return err + } + p.PropertyProperties = &propertyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + p.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + p.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + p.Type = &typeVar + } + } + } + + return nil +} + +// PropertyProperties the billing property. +type PropertyProperties struct { + // AccountAdminNotificationEmailAddress - READ-ONLY; The email address on which the account admin gets all Azure notifications. + AccountAdminNotificationEmailAddress *string `json:"accountAdminNotificationEmailAddress,omitempty"` + // BillingTenantID - READ-ONLY; The Azure AD tenant ID of the billing account for the subscription. + BillingTenantID *string `json:"billingTenantId,omitempty"` + // BillingAccountID - READ-ONLY; The ID of the billing account to which the subscription is billed. + BillingAccountID *string `json:"billingAccountId,omitempty"` + // BillingAccountDisplayName - READ-ONLY; The name of the billing account to which the subscription is billed. + BillingAccountDisplayName *string `json:"billingAccountDisplayName,omitempty"` + // BillingProfileID - READ-ONLY; The ID of the billing profile to which the subscription is billed. + BillingProfileID *string `json:"billingProfileId,omitempty"` + // BillingProfileDisplayName - READ-ONLY; The name of the billing profile to which the subscription is billed. + BillingProfileDisplayName *string `json:"billingProfileDisplayName,omitempty"` + // BillingProfileStatus - READ-ONLY; The status of the billing profile. Possible values include: 'ProfileStatusActive', 'ProfileStatusDisabled', 'ProfileStatusWarned' + BillingProfileStatus ProfileStatus `json:"billingProfileStatus,omitempty"` + // BillingProfileStatusReasonCode - READ-ONLY; Reason for the specified billing profile status. Possible values include: 'PastDue', 'SpendingLimitReached', 'SpendingLimitExpired' + BillingProfileStatusReasonCode ProfileStatusReasonCode `json:"billingProfileStatusReasonCode,omitempty"` + // BillingProfileSpendingLimit - READ-ONLY; The billing profile spending limit. Possible values include: 'ProfileSpendingLimitOff', 'ProfileSpendingLimitOn' + BillingProfileSpendingLimit ProfileSpendingLimit `json:"billingProfileSpendingLimit,omitempty"` + // CostCenter - The cost center applied to the subscription. + CostCenter *string `json:"costCenter,omitempty"` + // InvoiceSectionID - READ-ONLY; The ID of the invoice section to which the subscription is billed. + InvoiceSectionID *string `json:"invoiceSectionId,omitempty"` + // InvoiceSectionDisplayName - READ-ONLY; The name of the invoice section to which the subscription is billed. + InvoiceSectionDisplayName *string `json:"invoiceSectionDisplayName,omitempty"` + // IsAccountAdmin - READ-ONLY; Indicates whether user is the account admin. + IsAccountAdmin *bool `json:"isAccountAdmin,omitempty"` + // ProductID - READ-ONLY; The product ID of the Azure plan. + ProductID *string `json:"productId,omitempty"` + // ProductName - READ-ONLY; The product name of the Azure plan. + ProductName *string `json:"productName,omitempty"` + // SkuID - READ-ONLY; The sku ID of the Azure plan for the subscription. + SkuID *string `json:"skuId,omitempty"` + // SkuDescription - READ-ONLY; The sku description of the Azure plan for the subscription. + SkuDescription *string `json:"skuDescription,omitempty"` +} + +// Reseller details of the reseller. +type Reseller struct { + // ResellerID - READ-ONLY; The MPN ID of the reseller. + ResellerID *string `json:"resellerId,omitempty"` + // Description - READ-ONLY; The name of the reseller. + Description *string `json:"description,omitempty"` +} + +// Resource the Resource model definition. +type Resource struct { + // ID - READ-ONLY; Resource Id. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// RoleAssignment the role assignment +type RoleAssignment struct { + autorest.Response `json:"-"` + // RoleAssignmentProperties - The properties of the role assignment. + *RoleAssignmentProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RoleAssignment. +func (ra RoleAssignment) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ra.RoleAssignmentProperties != nil { + objectMap["properties"] = ra.RoleAssignmentProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RoleAssignment struct. +func (ra *RoleAssignment) 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 roleAssignmentProperties RoleAssignmentProperties + err = json.Unmarshal(*v, &roleAssignmentProperties) + if err != nil { + return err + } + ra.RoleAssignmentProperties = &roleAssignmentProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + ra.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + ra.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + ra.Type = &typeVar + } + } + } + + return nil +} + +// RoleAssignmentListResult the list of role assignments. +type RoleAssignmentListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The list of role assignments. + Value *[]RoleAssignment `json:"value,omitempty"` + // NextLink - READ-ONLY; The link (url) to the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// RoleAssignmentListResultIterator provides access to a complete listing of RoleAssignment values. +type RoleAssignmentListResultIterator struct { + i int + page RoleAssignmentListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *RoleAssignmentListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *RoleAssignmentListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter RoleAssignmentListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter RoleAssignmentListResultIterator) Response() RoleAssignmentListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter RoleAssignmentListResultIterator) Value() RoleAssignment { + if !iter.page.NotDone() { + return RoleAssignment{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the RoleAssignmentListResultIterator type. +func NewRoleAssignmentListResultIterator(page RoleAssignmentListResultPage) RoleAssignmentListResultIterator { + return RoleAssignmentListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ralr RoleAssignmentListResult) IsEmpty() bool { + return ralr.Value == nil || len(*ralr.Value) == 0 +} + +// roleAssignmentListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ralr RoleAssignmentListResult) roleAssignmentListResultPreparer(ctx context.Context) (*http.Request, error) { + if ralr.NextLink == nil || len(to.String(ralr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ralr.NextLink))) +} + +// RoleAssignmentListResultPage contains a page of RoleAssignment values. +type RoleAssignmentListResultPage struct { + fn func(context.Context, RoleAssignmentListResult) (RoleAssignmentListResult, error) + ralr RoleAssignmentListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *RoleAssignmentListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.ralr) + if err != nil { + return err + } + page.ralr = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *RoleAssignmentListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page RoleAssignmentListResultPage) NotDone() bool { + return !page.ralr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page RoleAssignmentListResultPage) Response() RoleAssignmentListResult { + return page.ralr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page RoleAssignmentListResultPage) Values() []RoleAssignment { + if page.ralr.IsEmpty() { + return nil + } + return *page.ralr.Value +} + +// Creates a new instance of the RoleAssignmentListResultPage type. +func NewRoleAssignmentListResultPage(getNextPage func(context.Context, RoleAssignmentListResult) (RoleAssignmentListResult, error)) RoleAssignmentListResultPage { + return RoleAssignmentListResultPage{fn: getNextPage} +} + +// RoleAssignmentProperties the properties of the role assignment. +type RoleAssignmentProperties struct { + // CreatedOn - READ-ONLY; The date the role assignment was created. + CreatedOn *string `json:"createdOn,omitempty"` + // CreatedByPrincipalTenantID - READ-ONLY; The tenant Id of the user who created the role assignment. + CreatedByPrincipalTenantID *string `json:"createdByPrincipalTenantId,omitempty"` + // CreatedByPrincipalID - READ-ONLY; The principal Id of the user who created the role assignment. + CreatedByPrincipalID *string `json:"createdByPrincipalId,omitempty"` + // CreatedByUserEmailAddress - READ-ONLY; The email address of the user who created the role assignment. + CreatedByUserEmailAddress *string `json:"createdByUserEmailAddress,omitempty"` + // PrincipalID - READ-ONLY; The principal id of the user to whom the role was assigned. + PrincipalID *string `json:"principalId,omitempty"` + // PrincipalTenantID - READ-ONLY; The principal tenant id of the user to whom the role was assigned. + PrincipalTenantID *string `json:"principalTenantId,omitempty"` + // RoleDefinitionID - READ-ONLY; The ID of the role definition. + RoleDefinitionID *string `json:"roleDefinitionId,omitempty"` + // Scope - READ-ONLY; The scope at which the role was assigned. + Scope *string `json:"scope,omitempty"` + // UserAuthenticationType - READ-ONLY; The authentication type. + UserAuthenticationType *string `json:"userAuthenticationType,omitempty"` + // UserEmailAddress - READ-ONLY; The email address of the user. + UserEmailAddress *string `json:"userEmailAddress,omitempty"` +} + +// RoleDefinition the properties of a role definition. +type RoleDefinition struct { + autorest.Response `json:"-"` + // RoleDefinitionProperties - The properties of the a role definition. + *RoleDefinitionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for RoleDefinition. +func (rd RoleDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if rd.RoleDefinitionProperties != nil { + objectMap["properties"] = rd.RoleDefinitionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for RoleDefinition struct. +func (rd *RoleDefinition) 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 roleDefinitionProperties RoleDefinitionProperties + err = json.Unmarshal(*v, &roleDefinitionProperties) + if err != nil { + return err + } + rd.RoleDefinitionProperties = &roleDefinitionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + rd.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + rd.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + rd.Type = &typeVar + } + } + } + + return nil +} + +// RoleDefinitionListResult the list of role definitions. +type RoleDefinitionListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The role definitions. + Value *[]RoleDefinition `json:"value,omitempty"` + // NextLink - READ-ONLY; The link (url) to the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// RoleDefinitionListResultIterator provides access to a complete listing of RoleDefinition values. +type RoleDefinitionListResultIterator struct { + i int + page RoleDefinitionListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *RoleDefinitionListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleDefinitionListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *RoleDefinitionListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter RoleDefinitionListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter RoleDefinitionListResultIterator) Response() RoleDefinitionListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter RoleDefinitionListResultIterator) Value() RoleDefinition { + if !iter.page.NotDone() { + return RoleDefinition{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the RoleDefinitionListResultIterator type. +func NewRoleDefinitionListResultIterator(page RoleDefinitionListResultPage) RoleDefinitionListResultIterator { + return RoleDefinitionListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (rdlr RoleDefinitionListResult) IsEmpty() bool { + return rdlr.Value == nil || len(*rdlr.Value) == 0 +} + +// roleDefinitionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (rdlr RoleDefinitionListResult) roleDefinitionListResultPreparer(ctx context.Context) (*http.Request, error) { + if rdlr.NextLink == nil || len(to.String(rdlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(rdlr.NextLink))) +} + +// RoleDefinitionListResultPage contains a page of RoleDefinition values. +type RoleDefinitionListResultPage struct { + fn func(context.Context, RoleDefinitionListResult) (RoleDefinitionListResult, error) + rdlr RoleDefinitionListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *RoleDefinitionListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleDefinitionListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.rdlr) + if err != nil { + return err + } + page.rdlr = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *RoleDefinitionListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page RoleDefinitionListResultPage) NotDone() bool { + return !page.rdlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page RoleDefinitionListResultPage) Response() RoleDefinitionListResult { + return page.rdlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page RoleDefinitionListResultPage) Values() []RoleDefinition { + if page.rdlr.IsEmpty() { + return nil + } + return *page.rdlr.Value +} + +// Creates a new instance of the RoleDefinitionListResultPage type. +func NewRoleDefinitionListResultPage(getNextPage func(context.Context, RoleDefinitionListResult) (RoleDefinitionListResult, error)) RoleDefinitionListResultPage { + return RoleDefinitionListResultPage{fn: getNextPage} +} + +// RoleDefinitionProperties the properties of the a role definition. +type RoleDefinitionProperties struct { + // Description - READ-ONLY; The role description + Description *string `json:"description,omitempty"` + // Permissions - The billingPermissions the role has + Permissions *[]PermissionsProperties `json:"permissions,omitempty"` + // RoleName - READ-ONLY; The name of the role + RoleName *string `json:"roleName,omitempty"` +} + +// Subscription a billing subscription. +type Subscription struct { + autorest.Response `json:"-"` + *SubscriptionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Subscription. +func (s Subscription) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if s.SubscriptionProperties != nil { + objectMap["properties"] = s.SubscriptionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Subscription struct. +func (s *Subscription) 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 subscriptionProperties SubscriptionProperties + err = json.Unmarshal(*v, &subscriptionProperties) + if err != nil { + return err + } + s.SubscriptionProperties = &subscriptionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + s.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + s.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + s.Type = &typeVar + } + } + } + + return nil +} + +// SubscriptionProperties the billing properties of a subscription. +type SubscriptionProperties struct { + // DisplayName - READ-ONLY; The name of the subscription. + DisplayName *string `json:"displayName,omitempty"` + // SubscriptionID - READ-ONLY; The ID of the subscription. + SubscriptionID *uuid.UUID `json:"subscriptionId,omitempty"` + // SubscriptionBillingStatus - The current billing status of the subscription. Possible values include: 'SubscriptionStatusTypeActive', 'SubscriptionStatusTypeInactive', 'SubscriptionStatusTypeAbandoned', 'SubscriptionStatusTypeDeleted', 'SubscriptionStatusTypeWarning' + SubscriptionBillingStatus SubscriptionStatusType `json:"subscriptionBillingStatus,omitempty"` + // LastMonthCharges - READ-ONLY; The last month charges. + LastMonthCharges *Amount `json:"lastMonthCharges,omitempty"` + // MonthToDateCharges - READ-ONLY; The current month to date charges. + MonthToDateCharges *Amount `json:"monthToDateCharges,omitempty"` + // BillingProfileID - READ-ONLY; The ID of the billing profile to which the subscription is billed. + BillingProfileID *string `json:"billingProfileId,omitempty"` + // BillingProfileDisplayName - READ-ONLY; The name of the billing profile to which the subscription is billed. + BillingProfileDisplayName *string `json:"billingProfileDisplayName,omitempty"` + // CostCenter - The cost center applied to the subscription. + CostCenter *string `json:"costCenter,omitempty"` + // CustomerID - READ-ONLY; The ID of the customer for whom the subscription was created. The field is applicable only for Microsoft Partner Agreement billing account. + CustomerID *string `json:"customerId,omitempty"` + // CustomerDisplayName - READ-ONLY; The name of the customer for whom the subscription was created. The field is applicable only for Microsoft Partner Agreement billing account. + CustomerDisplayName *string `json:"customerDisplayName,omitempty"` + // InvoiceSectionID - READ-ONLY; The ID of the invoice section to which the subscription is billed. + InvoiceSectionID *string `json:"invoiceSectionId,omitempty"` + // InvoiceSectionDisplayName - READ-ONLY; The name of the invoice section to which the subscription is billed. + InvoiceSectionDisplayName *string `json:"invoiceSectionDisplayName,omitempty"` + // Reseller - READ-ONLY; Reseller for this subscription. + Reseller *Reseller `json:"reseller,omitempty"` + // SkuID - The sku ID of the Azure plan for the subscription. + SkuID *string `json:"skuId,omitempty"` + // SkuDescription - READ-ONLY; The sku description of the Azure plan for the subscription. + SkuDescription *string `json:"skuDescription,omitempty"` +} + +// SubscriptionsListResult the list of billing subscriptions. +type SubscriptionsListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The list of billing subscriptions. + Value *[]Subscription `json:"value,omitempty"` + // NextLink - READ-ONLY; The link (url) to the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// SubscriptionsListResultIterator provides access to a complete listing of Subscription values. +type SubscriptionsListResultIterator struct { + i int + page SubscriptionsListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *SubscriptionsListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionsListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *SubscriptionsListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SubscriptionsListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter SubscriptionsListResultIterator) Response() SubscriptionsListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter SubscriptionsListResultIterator) Value() Subscription { + if !iter.page.NotDone() { + return Subscription{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SubscriptionsListResultIterator type. +func NewSubscriptionsListResultIterator(page SubscriptionsListResultPage) SubscriptionsListResultIterator { + return SubscriptionsListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (slr SubscriptionsListResult) IsEmpty() bool { + return slr.Value == nil || len(*slr.Value) == 0 +} + +// subscriptionsListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (slr SubscriptionsListResult) subscriptionsListResultPreparer(ctx context.Context) (*http.Request, error) { + if slr.NextLink == nil || len(to.String(slr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(slr.NextLink))) +} + +// SubscriptionsListResultPage contains a page of Subscription values. +type SubscriptionsListResultPage struct { + fn func(context.Context, SubscriptionsListResult) (SubscriptionsListResult, error) + slr SubscriptionsListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *SubscriptionsListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionsListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.slr) + if err != nil { + return err + } + page.slr = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *SubscriptionsListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SubscriptionsListResultPage) NotDone() bool { + return !page.slr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SubscriptionsListResultPage) Response() SubscriptionsListResult { + return page.slr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SubscriptionsListResultPage) Values() []Subscription { + if page.slr.IsEmpty() { + return nil + } + return *page.slr.Value +} + +// Creates a new instance of the SubscriptionsListResultPage type. +func NewSubscriptionsListResultPage(getNextPage func(context.Context, SubscriptionsListResult) (SubscriptionsListResult, error)) SubscriptionsListResultPage { + return SubscriptionsListResultPage{fn: getNextPage} +} + +// SubscriptionsMoveFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type SubscriptionsMoveFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *SubscriptionsMoveFuture) Result(client SubscriptionsClient) (s Subscription, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.SubscriptionsMoveFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("billing.SubscriptionsMoveFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if s.Response.Response, err = future.GetResult(sender); err == nil && s.Response.Response.StatusCode != http.StatusNoContent { + s, err = client.MoveResponder(s.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.SubscriptionsMoveFuture", "Result", s.Response.Response, "Failure responding to request") + } + } + return +} + +// Transaction a transaction. +type Transaction struct { + *TransactionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource Id. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type. + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for Transaction. +func (t Transaction) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if t.TransactionProperties != nil { + objectMap["properties"] = t.TransactionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Transaction struct. +func (t *Transaction) 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 transactionProperties TransactionProperties + err = json.Unmarshal(*v, &transactionProperties) + if err != nil { + return err + } + t.TransactionProperties = &transactionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + t.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + t.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + t.Type = &typeVar + } + } + } + + return nil +} + +// TransactionListResult the list of transactions. +type TransactionListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The list of transactions. + Value *[]Transaction `json:"value,omitempty"` + // NextLink - READ-ONLY; The link (url) to the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// TransactionListResultIterator provides access to a complete listing of Transaction values. +type TransactionListResultIterator struct { + i int + page TransactionListResultPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *TransactionListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TransactionListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *TransactionListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter TransactionListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter TransactionListResultIterator) Response() TransactionListResult { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter TransactionListResultIterator) Value() Transaction { + if !iter.page.NotDone() { + return Transaction{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the TransactionListResultIterator type. +func NewTransactionListResultIterator(page TransactionListResultPage) TransactionListResultIterator { + return TransactionListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (tlr TransactionListResult) IsEmpty() bool { + return tlr.Value == nil || len(*tlr.Value) == 0 +} + +// transactionListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (tlr TransactionListResult) transactionListResultPreparer(ctx context.Context) (*http.Request, error) { + if tlr.NextLink == nil || len(to.String(tlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(tlr.NextLink))) +} + +// TransactionListResultPage contains a page of Transaction values. +type TransactionListResultPage struct { + fn func(context.Context, TransactionListResult) (TransactionListResult, error) + tlr TransactionListResult +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *TransactionListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TransactionListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.tlr) + if err != nil { + return err + } + page.tlr = next + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *TransactionListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page TransactionListResultPage) NotDone() bool { + return !page.tlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page TransactionListResultPage) Response() TransactionListResult { + return page.tlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page TransactionListResultPage) Values() []Transaction { + if page.tlr.IsEmpty() { + return nil + } + return *page.tlr.Value +} + +// Creates a new instance of the TransactionListResultPage type. +func NewTransactionListResultPage(getNextPage func(context.Context, TransactionListResult) (TransactionListResult, error)) TransactionListResultPage { + return TransactionListResultPage{fn: getNextPage} +} + +// TransactionProperties the properties of a transaction. +type TransactionProperties struct { + // Kind - The kind of transaction. Options are all or reservation. Possible values include: 'All', 'Reservation' + Kind TransactionTypeKind `json:"kind,omitempty"` + // Date - READ-ONLY; The date of transaction. + Date *date.Time `json:"date,omitempty"` + // Invoice - READ-ONLY; Invoice on which the transaction was billed or 'pending' if the transaction is not billed. + Invoice *string `json:"invoice,omitempty"` + // InvoiceID - READ-ONLY; The ID of the invoice on which the transaction was billed. This field is only applicable for transactions which are billed. + InvoiceID *string `json:"invoiceId,omitempty"` + // OrderID - READ-ONLY; The order ID of the reservation. The field is only applicable for transaction of kind reservation. + OrderID *string `json:"orderId,omitempty"` + // OrderName - READ-ONLY; The name of the reservation order. The field is only applicable for transactions of kind reservation. + OrderName *string `json:"orderName,omitempty"` + // ProductFamily - READ-ONLY; The family of the product for which the transaction took place. + ProductFamily *string `json:"productFamily,omitempty"` + // ProductTypeID - READ-ONLY; The ID of the product type for which the transaction took place. + ProductTypeID *string `json:"productTypeId,omitempty"` + // ProductType - READ-ONLY; The type of the product for which the transaction took place. + ProductType *string `json:"productType,omitempty"` + // ProductDescription - READ-ONLY; The description of the product for which the transaction took place. + ProductDescription *string `json:"productDescription,omitempty"` + // TransactionType - The type of transaction. Possible values include: 'Purchase', 'UsageCharge' + TransactionType ReservationType `json:"transactionType,omitempty"` + // TransactionAmount - READ-ONLY; The charge associated with the transaction. + TransactionAmount *Amount `json:"transactionAmount,omitempty"` + // Quantity - READ-ONLY; The quantity purchased in the transaction. + Quantity *int32 `json:"quantity,omitempty"` + // InvoiceSectionID - READ-ONLY; The ID of the invoice section which will be billed for the transaction. + InvoiceSectionID *string `json:"invoiceSectionId,omitempty"` + // InvoiceSectionDisplayName - READ-ONLY; The name of the invoice section which will be billed for the transaction. + InvoiceSectionDisplayName *string `json:"invoiceSectionDisplayName,omitempty"` + // BillingProfileID - READ-ONLY; The ID of the billing profile which will be billed for the transaction. + BillingProfileID *string `json:"billingProfileId,omitempty"` + // BillingProfileDisplayName - READ-ONLY; The name of the billing profile which will be billed for the transaction. + BillingProfileDisplayName *string `json:"billingProfileDisplayName,omitempty"` + // CustomerID - READ-ONLY; The ID of the customer for which the transaction took place. The field is applicable only for Microsoft Partner Agreement billing account. + CustomerID *string `json:"customerId,omitempty"` + // CustomerDisplayName - READ-ONLY; The name of the customer for which the transaction took place. The field is applicable only for Microsoft Partner Agreement billing account. + CustomerDisplayName *string `json:"customerDisplayName,omitempty"` + // SubscriptionID - READ-ONLY; The ID of the subscription that was used for the transaction. The field is only applicable for transaction of kind reservation. + SubscriptionID *string `json:"subscriptionId,omitempty"` + // SubscriptionName - READ-ONLY; The name of the subscription that was used for the transaction. The field is only applicable for transaction of kind reservation. + SubscriptionName *string `json:"subscriptionName,omitempty"` + // AzurePlan - READ-ONLY; The type of azure plan of the subscription that was used for the transaction. + AzurePlan *string `json:"azurePlan,omitempty"` + // AzureCreditApplied - READ-ONLY; The amount of any Azure credits automatically applied to this transaction. + AzureCreditApplied *Amount `json:"azureCreditApplied,omitempty"` + // BillingCurrency - READ-ONLY; The ISO 4217 code for the currency in which this transaction is billed. + BillingCurrency *string `json:"billingCurrency,omitempty"` + // Discount - READ-ONLY; The percentage discount, if any, applied to this transaction. + Discount *float64 `json:"discount,omitempty"` + // EffectivePrice - READ-ONLY; The price of the product after applying any discounts. + EffectivePrice *Amount `json:"effectivePrice,omitempty"` + // ExchangeRate - READ-ONLY; The exchange rate used to convert charged amount to billing currency, if applicable. + ExchangeRate *float64 `json:"exchangeRate,omitempty"` + // MarketPrice - READ-ONLY; The retail price of the product. + MarketPrice *Amount `json:"marketPrice,omitempty"` + // PricingCurrency - READ-ONLY; The ISO 4217 code for the currency in which the product is priced. + PricingCurrency *string `json:"pricingCurrency,omitempty"` + // ServicePeriodStartDate - READ-ONLY; The date of the purchase of the product, or the start date of the month in which usage started. + ServicePeriodStartDate *date.Time `json:"servicePeriodStartDate,omitempty"` + // ServicePeriodEndDate - READ-ONLY; The end date of the product term, or the end date of the month in which usage ended. + ServicePeriodEndDate *date.Time `json:"servicePeriodEndDate,omitempty"` + // SubTotal - READ-ONLY; The pre-tax charged amount for the transaction. + SubTotal *Amount `json:"subTotal,omitempty"` + // Tax - READ-ONLY; The tax amount applied to the transaction. + Tax *Amount `json:"tax,omitempty"` + // UnitOfMeasure - READ-ONLY; The unit of measure used to bill for the product. For example, compute services are billed per hour. + UnitOfMeasure *string `json:"unitOfMeasure,omitempty"` + // Units - READ-ONLY; The number of units used for a given product. + Units *float64 `json:"units,omitempty"` + // UnitType - READ-ONLY; The description for the unit of measure for a given product. + UnitType *string `json:"unitType,omitempty"` +} + +// TransferBillingSubscriptionRequestProperties request parameters to transfer billing subscription. +type TransferBillingSubscriptionRequestProperties struct { + // DestinationInvoiceSectionID - The destination invoice section id. + DestinationInvoiceSectionID *string `json:"destinationInvoiceSectionId,omitempty"` +} + +// TransferProductRequestProperties the properties of the product to initiate a transfer. +type TransferProductRequestProperties struct { + // DestinationInvoiceSectionID - The destination invoice section id. + DestinationInvoiceSectionID *string `json:"destinationInvoiceSectionId,omitempty"` +} + +// ValidateAddressResponse result of the address validation +type ValidateAddressResponse struct { + autorest.Response `json:"-"` + // Status - status of the address validation. Possible values include: 'Valid', 'Invalid' + Status AddressValidationStatus `json:"status,omitempty"` + // SuggestedAddresses - The list of suggested addresses. + SuggestedAddresses *[]AddressDetails `json:"suggestedAddresses,omitempty"` + // ValidationMessage - Validation error message. + ValidationMessage *string `json:"validationMessage,omitempty"` +} + +// ValidateProductTransferEligibilityError error details of the product transfer eligibility validation. +type ValidateProductTransferEligibilityError struct { + // Code - Error code for the product transfer validation. Possible values include: 'InvalidSource', 'ProductNotActive', 'InsufficientPermissionOnSource', 'InsufficientPermissionOnDestination', 'DestinationBillingProfilePastDue', 'ProductTypeNotSupported', 'CrossBillingAccountNotAllowed', 'NotAvailableForDestinationMarket', 'OneTimePurchaseProductTransferNotAllowed' + Code ProductTransferValidationErrorCode `json:"code,omitempty"` + // Message - The error message. + Message *string `json:"message,omitempty"` + // Details - Detailed error message explaining the error. + Details *string `json:"details,omitempty"` +} + +// ValidateProductTransferEligibilityResult result of the product transfer eligibility validation. +type ValidateProductTransferEligibilityResult struct { + autorest.Response `json:"-"` + // IsMoveEligible - READ-ONLY; Specifies whether the transfer is eligible or not. + IsMoveEligible *bool `json:"isMoveEligible,omitempty"` + // ErrorDetails - Validation error details. + ErrorDetails *ValidateProductTransferEligibilityError `json:"errorDetails,omitempty"` +} + +// ValidateSubscriptionTransferEligibilityError error details of the transfer eligibility validation +type ValidateSubscriptionTransferEligibilityError struct { + // Code - Error code for the product transfer validation. Possible values include: 'SubscriptionTransferValidationErrorCodeInvalidSource', 'SubscriptionTransferValidationErrorCodeSubscriptionNotActive', 'SubscriptionTransferValidationErrorCodeInsufficientPermissionOnSource', 'SubscriptionTransferValidationErrorCodeInsufficientPermissionOnDestination', 'SubscriptionTransferValidationErrorCodeDestinationBillingProfilePastDue', 'SubscriptionTransferValidationErrorCodeSubscriptionTypeNotSupported', 'SubscriptionTransferValidationErrorCodeCrossBillingAccountNotAllowed', 'SubscriptionTransferValidationErrorCodeNotAvailableForDestinationMarket' + Code SubscriptionTransferValidationErrorCode `json:"code,omitempty"` + // Message - The error message. + Message *string `json:"message,omitempty"` + // Details - Detailed error message explaining the error. + Details *string `json:"details,omitempty"` +} + +// ValidateSubscriptionTransferEligibilityResult result of the transfer eligibility validation. +type ValidateSubscriptionTransferEligibilityResult struct { + autorest.Response `json:"-"` + // IsMoveEligible - READ-ONLY; Specifies whether the subscription is eligible to be transferred. + IsMoveEligible *bool `json:"isMoveEligible,omitempty"` + // ErrorDetails - Validation error details. + ErrorDetails *ValidateSubscriptionTransferEligibilityError `json:"errorDetails,omitempty"` +} diff --git a/services/preview/billing/mgmt/2020-05-01-preview/billing/operations.go b/services/preview/billing/mgmt/2020-05-01-preview/billing/operations.go new file mode 100644 index 000000000000..a933ad2af01e --- /dev/null +++ b/services/preview/billing/mgmt/2020-05-01-preview/billing/operations.go @@ -0,0 +1,146 @@ +package billing + +// 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/tracing" + "net/http" +) + +// OperationsClient is the billing client provides access to billing resources for Azure subscriptions. +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists the available billing REST API operations. +func (client OperationsClient) List(ctx context.Context) (result OperationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.olr.Response.Response != nil { + sc = result.olr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.olr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.olr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.OperationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Billing/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client OperationsClient) listNextResults(ctx context.Context, lastResults OperationListResult) (result OperationListResult, err error) { + req, err := lastResults.operationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.OperationsClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.OperationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OperationsClient) ListComplete(ctx context.Context) (result OperationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return +} diff --git a/services/preview/billing/mgmt/2020-05-01-preview/billing/permissions.go b/services/preview/billing/mgmt/2020-05-01-preview/billing/permissions.go new file mode 100644 index 000000000000..5dc7ddf4d9be --- /dev/null +++ b/services/preview/billing/mgmt/2020-05-01-preview/billing/permissions.go @@ -0,0 +1,490 @@ +package billing + +// 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/tracing" + "net/http" +) + +// PermissionsClient is the billing client provides access to billing resources for Azure subscriptions. +type PermissionsClient struct { + BaseClient +} + +// NewPermissionsClient creates an instance of the PermissionsClient client. +func NewPermissionsClient(subscriptionID string) PermissionsClient { + return NewPermissionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPermissionsClientWithBaseURI creates an instance of the PermissionsClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewPermissionsClientWithBaseURI(baseURI string, subscriptionID string) PermissionsClient { + return PermissionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByBillingAccount lists the billing permissions the caller has on a billing account. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +func (client PermissionsClient) ListByBillingAccount(ctx context.Context, billingAccountName string) (result PermissionsListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PermissionsClient.ListByBillingAccount") + defer func() { + sc := -1 + if result.plr.Response.Response != nil { + sc = result.plr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByBillingAccountNextResults + req, err := client.ListByBillingAccountPreparer(ctx, billingAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PermissionsClient", "ListByBillingAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByBillingAccountSender(req) + if err != nil { + result.plr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.PermissionsClient", "ListByBillingAccount", resp, "Failure sending request") + return + } + + result.plr, err = client.ListByBillingAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PermissionsClient", "ListByBillingAccount", resp, "Failure responding to request") + } + + return +} + +// ListByBillingAccountPreparer prepares the ListByBillingAccount request. +func (client PermissionsClient) ListByBillingAccountPreparer(ctx context.Context, billingAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingPermissions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByBillingAccountSender sends the ListByBillingAccount request. The method will close the +// http.Response Body if it receives an error. +func (client PermissionsClient) ListByBillingAccountSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListByBillingAccountResponder handles the response to the ListByBillingAccount request. The method always +// closes the http.Response Body. +func (client PermissionsClient) ListByBillingAccountResponder(resp *http.Response) (result PermissionsListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByBillingAccountNextResults retrieves the next set of results, if any. +func (client PermissionsClient) listByBillingAccountNextResults(ctx context.Context, lastResults PermissionsListResult) (result PermissionsListResult, err error) { + req, err := lastResults.permissionsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.PermissionsClient", "listByBillingAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByBillingAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.PermissionsClient", "listByBillingAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByBillingAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PermissionsClient", "listByBillingAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByBillingAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client PermissionsClient) ListByBillingAccountComplete(ctx context.Context, billingAccountName string) (result PermissionsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PermissionsClient.ListByBillingAccount") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByBillingAccount(ctx, billingAccountName) + return +} + +// ListByBillingProfile lists the billing permissions the caller has on a billing profile. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// billingProfileName - the ID that uniquely identifies a billing profile. +func (client PermissionsClient) ListByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string) (result PermissionsListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PermissionsClient.ListByBillingProfile") + defer func() { + sc := -1 + if result.plr.Response.Response != nil { + sc = result.plr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByBillingProfileNextResults + req, err := client.ListByBillingProfilePreparer(ctx, billingAccountName, billingProfileName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PermissionsClient", "ListByBillingProfile", nil, "Failure preparing request") + return + } + + resp, err := client.ListByBillingProfileSender(req) + if err != nil { + result.plr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.PermissionsClient", "ListByBillingProfile", resp, "Failure sending request") + return + } + + result.plr, err = client.ListByBillingProfileResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PermissionsClient", "ListByBillingProfile", resp, "Failure responding to request") + } + + return +} + +// ListByBillingProfilePreparer prepares the ListByBillingProfile request. +func (client PermissionsClient) ListByBillingProfilePreparer(ctx context.Context, billingAccountName string, billingProfileName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingProfileName": autorest.Encode("path", billingProfileName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingPermissions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByBillingProfileSender sends the ListByBillingProfile request. The method will close the +// http.Response Body if it receives an error. +func (client PermissionsClient) ListByBillingProfileSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListByBillingProfileResponder handles the response to the ListByBillingProfile request. The method always +// closes the http.Response Body. +func (client PermissionsClient) ListByBillingProfileResponder(resp *http.Response) (result PermissionsListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByBillingProfileNextResults retrieves the next set of results, if any. +func (client PermissionsClient) listByBillingProfileNextResults(ctx context.Context, lastResults PermissionsListResult) (result PermissionsListResult, err error) { + req, err := lastResults.permissionsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.PermissionsClient", "listByBillingProfileNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByBillingProfileSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.PermissionsClient", "listByBillingProfileNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByBillingProfileResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PermissionsClient", "listByBillingProfileNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByBillingProfileComplete enumerates all values, automatically crossing page boundaries as required. +func (client PermissionsClient) ListByBillingProfileComplete(ctx context.Context, billingAccountName string, billingProfileName string) (result PermissionsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PermissionsClient.ListByBillingProfile") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByBillingProfile(ctx, billingAccountName, billingProfileName) + return +} + +// ListByCustomer lists the billing permissions the caller has for a customer. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// customerName - the ID that uniquely identifies a customer. +func (client PermissionsClient) ListByCustomer(ctx context.Context, billingAccountName string, customerName string) (result PermissionsListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PermissionsClient.ListByCustomer") + defer func() { + sc := -1 + if result.plr.Response.Response != nil { + sc = result.plr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByCustomerNextResults + req, err := client.ListByCustomerPreparer(ctx, billingAccountName, customerName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PermissionsClient", "ListByCustomer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByCustomerSender(req) + if err != nil { + result.plr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.PermissionsClient", "ListByCustomer", resp, "Failure sending request") + return + } + + result.plr, err = client.ListByCustomerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PermissionsClient", "ListByCustomer", resp, "Failure responding to request") + } + + return +} + +// ListByCustomerPreparer prepares the ListByCustomer request. +func (client PermissionsClient) ListByCustomerPreparer(ctx context.Context, billingAccountName string, customerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "customerName": autorest.Encode("path", customerName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/billingPermissions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByCustomerSender sends the ListByCustomer request. The method will close the +// http.Response Body if it receives an error. +func (client PermissionsClient) ListByCustomerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListByCustomerResponder handles the response to the ListByCustomer request. The method always +// closes the http.Response Body. +func (client PermissionsClient) ListByCustomerResponder(resp *http.Response) (result PermissionsListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByCustomerNextResults retrieves the next set of results, if any. +func (client PermissionsClient) listByCustomerNextResults(ctx context.Context, lastResults PermissionsListResult) (result PermissionsListResult, err error) { + req, err := lastResults.permissionsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.PermissionsClient", "listByCustomerNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByCustomerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.PermissionsClient", "listByCustomerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByCustomerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PermissionsClient", "listByCustomerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByCustomerComplete enumerates all values, automatically crossing page boundaries as required. +func (client PermissionsClient) ListByCustomerComplete(ctx context.Context, billingAccountName string, customerName string) (result PermissionsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PermissionsClient.ListByCustomer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByCustomer(ctx, billingAccountName, customerName) + return +} + +// ListByInvoiceSections lists the billing permissions the caller has on an invoice section. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// billingProfileName - the ID that uniquely identifies a billing profile. +// invoiceSectionName - the ID that uniquely identifies an invoice section. +func (client PermissionsClient) ListByInvoiceSections(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string) (result PermissionsListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PermissionsClient.ListByInvoiceSections") + defer func() { + sc := -1 + if result.plr.Response.Response != nil { + sc = result.plr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByInvoiceSectionsNextResults + req, err := client.ListByInvoiceSectionsPreparer(ctx, billingAccountName, billingProfileName, invoiceSectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PermissionsClient", "ListByInvoiceSections", nil, "Failure preparing request") + return + } + + resp, err := client.ListByInvoiceSectionsSender(req) + if err != nil { + result.plr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.PermissionsClient", "ListByInvoiceSections", resp, "Failure sending request") + return + } + + result.plr, err = client.ListByInvoiceSectionsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PermissionsClient", "ListByInvoiceSections", resp, "Failure responding to request") + } + + return +} + +// ListByInvoiceSectionsPreparer prepares the ListByInvoiceSections request. +func (client PermissionsClient) ListByInvoiceSectionsPreparer(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingProfileName": autorest.Encode("path", billingProfileName), + "invoiceSectionName": autorest.Encode("path", invoiceSectionName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingPermissions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByInvoiceSectionsSender sends the ListByInvoiceSections request. The method will close the +// http.Response Body if it receives an error. +func (client PermissionsClient) ListByInvoiceSectionsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListByInvoiceSectionsResponder handles the response to the ListByInvoiceSections request. The method always +// closes the http.Response Body. +func (client PermissionsClient) ListByInvoiceSectionsResponder(resp *http.Response) (result PermissionsListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByInvoiceSectionsNextResults retrieves the next set of results, if any. +func (client PermissionsClient) listByInvoiceSectionsNextResults(ctx context.Context, lastResults PermissionsListResult) (result PermissionsListResult, err error) { + req, err := lastResults.permissionsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.PermissionsClient", "listByInvoiceSectionsNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByInvoiceSectionsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.PermissionsClient", "listByInvoiceSectionsNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByInvoiceSectionsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PermissionsClient", "listByInvoiceSectionsNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByInvoiceSectionsComplete enumerates all values, automatically crossing page boundaries as required. +func (client PermissionsClient) ListByInvoiceSectionsComplete(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string) (result PermissionsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PermissionsClient.ListByInvoiceSections") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByInvoiceSections(ctx, billingAccountName, billingProfileName, invoiceSectionName) + return +} diff --git a/services/preview/billing/mgmt/2020-05-01-preview/billing/policies.go b/services/preview/billing/mgmt/2020-05-01-preview/billing/policies.go new file mode 100644 index 000000000000..bb26fafdd9f0 --- /dev/null +++ b/services/preview/billing/mgmt/2020-05-01-preview/billing/policies.go @@ -0,0 +1,348 @@ +package billing + +// 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/tracing" + "net/http" +) + +// PoliciesClient is the billing client provides access to billing resources for Azure subscriptions. +type PoliciesClient struct { + BaseClient +} + +// NewPoliciesClient creates an instance of the PoliciesClient client. +func NewPoliciesClient(subscriptionID string) PoliciesClient { + return NewPoliciesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPoliciesClientWithBaseURI creates an instance of the PoliciesClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewPoliciesClientWithBaseURI(baseURI string, subscriptionID string) PoliciesClient { + return PoliciesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// GetByBillingProfile lists the policies for a billing profile. This operation is supported only for billing accounts +// with agreement type Microsoft Customer Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// billingProfileName - the ID that uniquely identifies a billing profile. +func (client PoliciesClient) GetByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string) (result Policy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PoliciesClient.GetByBillingProfile") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetByBillingProfilePreparer(ctx, billingAccountName, billingProfileName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PoliciesClient", "GetByBillingProfile", nil, "Failure preparing request") + return + } + + resp, err := client.GetByBillingProfileSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.PoliciesClient", "GetByBillingProfile", resp, "Failure sending request") + return + } + + result, err = client.GetByBillingProfileResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PoliciesClient", "GetByBillingProfile", resp, "Failure responding to request") + } + + return +} + +// GetByBillingProfilePreparer prepares the GetByBillingProfile request. +func (client PoliciesClient) GetByBillingProfilePreparer(ctx context.Context, billingAccountName string, billingProfileName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingProfileName": autorest.Encode("path", billingProfileName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/policies/default", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetByBillingProfileSender sends the GetByBillingProfile request. The method will close the +// http.Response Body if it receives an error. +func (client PoliciesClient) GetByBillingProfileSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetByBillingProfileResponder handles the response to the GetByBillingProfile request. The method always +// closes the http.Response Body. +func (client PoliciesClient) GetByBillingProfileResponder(resp *http.Response) (result Policy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetByCustomer lists the policies for a customer. This operation is supported only for billing accounts with +// agreement type Microsoft Partner Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// customerName - the ID that uniquely identifies a customer. +func (client PoliciesClient) GetByCustomer(ctx context.Context, billingAccountName string, customerName string) (result CustomerPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PoliciesClient.GetByCustomer") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetByCustomerPreparer(ctx, billingAccountName, customerName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PoliciesClient", "GetByCustomer", nil, "Failure preparing request") + return + } + + resp, err := client.GetByCustomerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.PoliciesClient", "GetByCustomer", resp, "Failure sending request") + return + } + + result, err = client.GetByCustomerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PoliciesClient", "GetByCustomer", resp, "Failure responding to request") + } + + return +} + +// GetByCustomerPreparer prepares the GetByCustomer request. +func (client PoliciesClient) GetByCustomerPreparer(ctx context.Context, billingAccountName string, customerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "customerName": autorest.Encode("path", customerName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/policies/default", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetByCustomerSender sends the GetByCustomer request. The method will close the +// http.Response Body if it receives an error. +func (client PoliciesClient) GetByCustomerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetByCustomerResponder handles the response to the GetByCustomer request. The method always +// closes the http.Response Body. +func (client PoliciesClient) GetByCustomerResponder(resp *http.Response) (result CustomerPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates the policies for a billing profile. This operation is supported only for billing accounts with +// agreement type Microsoft Customer Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// billingProfileName - the ID that uniquely identifies a billing profile. +// parameters - request parameters that are provided to the update policies operation. +func (client PoliciesClient) Update(ctx context.Context, billingAccountName string, billingProfileName string, parameters Policy) (result Policy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PoliciesClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, billingAccountName, billingProfileName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PoliciesClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.PoliciesClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PoliciesClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client PoliciesClient) UpdatePreparer(ctx context.Context, billingAccountName string, billingProfileName string, parameters Policy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingProfileName": autorest.Encode("path", billingProfileName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/policies/default", pathParameters), + autorest.WithJSON(parameters), + 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 PoliciesClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client PoliciesClient) UpdateResponder(resp *http.Response) (result Policy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// UpdateCustomer updates the policies for a customer. This operation is supported only for billing accounts with +// agreement type Microsoft Partner Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// customerName - the ID that uniquely identifies a customer. +// parameters - request parameters that are provided to the update policies operation. +func (client PoliciesClient) UpdateCustomer(ctx context.Context, billingAccountName string, customerName string, parameters CustomerPolicy) (result CustomerPolicy, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PoliciesClient.UpdateCustomer") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdateCustomerPreparer(ctx, billingAccountName, customerName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PoliciesClient", "UpdateCustomer", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateCustomerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.PoliciesClient", "UpdateCustomer", resp, "Failure sending request") + return + } + + result, err = client.UpdateCustomerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PoliciesClient", "UpdateCustomer", resp, "Failure responding to request") + } + + return +} + +// UpdateCustomerPreparer prepares the UpdateCustomer request. +func (client PoliciesClient) UpdateCustomerPreparer(ctx context.Context, billingAccountName string, customerName string, parameters CustomerPolicy) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "customerName": autorest.Encode("path", customerName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/policies/default", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateCustomerSender sends the UpdateCustomer request. The method will close the +// http.Response Body if it receives an error. +func (client PoliciesClient) UpdateCustomerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// UpdateCustomerResponder handles the response to the UpdateCustomer request. The method always +// closes the http.Response Body. +func (client PoliciesClient) UpdateCustomerResponder(resp *http.Response) (result CustomerPolicy, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/billing/mgmt/2020-05-01-preview/billing/products.go b/services/preview/billing/mgmt/2020-05-01-preview/billing/products.go new file mode 100644 index 000000000000..06bc94ad3a1e --- /dev/null +++ b/services/preview/billing/mgmt/2020-05-01-preview/billing/products.go @@ -0,0 +1,825 @@ +package billing + +// 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/tracing" + "net/http" +) + +// ProductsClient is the billing client provides access to billing resources for Azure subscriptions. +type ProductsClient struct { + BaseClient +} + +// NewProductsClient creates an instance of the ProductsClient client. +func NewProductsClient(subscriptionID string) ProductsClient { + return NewProductsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewProductsClientWithBaseURI creates an instance of the ProductsClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewProductsClientWithBaseURI(baseURI string, subscriptionID string) ProductsClient { + return ProductsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a product by ID. The operation is supported only for billing accounts with agreement type Microsoft +// Customer Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// productName - the ID that uniquely identifies a product. +func (client ProductsClient) Get(ctx context.Context, billingAccountName string, productName string) (result Product, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, billingAccountName, productName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProductsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.ProductsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProductsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ProductsClient) GetPreparer(ctx context.Context, billingAccountName string, productName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "productName": autorest.Encode("path", productName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/products/{productName}", 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 ProductsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ProductsClient) GetResponder(resp *http.Response) (result Product, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByBillingAccount lists the products for a billing account. These don't include products billed based on usage. +// The operation is supported for billing accounts with agreement type Microsoft Customer Agreement or Microsoft +// Partner Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// filter - may be used to filter by product type. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. +// It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and +// value are separated by a colon (:). +func (client ProductsClient) ListByBillingAccount(ctx context.Context, billingAccountName string, filter string) (result ProductsListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductsClient.ListByBillingAccount") + defer func() { + sc := -1 + if result.plr.Response.Response != nil { + sc = result.plr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByBillingAccountNextResults + req, err := client.ListByBillingAccountPreparer(ctx, billingAccountName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProductsClient", "ListByBillingAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByBillingAccountSender(req) + if err != nil { + result.plr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.ProductsClient", "ListByBillingAccount", resp, "Failure sending request") + return + } + + result.plr, err = client.ListByBillingAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProductsClient", "ListByBillingAccount", resp, "Failure responding to request") + } + + return +} + +// ListByBillingAccountPreparer prepares the ListByBillingAccount request. +func (client ProductsClient) ListByBillingAccountPreparer(ctx context.Context, billingAccountName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/products", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByBillingAccountSender sends the ListByBillingAccount request. The method will close the +// http.Response Body if it receives an error. +func (client ProductsClient) ListByBillingAccountSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListByBillingAccountResponder handles the response to the ListByBillingAccount request. The method always +// closes the http.Response Body. +func (client ProductsClient) ListByBillingAccountResponder(resp *http.Response) (result ProductsListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByBillingAccountNextResults retrieves the next set of results, if any. +func (client ProductsClient) listByBillingAccountNextResults(ctx context.Context, lastResults ProductsListResult) (result ProductsListResult, err error) { + req, err := lastResults.productsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.ProductsClient", "listByBillingAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByBillingAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.ProductsClient", "listByBillingAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByBillingAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProductsClient", "listByBillingAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByBillingAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client ProductsClient) ListByBillingAccountComplete(ctx context.Context, billingAccountName string, filter string) (result ProductsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductsClient.ListByBillingAccount") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByBillingAccount(ctx, billingAccountName, filter) + return +} + +// ListByBillingProfile lists the products for a billing profile. These don't include products billed based on usage. +// The operation is supported for billing accounts with agreement type Microsoft Customer Agreement or Microsoft +// Partner Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// billingProfileName - the ID that uniquely identifies a billing profile. +// filter - may be used to filter by product type. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. +// It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and +// value are separated by a colon (:). +func (client ProductsClient) ListByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string, filter string) (result ProductsListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductsClient.ListByBillingProfile") + defer func() { + sc := -1 + if result.plr.Response.Response != nil { + sc = result.plr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByBillingProfileNextResults + req, err := client.ListByBillingProfilePreparer(ctx, billingAccountName, billingProfileName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProductsClient", "ListByBillingProfile", nil, "Failure preparing request") + return + } + + resp, err := client.ListByBillingProfileSender(req) + if err != nil { + result.plr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.ProductsClient", "ListByBillingProfile", resp, "Failure sending request") + return + } + + result.plr, err = client.ListByBillingProfileResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProductsClient", "ListByBillingProfile", resp, "Failure responding to request") + } + + return +} + +// ListByBillingProfilePreparer prepares the ListByBillingProfile request. +func (client ProductsClient) ListByBillingProfilePreparer(ctx context.Context, billingAccountName string, billingProfileName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingProfileName": autorest.Encode("path", billingProfileName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/products", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByBillingProfileSender sends the ListByBillingProfile request. The method will close the +// http.Response Body if it receives an error. +func (client ProductsClient) ListByBillingProfileSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListByBillingProfileResponder handles the response to the ListByBillingProfile request. The method always +// closes the http.Response Body. +func (client ProductsClient) ListByBillingProfileResponder(resp *http.Response) (result ProductsListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByBillingProfileNextResults retrieves the next set of results, if any. +func (client ProductsClient) listByBillingProfileNextResults(ctx context.Context, lastResults ProductsListResult) (result ProductsListResult, err error) { + req, err := lastResults.productsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.ProductsClient", "listByBillingProfileNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByBillingProfileSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.ProductsClient", "listByBillingProfileNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByBillingProfileResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProductsClient", "listByBillingProfileNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByBillingProfileComplete enumerates all values, automatically crossing page boundaries as required. +func (client ProductsClient) ListByBillingProfileComplete(ctx context.Context, billingAccountName string, billingProfileName string, filter string) (result ProductsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductsClient.ListByBillingProfile") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByBillingProfile(ctx, billingAccountName, billingProfileName, filter) + return +} + +// ListByCustomer lists the products for a customer. These don't include products billed based on usage.The operation +// is supported only for billing accounts with agreement type Microsoft Partner Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// customerName - the ID that uniquely identifies a customer. +func (client ProductsClient) ListByCustomer(ctx context.Context, billingAccountName string, customerName string) (result ProductsListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductsClient.ListByCustomer") + defer func() { + sc := -1 + if result.plr.Response.Response != nil { + sc = result.plr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByCustomerNextResults + req, err := client.ListByCustomerPreparer(ctx, billingAccountName, customerName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProductsClient", "ListByCustomer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByCustomerSender(req) + if err != nil { + result.plr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.ProductsClient", "ListByCustomer", resp, "Failure sending request") + return + } + + result.plr, err = client.ListByCustomerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProductsClient", "ListByCustomer", resp, "Failure responding to request") + } + + return +} + +// ListByCustomerPreparer prepares the ListByCustomer request. +func (client ProductsClient) ListByCustomerPreparer(ctx context.Context, billingAccountName string, customerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "customerName": autorest.Encode("path", customerName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/products", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByCustomerSender sends the ListByCustomer request. The method will close the +// http.Response Body if it receives an error. +func (client ProductsClient) ListByCustomerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListByCustomerResponder handles the response to the ListByCustomer request. The method always +// closes the http.Response Body. +func (client ProductsClient) ListByCustomerResponder(resp *http.Response) (result ProductsListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByCustomerNextResults retrieves the next set of results, if any. +func (client ProductsClient) listByCustomerNextResults(ctx context.Context, lastResults ProductsListResult) (result ProductsListResult, err error) { + req, err := lastResults.productsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.ProductsClient", "listByCustomerNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByCustomerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.ProductsClient", "listByCustomerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByCustomerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProductsClient", "listByCustomerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByCustomerComplete enumerates all values, automatically crossing page boundaries as required. +func (client ProductsClient) ListByCustomerComplete(ctx context.Context, billingAccountName string, customerName string) (result ProductsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductsClient.ListByCustomer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByCustomer(ctx, billingAccountName, customerName) + return +} + +// ListByInvoiceSection lists the products for an invoice section. These don't include products billed based on usage. +// The operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// billingProfileName - the ID that uniquely identifies a billing profile. +// invoiceSectionName - the ID that uniquely identifies an invoice section. +// filter - may be used to filter by product type. The filter supports 'eq', 'lt', 'gt', 'le', 'ge', and 'and'. +// It does not currently support 'ne', 'or', or 'not'. Tag filter is a key value pair string where key and +// value are separated by a colon (:). +func (client ProductsClient) ListByInvoiceSection(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, filter string) (result ProductsListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductsClient.ListByInvoiceSection") + defer func() { + sc := -1 + if result.plr.Response.Response != nil { + sc = result.plr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByInvoiceSectionNextResults + req, err := client.ListByInvoiceSectionPreparer(ctx, billingAccountName, billingProfileName, invoiceSectionName, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProductsClient", "ListByInvoiceSection", nil, "Failure preparing request") + return + } + + resp, err := client.ListByInvoiceSectionSender(req) + if err != nil { + result.plr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.ProductsClient", "ListByInvoiceSection", resp, "Failure sending request") + return + } + + result.plr, err = client.ListByInvoiceSectionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProductsClient", "ListByInvoiceSection", resp, "Failure responding to request") + } + + return +} + +// ListByInvoiceSectionPreparer prepares the ListByInvoiceSection request. +func (client ProductsClient) ListByInvoiceSectionPreparer(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingProfileName": autorest.Encode("path", billingProfileName), + "invoiceSectionName": autorest.Encode("path", invoiceSectionName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/products", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByInvoiceSectionSender sends the ListByInvoiceSection request. The method will close the +// http.Response Body if it receives an error. +func (client ProductsClient) ListByInvoiceSectionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListByInvoiceSectionResponder handles the response to the ListByInvoiceSection request. The method always +// closes the http.Response Body. +func (client ProductsClient) ListByInvoiceSectionResponder(resp *http.Response) (result ProductsListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByInvoiceSectionNextResults retrieves the next set of results, if any. +func (client ProductsClient) listByInvoiceSectionNextResults(ctx context.Context, lastResults ProductsListResult) (result ProductsListResult, err error) { + req, err := lastResults.productsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.ProductsClient", "listByInvoiceSectionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByInvoiceSectionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.ProductsClient", "listByInvoiceSectionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByInvoiceSectionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProductsClient", "listByInvoiceSectionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByInvoiceSectionComplete enumerates all values, automatically crossing page boundaries as required. +func (client ProductsClient) ListByInvoiceSectionComplete(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, filter string) (result ProductsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductsClient.ListByInvoiceSection") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByInvoiceSection(ctx, billingAccountName, billingProfileName, invoiceSectionName, filter) + return +} + +// Move moves a product's charges to a new invoice section. The new invoice section must belong to the same billing +// profile as the existing invoice section. This operation is supported only for products that are purchased with a +// recurring charge and for billing accounts with agreement type Microsoft Customer Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// productName - the ID that uniquely identifies a product. +// parameters - request parameters that are provided to the move product operation. +func (client ProductsClient) Move(ctx context.Context, billingAccountName string, productName string, parameters TransferProductRequestProperties) (result Product, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductsClient.Move") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.MovePreparer(ctx, billingAccountName, productName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProductsClient", "Move", nil, "Failure preparing request") + return + } + + resp, err := client.MoveSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.ProductsClient", "Move", resp, "Failure sending request") + return + } + + result, err = client.MoveResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProductsClient", "Move", resp, "Failure responding to request") + } + + return +} + +// MovePreparer prepares the Move request. +func (client ProductsClient) MovePreparer(ctx context.Context, billingAccountName string, productName string, parameters TransferProductRequestProperties) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "productName": autorest.Encode("path", productName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/products/{productName}/move", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// MoveSender sends the Move request. The method will close the +// http.Response Body if it receives an error. +func (client ProductsClient) MoveSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// MoveResponder handles the response to the Move request. The method always +// closes the http.Response Body. +func (client ProductsClient) MoveResponder(resp *http.Response) (result Product, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates the properties of a Product. Currently, auto renew can be updated. The operation is supported only +// for billing accounts with agreement type Microsoft Customer Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// productName - the ID that uniquely identifies a product. +// parameters - request parameters that are provided to the update product operation. +func (client ProductsClient) Update(ctx context.Context, billingAccountName string, productName string, parameters Product) (result Product, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductsClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, billingAccountName, productName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProductsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.ProductsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProductsClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ProductsClient) UpdatePreparer(ctx context.Context, billingAccountName string, productName string, parameters Product) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "productName": autorest.Encode("path", productName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/products/{productName}", pathParameters), + autorest.WithJSON(parameters), + 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 ProductsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ProductsClient) UpdateResponder(resp *http.Response) (result Product, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ValidateMove validates if a product's charges can be moved to a new invoice section. This operation is supported +// only for products that are purchased with a recurring charge and for billing accounts with agreement type Microsoft +// Customer Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// productName - the ID that uniquely identifies a product. +// parameters - request parameters that are provided to the validate move eligibility operation. +func (client ProductsClient) ValidateMove(ctx context.Context, billingAccountName string, productName string, parameters TransferProductRequestProperties) (result ValidateProductTransferEligibilityResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductsClient.ValidateMove") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ValidateMovePreparer(ctx, billingAccountName, productName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProductsClient", "ValidateMove", nil, "Failure preparing request") + return + } + + resp, err := client.ValidateMoveSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.ProductsClient", "ValidateMove", resp, "Failure sending request") + return + } + + result, err = client.ValidateMoveResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProductsClient", "ValidateMove", resp, "Failure responding to request") + } + + return +} + +// ValidateMovePreparer prepares the ValidateMove request. +func (client ProductsClient) ValidateMovePreparer(ctx context.Context, billingAccountName string, productName string, parameters TransferProductRequestProperties) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "productName": autorest.Encode("path", productName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/products/{productName}/validateMoveEligibility", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ValidateMoveSender sends the ValidateMove request. The method will close the +// http.Response Body if it receives an error. +func (client ProductsClient) ValidateMoveSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ValidateMoveResponder handles the response to the ValidateMove request. The method always +// closes the http.Response Body. +func (client ProductsClient) ValidateMoveResponder(resp *http.Response) (result ValidateProductTransferEligibilityResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/billing/mgmt/2020-05-01-preview/billing/profiles.go b/services/preview/billing/mgmt/2020-05-01-preview/billing/profiles.go new file mode 100644 index 000000000000..e2857d17bf69 --- /dev/null +++ b/services/preview/billing/mgmt/2020-05-01-preview/billing/profiles.go @@ -0,0 +1,326 @@ +package billing + +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// ProfilesClient is the billing client provides access to billing resources for Azure subscriptions. +type ProfilesClient struct { + BaseClient +} + +// NewProfilesClient creates an instance of the ProfilesClient client. +func NewProfilesClient(subscriptionID string) ProfilesClient { + return NewProfilesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewProfilesClientWithBaseURI creates an instance of the ProfilesClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewProfilesClientWithBaseURI(baseURI string, subscriptionID string) ProfilesClient { + return ProfilesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate creates or updates a billing profile. The operation is supported for billing accounts with agreement +// type Microsoft Customer Agreement or Microsoft Partner Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// billingProfileName - the ID that uniquely identifies a billing profile. +// parameters - the new or updated billing profile. +func (client ProfilesClient) CreateOrUpdate(ctx context.Context, billingAccountName string, billingProfileName string, parameters Profile) (result ProfilesCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProfilesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.ProfileProperties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ProfileProperties.BillTo", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.ProfileProperties.BillTo.AddressLine1", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "parameters.ProfileProperties.BillTo.Country", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}}}}); err != nil { + return result, validation.NewError("billing.ProfilesClient", "CreateOrUpdate", err.Error()) + } + + req, err := client.CreateOrUpdatePreparer(ctx, billingAccountName, billingProfileName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProfilesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProfilesClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client ProfilesClient) CreateOrUpdatePreparer(ctx context.Context, billingAccountName string, billingProfileName string, parameters Profile) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingProfileName": autorest.Encode("path", billingProfileName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}", 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 ProfilesClient) CreateOrUpdateSender(req *http.Request) (future ProfilesCreateOrUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client ProfilesClient) CreateOrUpdateResponder(resp *http.Response) (result Profile, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets a billing profile by its ID. The operation is supported for billing accounts with agreement type Microsoft +// Customer Agreement or Microsoft Partner Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// billingProfileName - the ID that uniquely identifies a billing profile. +// expand - may be used to expand the invoice sections. +func (client ProfilesClient) Get(ctx context.Context, billingAccountName string, billingProfileName string, expand string) (result Profile, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProfilesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, billingAccountName, billingProfileName, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProfilesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.ProfilesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProfilesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client ProfilesClient) GetPreparer(ctx context.Context, billingAccountName string, billingProfileName string, expand string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingProfileName": autorest.Encode("path", billingProfileName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}", 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 ProfilesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client ProfilesClient) GetResponder(resp *http.Response) (result Profile, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByBillingAccount lists the billing profiles that a user has access to. The operation is supported for billing +// accounts with agreement type Microsoft Customer Agreement or Microsoft Partner Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// expand - may be used to expand the invoice sections. +func (client ProfilesClient) ListByBillingAccount(ctx context.Context, billingAccountName string, expand string) (result ProfileListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProfilesClient.ListByBillingAccount") + defer func() { + sc := -1 + if result.plr.Response.Response != nil { + sc = result.plr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByBillingAccountNextResults + req, err := client.ListByBillingAccountPreparer(ctx, billingAccountName, expand) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProfilesClient", "ListByBillingAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByBillingAccountSender(req) + if err != nil { + result.plr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.ProfilesClient", "ListByBillingAccount", resp, "Failure sending request") + return + } + + result.plr, err = client.ListByBillingAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProfilesClient", "ListByBillingAccount", resp, "Failure responding to request") + } + + return +} + +// ListByBillingAccountPreparer prepares the ListByBillingAccount request. +func (client ProfilesClient) ListByBillingAccountPreparer(ctx context.Context, billingAccountName string, expand string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(expand) > 0 { + queryParameters["$expand"] = autorest.Encode("query", expand) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByBillingAccountSender sends the ListByBillingAccount request. The method will close the +// http.Response Body if it receives an error. +func (client ProfilesClient) ListByBillingAccountSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListByBillingAccountResponder handles the response to the ListByBillingAccount request. The method always +// closes the http.Response Body. +func (client ProfilesClient) ListByBillingAccountResponder(resp *http.Response) (result ProfileListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByBillingAccountNextResults retrieves the next set of results, if any. +func (client ProfilesClient) listByBillingAccountNextResults(ctx context.Context, lastResults ProfileListResult) (result ProfileListResult, err error) { + req, err := lastResults.profileListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.ProfilesClient", "listByBillingAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByBillingAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.ProfilesClient", "listByBillingAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByBillingAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProfilesClient", "listByBillingAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByBillingAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client ProfilesClient) ListByBillingAccountComplete(ctx context.Context, billingAccountName string, expand string) (result ProfileListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProfilesClient.ListByBillingAccount") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByBillingAccount(ctx, billingAccountName, expand) + return +} diff --git a/services/preview/billing/mgmt/2020-05-01-preview/billing/property.go b/services/preview/billing/mgmt/2020-05-01-preview/billing/property.go new file mode 100644 index 000000000000..e3552a270530 --- /dev/null +++ b/services/preview/billing/mgmt/2020-05-01-preview/billing/property.go @@ -0,0 +1,188 @@ +package billing + +// 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/tracing" + "net/http" +) + +// PropertyClient is the billing client provides access to billing resources for Azure subscriptions. +type PropertyClient struct { + BaseClient +} + +// NewPropertyClient creates an instance of the PropertyClient client. +func NewPropertyClient(subscriptionID string) PropertyClient { + return NewPropertyClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPropertyClientWithBaseURI creates an instance of the PropertyClient client using a custom endpoint. Use this +// when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewPropertyClientWithBaseURI(baseURI string, subscriptionID string) PropertyClient { + return PropertyClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get get the billing properties for a subscription. This operation is not supported for billing accounts with +// agreement type Enterprise Agreement. +func (client PropertyClient) Get(ctx context.Context) (result Property, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PropertyClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PropertyClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.PropertyClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PropertyClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client PropertyClient) GetPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingProperty/default", 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 PropertyClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PropertyClient) GetResponder(resp *http.Response) (result Property, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates the billing property of a subscription. Currently, cost center can be updated. The operation is +// supported only for billing accounts with agreement type Microsoft Customer Agreement. +// Parameters: +// parameters - request parameters that are provided to the update billing property operation. +func (client PropertyClient) Update(ctx context.Context, parameters Property) (result Property, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PropertyClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PropertyClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.PropertyClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PropertyClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client PropertyClient) UpdatePreparer(ctx context.Context, parameters Property) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingProperty/default", pathParameters), + autorest.WithJSON(parameters), + 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 PropertyClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client PropertyClient) UpdateResponder(resp *http.Response) (result Property, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/billing/mgmt/2020-05-01-preview/billing/roleassignments.go b/services/preview/billing/mgmt/2020-05-01-preview/billing/roleassignments.go new file mode 100644 index 000000000000..b0371f080e45 --- /dev/null +++ b/services/preview/billing/mgmt/2020-05-01-preview/billing/roleassignments.go @@ -0,0 +1,843 @@ +package billing + +// 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/tracing" + "net/http" +) + +// RoleAssignmentsClient is the billing client provides access to billing resources for Azure subscriptions. +type RoleAssignmentsClient struct { + BaseClient +} + +// NewRoleAssignmentsClient creates an instance of the RoleAssignmentsClient client. +func NewRoleAssignmentsClient(subscriptionID string) RoleAssignmentsClient { + return NewRoleAssignmentsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRoleAssignmentsClientWithBaseURI creates an instance of the RoleAssignmentsClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewRoleAssignmentsClientWithBaseURI(baseURI string, subscriptionID string) RoleAssignmentsClient { + return RoleAssignmentsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// DeleteByBillingAccount deletes a role assignment for the caller on a billing account. The operation is supported for +// billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// billingRoleAssignmentName - the ID that uniquely identifies a role assignment. +func (client RoleAssignmentsClient) DeleteByBillingAccount(ctx context.Context, billingAccountName string, billingRoleAssignmentName string) (result RoleAssignment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.DeleteByBillingAccount") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeleteByBillingAccountPreparer(ctx, billingAccountName, billingRoleAssignmentName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.RoleAssignmentsClient", "DeleteByBillingAccount", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteByBillingAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.RoleAssignmentsClient", "DeleteByBillingAccount", resp, "Failure sending request") + return + } + + result, err = client.DeleteByBillingAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.RoleAssignmentsClient", "DeleteByBillingAccount", resp, "Failure responding to request") + } + + return +} + +// DeleteByBillingAccountPreparer prepares the DeleteByBillingAccount request. +func (client RoleAssignmentsClient) DeleteByBillingAccountPreparer(ctx context.Context, billingAccountName string, billingRoleAssignmentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingRoleAssignmentName": autorest.Encode("path", billingRoleAssignmentName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleAssignments/{billingRoleAssignmentName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteByBillingAccountSender sends the DeleteByBillingAccount request. The method will close the +// http.Response Body if it receives an error. +func (client RoleAssignmentsClient) DeleteByBillingAccountSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// DeleteByBillingAccountResponder handles the response to the DeleteByBillingAccount request. The method always +// closes the http.Response Body. +func (client RoleAssignmentsClient) DeleteByBillingAccountResponder(resp *http.Response) (result RoleAssignment, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// DeleteByBillingProfile deletes a role assignment for the caller on a billing profile. The operation is supported for +// billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// billingProfileName - the ID that uniquely identifies a billing profile. +// billingRoleAssignmentName - the ID that uniquely identifies a role assignment. +func (client RoleAssignmentsClient) DeleteByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string, billingRoleAssignmentName string) (result RoleAssignment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.DeleteByBillingProfile") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeleteByBillingProfilePreparer(ctx, billingAccountName, billingProfileName, billingRoleAssignmentName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.RoleAssignmentsClient", "DeleteByBillingProfile", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteByBillingProfileSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.RoleAssignmentsClient", "DeleteByBillingProfile", resp, "Failure sending request") + return + } + + result, err = client.DeleteByBillingProfileResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.RoleAssignmentsClient", "DeleteByBillingProfile", resp, "Failure responding to request") + } + + return +} + +// DeleteByBillingProfilePreparer prepares the DeleteByBillingProfile request. +func (client RoleAssignmentsClient) DeleteByBillingProfilePreparer(ctx context.Context, billingAccountName string, billingProfileName string, billingRoleAssignmentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingProfileName": autorest.Encode("path", billingProfileName), + "billingRoleAssignmentName": autorest.Encode("path", billingRoleAssignmentName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRoleAssignments/{billingRoleAssignmentName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteByBillingProfileSender sends the DeleteByBillingProfile request. The method will close the +// http.Response Body if it receives an error. +func (client RoleAssignmentsClient) DeleteByBillingProfileSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// DeleteByBillingProfileResponder handles the response to the DeleteByBillingProfile request. The method always +// closes the http.Response Body. +func (client RoleAssignmentsClient) DeleteByBillingProfileResponder(resp *http.Response) (result RoleAssignment, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// DeleteByInvoiceSection deletes a role assignment for the caller on an invoice section. The operation is supported +// for billing accounts with agreement type Microsoft Customer Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// billingProfileName - the ID that uniquely identifies a billing profile. +// invoiceSectionName - the ID that uniquely identifies an invoice section. +// billingRoleAssignmentName - the ID that uniquely identifies a role assignment. +func (client RoleAssignmentsClient) DeleteByInvoiceSection(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, billingRoleAssignmentName string) (result RoleAssignment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.DeleteByInvoiceSection") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeleteByInvoiceSectionPreparer(ctx, billingAccountName, billingProfileName, invoiceSectionName, billingRoleAssignmentName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.RoleAssignmentsClient", "DeleteByInvoiceSection", nil, "Failure preparing request") + return + } + + resp, err := client.DeleteByInvoiceSectionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.RoleAssignmentsClient", "DeleteByInvoiceSection", resp, "Failure sending request") + return + } + + result, err = client.DeleteByInvoiceSectionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.RoleAssignmentsClient", "DeleteByInvoiceSection", resp, "Failure responding to request") + } + + return +} + +// DeleteByInvoiceSectionPreparer prepares the DeleteByInvoiceSection request. +func (client RoleAssignmentsClient) DeleteByInvoiceSectionPreparer(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, billingRoleAssignmentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingProfileName": autorest.Encode("path", billingProfileName), + "billingRoleAssignmentName": autorest.Encode("path", billingRoleAssignmentName), + "invoiceSectionName": autorest.Encode("path", invoiceSectionName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRoleAssignments/{billingRoleAssignmentName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteByInvoiceSectionSender sends the DeleteByInvoiceSection request. The method will close the +// http.Response Body if it receives an error. +func (client RoleAssignmentsClient) DeleteByInvoiceSectionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// DeleteByInvoiceSectionResponder handles the response to the DeleteByInvoiceSection request. The method always +// closes the http.Response Body. +func (client RoleAssignmentsClient) DeleteByInvoiceSectionResponder(resp *http.Response) (result RoleAssignment, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetByBillingAccount gets a role assignment for the caller on a billing account. The operation is supported for +// billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// billingRoleAssignmentName - the ID that uniquely identifies a role assignment. +func (client RoleAssignmentsClient) GetByBillingAccount(ctx context.Context, billingAccountName string, billingRoleAssignmentName string) (result RoleAssignment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.GetByBillingAccount") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetByBillingAccountPreparer(ctx, billingAccountName, billingRoleAssignmentName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.RoleAssignmentsClient", "GetByBillingAccount", nil, "Failure preparing request") + return + } + + resp, err := client.GetByBillingAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.RoleAssignmentsClient", "GetByBillingAccount", resp, "Failure sending request") + return + } + + result, err = client.GetByBillingAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.RoleAssignmentsClient", "GetByBillingAccount", resp, "Failure responding to request") + } + + return +} + +// GetByBillingAccountPreparer prepares the GetByBillingAccount request. +func (client RoleAssignmentsClient) GetByBillingAccountPreparer(ctx context.Context, billingAccountName string, billingRoleAssignmentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingRoleAssignmentName": autorest.Encode("path", billingRoleAssignmentName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleAssignments/{billingRoleAssignmentName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetByBillingAccountSender sends the GetByBillingAccount request. The method will close the +// http.Response Body if it receives an error. +func (client RoleAssignmentsClient) GetByBillingAccountSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetByBillingAccountResponder handles the response to the GetByBillingAccount request. The method always +// closes the http.Response Body. +func (client RoleAssignmentsClient) GetByBillingAccountResponder(resp *http.Response) (result RoleAssignment, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetByBillingProfile gets a role assignment for the caller on a billing profile. The operation is supported for +// billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// billingProfileName - the ID that uniquely identifies a billing profile. +// billingRoleAssignmentName - the ID that uniquely identifies a role assignment. +func (client RoleAssignmentsClient) GetByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string, billingRoleAssignmentName string) (result RoleAssignment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.GetByBillingProfile") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetByBillingProfilePreparer(ctx, billingAccountName, billingProfileName, billingRoleAssignmentName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.RoleAssignmentsClient", "GetByBillingProfile", nil, "Failure preparing request") + return + } + + resp, err := client.GetByBillingProfileSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.RoleAssignmentsClient", "GetByBillingProfile", resp, "Failure sending request") + return + } + + result, err = client.GetByBillingProfileResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.RoleAssignmentsClient", "GetByBillingProfile", resp, "Failure responding to request") + } + + return +} + +// GetByBillingProfilePreparer prepares the GetByBillingProfile request. +func (client RoleAssignmentsClient) GetByBillingProfilePreparer(ctx context.Context, billingAccountName string, billingProfileName string, billingRoleAssignmentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingProfileName": autorest.Encode("path", billingProfileName), + "billingRoleAssignmentName": autorest.Encode("path", billingRoleAssignmentName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRoleAssignments/{billingRoleAssignmentName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetByBillingProfileSender sends the GetByBillingProfile request. The method will close the +// http.Response Body if it receives an error. +func (client RoleAssignmentsClient) GetByBillingProfileSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetByBillingProfileResponder handles the response to the GetByBillingProfile request. The method always +// closes the http.Response Body. +func (client RoleAssignmentsClient) GetByBillingProfileResponder(resp *http.Response) (result RoleAssignment, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetByInvoiceSection gets a role assignment for the caller on an invoice section. The operation is supported for +// billing accounts with agreement type Microsoft Customer Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// billingProfileName - the ID that uniquely identifies a billing profile. +// invoiceSectionName - the ID that uniquely identifies an invoice section. +// billingRoleAssignmentName - the ID that uniquely identifies a role assignment. +func (client RoleAssignmentsClient) GetByInvoiceSection(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, billingRoleAssignmentName string) (result RoleAssignment, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.GetByInvoiceSection") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetByInvoiceSectionPreparer(ctx, billingAccountName, billingProfileName, invoiceSectionName, billingRoleAssignmentName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.RoleAssignmentsClient", "GetByInvoiceSection", nil, "Failure preparing request") + return + } + + resp, err := client.GetByInvoiceSectionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.RoleAssignmentsClient", "GetByInvoiceSection", resp, "Failure sending request") + return + } + + result, err = client.GetByInvoiceSectionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.RoleAssignmentsClient", "GetByInvoiceSection", resp, "Failure responding to request") + } + + return +} + +// GetByInvoiceSectionPreparer prepares the GetByInvoiceSection request. +func (client RoleAssignmentsClient) GetByInvoiceSectionPreparer(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, billingRoleAssignmentName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingProfileName": autorest.Encode("path", billingProfileName), + "billingRoleAssignmentName": autorest.Encode("path", billingRoleAssignmentName), + "invoiceSectionName": autorest.Encode("path", invoiceSectionName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRoleAssignments/{billingRoleAssignmentName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetByInvoiceSectionSender sends the GetByInvoiceSection request. The method will close the +// http.Response Body if it receives an error. +func (client RoleAssignmentsClient) GetByInvoiceSectionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetByInvoiceSectionResponder handles the response to the GetByInvoiceSection request. The method always +// closes the http.Response Body. +func (client RoleAssignmentsClient) GetByInvoiceSectionResponder(resp *http.Response) (result RoleAssignment, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByBillingAccount lists the role assignments for the caller on a billing account. The operation is supported for +// billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +func (client RoleAssignmentsClient) ListByBillingAccount(ctx context.Context, billingAccountName string) (result RoleAssignmentListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.ListByBillingAccount") + defer func() { + sc := -1 + if result.ralr.Response.Response != nil { + sc = result.ralr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByBillingAccountNextResults + req, err := client.ListByBillingAccountPreparer(ctx, billingAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.RoleAssignmentsClient", "ListByBillingAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByBillingAccountSender(req) + if err != nil { + result.ralr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.RoleAssignmentsClient", "ListByBillingAccount", resp, "Failure sending request") + return + } + + result.ralr, err = client.ListByBillingAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.RoleAssignmentsClient", "ListByBillingAccount", resp, "Failure responding to request") + } + + return +} + +// ListByBillingAccountPreparer prepares the ListByBillingAccount request. +func (client RoleAssignmentsClient) ListByBillingAccountPreparer(ctx context.Context, billingAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleAssignments", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByBillingAccountSender sends the ListByBillingAccount request. The method will close the +// http.Response Body if it receives an error. +func (client RoleAssignmentsClient) ListByBillingAccountSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListByBillingAccountResponder handles the response to the ListByBillingAccount request. The method always +// closes the http.Response Body. +func (client RoleAssignmentsClient) ListByBillingAccountResponder(resp *http.Response) (result RoleAssignmentListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByBillingAccountNextResults retrieves the next set of results, if any. +func (client RoleAssignmentsClient) listByBillingAccountNextResults(ctx context.Context, lastResults RoleAssignmentListResult) (result RoleAssignmentListResult, err error) { + req, err := lastResults.roleAssignmentListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.RoleAssignmentsClient", "listByBillingAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByBillingAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.RoleAssignmentsClient", "listByBillingAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByBillingAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.RoleAssignmentsClient", "listByBillingAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByBillingAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client RoleAssignmentsClient) ListByBillingAccountComplete(ctx context.Context, billingAccountName string) (result RoleAssignmentListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.ListByBillingAccount") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByBillingAccount(ctx, billingAccountName) + return +} + +// ListByBillingProfile lists the role assignments for the caller on a billing profile. The operation is supported for +// billing accounts with agreement type Microsoft Customer Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// billingProfileName - the ID that uniquely identifies a billing profile. +func (client RoleAssignmentsClient) ListByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string) (result RoleAssignmentListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.ListByBillingProfile") + defer func() { + sc := -1 + if result.ralr.Response.Response != nil { + sc = result.ralr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByBillingProfileNextResults + req, err := client.ListByBillingProfilePreparer(ctx, billingAccountName, billingProfileName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.RoleAssignmentsClient", "ListByBillingProfile", nil, "Failure preparing request") + return + } + + resp, err := client.ListByBillingProfileSender(req) + if err != nil { + result.ralr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.RoleAssignmentsClient", "ListByBillingProfile", resp, "Failure sending request") + return + } + + result.ralr, err = client.ListByBillingProfileResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.RoleAssignmentsClient", "ListByBillingProfile", resp, "Failure responding to request") + } + + return +} + +// ListByBillingProfilePreparer prepares the ListByBillingProfile request. +func (client RoleAssignmentsClient) ListByBillingProfilePreparer(ctx context.Context, billingAccountName string, billingProfileName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingProfileName": autorest.Encode("path", billingProfileName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRoleAssignments", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByBillingProfileSender sends the ListByBillingProfile request. The method will close the +// http.Response Body if it receives an error. +func (client RoleAssignmentsClient) ListByBillingProfileSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListByBillingProfileResponder handles the response to the ListByBillingProfile request. The method always +// closes the http.Response Body. +func (client RoleAssignmentsClient) ListByBillingProfileResponder(resp *http.Response) (result RoleAssignmentListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByBillingProfileNextResults retrieves the next set of results, if any. +func (client RoleAssignmentsClient) listByBillingProfileNextResults(ctx context.Context, lastResults RoleAssignmentListResult) (result RoleAssignmentListResult, err error) { + req, err := lastResults.roleAssignmentListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.RoleAssignmentsClient", "listByBillingProfileNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByBillingProfileSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.RoleAssignmentsClient", "listByBillingProfileNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByBillingProfileResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.RoleAssignmentsClient", "listByBillingProfileNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByBillingProfileComplete enumerates all values, automatically crossing page boundaries as required. +func (client RoleAssignmentsClient) ListByBillingProfileComplete(ctx context.Context, billingAccountName string, billingProfileName string) (result RoleAssignmentListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.ListByBillingProfile") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByBillingProfile(ctx, billingAccountName, billingProfileName) + return +} + +// ListByInvoiceSection lists the role assignments for the caller on an invoice section. The operation is supported for +// billing accounts with agreement type Microsoft Customer Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// billingProfileName - the ID that uniquely identifies a billing profile. +// invoiceSectionName - the ID that uniquely identifies an invoice section. +func (client RoleAssignmentsClient) ListByInvoiceSection(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string) (result RoleAssignmentListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.ListByInvoiceSection") + defer func() { + sc := -1 + if result.ralr.Response.Response != nil { + sc = result.ralr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByInvoiceSectionNextResults + req, err := client.ListByInvoiceSectionPreparer(ctx, billingAccountName, billingProfileName, invoiceSectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.RoleAssignmentsClient", "ListByInvoiceSection", nil, "Failure preparing request") + return + } + + resp, err := client.ListByInvoiceSectionSender(req) + if err != nil { + result.ralr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.RoleAssignmentsClient", "ListByInvoiceSection", resp, "Failure sending request") + return + } + + result.ralr, err = client.ListByInvoiceSectionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.RoleAssignmentsClient", "ListByInvoiceSection", resp, "Failure responding to request") + } + + return +} + +// ListByInvoiceSectionPreparer prepares the ListByInvoiceSection request. +func (client RoleAssignmentsClient) ListByInvoiceSectionPreparer(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingProfileName": autorest.Encode("path", billingProfileName), + "invoiceSectionName": autorest.Encode("path", invoiceSectionName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRoleAssignments", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByInvoiceSectionSender sends the ListByInvoiceSection request. The method will close the +// http.Response Body if it receives an error. +func (client RoleAssignmentsClient) ListByInvoiceSectionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListByInvoiceSectionResponder handles the response to the ListByInvoiceSection request. The method always +// closes the http.Response Body. +func (client RoleAssignmentsClient) ListByInvoiceSectionResponder(resp *http.Response) (result RoleAssignmentListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByInvoiceSectionNextResults retrieves the next set of results, if any. +func (client RoleAssignmentsClient) listByInvoiceSectionNextResults(ctx context.Context, lastResults RoleAssignmentListResult) (result RoleAssignmentListResult, err error) { + req, err := lastResults.roleAssignmentListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.RoleAssignmentsClient", "listByInvoiceSectionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByInvoiceSectionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.RoleAssignmentsClient", "listByInvoiceSectionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByInvoiceSectionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.RoleAssignmentsClient", "listByInvoiceSectionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByInvoiceSectionComplete enumerates all values, automatically crossing page boundaries as required. +func (client RoleAssignmentsClient) ListByInvoiceSectionComplete(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string) (result RoleAssignmentListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleAssignmentsClient.ListByInvoiceSection") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByInvoiceSection(ctx, billingAccountName, billingProfileName, invoiceSectionName) + return +} diff --git a/services/preview/billing/mgmt/2020-05-01-preview/billing/roledefinitions.go b/services/preview/billing/mgmt/2020-05-01-preview/billing/roledefinitions.go new file mode 100644 index 000000000000..3ae3438b2c00 --- /dev/null +++ b/services/preview/billing/mgmt/2020-05-01-preview/billing/roledefinitions.go @@ -0,0 +1,612 @@ +package billing + +// 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/tracing" + "net/http" +) + +// RoleDefinitionsClient is the billing client provides access to billing resources for Azure subscriptions. +type RoleDefinitionsClient struct { + BaseClient +} + +// NewRoleDefinitionsClient creates an instance of the RoleDefinitionsClient client. +func NewRoleDefinitionsClient(subscriptionID string) RoleDefinitionsClient { + return NewRoleDefinitionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRoleDefinitionsClientWithBaseURI creates an instance of the RoleDefinitionsClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewRoleDefinitionsClientWithBaseURI(baseURI string, subscriptionID string) RoleDefinitionsClient { + return RoleDefinitionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// GetByBillingAccount gets the definition for a role on a billing account. The operation is supported for billing +// accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// billingRoleDefinitionName - the ID that uniquely identifies a role definition. +func (client RoleDefinitionsClient) GetByBillingAccount(ctx context.Context, billingAccountName string, billingRoleDefinitionName string) (result RoleDefinition, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleDefinitionsClient.GetByBillingAccount") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetByBillingAccountPreparer(ctx, billingAccountName, billingRoleDefinitionName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.RoleDefinitionsClient", "GetByBillingAccount", nil, "Failure preparing request") + return + } + + resp, err := client.GetByBillingAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.RoleDefinitionsClient", "GetByBillingAccount", resp, "Failure sending request") + return + } + + result, err = client.GetByBillingAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.RoleDefinitionsClient", "GetByBillingAccount", resp, "Failure responding to request") + } + + return +} + +// GetByBillingAccountPreparer prepares the GetByBillingAccount request. +func (client RoleDefinitionsClient) GetByBillingAccountPreparer(ctx context.Context, billingAccountName string, billingRoleDefinitionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingRoleDefinitionName": autorest.Encode("path", billingRoleDefinitionName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleDefinitions/{billingRoleDefinitionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetByBillingAccountSender sends the GetByBillingAccount request. The method will close the +// http.Response Body if it receives an error. +func (client RoleDefinitionsClient) GetByBillingAccountSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetByBillingAccountResponder handles the response to the GetByBillingAccount request. The method always +// closes the http.Response Body. +func (client RoleDefinitionsClient) GetByBillingAccountResponder(resp *http.Response) (result RoleDefinition, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetByBillingProfile gets the definition for a role on a billing profile. The operation is supported for billing +// accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// billingProfileName - the ID that uniquely identifies a billing profile. +// billingRoleDefinitionName - the ID that uniquely identifies a role definition. +func (client RoleDefinitionsClient) GetByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string, billingRoleDefinitionName string) (result RoleDefinition, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleDefinitionsClient.GetByBillingProfile") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetByBillingProfilePreparer(ctx, billingAccountName, billingProfileName, billingRoleDefinitionName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.RoleDefinitionsClient", "GetByBillingProfile", nil, "Failure preparing request") + return + } + + resp, err := client.GetByBillingProfileSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.RoleDefinitionsClient", "GetByBillingProfile", resp, "Failure sending request") + return + } + + result, err = client.GetByBillingProfileResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.RoleDefinitionsClient", "GetByBillingProfile", resp, "Failure responding to request") + } + + return +} + +// GetByBillingProfilePreparer prepares the GetByBillingProfile request. +func (client RoleDefinitionsClient) GetByBillingProfilePreparer(ctx context.Context, billingAccountName string, billingProfileName string, billingRoleDefinitionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingProfileName": autorest.Encode("path", billingProfileName), + "billingRoleDefinitionName": autorest.Encode("path", billingRoleDefinitionName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRoleDefinitions/{billingRoleDefinitionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetByBillingProfileSender sends the GetByBillingProfile request. The method will close the +// http.Response Body if it receives an error. +func (client RoleDefinitionsClient) GetByBillingProfileSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetByBillingProfileResponder handles the response to the GetByBillingProfile request. The method always +// closes the http.Response Body. +func (client RoleDefinitionsClient) GetByBillingProfileResponder(resp *http.Response) (result RoleDefinition, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetByInvoiceSection gets the definition for a role on an invoice section. The operation is supported only for +// billing accounts with agreement type Microsoft Customer Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// billingProfileName - the ID that uniquely identifies a billing profile. +// invoiceSectionName - the ID that uniquely identifies an invoice section. +// billingRoleDefinitionName - the ID that uniquely identifies a role definition. +func (client RoleDefinitionsClient) GetByInvoiceSection(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, billingRoleDefinitionName string) (result RoleDefinition, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleDefinitionsClient.GetByInvoiceSection") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetByInvoiceSectionPreparer(ctx, billingAccountName, billingProfileName, invoiceSectionName, billingRoleDefinitionName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.RoleDefinitionsClient", "GetByInvoiceSection", nil, "Failure preparing request") + return + } + + resp, err := client.GetByInvoiceSectionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.RoleDefinitionsClient", "GetByInvoiceSection", resp, "Failure sending request") + return + } + + result, err = client.GetByInvoiceSectionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.RoleDefinitionsClient", "GetByInvoiceSection", resp, "Failure responding to request") + } + + return +} + +// GetByInvoiceSectionPreparer prepares the GetByInvoiceSection request. +func (client RoleDefinitionsClient) GetByInvoiceSectionPreparer(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string, billingRoleDefinitionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingProfileName": autorest.Encode("path", billingProfileName), + "billingRoleDefinitionName": autorest.Encode("path", billingRoleDefinitionName), + "invoiceSectionName": autorest.Encode("path", invoiceSectionName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRoleDefinitions/{billingRoleDefinitionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetByInvoiceSectionSender sends the GetByInvoiceSection request. The method will close the +// http.Response Body if it receives an error. +func (client RoleDefinitionsClient) GetByInvoiceSectionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetByInvoiceSectionResponder handles the response to the GetByInvoiceSection request. The method always +// closes the http.Response Body. +func (client RoleDefinitionsClient) GetByInvoiceSectionResponder(resp *http.Response) (result RoleDefinition, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByBillingAccount lists the role definitions for a billing account. The operation is supported for billing +// accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +func (client RoleDefinitionsClient) ListByBillingAccount(ctx context.Context, billingAccountName string) (result RoleDefinitionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleDefinitionsClient.ListByBillingAccount") + defer func() { + sc := -1 + if result.rdlr.Response.Response != nil { + sc = result.rdlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByBillingAccountNextResults + req, err := client.ListByBillingAccountPreparer(ctx, billingAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.RoleDefinitionsClient", "ListByBillingAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByBillingAccountSender(req) + if err != nil { + result.rdlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.RoleDefinitionsClient", "ListByBillingAccount", resp, "Failure sending request") + return + } + + result.rdlr, err = client.ListByBillingAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.RoleDefinitionsClient", "ListByBillingAccount", resp, "Failure responding to request") + } + + return +} + +// ListByBillingAccountPreparer prepares the ListByBillingAccount request. +func (client RoleDefinitionsClient) ListByBillingAccountPreparer(ctx context.Context, billingAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleDefinitions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByBillingAccountSender sends the ListByBillingAccount request. The method will close the +// http.Response Body if it receives an error. +func (client RoleDefinitionsClient) ListByBillingAccountSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListByBillingAccountResponder handles the response to the ListByBillingAccount request. The method always +// closes the http.Response Body. +func (client RoleDefinitionsClient) ListByBillingAccountResponder(resp *http.Response) (result RoleDefinitionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByBillingAccountNextResults retrieves the next set of results, if any. +func (client RoleDefinitionsClient) listByBillingAccountNextResults(ctx context.Context, lastResults RoleDefinitionListResult) (result RoleDefinitionListResult, err error) { + req, err := lastResults.roleDefinitionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.RoleDefinitionsClient", "listByBillingAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByBillingAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.RoleDefinitionsClient", "listByBillingAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByBillingAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.RoleDefinitionsClient", "listByBillingAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByBillingAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client RoleDefinitionsClient) ListByBillingAccountComplete(ctx context.Context, billingAccountName string) (result RoleDefinitionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleDefinitionsClient.ListByBillingAccount") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByBillingAccount(ctx, billingAccountName) + return +} + +// ListByBillingProfile lists the role definitions for a billing profile. The operation is supported for billing +// accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// billingProfileName - the ID that uniquely identifies a billing profile. +func (client RoleDefinitionsClient) ListByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string) (result RoleDefinitionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleDefinitionsClient.ListByBillingProfile") + defer func() { + sc := -1 + if result.rdlr.Response.Response != nil { + sc = result.rdlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByBillingProfileNextResults + req, err := client.ListByBillingProfilePreparer(ctx, billingAccountName, billingProfileName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.RoleDefinitionsClient", "ListByBillingProfile", nil, "Failure preparing request") + return + } + + resp, err := client.ListByBillingProfileSender(req) + if err != nil { + result.rdlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.RoleDefinitionsClient", "ListByBillingProfile", resp, "Failure sending request") + return + } + + result.rdlr, err = client.ListByBillingProfileResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.RoleDefinitionsClient", "ListByBillingProfile", resp, "Failure responding to request") + } + + return +} + +// ListByBillingProfilePreparer prepares the ListByBillingProfile request. +func (client RoleDefinitionsClient) ListByBillingProfilePreparer(ctx context.Context, billingAccountName string, billingProfileName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingProfileName": autorest.Encode("path", billingProfileName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRoleDefinitions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByBillingProfileSender sends the ListByBillingProfile request. The method will close the +// http.Response Body if it receives an error. +func (client RoleDefinitionsClient) ListByBillingProfileSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListByBillingProfileResponder handles the response to the ListByBillingProfile request. The method always +// closes the http.Response Body. +func (client RoleDefinitionsClient) ListByBillingProfileResponder(resp *http.Response) (result RoleDefinitionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByBillingProfileNextResults retrieves the next set of results, if any. +func (client RoleDefinitionsClient) listByBillingProfileNextResults(ctx context.Context, lastResults RoleDefinitionListResult) (result RoleDefinitionListResult, err error) { + req, err := lastResults.roleDefinitionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.RoleDefinitionsClient", "listByBillingProfileNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByBillingProfileSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.RoleDefinitionsClient", "listByBillingProfileNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByBillingProfileResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.RoleDefinitionsClient", "listByBillingProfileNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByBillingProfileComplete enumerates all values, automatically crossing page boundaries as required. +func (client RoleDefinitionsClient) ListByBillingProfileComplete(ctx context.Context, billingAccountName string, billingProfileName string) (result RoleDefinitionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleDefinitionsClient.ListByBillingProfile") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByBillingProfile(ctx, billingAccountName, billingProfileName) + return +} + +// ListByInvoiceSection lists the role definitions for an invoice section. The operation is supported for billing +// accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// billingProfileName - the ID that uniquely identifies a billing profile. +// invoiceSectionName - the ID that uniquely identifies an invoice section. +func (client RoleDefinitionsClient) ListByInvoiceSection(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string) (result RoleDefinitionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleDefinitionsClient.ListByInvoiceSection") + defer func() { + sc := -1 + if result.rdlr.Response.Response != nil { + sc = result.rdlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByInvoiceSectionNextResults + req, err := client.ListByInvoiceSectionPreparer(ctx, billingAccountName, billingProfileName, invoiceSectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.RoleDefinitionsClient", "ListByInvoiceSection", nil, "Failure preparing request") + return + } + + resp, err := client.ListByInvoiceSectionSender(req) + if err != nil { + result.rdlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.RoleDefinitionsClient", "ListByInvoiceSection", resp, "Failure sending request") + return + } + + result.rdlr, err = client.ListByInvoiceSectionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.RoleDefinitionsClient", "ListByInvoiceSection", resp, "Failure responding to request") + } + + return +} + +// ListByInvoiceSectionPreparer prepares the ListByInvoiceSection request. +func (client RoleDefinitionsClient) ListByInvoiceSectionPreparer(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingProfileName": autorest.Encode("path", billingProfileName), + "invoiceSectionName": autorest.Encode("path", invoiceSectionName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRoleDefinitions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByInvoiceSectionSender sends the ListByInvoiceSection request. The method will close the +// http.Response Body if it receives an error. +func (client RoleDefinitionsClient) ListByInvoiceSectionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListByInvoiceSectionResponder handles the response to the ListByInvoiceSection request. The method always +// closes the http.Response Body. +func (client RoleDefinitionsClient) ListByInvoiceSectionResponder(resp *http.Response) (result RoleDefinitionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByInvoiceSectionNextResults retrieves the next set of results, if any. +func (client RoleDefinitionsClient) listByInvoiceSectionNextResults(ctx context.Context, lastResults RoleDefinitionListResult) (result RoleDefinitionListResult, err error) { + req, err := lastResults.roleDefinitionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.RoleDefinitionsClient", "listByInvoiceSectionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByInvoiceSectionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.RoleDefinitionsClient", "listByInvoiceSectionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByInvoiceSectionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.RoleDefinitionsClient", "listByInvoiceSectionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByInvoiceSectionComplete enumerates all values, automatically crossing page boundaries as required. +func (client RoleDefinitionsClient) ListByInvoiceSectionComplete(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string) (result RoleDefinitionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RoleDefinitionsClient.ListByInvoiceSection") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByInvoiceSection(ctx, billingAccountName, billingProfileName, invoiceSectionName) + return +} diff --git a/services/preview/billing/mgmt/2020-05-01-preview/billing/subscriptions.go b/services/preview/billing/mgmt/2020-05-01-preview/billing/subscriptions.go new file mode 100644 index 000000000000..e77f60f03cc8 --- /dev/null +++ b/services/preview/billing/mgmt/2020-05-01-preview/billing/subscriptions.go @@ -0,0 +1,813 @@ +package billing + +// 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" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// SubscriptionsClient is the billing client provides access to billing resources for Azure subscriptions. +type SubscriptionsClient struct { + BaseClient +} + +// NewSubscriptionsClient creates an instance of the SubscriptionsClient client. +func NewSubscriptionsClient(subscriptionID string) SubscriptionsClient { + return NewSubscriptionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewSubscriptionsClientWithBaseURI creates an instance of the SubscriptionsClient client using a custom endpoint. +// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewSubscriptionsClientWithBaseURI(baseURI string, subscriptionID string) SubscriptionsClient { + return SubscriptionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get gets a subscription by its ID. The operation is supported for billing accounts with agreement type Microsoft +// Customer Agreement and Microsoft Partner Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +func (client SubscriptionsClient) Get(ctx context.Context, billingAccountName string) (result Subscription, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, billingAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client SubscriptionsClient) GetPreparer(ctx context.Context, billingAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{subscriptionId}", 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 SubscriptionsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SubscriptionsClient) GetResponder(resp *http.Response) (result Subscription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByBillingAccount lists the subscriptions for a billing account. The operation is supported for billing accounts +// with agreement type Microsoft Customer Agreement or Microsoft Partner Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +func (client SubscriptionsClient) ListByBillingAccount(ctx context.Context, billingAccountName string) (result SubscriptionsListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionsClient.ListByBillingAccount") + defer func() { + sc := -1 + if result.slr.Response.Response != nil { + sc = result.slr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByBillingAccountNextResults + req, err := client.ListByBillingAccountPreparer(ctx, billingAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "ListByBillingAccount", nil, "Failure preparing request") + return + } + + resp, err := client.ListByBillingAccountSender(req) + if err != nil { + result.slr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "ListByBillingAccount", resp, "Failure sending request") + return + } + + result.slr, err = client.ListByBillingAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "ListByBillingAccount", resp, "Failure responding to request") + } + + return +} + +// ListByBillingAccountPreparer prepares the ListByBillingAccount request. +func (client SubscriptionsClient) ListByBillingAccountPreparer(ctx context.Context, billingAccountName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByBillingAccountSender sends the ListByBillingAccount request. The method will close the +// http.Response Body if it receives an error. +func (client SubscriptionsClient) ListByBillingAccountSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListByBillingAccountResponder handles the response to the ListByBillingAccount request. The method always +// closes the http.Response Body. +func (client SubscriptionsClient) ListByBillingAccountResponder(resp *http.Response) (result SubscriptionsListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByBillingAccountNextResults retrieves the next set of results, if any. +func (client SubscriptionsClient) listByBillingAccountNextResults(ctx context.Context, lastResults SubscriptionsListResult) (result SubscriptionsListResult, err error) { + req, err := lastResults.subscriptionsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "listByBillingAccountNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByBillingAccountSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "listByBillingAccountNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByBillingAccountResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "listByBillingAccountNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByBillingAccountComplete enumerates all values, automatically crossing page boundaries as required. +func (client SubscriptionsClient) ListByBillingAccountComplete(ctx context.Context, billingAccountName string) (result SubscriptionsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionsClient.ListByBillingAccount") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByBillingAccount(ctx, billingAccountName) + return +} + +// ListByBillingProfile lists the subscriptions that are billed to a billing profile. The operation is supported for +// billing accounts with agreement type Microsoft Customer Agreement or Microsoft Partner Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// billingProfileName - the ID that uniquely identifies a billing profile. +func (client SubscriptionsClient) ListByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string) (result SubscriptionsListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionsClient.ListByBillingProfile") + defer func() { + sc := -1 + if result.slr.Response.Response != nil { + sc = result.slr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByBillingProfileNextResults + req, err := client.ListByBillingProfilePreparer(ctx, billingAccountName, billingProfileName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "ListByBillingProfile", nil, "Failure preparing request") + return + } + + resp, err := client.ListByBillingProfileSender(req) + if err != nil { + result.slr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "ListByBillingProfile", resp, "Failure sending request") + return + } + + result.slr, err = client.ListByBillingProfileResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "ListByBillingProfile", resp, "Failure responding to request") + } + + return +} + +// ListByBillingProfilePreparer prepares the ListByBillingProfile request. +func (client SubscriptionsClient) ListByBillingProfilePreparer(ctx context.Context, billingAccountName string, billingProfileName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingProfileName": autorest.Encode("path", billingProfileName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingSubscriptions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByBillingProfileSender sends the ListByBillingProfile request. The method will close the +// http.Response Body if it receives an error. +func (client SubscriptionsClient) ListByBillingProfileSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListByBillingProfileResponder handles the response to the ListByBillingProfile request. The method always +// closes the http.Response Body. +func (client SubscriptionsClient) ListByBillingProfileResponder(resp *http.Response) (result SubscriptionsListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByBillingProfileNextResults retrieves the next set of results, if any. +func (client SubscriptionsClient) listByBillingProfileNextResults(ctx context.Context, lastResults SubscriptionsListResult) (result SubscriptionsListResult, err error) { + req, err := lastResults.subscriptionsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "listByBillingProfileNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByBillingProfileSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "listByBillingProfileNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByBillingProfileResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "listByBillingProfileNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByBillingProfileComplete enumerates all values, automatically crossing page boundaries as required. +func (client SubscriptionsClient) ListByBillingProfileComplete(ctx context.Context, billingAccountName string, billingProfileName string) (result SubscriptionsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionsClient.ListByBillingProfile") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByBillingProfile(ctx, billingAccountName, billingProfileName) + return +} + +// ListByCustomer lists the subscriptions for a customer. The operation is supported only for billing accounts with +// agreement type Microsoft Partner Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// customerName - the ID that uniquely identifies a customer. +func (client SubscriptionsClient) ListByCustomer(ctx context.Context, billingAccountName string, customerName string) (result SubscriptionsListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionsClient.ListByCustomer") + defer func() { + sc := -1 + if result.slr.Response.Response != nil { + sc = result.slr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByCustomerNextResults + req, err := client.ListByCustomerPreparer(ctx, billingAccountName, customerName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "ListByCustomer", nil, "Failure preparing request") + return + } + + resp, err := client.ListByCustomerSender(req) + if err != nil { + result.slr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "ListByCustomer", resp, "Failure sending request") + return + } + + result.slr, err = client.ListByCustomerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "ListByCustomer", resp, "Failure responding to request") + } + + return +} + +// ListByCustomerPreparer prepares the ListByCustomer request. +func (client SubscriptionsClient) ListByCustomerPreparer(ctx context.Context, billingAccountName string, customerName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "customerName": autorest.Encode("path", customerName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/billingSubscriptions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByCustomerSender sends the ListByCustomer request. The method will close the +// http.Response Body if it receives an error. +func (client SubscriptionsClient) ListByCustomerSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListByCustomerResponder handles the response to the ListByCustomer request. The method always +// closes the http.Response Body. +func (client SubscriptionsClient) ListByCustomerResponder(resp *http.Response) (result SubscriptionsListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByCustomerNextResults retrieves the next set of results, if any. +func (client SubscriptionsClient) listByCustomerNextResults(ctx context.Context, lastResults SubscriptionsListResult) (result SubscriptionsListResult, err error) { + req, err := lastResults.subscriptionsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "listByCustomerNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByCustomerSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "listByCustomerNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByCustomerResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "listByCustomerNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByCustomerComplete enumerates all values, automatically crossing page boundaries as required. +func (client SubscriptionsClient) ListByCustomerComplete(ctx context.Context, billingAccountName string, customerName string) (result SubscriptionsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionsClient.ListByCustomer") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByCustomer(ctx, billingAccountName, customerName) + return +} + +// ListByInvoiceSection lists the subscriptions that are billed to an invoice section. The operation is supported only +// for billing accounts with agreement type Microsoft Customer Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// billingProfileName - the ID that uniquely identifies a billing profile. +// invoiceSectionName - the ID that uniquely identifies an invoice section. +func (client SubscriptionsClient) ListByInvoiceSection(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string) (result SubscriptionsListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionsClient.ListByInvoiceSection") + defer func() { + sc := -1 + if result.slr.Response.Response != nil { + sc = result.slr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByInvoiceSectionNextResults + req, err := client.ListByInvoiceSectionPreparer(ctx, billingAccountName, billingProfileName, invoiceSectionName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "ListByInvoiceSection", nil, "Failure preparing request") + return + } + + resp, err := client.ListByInvoiceSectionSender(req) + if err != nil { + result.slr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "ListByInvoiceSection", resp, "Failure sending request") + return + } + + result.slr, err = client.ListByInvoiceSectionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "ListByInvoiceSection", resp, "Failure responding to request") + } + + return +} + +// ListByInvoiceSectionPreparer prepares the ListByInvoiceSection request. +func (client SubscriptionsClient) ListByInvoiceSectionPreparer(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingProfileName": autorest.Encode("path", billingProfileName), + "invoiceSectionName": autorest.Encode("path", invoiceSectionName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingSubscriptions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByInvoiceSectionSender sends the ListByInvoiceSection request. The method will close the +// http.Response Body if it receives an error. +func (client SubscriptionsClient) ListByInvoiceSectionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListByInvoiceSectionResponder handles the response to the ListByInvoiceSection request. The method always +// closes the http.Response Body. +func (client SubscriptionsClient) ListByInvoiceSectionResponder(resp *http.Response) (result SubscriptionsListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByInvoiceSectionNextResults retrieves the next set of results, if any. +func (client SubscriptionsClient) listByInvoiceSectionNextResults(ctx context.Context, lastResults SubscriptionsListResult) (result SubscriptionsListResult, err error) { + req, err := lastResults.subscriptionsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "listByInvoiceSectionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByInvoiceSectionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "listByInvoiceSectionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByInvoiceSectionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "listByInvoiceSectionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByInvoiceSectionComplete enumerates all values, automatically crossing page boundaries as required. +func (client SubscriptionsClient) ListByInvoiceSectionComplete(ctx context.Context, billingAccountName string, billingProfileName string, invoiceSectionName string) (result SubscriptionsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionsClient.ListByInvoiceSection") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByInvoiceSection(ctx, billingAccountName, billingProfileName, invoiceSectionName) + return +} + +// Move moves a subscription's charges to a new invoice section. The new invoice section must belong to the same +// billing profile as the existing invoice section. This operation is supported for billing accounts with agreement +// type Microsoft Customer Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// parameters - request parameters that are provided to the move subscription operation. +func (client SubscriptionsClient) Move(ctx context.Context, billingAccountName string, parameters TransferBillingSubscriptionRequestProperties) (result SubscriptionsMoveFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionsClient.Move") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.DestinationInvoiceSectionID", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("billing.SubscriptionsClient", "Move", err.Error()) + } + + req, err := client.MovePreparer(ctx, billingAccountName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "Move", nil, "Failure preparing request") + return + } + + result, err = client.MoveSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "Move", result.Response(), "Failure sending request") + return + } + + return +} + +// MovePreparer prepares the Move request. +func (client SubscriptionsClient) MovePreparer(ctx context.Context, billingAccountName string, parameters TransferBillingSubscriptionRequestProperties) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{subscriptionId}/move", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// MoveSender sends the Move request. The method will close the +// http.Response Body if it receives an error. +func (client SubscriptionsClient) MoveSender(req *http.Request) (future SubscriptionsMoveFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// MoveResponder handles the response to the Move request. The method always +// closes the http.Response Body. +func (client SubscriptionsClient) MoveResponder(resp *http.Response) (result Subscription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update updates the properties of a billing subscription. Currently, cost center can be updated. The operation is +// supported only for billing accounts with agreement type Microsoft Customer Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// parameters - request parameters that are provided to the update billing subscription operation. +func (client SubscriptionsClient) Update(ctx context.Context, billingAccountName string, parameters Subscription) (result Subscription, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionsClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, billingAccountName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client SubscriptionsClient) UpdatePreparer(ctx context.Context, billingAccountName string, parameters Subscription) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{subscriptionId}", pathParameters), + autorest.WithJSON(parameters), + 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 SubscriptionsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client SubscriptionsClient) UpdateResponder(resp *http.Response) (result Subscription, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ValidateMove validates if a subscription's charges can be moved to a new invoice section. This operation is +// supported for billing accounts with agreement type Microsoft Customer Agreement. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// parameters - request parameters that are provided to the validate move eligibility operation. +func (client SubscriptionsClient) ValidateMove(ctx context.Context, billingAccountName string, parameters TransferBillingSubscriptionRequestProperties) (result ValidateSubscriptionTransferEligibilityResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionsClient.ValidateMove") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.DestinationInvoiceSectionID", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("billing.SubscriptionsClient", "ValidateMove", err.Error()) + } + + req, err := client.ValidateMovePreparer(ctx, billingAccountName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "ValidateMove", nil, "Failure preparing request") + return + } + + resp, err := client.ValidateMoveSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "ValidateMove", resp, "Failure sending request") + return + } + + result, err = client.ValidateMoveResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "ValidateMove", resp, "Failure responding to request") + } + + return +} + +// ValidateMovePreparer prepares the ValidateMove request. +func (client SubscriptionsClient) ValidateMovePreparer(ctx context.Context, billingAccountName string, parameters TransferBillingSubscriptionRequestProperties) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{subscriptionId}/validateMoveEligibility", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ValidateMoveSender sends the ValidateMove request. The method will close the +// http.Response Body if it receives an error. +func (client SubscriptionsClient) ValidateMoveSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ValidateMoveResponder handles the response to the ValidateMove request. The method always +// closes the http.Response Body. +func (client SubscriptionsClient) ValidateMoveResponder(resp *http.Response) (result ValidateSubscriptionTransferEligibilityResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/billing/mgmt/2020-05-01-preview/billing/transactions.go b/services/preview/billing/mgmt/2020-05-01-preview/billing/transactions.go new file mode 100644 index 000000000000..f3b0c40b8984 --- /dev/null +++ b/services/preview/billing/mgmt/2020-05-01-preview/billing/transactions.go @@ -0,0 +1,155 @@ +package billing + +// 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/tracing" + "net/http" +) + +// TransactionsClient is the billing client provides access to billing resources for Azure subscriptions. +type TransactionsClient struct { + BaseClient +} + +// NewTransactionsClient creates an instance of the TransactionsClient client. +func NewTransactionsClient(subscriptionID string) TransactionsClient { + return NewTransactionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewTransactionsClientWithBaseURI creates an instance of the TransactionsClient client using a custom endpoint. Use +// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewTransactionsClientWithBaseURI(baseURI string, subscriptionID string) TransactionsClient { + return TransactionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ListByInvoice lists the transactions for an invoice. Transactions include purchases, refunds and Azure usage +// charges. +// Parameters: +// billingAccountName - the ID that uniquely identifies a billing account. +// invoiceName - the ID that uniquely identifies an invoice. +func (client TransactionsClient) ListByInvoice(ctx context.Context, billingAccountName string, invoiceName string) (result TransactionListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TransactionsClient.ListByInvoice") + defer func() { + sc := -1 + if result.tlr.Response.Response != nil { + sc = result.tlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByInvoiceNextResults + req, err := client.ListByInvoicePreparer(ctx, billingAccountName, invoiceName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.TransactionsClient", "ListByInvoice", nil, "Failure preparing request") + return + } + + resp, err := client.ListByInvoiceSender(req) + if err != nil { + result.tlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.TransactionsClient", "ListByInvoice", resp, "Failure sending request") + return + } + + result.tlr, err = client.ListByInvoiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.TransactionsClient", "ListByInvoice", resp, "Failure responding to request") + } + + return +} + +// ListByInvoicePreparer prepares the ListByInvoice request. +func (client TransactionsClient) ListByInvoicePreparer(ctx context.Context, billingAccountName string, invoiceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "invoiceName": autorest.Encode("path", invoiceName), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/{invoiceName}/transactions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByInvoiceSender sends the ListByInvoice request. The method will close the +// http.Response Body if it receives an error. +func (client TransactionsClient) ListByInvoiceSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListByInvoiceResponder handles the response to the ListByInvoice request. The method always +// closes the http.Response Body. +func (client TransactionsClient) ListByInvoiceResponder(resp *http.Response) (result TransactionListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByInvoiceNextResults retrieves the next set of results, if any. +func (client TransactionsClient) listByInvoiceNextResults(ctx context.Context, lastResults TransactionListResult) (result TransactionListResult, err error) { + req, err := lastResults.transactionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.TransactionsClient", "listByInvoiceNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByInvoiceSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.TransactionsClient", "listByInvoiceNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByInvoiceResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.TransactionsClient", "listByInvoiceNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByInvoiceComplete enumerates all values, automatically crossing page boundaries as required. +func (client TransactionsClient) ListByInvoiceComplete(ctx context.Context, billingAccountName string, invoiceName string) (result TransactionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TransactionsClient.ListByInvoice") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByInvoice(ctx, billingAccountName, invoiceName) + return +} diff --git a/services/preview/billing/mgmt/2020-05-01-preview/billing/version.go b/services/preview/billing/mgmt/2020-05-01-preview/billing/version.go new file mode 100644 index 000000000000..4e7c9c5d7fad --- /dev/null +++ b/services/preview/billing/mgmt/2020-05-01-preview/billing/version.go @@ -0,0 +1,30 @@ +package billing + +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() + " billing/2020-05-01" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +}