diff --git a/profiles/preview/preview/billing/mgmt/billing/billingapi/models.go b/profiles/preview/preview/billing/mgmt/billing/billingapi/models.go index 35c522e07b36..1bd9da01c6e7 100644 --- a/profiles/preview/preview/billing/mgmt/billing/billingapi/models.go +++ b/profiles/preview/preview/billing/mgmt/billing/billingapi/models.go @@ -22,9 +22,10 @@ package billingapi import original "github.com/Azure/azure-sdk-for-go/services/preview/billing/mgmt/2018-11-01-preview/billing/billingapi" type AccountsClientAPI = original.AccountsClientAPI -type AccountsValidateAddressClientAPI = original.AccountsValidateAddressClientAPI +type AddressesClientAPI = original.AddressesClientAPI type AgreementsClientAPI = original.AgreementsClientAPI type AvailableBalancesClientAPI = original.AvailableBalancesClientAPI +type CustomersClientAPI = original.CustomersClientAPI type DepartmentsClientAPI = original.DepartmentsClientAPI type EnrollmentAccountsClientAPI = original.EnrollmentAccountsClientAPI type InvoiceSectionsClientAPI = original.InvoiceSectionsClientAPI diff --git a/profiles/preview/preview/billing/mgmt/billing/models.go b/profiles/preview/preview/billing/mgmt/billing/models.go index c8e4fc3313b3..9ca38bc4b289 100644 --- a/profiles/preview/preview/billing/mgmt/billing/models.go +++ b/profiles/preview/preview/billing/mgmt/billing/models.go @@ -97,6 +97,20 @@ const ( NotStarted ProductTransferStatus = original.NotStarted ) +type ProductTransferValidationErrorCode = original.ProductTransferValidationErrorCode + +const ( + CrossBillingAccountNotAllowed ProductTransferValidationErrorCode = original.CrossBillingAccountNotAllowed + DestinationBillingProfilePastDue ProductTransferValidationErrorCode = original.DestinationBillingProfilePastDue + InsufficientPermissionOnDestination ProductTransferValidationErrorCode = original.InsufficientPermissionOnDestination + InsufficientPermissionOnSource ProductTransferValidationErrorCode = original.InsufficientPermissionOnSource + InvalidSource ProductTransferValidationErrorCode = original.InvalidSource + NotAvailableForDestinationMarket ProductTransferValidationErrorCode = original.NotAvailableForDestinationMarket + OneTimePurchaseProductTransferNotAllowed ProductTransferValidationErrorCode = original.OneTimePurchaseProductTransferNotAllowed + ProductNotActive ProductTransferValidationErrorCode = original.ProductNotActive + ProductTypeNotSupported ProductTransferValidationErrorCode = original.ProductTypeNotSupported +) + type ProductType = original.ProductType const ( @@ -137,6 +151,19 @@ const ( SubscriptionStatusTypeWarning SubscriptionStatusType = original.SubscriptionStatusTypeWarning ) +type SubscriptionTransferValidationErrorCode = original.SubscriptionTransferValidationErrorCode + +const ( + SubscriptionTransferValidationErrorCodeCrossBillingAccountNotAllowed SubscriptionTransferValidationErrorCode = original.SubscriptionTransferValidationErrorCodeCrossBillingAccountNotAllowed + SubscriptionTransferValidationErrorCodeDestinationBillingProfilePastDue SubscriptionTransferValidationErrorCode = original.SubscriptionTransferValidationErrorCodeDestinationBillingProfilePastDue + SubscriptionTransferValidationErrorCodeInsufficientPermissionOnDestination SubscriptionTransferValidationErrorCode = original.SubscriptionTransferValidationErrorCodeInsufficientPermissionOnDestination + SubscriptionTransferValidationErrorCodeInsufficientPermissionOnSource SubscriptionTransferValidationErrorCode = original.SubscriptionTransferValidationErrorCodeInsufficientPermissionOnSource + SubscriptionTransferValidationErrorCodeInvalidSource SubscriptionTransferValidationErrorCode = original.SubscriptionTransferValidationErrorCodeInvalidSource + SubscriptionTransferValidationErrorCodeNotAvailableForDestinationMarket SubscriptionTransferValidationErrorCode = original.SubscriptionTransferValidationErrorCodeNotAvailableForDestinationMarket + SubscriptionTransferValidationErrorCodeSubscriptionNotActive SubscriptionTransferValidationErrorCode = original.SubscriptionTransferValidationErrorCodeSubscriptionNotActive + SubscriptionTransferValidationErrorCodeSubscriptionTypeNotSupported SubscriptionTransferValidationErrorCode = original.SubscriptionTransferValidationErrorCodeSubscriptionTypeNotSupported +) + type TransactionTypeKind = original.TransactionTypeKind const ( @@ -171,8 +198,8 @@ type AccountProperties = original.AccountProperties type AccountUpdateProperties = original.AccountUpdateProperties type AccountsClient = original.AccountsClient type AccountsUpdateFuture = original.AccountsUpdateFuture -type AccountsValidateAddressClient = original.AccountsValidateAddressClient type Address = original.Address +type AddressesClient = original.AddressesClient type Agreement = original.Agreement type AgreementListResult = original.AgreementListResult type AgreementProperties = original.AgreementProperties @@ -182,6 +209,10 @@ type AvailableBalance = original.AvailableBalance type AvailableBalanceProperties = original.AvailableBalanceProperties type AvailableBalancesClient = original.AvailableBalancesClient type BaseClient = original.BaseClient +type Customer = original.Customer +type CustomerListResult = original.CustomerListResult +type CustomerProperties = original.CustomerProperties +type CustomersClient = original.CustomersClient type Department = original.Department type DepartmentListResult = original.DepartmentListResult type DepartmentProperties = original.DepartmentProperties @@ -248,9 +279,11 @@ type ProductsListResult = original.ProductsListResult type ProductsListResultIterator = original.ProductsListResultIterator type ProductsListResultPage = original.ProductsListResultPage type Profile = original.Profile +type ProfileCreationParameters = original.ProfileCreationParameters type ProfileListResult = original.ProfileListResult type ProfileProperties = original.ProfileProperties type ProfilesClient = original.ProfilesClient +type ProfilesCreateFuture = original.ProfilesCreateFuture type ProfilesUpdateFuture = original.ProfilesUpdateFuture type Property = original.Property type PropertyClient = original.PropertyClient @@ -271,6 +304,7 @@ type RoleDefinition = original.RoleDefinition type RoleDefinitionListResult = original.RoleDefinitionListResult type RoleDefinitionProperties = original.RoleDefinitionProperties type RoleDefinitionsClient = original.RoleDefinitionsClient +type ServiceProvider = original.ServiceProvider type SubscriptionProperties = original.SubscriptionProperties type SubscriptionSummary = original.SubscriptionSummary type SubscriptionsClient = original.SubscriptionsClient @@ -299,6 +333,10 @@ type UpdateAutoRenewOperationSummary = original.UpdateAutoRenewOperationSummary type UpdateAutoRenewOperationSummaryProperties = original.UpdateAutoRenewOperationSummaryProperties type UpdateAutoRenewRequest = original.UpdateAutoRenewRequest type ValidateAddressResponse = original.ValidateAddressResponse +type ValidateProductTransferEligibilityError = original.ValidateProductTransferEligibilityError +type ValidateProductTransferEligibilityResult = original.ValidateProductTransferEligibilityResult +type ValidateSubscriptionTransferEligibilityError = original.ValidateSubscriptionTransferEligibilityError +type ValidateSubscriptionTransferEligibilityResult = original.ValidateSubscriptionTransferEligibilityResult func New(subscriptionID string) BaseClient { return original.New(subscriptionID) @@ -309,11 +347,11 @@ func NewAccountsClient(subscriptionID string) AccountsClient { func NewAccountsClientWithBaseURI(baseURI string, subscriptionID string) AccountsClient { return original.NewAccountsClientWithBaseURI(baseURI, subscriptionID) } -func NewAccountsValidateAddressClient(subscriptionID string) AccountsValidateAddressClient { - return original.NewAccountsValidateAddressClient(subscriptionID) +func NewAddressesClient(subscriptionID string) AddressesClient { + return original.NewAddressesClient(subscriptionID) } -func NewAccountsValidateAddressClientWithBaseURI(baseURI string, subscriptionID string) AccountsValidateAddressClient { - return original.NewAccountsValidateAddressClientWithBaseURI(baseURI, subscriptionID) +func NewAddressesClientWithBaseURI(baseURI string, subscriptionID string) AddressesClient { + return original.NewAddressesClientWithBaseURI(baseURI, subscriptionID) } func NewAgreementsClient(subscriptionID string) AgreementsClient { return original.NewAgreementsClient(subscriptionID) @@ -327,6 +365,12 @@ func NewAvailableBalancesClient(subscriptionID string) AvailableBalancesClient { func NewAvailableBalancesClientWithBaseURI(baseURI string, subscriptionID string) AvailableBalancesClient { return original.NewAvailableBalancesClientWithBaseURI(baseURI, subscriptionID) } +func NewCustomersClient(subscriptionID string) CustomersClient { + return original.NewCustomersClient(subscriptionID) +} +func NewCustomersClientWithBaseURI(baseURI string, subscriptionID string) CustomersClient { + return original.NewCustomersClientWithBaseURI(baseURI, subscriptionID) +} func NewDepartmentsClient(subscriptionID string) DepartmentsClient { return original.NewDepartmentsClient(subscriptionID) } @@ -510,6 +554,9 @@ func PossibleProductStatusTypeValues() []ProductStatusType { func PossibleProductTransferStatusValues() []ProductTransferStatus { return original.PossibleProductTransferStatusValues() } +func PossibleProductTransferValidationErrorCodeValues() []ProductTransferValidationErrorCode { + return original.PossibleProductTransferValidationErrorCodeValues() +} func PossibleProductTypeValues() []ProductType { return original.PossibleProductTypeValues() } @@ -525,6 +572,9 @@ func PossibleStatusValues() []Status { func PossibleSubscriptionStatusTypeValues() []SubscriptionStatusType { return original.PossibleSubscriptionStatusTypeValues() } +func PossibleSubscriptionTransferValidationErrorCodeValues() []SubscriptionTransferValidationErrorCode { + return original.PossibleSubscriptionTransferValidationErrorCodeValues() +} func PossibleTransactionTypeKindValues() []TransactionTypeKind { return original.PossibleTransactionTypeKindValues() } diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/accounts.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/accounts.go index 4ae7a3680fbe..2acca5253f9b 100644 --- a/services/preview/billing/mgmt/2018-11-01-preview/billing/accounts.go +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/accounts.go @@ -118,7 +118,7 @@ func (client AccountsClient) GetResponder(resp *http.Response) (result Account, return } -// List lists all billing accounts for a user which he has access to. +// List lists all billing accounts for which a user has access. // Parameters: // expand - may be used to expand the invoiceSections and billingProfiles. func (client AccountsClient) List(ctx context.Context, expand string) (result AccountListResult, err error) { diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/accountsvalidateaddress.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/accountsvalidateaddress.go deleted file mode 100644 index b87e8a2701c7..000000000000 --- a/services/preview/billing/mgmt/2018-11-01-preview/billing/accountsvalidateaddress.go +++ /dev/null @@ -1,117 +0,0 @@ -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" -) - -// AccountsValidateAddressClient is the billing client provides access to billing resources for Azure subscriptions. -type AccountsValidateAddressClient struct { - BaseClient -} - -// NewAccountsValidateAddressClient creates an instance of the AccountsValidateAddressClient client. -func NewAccountsValidateAddressClient(subscriptionID string) AccountsValidateAddressClient { - return NewAccountsValidateAddressClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewAccountsValidateAddressClientWithBaseURI creates an instance of the AccountsValidateAddressClient client. -func NewAccountsValidateAddressClientWithBaseURI(baseURI string, subscriptionID string) AccountsValidateAddressClient { - return AccountsValidateAddressClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// Post validates the address. -// Parameters: -// billingAccountName - billing Account Id. -func (client AccountsValidateAddressClient) Post(ctx context.Context, billingAccountName string, address Address) (result ValidateAddressResponse, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/AccountsValidateAddressClient.Post") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.PostPreparer(ctx, billingAccountName, address) - if err != nil { - err = autorest.NewErrorWithError(err, "billing.AccountsValidateAddressClient", "Post", nil, "Failure preparing request") - return - } - - resp, err := client.PostSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "billing.AccountsValidateAddressClient", "Post", resp, "Failure sending request") - return - } - - result, err = client.PostResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "billing.AccountsValidateAddressClient", "Post", resp, "Failure responding to request") - } - - return -} - -// PostPreparer prepares the Post request. -func (client AccountsValidateAddressClient) PostPreparer(ctx context.Context, billingAccountName string, address Address) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "billingAccountName": autorest.Encode("path", billingAccountName), - } - - const APIVersion = "2018-11-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/validateAddress", pathParameters), - autorest.WithJSON(address), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// PostSender sends the Post request. The method will close the -// http.Response Body if it receives an error. -func (client AccountsValidateAddressClient) PostSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} - -// PostResponder handles the response to the Post request. The method always -// closes the http.Response Body. -func (client AccountsValidateAddressClient) PostResponder(resp *http.Response) (result ValidateAddressResponse, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/addresses.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/addresses.go new file mode 100644 index 000000000000..56333fe01201 --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/addresses.go @@ -0,0 +1,111 @@ +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" +) + +// AddressesClient is the billing client provides access to billing resources for Azure subscriptions. +type AddressesClient struct { + BaseClient +} + +// NewAddressesClient creates an instance of the AddressesClient client. +func NewAddressesClient(subscriptionID string) AddressesClient { + return NewAddressesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAddressesClientWithBaseURI creates an instance of the AddressesClient client. +func NewAddressesClientWithBaseURI(baseURI string, subscriptionID string) AddressesClient { + return AddressesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Validate validates the address. +func (client AddressesClient) Validate(ctx context.Context, address Address) (result ValidateAddressResponse, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AddressesClient.Validate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ValidatePreparer(ctx, address) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AddressesClient", "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.AddressesClient", "Validate", resp, "Failure sending request") + return + } + + result, err = client.ValidateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AddressesClient", "Validate", resp, "Failure responding to request") + } + + return +} + +// ValidatePreparer prepares the Validate request. +func (client AddressesClient) ValidatePreparer(ctx context.Context, address Address) (*http.Request, error) { + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.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 AddressesClient) ValidateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, 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 AddressesClient) ValidateResponder(resp *http.Response) (result ValidateAddressResponse, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/billingapi/interfaces.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/billingapi/interfaces.go index d2afae1a485a..21df887cd012 100644 --- a/services/preview/billing/mgmt/2018-11-01-preview/billing/billingapi/interfaces.go +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/billingapi/interfaces.go @@ -40,12 +40,12 @@ type PaymentMethodsClientAPI interface { var _ PaymentMethodsClientAPI = (*billing.PaymentMethodsClient)(nil) -// AccountsValidateAddressClientAPI contains the set of methods on the AccountsValidateAddressClient type. -type AccountsValidateAddressClientAPI interface { - Post(ctx context.Context, billingAccountName string, address billing.Address) (result billing.ValidateAddressResponse, err error) +// AddressesClientAPI contains the set of methods on the AddressesClient type. +type AddressesClientAPI interface { + Validate(ctx context.Context, address billing.Address) (result billing.ValidateAddressResponse, err error) } -var _ AccountsValidateAddressClientAPI = (*billing.AccountsValidateAddressClient)(nil) +var _ AddressesClientAPI = (*billing.AddressesClient)(nil) // AvailableBalancesClientAPI contains the set of methods on the AvailableBalancesClient type. type AvailableBalancesClientAPI interface { @@ -56,6 +56,7 @@ var _ AvailableBalancesClientAPI = (*billing.AvailableBalancesClient)(nil) // ProfilesClientAPI contains the set of methods on the ProfilesClient type. type ProfilesClientAPI interface { + Create(ctx context.Context, billingAccountName string, parameters billing.ProfileCreationParameters) (result billing.ProfilesCreateFuture, err error) Get(ctx context.Context, billingAccountName string, billingProfileName string, expand string) (result billing.Profile, err error) ListByBillingAccountName(ctx context.Context, billingAccountName string, expand string) (result billing.ProfileListResult, err error) Update(ctx context.Context, billingAccountName string, billingProfileName string, parameters billing.Profile) (result billing.ProfilesUpdateFuture, err error) @@ -63,6 +64,14 @@ type ProfilesClientAPI interface { 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) + ListByBillingAccountName(ctx context.Context, billingAccountName string, filter string, skiptoken string) (result billing.CustomerListResult, err error) +} + +var _ CustomersClientAPI = (*billing.CustomersClient)(nil) + // InvoiceSectionsClientAPI contains the set of methods on the InvoiceSectionsClient type. type InvoiceSectionsClientAPI interface { Create(ctx context.Context, billingAccountName string, parameters billing.InvoiceSectionCreationRequest) (result billing.InvoiceSectionsCreateFuture, err error) @@ -111,10 +120,13 @@ var _ PriceSheetClientAPI = (*billing.PriceSheetClient)(nil) // SubscriptionsClientAPI contains the set of methods on the SubscriptionsClient type. type SubscriptionsClientAPI interface { Get(ctx context.Context, billingAccountName string, invoiceSectionName string, billingSubscriptionName string) (result billing.SubscriptionSummary, err error) + GetByCustomerName(ctx context.Context, billingAccountName string, customerName string, billingSubscriptionName string) (result billing.SubscriptionSummary, err error) ListByBillingAccountName(ctx context.Context, billingAccountName string) (result billing.SubscriptionsListResultPage, err error) ListByBillingProfileName(ctx context.Context, billingAccountName string, billingProfileName string) (result billing.SubscriptionsListResult, err error) + ListByCustomerName(ctx context.Context, billingAccountName string, customerName string) (result billing.SubscriptionsListResult, err error) ListByInvoiceSectionName(ctx context.Context, billingAccountName string, invoiceSectionName string) (result billing.SubscriptionsListResult, err error) Transfer(ctx context.Context, billingAccountName string, invoiceSectionName string, billingSubscriptionName string, parameters billing.TransferBillingSubscriptionRequestProperties) (result billing.SubscriptionsTransferFuture, err error) + ValidateTransfer(ctx context.Context, billingAccountName string, invoiceSectionName string, billingSubscriptionName string, parameters billing.TransferBillingSubscriptionRequestProperties) (result billing.ValidateSubscriptionTransferEligibilityResult, err error) } var _ SubscriptionsClientAPI = (*billing.SubscriptionsClient)(nil) @@ -127,6 +139,7 @@ type ProductsClientAPI interface { Transfer(ctx context.Context, billingAccountName string, invoiceSectionName string, productName string, parameters billing.TransferProductRequestProperties) (result billing.ProductSummary, err error) UpdateAutoRenewByBillingAccountName(ctx context.Context, billingAccountName string, productName string, body billing.UpdateAutoRenewRequest) (result billing.UpdateAutoRenewOperationSummary, err error) UpdateAutoRenewByInvoiceSectionName(ctx context.Context, billingAccountName string, invoiceSectionName string, productName string, body billing.UpdateAutoRenewRequest) (result billing.UpdateAutoRenewOperationSummary, err error) + ValidateTransfer(ctx context.Context, billingAccountName string, invoiceSectionName string, productName string, parameters billing.TransferProductRequestProperties) (result billing.ValidateProductTransferEligibilityResult, err error) } var _ ProductsClientAPI = (*billing.ProductsClient)(nil) @@ -135,6 +148,7 @@ var _ ProductsClientAPI = (*billing.ProductsClient)(nil) type TransactionsClientAPI interface { ListByBillingAccountName(ctx context.Context, billingAccountName string, startDate string, endDate string, filter string) (result billing.TransactionsListResultPage, err error) ListByBillingProfileName(ctx context.Context, billingAccountName string, billingProfileName string, startDate string, endDate string, filter string) (result billing.TransactionsListResult, err error) + ListByCustomerName(ctx context.Context, billingAccountName string, customerName string, startDate string, endDate string, filter string) (result billing.TransactionsListResult, err error) ListByInvoiceSectionName(ctx context.Context, billingAccountName string, invoiceSectionName string, startDate string, endDate string, filter string) (result billing.TransactionsListResult, err error) } @@ -186,6 +200,7 @@ var _ OperationsClientAPI = (*billing.OperationsClient)(nil) type PermissionsClientAPI interface { ListByBillingAccount(ctx context.Context, billingAccountName string) (result billing.PermissionsListResult, err error) ListByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string) (result billing.PermissionsListResult, err error) + ListByCustomers(ctx context.Context, billingAccountName string, customerName string) (result billing.PermissionsListResult, err error) ListByInvoiceSections(ctx context.Context, billingAccountName string, invoiceSectionName string) (result billing.PermissionsListResult, err error) } diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/customers.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/customers.go new file mode 100644 index 000000000000..9a885ab75a40 --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/customers.go @@ -0,0 +1,206 @@ +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. +func NewCustomersClientWithBaseURI(baseURI string, subscriptionID string) CustomersClient { + return CustomersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get get the customer by id. +// Parameters: +// billingAccountName - billing Account Id. +// customerName - customer Id. +// expand - may be used to expand enabledAzureSkus, serviceProviders. +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 = "2018-11-01-preview" + 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 autorest.SendWithSender(client, 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, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByBillingAccountName lists all customers which the current user can work with on-behalf of a partner. +// Parameters: +// billingAccountName - billing Account Id. +// filter - may be used to filter using hasPermission('{permissionId}') to only return customers for which the +// caller has the specified permission. +// skiptoken - skiptoken is only used if a previous operation returned a partial result. If a previous response +// contains a nextLink element, the value of the nextLink element will include a skiptoken parameter that +// specifies a starting point to use for subsequent calls. +func (client CustomersClient) ListByBillingAccountName(ctx context.Context, billingAccountName string, filter string, skiptoken string) (result CustomerListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CustomersClient.ListByBillingAccountName") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByBillingAccountNamePreparer(ctx, billingAccountName, filter, skiptoken) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.CustomersClient", "ListByBillingAccountName", nil, "Failure preparing request") + return + } + + resp, err := client.ListByBillingAccountNameSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.CustomersClient", "ListByBillingAccountName", resp, "Failure sending request") + return + } + + result, err = client.ListByBillingAccountNameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.CustomersClient", "ListByBillingAccountName", resp, "Failure responding to request") + } + + return +} + +// ListByBillingAccountNamePreparer prepares the ListByBillingAccountName request. +func (client CustomersClient) ListByBillingAccountNamePreparer(ctx context.Context, billingAccountName string, filter string, skiptoken string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + } + + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if len(filter) > 0 { + queryParameters["$filter"] = autorest.Encode("query", filter) + } + if len(skiptoken) > 0 { + queryParameters["$skiptoken"] = autorest.Encode("query", skiptoken) + } + + 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)) +} + +// ListByBillingAccountNameSender sends the ListByBillingAccountName request. The method will close the +// http.Response Body if it receives an error. +func (client CustomersClient) ListByBillingAccountNameSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListByBillingAccountNameResponder handles the response to the ListByBillingAccountName request. The method always +// closes the http.Response Body. +func (client CustomersClient) ListByBillingAccountNameResponder(resp *http.Response) (result CustomerListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/departments.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/departments.go index 34c369870561..5795c6871dd1 100644 --- a/services/preview/billing/mgmt/2018-11-01-preview/billing/departments.go +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/departments.go @@ -125,7 +125,7 @@ func (client DepartmentsClient) GetResponder(resp *http.Response) (result Depart return } -// ListByBillingAccountName lists all departments for a user which he has access to. +// ListByBillingAccountName lists all departments for which a user has access. // Parameters: // billingAccountName - billing Account Id. // expand - may be used to expand the enrollmentAccounts. diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/enrollmentaccounts.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/enrollmentaccounts.go index 07b0a01c639e..b463d00011ca 100644 --- a/services/preview/billing/mgmt/2018-11-01-preview/billing/enrollmentaccounts.go +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/enrollmentaccounts.go @@ -125,7 +125,7 @@ func (client EnrollmentAccountsClient) GetByEnrollmentAccountIDResponder(resp *h return } -// ListByBillingAccountName lists all Enrollment Accounts for a user which he has access to. +// ListByBillingAccountName lists all Enrollment Accounts for which a user has access. // Parameters: // billingAccountName - billing Account Id. // expand - may be used to expand the department. diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/invoicesections.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/invoicesections.go index 5ca7c1d620b7..5e9f81e67313 100644 --- a/services/preview/billing/mgmt/2018-11-01-preview/billing/invoicesections.go +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/invoicesections.go @@ -266,7 +266,7 @@ func (client InvoiceSectionsClient) GetResponder(resp *http.Response) (result In return } -// ListByBillingAccountName lists all invoice sections for a user which he has access to. +// ListByBillingAccountName lists all invoice sections for which a user has access. // Parameters: // billingAccountName - billing Account Id. // expand - may be used to expand the billingProfiles. @@ -344,7 +344,7 @@ func (client InvoiceSectionsClient) ListByBillingAccountNameResponder(resp *http return } -// ListByBillingProfileName lists all invoice sections under a billing profile for a user which he has access to. +// ListByBillingProfileName lists all invoice sections under a billing profile for which a user has access. // Parameters: // billingAccountName - billing Account Id. // billingProfileName - billing Profile Id. diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/models.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/models.go index 6ab226ed8645..fb0c809926ae 100644 --- a/services/preview/billing/mgmt/2018-11-01-preview/billing/models.go +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/models.go @@ -176,6 +176,35 @@ func PossibleProductTransferStatusValues() []ProductTransferStatus { return []ProductTransferStatus{Completed, Failed, InProgress, NotStarted} } +// 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} +} + // ProductType enumerates the values for product type. type ProductType string @@ -261,6 +290,34 @@ 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 @@ -743,6 +800,98 @@ type AvailableBalanceProperties struct { Amount *Amount `json:"amount,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 result of listing 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"` +} + +// CustomerProperties the properties of a customer. +type CustomerProperties struct { + // DisplayName - The name of the customer. + DisplayName *string `json:"displayName,omitempty"` + // EnabledAzureSKUs - Information about the product. + EnabledAzureSKUs *[]EnabledAzureSKUs `json:"enabledAzureSKUs,omitempty"` + // ServiceProviders - The service providers which are allowed to provide service to this customer. + ServiceProviders *[]ServiceProvider `json:"serviceProviders,omitempty"` +} + // Department a department resource. type Department struct { autorest.Response `json:"-"` @@ -868,7 +1017,7 @@ type DownloadURL struct { // EnabledAzureSKUs details about the enabled azure sku. type EnabledAzureSKUs struct { - // SkuID - READ-ONLY; The sku id. + // SkuID - The sku id. SkuID *string `json:"skuId,omitempty"` // SkuDescription - READ-ONLY; The sku description. SkuDescription *string `json:"skuDescription,omitempty"` @@ -2363,6 +2512,20 @@ func (p *Profile) UnmarshalJSON(body []byte) error { return nil } +// ProfileCreationParameters the parameters for creating a new billing profile. +type ProfileCreationParameters struct { + // DisplayName - The billing profile name. + DisplayName *string `json:"displayName,omitempty"` + // PoNumber - Purchase order number. + PoNumber *string `json:"poNumber,omitempty"` + // Address - Billing address. + Address *Address `json:"address,omitempty"` + // InvoiceEmailOptIn - If the billing profile is opted in to receive invoices via email. + InvoiceEmailOptIn *bool `json:"invoiceEmailOptIn,omitempty"` + // EnableAzureSKUs - Azure skus to enable for this billing profile.. + EnableAzureSKUs *[]EnabledAzureSKUs `json:"enableAzureSKUs,omitempty"` +} + // ProfileListResult result of listing billing profiles. type ProfileListResult struct { autorest.Response `json:"-"` @@ -2394,6 +2557,35 @@ type ProfileProperties struct { InvoiceSections *[]InvoiceSection `json:"invoiceSections,omitempty"` } +// ProfilesCreateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ProfilesCreateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ProfilesCreateFuture) 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.ProfilesCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("billing.ProfilesCreateFuture") + 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.CreateResponder(p.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProfilesCreateFuture", "Result", p.Response.Response, "Failure responding to request") + } + } + return +} + // ProfilesUpdateFuture an abstraction for monitoring and retrieving the results of a long-running // operation. type ProfilesUpdateFuture struct { @@ -2990,6 +3182,14 @@ func (rdp *RoleDefinitionProperties) UnmarshalJSON(body []byte) error { return nil } +// ServiceProvider details about a service provider. +type ServiceProvider struct { + // ServiceProviderID - READ-ONLY; The service provider id. + ServiceProviderID *string `json:"serviceProviderId,omitempty"` + // Description - READ-ONLY; A description of the service provider. + Description *string `json:"description,omitempty"` +} + // SubscriptionProperties the usage context properties. type SubscriptionProperties struct { // DisplayName - READ-ONLY; display name. @@ -3006,6 +3206,10 @@ type SubscriptionProperties struct { BillingProfileID *string `json:"billingProfileId,omitempty"` // BillingProfileName - READ-ONLY; Billing Profile name to which this product belongs. BillingProfileName *string `json:"billingProfileName,omitempty"` + // CustomerID - READ-ONLY; Customer id to which this product belongs. + CustomerID *string `json:"customerId,omitempty"` + // CustomerDisplayName - READ-ONLY; Display name of customer to which this product belongs. + CustomerDisplayName *string `json:"customerDisplayName,omitempty"` // InvoiceSectionID - READ-ONLY; Invoice section id to which this product belongs. InvoiceSectionID *string `json:"invoiceSectionId,omitempty"` // InvoiceSectionName - READ-ONLY; Invoice section name to which this product belongs. @@ -3014,6 +3218,10 @@ type SubscriptionProperties struct { SkuID *string `json:"skuId,omitempty"` // SkuDescription - READ-ONLY; The sku description. SkuDescription *string `json:"skuDescription,omitempty"` + // ServiceProviderID - The service provider id. + ServiceProviderID *string `json:"serviceProviderId,omitempty"` + // ServiceProviderDescription - READ-ONLY; The service provider description. + ServiceProviderDescription *string `json:"serviceProviderDescription,omitempty"` } // SubscriptionsListResult result of listing billing subscriptions summary. @@ -3506,6 +3714,10 @@ type TransactionsSummaryProperties struct { TransactionAmount *Amount `json:"transactionAmount,omitempty"` // Quantity - READ-ONLY; Purchase quantity. Quantity *int32 `json:"quantity,omitempty"` + // CustomerID - READ-ONLY; Customer id to which this product belongs. + CustomerID *string `json:"customerId,omitempty"` + // CustomerDisplayName - READ-ONLY; Display name of customer to which this product belongs. + CustomerDisplayName *string `json:"customerDisplayName,omitempty"` // InvoiceSectionID - READ-ONLY; Invoice section id to which this product belongs. InvoiceSectionID *string `json:"invoiceSectionId,omitempty"` // InvoiceSectionName - READ-ONLY; Invoice section name to which this product belongs. @@ -3563,6 +3775,8 @@ func (tbsr *TransferBillingSubscriptionRequest) UnmarshalJSON(body []byte) error type TransferBillingSubscriptionRequestProperties struct { // DestinationInvoiceSectionID - The destination invoice section id. DestinationInvoiceSectionID *string `json:"destinationInvoiceSectionId,omitempty"` + // DestinationBillingProfileID - The destination billing profile id. + DestinationBillingProfileID *string `json:"destinationBillingProfileId,omitempty"` } // TransferBillingSubscriptionResult request parameters to transfer billing subscription. @@ -3799,8 +4013,10 @@ func NewTransferDetailsListResultPage(getNextPage func(context.Context, Transfer // TransferProductRequestProperties the properties of the product to initiate a transfer. type TransferProductRequestProperties struct { - // DestinationInvoiceSectionID - Destination invoice section id. + // DestinationInvoiceSectionID - The destination invoice section id. DestinationInvoiceSectionID *string `json:"destinationInvoiceSectionId,omitempty"` + // DestinationBillingProfileID - The destination billing profile id. + DestinationBillingProfileID *string `json:"destinationBillingProfileId,omitempty"` } // TransferProperties transfer details @@ -3889,3 +4105,41 @@ type ValidateAddressResponse struct { // 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:"-"` + // IsTransferEligible - READ-ONLY; Specifies whether the transfer is eligible or not. + IsTransferEligible *bool `json:"isTransferEligible,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:"-"` + // IsTransferEligible - READ-ONLY; Specifies whether the transfer is eligible or not. + IsTransferEligible *bool `json:"isTransferEligible,omitempty"` + // ErrorDetails - Validation error details. + ErrorDetails *ValidateSubscriptionTransferEligibilityError `json:"errorDetails,omitempty"` +} diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/permissions.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/permissions.go index 17d9dd91d6d4..b52b3e1d5a19 100644 --- a/services/preview/billing/mgmt/2018-11-01-preview/billing/permissions.go +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/permissions.go @@ -190,6 +190,82 @@ func (client PermissionsClient) ListByBillingProfileResponder(resp *http.Respons return } +// ListByCustomers lists all billing permissions for the caller under customer. +// Parameters: +// billingAccountName - billing Account Id. +// customerName - customer Id. +func (client PermissionsClient) ListByCustomers(ctx context.Context, billingAccountName string, customerName string) (result PermissionsListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PermissionsClient.ListByCustomers") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByCustomersPreparer(ctx, billingAccountName, customerName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PermissionsClient", "ListByCustomers", nil, "Failure preparing request") + return + } + + resp, err := client.ListByCustomersSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.PermissionsClient", "ListByCustomers", resp, "Failure sending request") + return + } + + result, err = client.ListByCustomersResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PermissionsClient", "ListByCustomers", resp, "Failure responding to request") + } + + return +} + +// ListByCustomersPreparer prepares the ListByCustomers request. +func (client PermissionsClient) ListByCustomersPreparer(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 = "2018-11-01-preview" + 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}/providers/Microsoft.Billing/billingPermissions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByCustomersSender sends the ListByCustomers request. The method will close the +// http.Response Body if it receives an error. +func (client PermissionsClient) ListByCustomersSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListByCustomersResponder handles the response to the ListByCustomers request. The method always +// closes the http.Response Body. +func (client PermissionsClient) ListByCustomersResponder(resp *http.Response) (result PermissionsListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + // ListByInvoiceSections lists all billing permissions for the caller under invoice section. // Parameters: // billingAccountName - billing Account Id. diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/products.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/products.go index 105baa3911d4..ae06bdc61f83 100644 --- a/services/preview/billing/mgmt/2018-11-01-preview/billing/products.go +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/products.go @@ -558,3 +558,78 @@ func (client ProductsClient) UpdateAutoRenewByInvoiceSectionNameResponder(resp * result.Response = autorest.Response{Response: resp} return } + +// ValidateTransfer validates the transfer of products across invoice sections. +// Parameters: +// billingAccountName - billing Account Id. +// invoiceSectionName - invoiceSection Id. +// productName - invoice Id. +// parameters - parameters supplied to the Transfer Products operation. +func (client ProductsClient) ValidateTransfer(ctx context.Context, billingAccountName string, invoiceSectionName string, productName string, parameters TransferProductRequestProperties) (result ValidateProductTransferEligibilityResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductsClient.ValidateTransfer") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ValidateTransferPreparer(ctx, billingAccountName, invoiceSectionName, productName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProductsClient", "ValidateTransfer", nil, "Failure preparing request") + return + } + + resp, err := client.ValidateTransferSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.ProductsClient", "ValidateTransfer", resp, "Failure sending request") + return + } + + result, err = client.ValidateTransferResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProductsClient", "ValidateTransfer", resp, "Failure responding to request") + } + + return +} + +// ValidateTransferPreparer prepares the ValidateTransfer request. +func (client ProductsClient) ValidateTransferPreparer(ctx context.Context, billingAccountName string, invoiceSectionName string, productName string, parameters TransferProductRequestProperties) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "invoiceSectionName": autorest.Encode("path", invoiceSectionName), + "productName": autorest.Encode("path", productName), + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoiceSections/{invoiceSectionName}/products/{productName}/validateTransferEligibility", pathParameters), + autorest.WithJSON(parameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ValidateTransferSender sends the ValidateTransfer request. The method will close the +// http.Response Body if it receives an error. +func (client ProductsClient) ValidateTransferSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ValidateTransferResponder handles the response to the ValidateTransfer request. The method always +// closes the http.Response Body. +func (client ProductsClient) ValidateTransferResponder(resp *http.Response) (result ValidateProductTransferEligibilityResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/profiles.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/profiles.go index 9a1816f2ede7..90e2d4bb91e3 100644 --- a/services/preview/billing/mgmt/2018-11-01-preview/billing/profiles.go +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/profiles.go @@ -40,6 +40,83 @@ func NewProfilesClientWithBaseURI(baseURI string, subscriptionID string) Profile return ProfilesClient{NewWithBaseURI(baseURI, subscriptionID)} } +// Create the operation to create a BillingProfile. +// Parameters: +// billingAccountName - billing Account Id. +// parameters - parameters supplied to the Create BillingProfile operation. +func (client ProfilesClient) Create(ctx context.Context, billingAccountName string, parameters ProfileCreationParameters) (result ProfilesCreateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProfilesClient.Create") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreatePreparer(ctx, billingAccountName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProfilesClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProfilesClient", "Create", result.Response(), "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client ProfilesClient) CreatePreparer(ctx context.Context, billingAccountName string, parameters ProfileCreationParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + } + + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client ProfilesClient) CreateSender(req *http.Request) (future ProfilesCreateFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client ProfilesClient) CreateResponder(resp *http.Response) (result Profile, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + // Get get the billing profile by id. // Parameters: // billingAccountName - billing Account Id. diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/subscriptions.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/subscriptions.go index f07d50706cd4..f9640328d605 100644 --- a/services/preview/billing/mgmt/2018-11-01-preview/billing/subscriptions.go +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/subscriptions.go @@ -118,6 +118,84 @@ func (client SubscriptionsClient) GetResponder(resp *http.Response) (result Subs return } +// GetByCustomerName get a single billing subscription by name. +// Parameters: +// billingAccountName - billing Account Id. +// customerName - customer Id. +// billingSubscriptionName - billing Subscription Id. +func (client SubscriptionsClient) GetByCustomerName(ctx context.Context, billingAccountName string, customerName string, billingSubscriptionName string) (result SubscriptionSummary, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionsClient.GetByCustomerName") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetByCustomerNamePreparer(ctx, billingAccountName, customerName, billingSubscriptionName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "GetByCustomerName", nil, "Failure preparing request") + return + } + + resp, err := client.GetByCustomerNameSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "GetByCustomerName", resp, "Failure sending request") + return + } + + result, err = client.GetByCustomerNameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "GetByCustomerName", resp, "Failure responding to request") + } + + return +} + +// GetByCustomerNamePreparer prepares the GetByCustomerName request. +func (client SubscriptionsClient) GetByCustomerNamePreparer(ctx context.Context, billingAccountName string, customerName string, billingSubscriptionName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingSubscriptionName": autorest.Encode("path", billingSubscriptionName), + "customerName": autorest.Encode("path", customerName), + } + + const APIVersion = "2018-11-01-preview" + 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/{billingSubscriptionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetByCustomerNameSender sends the GetByCustomerName request. The method will close the +// http.Response Body if it receives an error. +func (client SubscriptionsClient) GetByCustomerNameSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// GetByCustomerNameResponder handles the response to the GetByCustomerName request. The method always +// closes the http.Response Body. +func (client SubscriptionsClient) GetByCustomerNameResponder(resp *http.Response) (result SubscriptionSummary, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + // ListByBillingAccountName lists billing subscriptions by billing account name. // Parameters: // billingAccountName - billing Account Id. @@ -306,6 +384,82 @@ func (client SubscriptionsClient) ListByBillingProfileNameResponder(resp *http.R return } +// ListByCustomerName lists billing subscription by customer name. +// Parameters: +// billingAccountName - billing Account Id. +// customerName - customer Id. +func (client SubscriptionsClient) ListByCustomerName(ctx context.Context, billingAccountName string, customerName string) (result SubscriptionsListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionsClient.ListByCustomerName") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByCustomerNamePreparer(ctx, billingAccountName, customerName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "ListByCustomerName", nil, "Failure preparing request") + return + } + + resp, err := client.ListByCustomerNameSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "ListByCustomerName", resp, "Failure sending request") + return + } + + result, err = client.ListByCustomerNameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "ListByCustomerName", resp, "Failure responding to request") + } + + return +} + +// ListByCustomerNamePreparer prepares the ListByCustomerName request. +func (client SubscriptionsClient) ListByCustomerNamePreparer(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 = "2018-11-01-preview" + 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)) +} + +// ListByCustomerNameSender sends the ListByCustomerName request. The method will close the +// http.Response Body if it receives an error. +func (client SubscriptionsClient) ListByCustomerNameSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListByCustomerNameResponder handles the response to the ListByCustomerName request. The method always +// closes the http.Response Body. +func (client SubscriptionsClient) ListByCustomerNameResponder(resp *http.Response) (result SubscriptionsListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + // ListByInvoiceSectionName lists billing subscription by invoice section name. // Parameters: // billingAccountName - billing Account Id. @@ -456,3 +610,78 @@ func (client SubscriptionsClient) TransferResponder(resp *http.Response) (result result.Response = autorest.Response{Response: resp} return } + +// ValidateTransfer validates the transfer of billing subscriptions across invoice sections. +// Parameters: +// billingAccountName - billing Account Id. +// invoiceSectionName - invoiceSection Id. +// billingSubscriptionName - billing Subscription Id. +// parameters - parameters supplied to the Transfer Billing Subscription operation. +func (client SubscriptionsClient) ValidateTransfer(ctx context.Context, billingAccountName string, invoiceSectionName string, billingSubscriptionName string, parameters TransferBillingSubscriptionRequestProperties) (result ValidateSubscriptionTransferEligibilityResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionsClient.ValidateTransfer") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ValidateTransferPreparer(ctx, billingAccountName, invoiceSectionName, billingSubscriptionName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "ValidateTransfer", nil, "Failure preparing request") + return + } + + resp, err := client.ValidateTransferSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "ValidateTransfer", resp, "Failure sending request") + return + } + + result, err = client.ValidateTransferResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "ValidateTransfer", resp, "Failure responding to request") + } + + return +} + +// ValidateTransferPreparer prepares the ValidateTransfer request. +func (client SubscriptionsClient) ValidateTransferPreparer(ctx context.Context, billingAccountName string, invoiceSectionName string, billingSubscriptionName string, parameters TransferBillingSubscriptionRequestProperties) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "billingSubscriptionName": autorest.Encode("path", billingSubscriptionName), + "invoiceSectionName": autorest.Encode("path", invoiceSectionName), + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoiceSections/{invoiceSectionName}/billingSubscriptions/{billingSubscriptionName}/validateTransferEligibility", pathParameters), + autorest.WithJSON(parameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ValidateTransferSender sends the ValidateTransfer request. The method will close the +// http.Response Body if it receives an error. +func (client SubscriptionsClient) ValidateTransferSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ValidateTransferResponder handles the response to the ValidateTransfer request. The method always +// closes the http.Response Body. +func (client SubscriptionsClient) ValidateTransferResponder(resp *http.Response) (result ValidateSubscriptionTransferEligibilityResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/transactions.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/transactions.go index 06086e93a20f..6d9d3b83b8b7 100644 --- a/services/preview/billing/mgmt/2018-11-01-preview/billing/transactions.go +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/transactions.go @@ -248,6 +248,92 @@ func (client TransactionsClient) ListByBillingProfileNameResponder(resp *http.Re return } +// ListByCustomerName lists the transactions by invoice section name for given start date and end date. +// Parameters: +// billingAccountName - billing Account Id. +// customerName - customer Id. +// startDate - start date +// endDate - end date +// filter - may be used to filter by transaction kind. 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 is separated by a colon (:). +func (client TransactionsClient) ListByCustomerName(ctx context.Context, billingAccountName string, customerName string, startDate string, endDate string, filter string) (result TransactionsListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TransactionsClient.ListByCustomerName") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByCustomerNamePreparer(ctx, billingAccountName, customerName, startDate, endDate, filter) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.TransactionsClient", "ListByCustomerName", nil, "Failure preparing request") + return + } + + resp, err := client.ListByCustomerNameSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.TransactionsClient", "ListByCustomerName", resp, "Failure sending request") + return + } + + result, err = client.ListByCustomerNameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.TransactionsClient", "ListByCustomerName", resp, "Failure responding to request") + } + + return +} + +// ListByCustomerNamePreparer prepares the ListByCustomerName request. +func (client TransactionsClient) ListByCustomerNamePreparer(ctx context.Context, billingAccountName string, customerName string, startDate string, endDate string, filter string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + "customerName": autorest.Encode("path", customerName), + } + + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + "endDate": autorest.Encode("query", endDate), + "startDate": autorest.Encode("query", startDate), + } + 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/{customerName}/transactions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByCustomerNameSender sends the ListByCustomerName request. The method will close the +// http.Response Body if it receives an error. +func (client TransactionsClient) ListByCustomerNameSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListByCustomerNameResponder handles the response to the ListByCustomerName request. The method always +// closes the http.Response Body. +func (client TransactionsClient) ListByCustomerNameResponder(resp *http.Response) (result TransactionsListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + // ListByInvoiceSectionName lists the transactions by invoice section name for given start date and end date. // Parameters: // billingAccountName - billing Account Id.