From 9f825348a14a9551b76cf32edbaf1547d340a5cd Mon Sep 17 00:00:00 2001 From: Arcturus Zhang Date: Fri, 16 Aug 2019 09:51:17 +0800 Subject: [PATCH] [AutoPR billing/resource-manager] [Do not merge] [Microsoft.Billing] Customers resource for partner-channel (#5343) * Generated from 7f7f0f2009acea6f3d52c4e1f8f4f4af37b5ae5b Update examples. * Generated from 967632713b1ea0e839baef7d47f3f857923f9ad1 Fix reseller property on billingSubscription. --- .../billing/mgmt/billing/billingapi/models.go | 1 + .../preview/billing/mgmt/billing/models.go | 75 + .../2018-11-01-preview/billing/accounts.go | 50 +- .../2018-11-01-preview/billing/agreements.go | 48 +- .../billing/billingapi/interfaces.go | 40 +- .../2018-11-01-preview/billing/customers.go | 244 +++ .../2018-11-01-preview/billing/departments.go | 50 +- .../billing/enrollmentaccounts.go | 50 +- .../2018-11-01-preview/billing/invoices.go | 96 +- .../billing/invoicesections.go | 100 +- .../mgmt/2018-11-01-preview/billing/models.go | 1398 +++++++++++++++-- .../2018-11-01-preview/billing/permissions.go | 76 + .../2018-11-01-preview/billing/products.go | 48 +- .../2018-11-01-preview/billing/profiles.go | 48 +- .../billing/subscriptions.go | 288 +++- .../billing/transactions.go | 220 ++- 16 files changed, 2647 insertions(+), 185 deletions(-) create mode 100644 services/preview/billing/mgmt/2018-11-01-preview/billing/customers.go diff --git a/profiles/preview/preview/billing/mgmt/billing/billingapi/models.go b/profiles/preview/preview/billing/mgmt/billing/billingapi/models.go index 7d015cc8d955..1bd9da01c6e7 100644 --- a/profiles/preview/preview/billing/mgmt/billing/billingapi/models.go +++ b/profiles/preview/preview/billing/mgmt/billing/billingapi/models.go @@ -25,6 +25,7 @@ type AccountsClientAPI = original.AccountsClientAPI 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 1c7f3a337240..2443bbc6ff68 100644 --- a/profiles/preview/preview/billing/mgmt/billing/models.go +++ b/profiles/preview/preview/billing/mgmt/billing/models.go @@ -194,6 +194,8 @@ type AcceptTransferProperties = original.AcceptTransferProperties type AcceptTransferRequest = original.AcceptTransferRequest type Account = original.Account type AccountListResult = original.AccountListResult +type AccountListResultIterator = original.AccountListResultIterator +type AccountListResultPage = original.AccountListResultPage type AccountProperties = original.AccountProperties type AccountUpdateProperties = original.AccountUpdateProperties type AccountsClient = original.AccountsClient @@ -202,6 +204,8 @@ type Address = original.Address type AddressesClient = original.AddressesClient type Agreement = original.Agreement type AgreementListResult = original.AgreementListResult +type AgreementListResultIterator = original.AgreementListResultIterator +type AgreementListResultPage = original.AgreementListResultPage type AgreementProperties = original.AgreementProperties type AgreementsClient = original.AgreementsClient type Amount = original.Amount @@ -209,8 +213,16 @@ 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 CustomerListResultIterator = original.CustomerListResultIterator +type CustomerListResultPage = original.CustomerListResultPage +type CustomerProperties = original.CustomerProperties +type CustomersClient = original.CustomersClient type Department = original.Department type DepartmentListResult = original.DepartmentListResult +type DepartmentListResultIterator = original.DepartmentListResultIterator +type DepartmentListResultPage = original.DepartmentListResultPage type DepartmentProperties = original.DepartmentProperties type DepartmentsClient = original.DepartmentsClient type DetailedTransferStatus = original.DetailedTransferStatus @@ -221,6 +233,8 @@ type Enrollment = original.Enrollment type EnrollmentAccount = original.EnrollmentAccount type EnrollmentAccountContext = original.EnrollmentAccountContext type EnrollmentAccountListResult = original.EnrollmentAccountListResult +type EnrollmentAccountListResultIterator = original.EnrollmentAccountListResultIterator +type EnrollmentAccountListResultPage = original.EnrollmentAccountListResultPage type EnrollmentAccountProperties = original.EnrollmentAccountProperties type EnrollmentAccountsClient = original.EnrollmentAccountsClient type EnrollmentPolicies = original.EnrollmentPolicies @@ -230,9 +244,13 @@ type ErrorResponse = original.ErrorResponse type InitiateTransferProperties = original.InitiateTransferProperties type InitiateTransferRequest = original.InitiateTransferRequest type InvoiceListResult = original.InvoiceListResult +type InvoiceListResultIterator = original.InvoiceListResultIterator +type InvoiceListResultPage = original.InvoiceListResultPage type InvoiceSection = original.InvoiceSection type InvoiceSectionCreationRequest = original.InvoiceSectionCreationRequest type InvoiceSectionListResult = original.InvoiceSectionListResult +type InvoiceSectionListResultIterator = original.InvoiceSectionListResultIterator +type InvoiceSectionListResultPage = original.InvoiceSectionListResultPage type InvoiceSectionProperties = original.InvoiceSectionProperties type InvoiceSectionsClient = original.InvoiceSectionsClient type InvoiceSectionsCreateFuture = original.InvoiceSectionsCreateFuture @@ -277,6 +295,8 @@ type ProductsListResultPage = original.ProductsListResultPage type Profile = original.Profile type ProfileCreationParameters = original.ProfileCreationParameters type ProfileListResult = original.ProfileListResult +type ProfileListResultIterator = original.ProfileListResultIterator +type ProfileListResultPage = original.ProfileListResultPage type ProfileProperties = original.ProfileProperties type ProfilesClient = original.ProfilesClient type ProfilesCreateFuture = original.ProfilesCreateFuture @@ -290,6 +310,7 @@ type RecipientTransferDetailsListResultIterator = original.RecipientTransferDeta type RecipientTransferDetailsListResultPage = original.RecipientTransferDetailsListResultPage type RecipientTransferProperties = original.RecipientTransferProperties type RecipientTransfersClient = original.RecipientTransfersClient +type Reseller = original.Reseller type Resource = original.Resource type RoleAssignment = original.RoleAssignment type RoleAssignmentListResult = original.RoleAssignmentListResult @@ -336,6 +357,12 @@ type ValidateSubscriptionTransferEligibilityResult = original.ValidateSubscripti func New(subscriptionID string) BaseClient { return original.New(subscriptionID) } +func NewAccountListResultIterator(page AccountListResultPage) AccountListResultIterator { + return original.NewAccountListResultIterator(page) +} +func NewAccountListResultPage(getNextPage func(context.Context, AccountListResult) (AccountListResult, error)) AccountListResultPage { + return original.NewAccountListResultPage(getNextPage) +} func NewAccountsClient(subscriptionID string) AccountsClient { return original.NewAccountsClient(subscriptionID) } @@ -348,6 +375,12 @@ func NewAddressesClient(subscriptionID string) AddressesClient { func NewAddressesClientWithBaseURI(baseURI string, subscriptionID string) AddressesClient { return original.NewAddressesClientWithBaseURI(baseURI, subscriptionID) } +func NewAgreementListResultIterator(page AgreementListResultPage) AgreementListResultIterator { + return original.NewAgreementListResultIterator(page) +} +func NewAgreementListResultPage(getNextPage func(context.Context, AgreementListResult) (AgreementListResult, error)) AgreementListResultPage { + return original.NewAgreementListResultPage(getNextPage) +} func NewAgreementsClient(subscriptionID string) AgreementsClient { return original.NewAgreementsClient(subscriptionID) } @@ -360,18 +393,54 @@ func NewAvailableBalancesClient(subscriptionID string) AvailableBalancesClient { func NewAvailableBalancesClientWithBaseURI(baseURI string, subscriptionID string) AvailableBalancesClient { return original.NewAvailableBalancesClientWithBaseURI(baseURI, subscriptionID) } +func NewCustomerListResultIterator(page CustomerListResultPage) CustomerListResultIterator { + return original.NewCustomerListResultIterator(page) +} +func NewCustomerListResultPage(getNextPage func(context.Context, CustomerListResult) (CustomerListResult, error)) CustomerListResultPage { + return original.NewCustomerListResultPage(getNextPage) +} +func NewCustomersClient(subscriptionID string) CustomersClient { + return original.NewCustomersClient(subscriptionID) +} +func NewCustomersClientWithBaseURI(baseURI string, subscriptionID string) CustomersClient { + return original.NewCustomersClientWithBaseURI(baseURI, subscriptionID) +} +func NewDepartmentListResultIterator(page DepartmentListResultPage) DepartmentListResultIterator { + return original.NewDepartmentListResultIterator(page) +} +func NewDepartmentListResultPage(getNextPage func(context.Context, DepartmentListResult) (DepartmentListResult, error)) DepartmentListResultPage { + return original.NewDepartmentListResultPage(getNextPage) +} func NewDepartmentsClient(subscriptionID string) DepartmentsClient { return original.NewDepartmentsClient(subscriptionID) } func NewDepartmentsClientWithBaseURI(baseURI string, subscriptionID string) DepartmentsClient { return original.NewDepartmentsClientWithBaseURI(baseURI, subscriptionID) } +func NewEnrollmentAccountListResultIterator(page EnrollmentAccountListResultPage) EnrollmentAccountListResultIterator { + return original.NewEnrollmentAccountListResultIterator(page) +} +func NewEnrollmentAccountListResultPage(getNextPage func(context.Context, EnrollmentAccountListResult) (EnrollmentAccountListResult, error)) EnrollmentAccountListResultPage { + return original.NewEnrollmentAccountListResultPage(getNextPage) +} func NewEnrollmentAccountsClient(subscriptionID string) EnrollmentAccountsClient { return original.NewEnrollmentAccountsClient(subscriptionID) } func NewEnrollmentAccountsClientWithBaseURI(baseURI string, subscriptionID string) EnrollmentAccountsClient { return original.NewEnrollmentAccountsClientWithBaseURI(baseURI, subscriptionID) } +func NewInvoiceListResultIterator(page InvoiceListResultPage) InvoiceListResultIterator { + return original.NewInvoiceListResultIterator(page) +} +func NewInvoiceListResultPage(getNextPage func(context.Context, InvoiceListResult) (InvoiceListResult, error)) InvoiceListResultPage { + return original.NewInvoiceListResultPage(getNextPage) +} +func NewInvoiceSectionListResultIterator(page InvoiceSectionListResultPage) InvoiceSectionListResultIterator { + return original.NewInvoiceSectionListResultIterator(page) +} +func NewInvoiceSectionListResultPage(getNextPage func(context.Context, InvoiceSectionListResult) (InvoiceSectionListResult, error)) InvoiceSectionListResultPage { + return original.NewInvoiceSectionListResultPage(getNextPage) +} func NewInvoiceSectionsClient(subscriptionID string) InvoiceSectionsClient { return original.NewInvoiceSectionsClient(subscriptionID) } @@ -444,6 +513,12 @@ func NewProductsListResultIterator(page ProductsListResultPage) ProductsListResu func NewProductsListResultPage(getNextPage func(context.Context, ProductsListResult) (ProductsListResult, error)) ProductsListResultPage { return original.NewProductsListResultPage(getNextPage) } +func NewProfileListResultIterator(page ProfileListResultPage) ProfileListResultIterator { + return original.NewProfileListResultIterator(page) +} +func NewProfileListResultPage(getNextPage func(context.Context, ProfileListResult) (ProfileListResult, error)) ProfileListResultPage { + return original.NewProfileListResultPage(getNextPage) +} func NewProfilesClient(subscriptionID string) ProfilesClient { return original.NewProfilesClient(subscriptionID) } 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 5bfda1c18a4e..987a43b45d32 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,20 +118,21 @@ 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) { +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.Response.Response != nil { - sc = result.Response.Response.StatusCode + 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") @@ -140,12 +141,12 @@ func (client AccountsClient) List(ctx context.Context, expand string) (result Ac resp, err := client.ListSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.alr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "billing.AccountsClient", "List", resp, "Failure sending request") return } - result, err = client.ListResponder(resp) + result.alr, err = client.ListResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "billing.AccountsClient", "List", resp, "Failure responding to request") } @@ -191,6 +192,43 @@ func (client AccountsClient) ListResponder(resp *http.Response) (result AccountL 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 +} + // Update the operation to update a billing account. // Parameters: // billingAccountName - billing Account Id. diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/agreements.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/agreements.go index c13aba8d0666..dfd35f44fef7 100644 --- a/services/preview/billing/mgmt/2018-11-01-preview/billing/agreements.go +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/agreements.go @@ -124,17 +124,18 @@ func (client AgreementsClient) GetResponder(resp *http.Response) (result Agreeme // Parameters: // billingAccountName - billing Account Id. // expand - may be used to expand the participants. -func (client AgreementsClient) ListByBillingAccountName(ctx context.Context, billingAccountName string, expand string) (result AgreementListResult, err error) { +func (client AgreementsClient) ListByBillingAccountName(ctx context.Context, billingAccountName string, expand string) (result AgreementListResultPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/AgreementsClient.ListByBillingAccountName") defer func() { sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode + if result.alr.Response.Response != nil { + sc = result.alr.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() } + result.fn = client.listByBillingAccountNameNextResults req, err := client.ListByBillingAccountNamePreparer(ctx, billingAccountName, expand) if err != nil { err = autorest.NewErrorWithError(err, "billing.AgreementsClient", "ListByBillingAccountName", nil, "Failure preparing request") @@ -143,12 +144,12 @@ func (client AgreementsClient) ListByBillingAccountName(ctx context.Context, bil resp, err := client.ListByBillingAccountNameSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.alr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "billing.AgreementsClient", "ListByBillingAccountName", resp, "Failure sending request") return } - result, err = client.ListByBillingAccountNameResponder(resp) + result.alr, err = client.ListByBillingAccountNameResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "billing.AgreementsClient", "ListByBillingAccountName", resp, "Failure responding to request") } @@ -197,3 +198,40 @@ func (client AgreementsClient) ListByBillingAccountNameResponder(resp *http.Resp result.Response = autorest.Response{Response: resp} return } + +// listByBillingAccountNameNextResults retrieves the next set of results, if any. +func (client AgreementsClient) listByBillingAccountNameNextResults(ctx context.Context, lastResults AgreementListResult) (result AgreementListResult, err error) { + req, err := lastResults.agreementListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.AgreementsClient", "listByBillingAccountNameNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByBillingAccountNameSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.AgreementsClient", "listByBillingAccountNameNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByBillingAccountNameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AgreementsClient", "listByBillingAccountNameNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByBillingAccountNameComplete enumerates all values, automatically crossing page boundaries as required. +func (client AgreementsClient) ListByBillingAccountNameComplete(ctx context.Context, billingAccountName string, expand string) (result AgreementListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AgreementsClient.ListByBillingAccountName") + 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.ListByBillingAccountName(ctx, billingAccountName, expand) + 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 d4dbd586a09b..e99ffd0d4b4b 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 @@ -26,7 +26,7 @@ import ( // 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.AccountListResult, err error) + List(ctx context.Context, expand string) (result billing.AccountListResultPage, err error) Update(ctx context.Context, billingAccountName string, parameters billing.AccountUpdateProperties) (result billing.AccountsUpdateFuture, err error) } @@ -58,20 +58,28 @@ var _ AvailableBalancesClientAPI = (*billing.AvailableBalancesClient)(nil) 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) + ListByBillingAccountName(ctx context.Context, billingAccountName string, expand string) (result billing.ProfileListResultPage, err error) Update(ctx context.Context, billingAccountName string, billingProfileName string, parameters billing.Profile) (result billing.ProfilesUpdateFuture, 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) + ListByBillingAccountName(ctx context.Context, billingAccountName string, filter string, skiptoken string) (result billing.CustomerListResultPage, 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) ElevateToBillingProfile(ctx context.Context, billingAccountName string, invoiceSectionName string) (result autorest.Response, err error) Get(ctx context.Context, billingAccountName string, invoiceSectionName string, expand string) (result billing.InvoiceSection, err error) ListByBillingAccountName(ctx context.Context, billingAccountName string, expand string) (result billing.InvoiceSectionListResult, err error) - ListByBillingProfileName(ctx context.Context, billingAccountName string, billingProfileName string) (result billing.InvoiceSectionListResult, err error) - ListByCreateSubscriptionPermission(ctx context.Context, billingAccountName string, expand string) (result billing.InvoiceSectionListResult, err error) + ListByBillingProfileName(ctx context.Context, billingAccountName string, billingProfileName string) (result billing.InvoiceSectionListResultPage, err error) + ListByCreateSubscriptionPermission(ctx context.Context, billingAccountName string, expand string) (result billing.InvoiceSectionListResultPage, err error) Update(ctx context.Context, billingAccountName string, invoiceSectionName string, parameters billing.InvoiceSection) (result billing.InvoiceSectionsUpdateFuture, err error) } @@ -80,7 +88,7 @@ var _ InvoiceSectionsClientAPI = (*billing.InvoiceSectionsClient)(nil) // DepartmentsClientAPI contains the set of methods on the DepartmentsClient type. type DepartmentsClientAPI interface { Get(ctx context.Context, billingAccountName string, departmentName string, expand string, filter string) (result billing.Department, err error) - ListByBillingAccountName(ctx context.Context, billingAccountName string, expand string, filter string) (result billing.DepartmentListResult, err error) + ListByBillingAccountName(ctx context.Context, billingAccountName string, expand string, filter string) (result billing.DepartmentListResultPage, err error) } var _ DepartmentsClientAPI = (*billing.DepartmentsClient)(nil) @@ -88,7 +96,7 @@ var _ DepartmentsClientAPI = (*billing.DepartmentsClient)(nil) // EnrollmentAccountsClientAPI contains the set of methods on the EnrollmentAccountsClient type. type EnrollmentAccountsClientAPI interface { GetByEnrollmentAccountID(ctx context.Context, billingAccountName string, enrollmentAccountName string, expand string, filter string) (result billing.EnrollmentAccount, err error) - ListByBillingAccountName(ctx context.Context, billingAccountName string, expand string, filter string) (result billing.EnrollmentAccountListResult, err error) + ListByBillingAccountName(ctx context.Context, billingAccountName string, expand string, filter string) (result billing.EnrollmentAccountListResultPage, err error) } var _ EnrollmentAccountsClientAPI = (*billing.EnrollmentAccountsClient)(nil) @@ -96,8 +104,8 @@ var _ EnrollmentAccountsClientAPI = (*billing.EnrollmentAccountsClient)(nil) // InvoicesClientAPI contains the set of methods on the InvoicesClient type. type InvoicesClientAPI interface { Get(ctx context.Context, billingAccountName string, billingProfileName string, invoiceName string) (result billing.InvoiceSummary, err error) - ListByBillingAccountName(ctx context.Context, billingAccountName string, periodStartDate string, periodEndDate string) (result billing.InvoiceListResult, err error) - ListByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string, periodStartDate string, periodEndDate string) (result billing.InvoiceListResult, err error) + ListByBillingAccountName(ctx context.Context, billingAccountName string, periodStartDate string, periodEndDate string) (result billing.InvoiceListResultPage, err error) + ListByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string, periodStartDate string, periodEndDate string) (result billing.InvoiceListResultPage, err error) } var _ InvoicesClientAPI = (*billing.InvoicesClient)(nil) @@ -112,9 +120,11 @@ 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) - ListByInvoiceSectionName(ctx context.Context, billingAccountName string, invoiceSectionName string) (result billing.SubscriptionsListResult, err error) + ListByBillingProfileName(ctx context.Context, billingAccountName string, billingProfileName string) (result billing.SubscriptionsListResultPage, err error) + ListByCustomerName(ctx context.Context, billingAccountName string, customerName string) (result billing.SubscriptionsListResultPage, err error) + ListByInvoiceSectionName(ctx context.Context, billingAccountName string, invoiceSectionName string) (result billing.SubscriptionsListResultPage, 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) } @@ -125,7 +135,7 @@ var _ SubscriptionsClientAPI = (*billing.SubscriptionsClient)(nil) type ProductsClientAPI interface { Get(ctx context.Context, billingAccountName string, invoiceSectionName string, productName string) (result billing.ProductSummary, err error) ListByBillingAccountName(ctx context.Context, billingAccountName string, filter string) (result billing.ProductsListResultPage, err error) - ListByInvoiceSectionName(ctx context.Context, billingAccountName string, invoiceSectionName string, filter string) (result billing.ProductsListResult, err error) + ListByInvoiceSectionName(ctx context.Context, billingAccountName string, invoiceSectionName string, filter string) (result billing.ProductsListResultPage, err error) 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) @@ -137,8 +147,9 @@ var _ ProductsClientAPI = (*billing.ProductsClient)(nil) // TransactionsClientAPI contains the set of methods on the TransactionsClient type. 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) - ListByInvoiceSectionName(ctx context.Context, billingAccountName string, invoiceSectionName string, startDate string, endDate string, filter string) (result billing.TransactionsListResult, err error) + ListByBillingProfileName(ctx context.Context, billingAccountName string, billingProfileName string, startDate string, endDate string, filter string) (result billing.TransactionsListResultPage, err error) + ListByCustomerName(ctx context.Context, billingAccountName string, customerName string, startDate string, endDate string, filter string) (result billing.TransactionsListResultPage, err error) + ListByInvoiceSectionName(ctx context.Context, billingAccountName string, invoiceSectionName string, startDate string, endDate string, filter string) (result billing.TransactionsListResultPage, err error) } var _ TransactionsClientAPI = (*billing.TransactionsClient)(nil) @@ -189,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) } @@ -227,7 +239,7 @@ 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) - ListByBillingAccountName(ctx context.Context, billingAccountName string, expand string) (result billing.AgreementListResult, err error) + ListByBillingAccountName(ctx context.Context, billingAccountName string, expand string) (result billing.AgreementListResultPage, err error) } var _ AgreementsClientAPI = (*billing.AgreementsClient)(nil) 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..1747fd15439e --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/customers.go @@ -0,0 +1,244 @@ +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, 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 = "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) { + sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + return autorest.SendWithSender(client, req, sd...) +} + +// 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 CustomerListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CustomersClient.ListByBillingAccountName") + defer func() { + sc := -1 + if result.clr.Response.Response != nil { + sc = result.clr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByBillingAccountNameNextResults + 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.clr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.CustomersClient", "ListByBillingAccountName", resp, "Failure sending request") + return + } + + result.clr, 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) { + sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + return autorest.SendWithSender(client, req, sd...) +} + +// 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 +} + +// listByBillingAccountNameNextResults retrieves the next set of results, if any. +func (client CustomersClient) listByBillingAccountNameNextResults(ctx context.Context, lastResults CustomerListResult) (result CustomerListResult, err error) { + req, err := lastResults.customerListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.CustomersClient", "listByBillingAccountNameNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByBillingAccountNameSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.CustomersClient", "listByBillingAccountNameNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByBillingAccountNameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.CustomersClient", "listByBillingAccountNameNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByBillingAccountNameComplete enumerates all values, automatically crossing page boundaries as required. +func (client CustomersClient) ListByBillingAccountNameComplete(ctx context.Context, billingAccountName string, filter string, skiptoken string) (result CustomerListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/CustomersClient.ListByBillingAccountName") + 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.ListByBillingAccountName(ctx, billingAccountName, filter, skiptoken) + 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 30dcd0aa2aef..3512a0433b5e 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,23 +125,24 @@ 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. // filter - 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 DepartmentsClient) ListByBillingAccountName(ctx context.Context, billingAccountName string, expand string, filter string) (result DepartmentListResult, err error) { +func (client DepartmentsClient) ListByBillingAccountName(ctx context.Context, billingAccountName string, expand string, filter string) (result DepartmentListResultPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/DepartmentsClient.ListByBillingAccountName") defer func() { sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode + if result.dlr.Response.Response != nil { + sc = result.dlr.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() } + result.fn = client.listByBillingAccountNameNextResults req, err := client.ListByBillingAccountNamePreparer(ctx, billingAccountName, expand, filter) if err != nil { err = autorest.NewErrorWithError(err, "billing.DepartmentsClient", "ListByBillingAccountName", nil, "Failure preparing request") @@ -150,12 +151,12 @@ func (client DepartmentsClient) ListByBillingAccountName(ctx context.Context, bi resp, err := client.ListByBillingAccountNameSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.dlr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "billing.DepartmentsClient", "ListByBillingAccountName", resp, "Failure sending request") return } - result, err = client.ListByBillingAccountNameResponder(resp) + result.dlr, err = client.ListByBillingAccountNameResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "billing.DepartmentsClient", "ListByBillingAccountName", resp, "Failure responding to request") } @@ -207,3 +208,40 @@ func (client DepartmentsClient) ListByBillingAccountNameResponder(resp *http.Res result.Response = autorest.Response{Response: resp} return } + +// listByBillingAccountNameNextResults retrieves the next set of results, if any. +func (client DepartmentsClient) listByBillingAccountNameNextResults(ctx context.Context, lastResults DepartmentListResult) (result DepartmentListResult, err error) { + req, err := lastResults.departmentListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.DepartmentsClient", "listByBillingAccountNameNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByBillingAccountNameSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.DepartmentsClient", "listByBillingAccountNameNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByBillingAccountNameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.DepartmentsClient", "listByBillingAccountNameNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByBillingAccountNameComplete enumerates all values, automatically crossing page boundaries as required. +func (client DepartmentsClient) ListByBillingAccountNameComplete(ctx context.Context, billingAccountName string, expand string, filter string) (result DepartmentListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DepartmentsClient.ListByBillingAccountName") + 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.ListByBillingAccountName(ctx, billingAccountName, expand, filter) + return +} 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 93a24a2fa7b7..23f2e222e9ba 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,23 +125,24 @@ 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. // filter - 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 EnrollmentAccountsClient) ListByBillingAccountName(ctx context.Context, billingAccountName string, expand string, filter string) (result EnrollmentAccountListResult, err error) { +func (client EnrollmentAccountsClient) ListByBillingAccountName(ctx context.Context, billingAccountName string, expand string, filter string) (result EnrollmentAccountListResultPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/EnrollmentAccountsClient.ListByBillingAccountName") defer func() { sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode + if result.ealr.Response.Response != nil { + sc = result.ealr.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() } + result.fn = client.listByBillingAccountNameNextResults req, err := client.ListByBillingAccountNamePreparer(ctx, billingAccountName, expand, filter) if err != nil { err = autorest.NewErrorWithError(err, "billing.EnrollmentAccountsClient", "ListByBillingAccountName", nil, "Failure preparing request") @@ -150,12 +151,12 @@ func (client EnrollmentAccountsClient) ListByBillingAccountName(ctx context.Cont resp, err := client.ListByBillingAccountNameSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.ealr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "billing.EnrollmentAccountsClient", "ListByBillingAccountName", resp, "Failure sending request") return } - result, err = client.ListByBillingAccountNameResponder(resp) + result.ealr, err = client.ListByBillingAccountNameResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "billing.EnrollmentAccountsClient", "ListByBillingAccountName", resp, "Failure responding to request") } @@ -207,3 +208,40 @@ func (client EnrollmentAccountsClient) ListByBillingAccountNameResponder(resp *h result.Response = autorest.Response{Response: resp} return } + +// listByBillingAccountNameNextResults retrieves the next set of results, if any. +func (client EnrollmentAccountsClient) listByBillingAccountNameNextResults(ctx context.Context, lastResults EnrollmentAccountListResult) (result EnrollmentAccountListResult, err error) { + req, err := lastResults.enrollmentAccountListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.EnrollmentAccountsClient", "listByBillingAccountNameNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByBillingAccountNameSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.EnrollmentAccountsClient", "listByBillingAccountNameNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByBillingAccountNameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.EnrollmentAccountsClient", "listByBillingAccountNameNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByBillingAccountNameComplete enumerates all values, automatically crossing page boundaries as required. +func (client EnrollmentAccountsClient) ListByBillingAccountNameComplete(ctx context.Context, billingAccountName string, expand string, filter string) (result EnrollmentAccountListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EnrollmentAccountsClient.ListByBillingAccountName") + 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.ListByBillingAccountName(ctx, billingAccountName, expand, filter) + return +} diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/invoices.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/invoices.go index ccd578af7e47..a777f9f5d36e 100644 --- a/services/preview/billing/mgmt/2018-11-01-preview/billing/invoices.go +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/invoices.go @@ -123,17 +123,18 @@ func (client InvoicesClient) GetResponder(resp *http.Response) (result InvoiceSu // billingAccountName - billing Account Id. // periodStartDate - invoice period start date. // periodEndDate - invoice period end date. -func (client InvoicesClient) ListByBillingAccountName(ctx context.Context, billingAccountName string, periodStartDate string, periodEndDate string) (result InvoiceListResult, err error) { +func (client InvoicesClient) ListByBillingAccountName(ctx context.Context, billingAccountName string, periodStartDate string, periodEndDate string) (result InvoiceListResultPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/InvoicesClient.ListByBillingAccountName") defer func() { sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode + if result.ilr.Response.Response != nil { + sc = result.ilr.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() } + result.fn = client.listByBillingAccountNameNextResults req, err := client.ListByBillingAccountNamePreparer(ctx, billingAccountName, periodStartDate, periodEndDate) if err != nil { err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "ListByBillingAccountName", nil, "Failure preparing request") @@ -142,12 +143,12 @@ func (client InvoicesClient) ListByBillingAccountName(ctx context.Context, billi resp, err := client.ListByBillingAccountNameSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.ilr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "ListByBillingAccountName", resp, "Failure sending request") return } - result, err = client.ListByBillingAccountNameResponder(resp) + result.ilr, err = client.ListByBillingAccountNameResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "ListByBillingAccountName", resp, "Failure responding to request") } @@ -196,23 +197,61 @@ func (client InvoicesClient) ListByBillingAccountNameResponder(resp *http.Respon return } +// listByBillingAccountNameNextResults retrieves the next set of results, if any. +func (client InvoicesClient) listByBillingAccountNameNextResults(ctx context.Context, lastResults InvoiceListResult) (result InvoiceListResult, err error) { + req, err := lastResults.invoiceListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.InvoicesClient", "listByBillingAccountNameNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByBillingAccountNameSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.InvoicesClient", "listByBillingAccountNameNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByBillingAccountNameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "listByBillingAccountNameNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByBillingAccountNameComplete enumerates all values, automatically crossing page boundaries as required. +func (client InvoicesClient) ListByBillingAccountNameComplete(ctx context.Context, billingAccountName string, periodStartDate string, periodEndDate string) (result InvoiceListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InvoicesClient.ListByBillingAccountName") + 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.ListByBillingAccountName(ctx, billingAccountName, periodStartDate, periodEndDate) + return +} + // ListByBillingProfile list of invoices for a billing profile. // Parameters: // billingAccountName - billing Account Id. // billingProfileName - billing Profile Id. // periodStartDate - invoice period start date. // periodEndDate - invoice period end date. -func (client InvoicesClient) ListByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string, periodStartDate string, periodEndDate string) (result InvoiceListResult, err error) { +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.Response.Response != nil { - sc = result.Response.Response.StatusCode + 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") @@ -221,12 +260,12 @@ func (client InvoicesClient) ListByBillingProfile(ctx context.Context, billingAc resp, err := client.ListByBillingProfileSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.ilr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "ListByBillingProfile", resp, "Failure sending request") return } - result, err = client.ListByBillingProfileResponder(resp) + result.ilr, err = client.ListByBillingProfileResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "billing.InvoicesClient", "ListByBillingProfile", resp, "Failure responding to request") } @@ -275,3 +314,40 @@ func (client InvoicesClient) ListByBillingProfileResponder(resp *http.Response) 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 +} 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 61e494cbaad6..e90f3652cf4e 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,21 +344,22 @@ 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. -func (client InvoiceSectionsClient) ListByBillingProfileName(ctx context.Context, billingAccountName string, billingProfileName string) (result InvoiceSectionListResult, err error) { +func (client InvoiceSectionsClient) ListByBillingProfileName(ctx context.Context, billingAccountName string, billingProfileName string) (result InvoiceSectionListResultPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/InvoiceSectionsClient.ListByBillingProfileName") defer func() { sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode + if result.islr.Response.Response != nil { + sc = result.islr.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() } + result.fn = client.listByBillingProfileNameNextResults req, err := client.ListByBillingProfileNamePreparer(ctx, billingAccountName, billingProfileName) if err != nil { err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "ListByBillingProfileName", nil, "Failure preparing request") @@ -367,12 +368,12 @@ func (client InvoiceSectionsClient) ListByBillingProfileName(ctx context.Context resp, err := client.ListByBillingProfileNameSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.islr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "ListByBillingProfileName", resp, "Failure sending request") return } - result, err = client.ListByBillingProfileNameResponder(resp) + result.islr, err = client.ListByBillingProfileNameResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "ListByBillingProfileName", resp, "Failure responding to request") } @@ -420,21 +421,59 @@ func (client InvoiceSectionsClient) ListByBillingProfileNameResponder(resp *http return } +// listByBillingProfileNameNextResults retrieves the next set of results, if any. +func (client InvoiceSectionsClient) listByBillingProfileNameNextResults(ctx context.Context, lastResults InvoiceSectionListResult) (result InvoiceSectionListResult, err error) { + req, err := lastResults.invoiceSectionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "listByBillingProfileNameNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByBillingProfileNameSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "listByBillingProfileNameNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByBillingProfileNameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "listByBillingProfileNameNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByBillingProfileNameComplete enumerates all values, automatically crossing page boundaries as required. +func (client InvoiceSectionsClient) ListByBillingProfileNameComplete(ctx context.Context, billingAccountName string, billingProfileName string) (result InvoiceSectionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InvoiceSectionsClient.ListByBillingProfileName") + 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.ListByBillingProfileName(ctx, billingAccountName, billingProfileName) + return +} + // ListByCreateSubscriptionPermission lists all invoiceSections with create subscription permission for a user. // Parameters: // billingAccountName - billing Account Id. // expand - may be used to expand the billingProfiles. -func (client InvoiceSectionsClient) ListByCreateSubscriptionPermission(ctx context.Context, billingAccountName string, expand string) (result InvoiceSectionListResult, err error) { +func (client InvoiceSectionsClient) ListByCreateSubscriptionPermission(ctx context.Context, billingAccountName string, expand string) (result InvoiceSectionListResultPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/InvoiceSectionsClient.ListByCreateSubscriptionPermission") defer func() { sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode + if result.islr.Response.Response != nil { + sc = result.islr.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() } + result.fn = client.listByCreateSubscriptionPermissionNextResults req, err := client.ListByCreateSubscriptionPermissionPreparer(ctx, billingAccountName, expand) if err != nil { err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "ListByCreateSubscriptionPermission", nil, "Failure preparing request") @@ -443,12 +482,12 @@ func (client InvoiceSectionsClient) ListByCreateSubscriptionPermission(ctx conte resp, err := client.ListByCreateSubscriptionPermissionSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.islr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "ListByCreateSubscriptionPermission", resp, "Failure sending request") return } - result, err = client.ListByCreateSubscriptionPermissionResponder(resp) + result.islr, err = client.ListByCreateSubscriptionPermissionResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "ListByCreateSubscriptionPermission", resp, "Failure responding to request") } @@ -498,6 +537,43 @@ func (client InvoiceSectionsClient) ListByCreateSubscriptionPermissionResponder( return } +// listByCreateSubscriptionPermissionNextResults retrieves the next set of results, if any. +func (client InvoiceSectionsClient) listByCreateSubscriptionPermissionNextResults(ctx context.Context, lastResults InvoiceSectionListResult) (result InvoiceSectionListResult, err error) { + req, err := lastResults.invoiceSectionListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "listByCreateSubscriptionPermissionNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByCreateSubscriptionPermissionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "listByCreateSubscriptionPermissionNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByCreateSubscriptionPermissionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.InvoiceSectionsClient", "listByCreateSubscriptionPermissionNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByCreateSubscriptionPermissionComplete enumerates all values, automatically crossing page boundaries as required. +func (client InvoiceSectionsClient) ListByCreateSubscriptionPermissionComplete(ctx context.Context, billingAccountName string, expand string) (result InvoiceSectionListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/InvoiceSectionsClient.ListByCreateSubscriptionPermission") + 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.ListByCreateSubscriptionPermission(ctx, billingAccountName, expand) + return +} + // Update the operation to update a InvoiceSection. // Parameters: // billingAccountName - billing Account 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 0c33e5243237..b74e76db7a73 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 @@ -500,6 +500,143 @@ type AccountListResult struct { 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 - READ-ONLY; The billing account name. @@ -700,6 +837,143 @@ type AgreementListResult struct { 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 the agreement. type AgreementProperties struct { // AgreementLink - READ-ONLY; The link to the agreement. @@ -800,11 +1074,11 @@ type AvailableBalanceProperties struct { Amount *Amount `json:"amount,omitempty"` } -// Department a department resource. -type Department struct { +// Customer a partner's customer. +type Customer struct { autorest.Response `json:"-"` - // DepartmentProperties - A department. - *DepartmentProperties `json:"properties,omitempty"` + // CustomerProperties - The customer. + *CustomerProperties `json:"properties,omitempty"` // ID - READ-ONLY; Resource Id. ID *string `json:"id,omitempty"` // Name - READ-ONLY; Resource name. @@ -813,17 +1087,17 @@ type Department struct { Type *string `json:"type,omitempty"` } -// MarshalJSON is the custom marshaler for Department. -func (d Department) MarshalJSON() ([]byte, error) { +// MarshalJSON is the custom marshaler for Customer. +func (c Customer) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if d.DepartmentProperties != nil { - objectMap["properties"] = d.DepartmentProperties + if c.CustomerProperties != nil { + objectMap["properties"] = c.CustomerProperties } return json.Marshal(objectMap) } -// UnmarshalJSON is the custom unmarshaler for Department struct. -func (d *Department) UnmarshalJSON(body []byte) error { +// 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 { @@ -833,12 +1107,12 @@ func (d *Department) UnmarshalJSON(body []byte) error { switch k { case "properties": if v != nil { - var departmentProperties DepartmentProperties - err = json.Unmarshal(*v, &departmentProperties) + var customerProperties CustomerProperties + err = json.Unmarshal(*v, &customerProperties) if err != nil { return err } - d.DepartmentProperties = &departmentProperties + c.CustomerProperties = &customerProperties } case "id": if v != nil { @@ -847,7 +1121,7 @@ func (d *Department) UnmarshalJSON(body []byte) error { if err != nil { return err } - d.ID = &ID + c.ID = &ID } case "name": if v != nil { @@ -856,7 +1130,7 @@ func (d *Department) UnmarshalJSON(body []byte) error { if err != nil { return err } - d.Name = &name + c.Name = &name } case "type": if v != nil { @@ -865,7 +1139,7 @@ func (d *Department) UnmarshalJSON(body []byte) error { if err != nil { return err } - d.Type = &typeVar + c.Type = &typeVar } } } @@ -873,54 +1147,420 @@ func (d *Department) UnmarshalJSON(body []byte) error { return nil } -// DepartmentListResult result of listing departments. -type DepartmentListResult struct { +// CustomerListResult result of listing customers. +type CustomerListResult struct { autorest.Response `json:"-"` - // Value - READ-ONLY; The list of departments. - Value *[]Department `json:"value,omitempty"` + // 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"` } -// DepartmentProperties the properties of the department. -type DepartmentProperties struct { - // DepartmentName - The name for department. - DepartmentName *string `json:"departmentName,omitempty"` - // CostCenter - The cost center name. - CostCenter *string `json:"costCenter,omitempty"` - // Status - The status for 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"` -} - -// DetailedTransferStatus detailed transfer status. -type DetailedTransferStatus struct { - // ProductType - READ-ONLY; Type of product being transferred. Possible values include: 'ProductTypeAzureSubscription', 'ProductTypeAzureReservation' - ProductType ProductType `json:"productType,omitempty"` - // ProductID - READ-ONLY; Id of product being transferred. - ProductID *string `json:"productId,omitempty"` - // TransferStatus - READ-ONLY; Transfer status. Possible values include: 'NotStarted', 'InProgress', 'Completed', 'Failed' - TransferStatus ProductTransferStatus `json:"transferStatus,omitempty"` - // ErrorDetails - Error details for transfer execution. - ErrorDetails *Error `json:"errorDetails,omitempty"` -} - -// DownloadProperties the properties of the invoice download. -type DownloadProperties struct { - // Kind - READ-ONLY; Document type. Possible values include: 'Invoice', 'VoidNote', 'Receipt', 'CreditNote' - Kind Kind `json:"kind,omitempty"` - // URL - READ-ONLY; Document URL. - URL *string `json:"url,omitempty"` +// CustomerListResultIterator provides access to a complete listing of Customer values. +type CustomerListResultIterator struct { + i int + page CustomerListResultPage } -// 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 at which this download URL will expire. - ExpiryTime *date.Time `json:"expiryTime,omitempty"` - // URL - READ-ONLY; The URL to the PDF file. - URL *string `json:"url,omitempty"` +// 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} +} + +// 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"` + // Resellers - The resellers which are allowed to provide service to this customer. + Resellers *[]Reseller `json:"resellers,omitempty"` +} + +// Department a department resource. +type Department struct { + autorest.Response `json:"-"` + // 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 +} + +// DepartmentListResult result of listing departments. +type DepartmentListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The list of departments. + Value *[]Department `json:"value,omitempty"` + // NextLink - READ-ONLY; The link (url) to the next page of results. + NextLink *string `json:"nextLink,omitempty"` +} + +// DepartmentListResultIterator provides access to a complete listing of Department values. +type DepartmentListResultIterator struct { + i int + page DepartmentListResultPage +} + +// 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 *DepartmentListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DepartmentListResultIterator.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 *DepartmentListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter DepartmentListResultIterator) 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 DepartmentListResultIterator) Response() DepartmentListResult { + 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 DepartmentListResultIterator) Value() Department { + if !iter.page.NotDone() { + return Department{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the DepartmentListResultIterator type. +func NewDepartmentListResultIterator(page DepartmentListResultPage) DepartmentListResultIterator { + return DepartmentListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (dlr DepartmentListResult) IsEmpty() bool { + return dlr.Value == nil || len(*dlr.Value) == 0 +} + +// departmentListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (dlr DepartmentListResult) departmentListResultPreparer(ctx context.Context) (*http.Request, error) { + if dlr.NextLink == nil || len(to.String(dlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(dlr.NextLink))) +} + +// DepartmentListResultPage contains a page of Department values. +type DepartmentListResultPage struct { + fn func(context.Context, DepartmentListResult) (DepartmentListResult, error) + dlr DepartmentListResult +} + +// 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 *DepartmentListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/DepartmentListResultPage.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.dlr) + if err != nil { + return err + } + page.dlr = 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 *DepartmentListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page DepartmentListResultPage) NotDone() bool { + return !page.dlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page DepartmentListResultPage) Response() DepartmentListResult { + return page.dlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page DepartmentListResultPage) Values() []Department { + if page.dlr.IsEmpty() { + return nil + } + return *page.dlr.Value +} + +// Creates a new instance of the DepartmentListResultPage type. +func NewDepartmentListResultPage(getNextPage func(context.Context, DepartmentListResult) (DepartmentListResult, error)) DepartmentListResultPage { + return DepartmentListResultPage{fn: getNextPage} +} + +// DepartmentProperties the properties of the department. +type DepartmentProperties struct { + // DepartmentName - The name for department. + DepartmentName *string `json:"departmentName,omitempty"` + // CostCenter - The cost center name. + CostCenter *string `json:"costCenter,omitempty"` + // Status - The status for 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"` +} + +// DetailedTransferStatus detailed transfer status. +type DetailedTransferStatus struct { + // ProductType - READ-ONLY; Type of product being transferred. Possible values include: 'ProductTypeAzureSubscription', 'ProductTypeAzureReservation' + ProductType ProductType `json:"productType,omitempty"` + // ProductID - READ-ONLY; Id of product being transferred. + ProductID *string `json:"productId,omitempty"` + // TransferStatus - READ-ONLY; Transfer status. Possible values include: 'NotStarted', 'InProgress', 'Completed', 'Failed' + TransferStatus ProductTransferStatus `json:"transferStatus,omitempty"` + // ErrorDetails - Error details for transfer execution. + ErrorDetails *Error `json:"errorDetails,omitempty"` +} + +// DownloadProperties the properties of the invoice download. +type DownloadProperties struct { + // Kind - READ-ONLY; Document type. Possible values include: 'Invoice', 'VoidNote', 'Receipt', 'CreditNote' + Kind Kind `json:"kind,omitempty"` + // URL - READ-ONLY; Document URL. + URL *string `json:"url,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 at which this download URL will expire. + ExpiryTime *date.Time `json:"expiryTime,omitempty"` + // URL - READ-ONLY; The URL to the PDF file. + URL *string `json:"url,omitempty"` } // EnabledAzureSKUs details about the enabled azure sku. @@ -1047,6 +1687,143 @@ type EnrollmentAccountListResult struct { NextLink *string `json:"nextLink,omitempty"` } +// EnrollmentAccountListResultIterator provides access to a complete listing of EnrollmentAccount values. +type EnrollmentAccountListResultIterator struct { + i int + page EnrollmentAccountListResultPage +} + +// 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 *EnrollmentAccountListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EnrollmentAccountListResultIterator.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 *EnrollmentAccountListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter EnrollmentAccountListResultIterator) 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 EnrollmentAccountListResultIterator) Response() EnrollmentAccountListResult { + 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 EnrollmentAccountListResultIterator) Value() EnrollmentAccount { + if !iter.page.NotDone() { + return EnrollmentAccount{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the EnrollmentAccountListResultIterator type. +func NewEnrollmentAccountListResultIterator(page EnrollmentAccountListResultPage) EnrollmentAccountListResultIterator { + return EnrollmentAccountListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ealr EnrollmentAccountListResult) IsEmpty() bool { + return ealr.Value == nil || len(*ealr.Value) == 0 +} + +// enrollmentAccountListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ealr EnrollmentAccountListResult) enrollmentAccountListResultPreparer(ctx context.Context) (*http.Request, error) { + if ealr.NextLink == nil || len(to.String(ealr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ealr.NextLink))) +} + +// EnrollmentAccountListResultPage contains a page of EnrollmentAccount values. +type EnrollmentAccountListResultPage struct { + fn func(context.Context, EnrollmentAccountListResult) (EnrollmentAccountListResult, error) + ealr EnrollmentAccountListResult +} + +// 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 *EnrollmentAccountListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/EnrollmentAccountListResultPage.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.ealr) + if err != nil { + return err + } + page.ealr = 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 *EnrollmentAccountListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page EnrollmentAccountListResultPage) NotDone() bool { + return !page.ealr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page EnrollmentAccountListResultPage) Response() EnrollmentAccountListResult { + return page.ealr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page EnrollmentAccountListResultPage) Values() []EnrollmentAccount { + if page.ealr.IsEmpty() { + return nil + } + return *page.ealr.Value +} + +// Creates a new instance of the EnrollmentAccountListResultPage type. +func NewEnrollmentAccountListResultPage(getNextPage func(context.Context, EnrollmentAccountListResult) (EnrollmentAccountListResult, error)) EnrollmentAccountListResultPage { + return EnrollmentAccountListResultPage{fn: getNextPage} +} + // EnrollmentAccountProperties the properties of the account. type EnrollmentAccountProperties struct { // AccountName - The account name. @@ -1110,52 +1887,189 @@ type InitiateTransferProperties struct { RecipientEmailID *string `json:"recipientEmailId,omitempty"` } -// InitiateTransferRequest request parameters to initiate transfer. -type InitiateTransferRequest struct { - // InitiateTransferProperties - Request parameters to initiate transfer. - *InitiateTransferProperties `json:"properties,omitempty"` +// InitiateTransferRequest request parameters to initiate transfer. +type InitiateTransferRequest struct { + // InitiateTransferProperties - Request parameters to initiate transfer. + *InitiateTransferProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for InitiateTransferRequest. +func (itr InitiateTransferRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if itr.InitiateTransferProperties != nil { + objectMap["properties"] = itr.InitiateTransferProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for InitiateTransferRequest struct. +func (itr *InitiateTransferRequest) 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 initiateTransferProperties InitiateTransferProperties + err = json.Unmarshal(*v, &initiateTransferProperties) + if err != nil { + return err + } + itr.InitiateTransferProperties = &initiateTransferProperties + } + } + } + + return nil +} + +// InvoiceListResult result of listing invoices. +type InvoiceListResult struct { + autorest.Response `json:"-"` + // Value - READ-ONLY; The list of invoices. + Value *[]InvoiceSummary `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 InvoiceSummary 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() InvoiceSummary { + if !iter.page.NotDone() { + return InvoiceSummary{} + } + 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 InvoiceSummary 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() } -// MarshalJSON is the custom marshaler for InitiateTransferRequest. -func (itr InitiateTransferRequest) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if itr.InitiateTransferProperties != nil { - objectMap["properties"] = itr.InitiateTransferProperties - } - return json.Marshal(objectMap) +// Response returns the raw server response from the last page request. +func (page InvoiceListResultPage) Response() InvoiceListResult { + return page.ilr } -// UnmarshalJSON is the custom unmarshaler for InitiateTransferRequest struct. -func (itr *InitiateTransferRequest) 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 initiateTransferProperties InitiateTransferProperties - err = json.Unmarshal(*v, &initiateTransferProperties) - if err != nil { - return err - } - itr.InitiateTransferProperties = &initiateTransferProperties - } - } +// Values returns the slice of values for the current page or nil if there are no values. +func (page InvoiceListResultPage) Values() []InvoiceSummary { + if page.ilr.IsEmpty() { + return nil } - - return nil + return *page.ilr.Value } -// InvoiceListResult result of listing invoices. -type InvoiceListResult struct { - autorest.Response `json:"-"` - // Value - READ-ONLY; The list of invoices. - Value *[]InvoiceSummary `json:"value,omitempty"` - // NextLink - READ-ONLY; The link (url) to the next page of results. - NextLink *string `json:"nextLink,omitempty"` +// Creates a new instance of the InvoiceListResultPage type. +func NewInvoiceListResultPage(getNextPage func(context.Context, InvoiceListResult) (InvoiceListResult, error)) InvoiceListResultPage { + return InvoiceListResultPage{fn: getNextPage} } // InvoiceSection an InvoiceSection resource. @@ -1248,6 +2162,143 @@ type InvoiceSectionListResult struct { 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} +} + // InvoiceSectionProperties the properties of an InvoiceSection. type InvoiceSectionProperties struct { // DisplayName - The name of the InvoiceSection. @@ -2443,6 +3494,143 @@ type ProfileListResult struct { 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 billing profile name. @@ -2833,6 +4021,14 @@ type RecipientTransferProperties struct { DetailedTransferStatus *[]DetailedTransferStatus `json:"detailedTransferStatus,omitempty"` } +// Reseller details about a reseller. +type Reseller struct { + // ResellerID - READ-ONLY; The reseller id. + ResellerID *string `json:"resellerId,omitempty"` + // Description - READ-ONLY; A description of the reseller. + Description *string `json:"description,omitempty"` +} + // Resource the Resource model definition. type Resource struct { // ID - READ-ONLY; Resource Id. @@ -3106,6 +4302,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. @@ -3114,6 +4314,8 @@ type SubscriptionProperties struct { SkuID *string `json:"skuId,omitempty"` // SkuDescription - READ-ONLY; The sku description. SkuDescription *string `json:"skuDescription,omitempty"` + // Reseller - READ-ONLY; Reseller for this subscription. + Reseller *Reseller `json:"reseller,omitempty"` } // SubscriptionsListResult result of listing billing subscriptions summary. @@ -3606,6 +4808,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. 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 38e0f4a8bff2..f1fdc51735e3 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) { + sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + return autorest.SendWithSender(client, req, sd...) +} + +// 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 b69105e4c645..69e700e8a92b 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 @@ -243,17 +243,18 @@ func (client ProductsClient) ListByBillingAccountNameComplete(ctx context.Contex // 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 is separated by a colon (:). -func (client ProductsClient) ListByInvoiceSectionName(ctx context.Context, billingAccountName string, invoiceSectionName string, filter string) (result ProductsListResult, err error) { +func (client ProductsClient) ListByInvoiceSectionName(ctx context.Context, billingAccountName string, invoiceSectionName string, filter string) (result ProductsListResultPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/ProductsClient.ListByInvoiceSectionName") defer func() { sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode + if result.plr.Response.Response != nil { + sc = result.plr.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() } + result.fn = client.listByInvoiceSectionNameNextResults req, err := client.ListByInvoiceSectionNamePreparer(ctx, billingAccountName, invoiceSectionName, filter) if err != nil { err = autorest.NewErrorWithError(err, "billing.ProductsClient", "ListByInvoiceSectionName", nil, "Failure preparing request") @@ -262,12 +263,12 @@ func (client ProductsClient) ListByInvoiceSectionName(ctx context.Context, billi resp, err := client.ListByInvoiceSectionNameSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.plr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "billing.ProductsClient", "ListByInvoiceSectionName", resp, "Failure sending request") return } - result, err = client.ListByInvoiceSectionNameResponder(resp) + result.plr, err = client.ListByInvoiceSectionNameResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "billing.ProductsClient", "ListByInvoiceSectionName", resp, "Failure responding to request") } @@ -318,6 +319,43 @@ func (client ProductsClient) ListByInvoiceSectionNameResponder(resp *http.Respon return } +// listByInvoiceSectionNameNextResults retrieves the next set of results, if any. +func (client ProductsClient) listByInvoiceSectionNameNextResults(ctx context.Context, lastResults ProductsListResult) (result ProductsListResult, err error) { + req, err := lastResults.productsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.ProductsClient", "listByInvoiceSectionNameNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByInvoiceSectionNameSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.ProductsClient", "listByInvoiceSectionNameNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByInvoiceSectionNameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProductsClient", "listByInvoiceSectionNameNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByInvoiceSectionNameComplete enumerates all values, automatically crossing page boundaries as required. +func (client ProductsClient) ListByInvoiceSectionNameComplete(ctx context.Context, billingAccountName string, invoiceSectionName string, filter string) (result ProductsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProductsClient.ListByInvoiceSectionName") + 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.ListByInvoiceSectionName(ctx, billingAccountName, invoiceSectionName, filter) + return +} + // Transfer the operation to transfer a Product to another invoice section. // Parameters: // billingAccountName - billing Account Id. 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 8c72d1a55103..fe4182176f86 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 @@ -201,17 +201,18 @@ func (client ProfilesClient) GetResponder(resp *http.Response) (result Profile, // Parameters: // billingAccountName - billing Account Id. // expand - may be used to expand the invoiceSections. -func (client ProfilesClient) ListByBillingAccountName(ctx context.Context, billingAccountName string, expand string) (result ProfileListResult, err error) { +func (client ProfilesClient) ListByBillingAccountName(ctx context.Context, billingAccountName string, expand string) (result ProfileListResultPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/ProfilesClient.ListByBillingAccountName") defer func() { sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode + if result.plr.Response.Response != nil { + sc = result.plr.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() } + result.fn = client.listByBillingAccountNameNextResults req, err := client.ListByBillingAccountNamePreparer(ctx, billingAccountName, expand) if err != nil { err = autorest.NewErrorWithError(err, "billing.ProfilesClient", "ListByBillingAccountName", nil, "Failure preparing request") @@ -220,12 +221,12 @@ func (client ProfilesClient) ListByBillingAccountName(ctx context.Context, billi resp, err := client.ListByBillingAccountNameSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.plr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "billing.ProfilesClient", "ListByBillingAccountName", resp, "Failure sending request") return } - result, err = client.ListByBillingAccountNameResponder(resp) + result.plr, err = client.ListByBillingAccountNameResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "billing.ProfilesClient", "ListByBillingAccountName", resp, "Failure responding to request") } @@ -275,6 +276,43 @@ func (client ProfilesClient) ListByBillingAccountNameResponder(resp *http.Respon return } +// listByBillingAccountNameNextResults retrieves the next set of results, if any. +func (client ProfilesClient) listByBillingAccountNameNextResults(ctx context.Context, lastResults ProfileListResult) (result ProfileListResult, err error) { + req, err := lastResults.profileListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.ProfilesClient", "listByBillingAccountNameNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByBillingAccountNameSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.ProfilesClient", "listByBillingAccountNameNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByBillingAccountNameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.ProfilesClient", "listByBillingAccountNameNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByBillingAccountNameComplete enumerates all values, automatically crossing page boundaries as required. +func (client ProfilesClient) ListByBillingAccountNameComplete(ctx context.Context, billingAccountName string, expand string) (result ProfileListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ProfilesClient.ListByBillingAccountName") + 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.ListByBillingAccountName(ctx, billingAccountName, expand) + return +} + // Update the operation to update a billing profile. // 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 b9bb84bb58fe..6bd533d78044 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) { + sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + return autorest.SendWithSender(client, req, sd...) +} + +// 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. @@ -234,17 +312,18 @@ func (client SubscriptionsClient) ListByBillingAccountNameComplete(ctx context.C // Parameters: // billingAccountName - billing Account Id. // billingProfileName - billing Profile Id. -func (client SubscriptionsClient) ListByBillingProfileName(ctx context.Context, billingAccountName string, billingProfileName string) (result SubscriptionsListResult, err error) { +func (client SubscriptionsClient) ListByBillingProfileName(ctx context.Context, billingAccountName string, billingProfileName string) (result SubscriptionsListResultPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionsClient.ListByBillingProfileName") defer func() { sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode + if result.slr.Response.Response != nil { + sc = result.slr.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() } + result.fn = client.listByBillingProfileNameNextResults req, err := client.ListByBillingProfileNamePreparer(ctx, billingAccountName, billingProfileName) if err != nil { err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "ListByBillingProfileName", nil, "Failure preparing request") @@ -253,12 +332,12 @@ func (client SubscriptionsClient) ListByBillingProfileName(ctx context.Context, resp, err := client.ListByBillingProfileNameSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.slr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "ListByBillingProfileName", resp, "Failure sending request") return } - result, err = client.ListByBillingProfileNameResponder(resp) + result.slr, err = client.ListByBillingProfileNameResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "ListByBillingProfileName", resp, "Failure responding to request") } @@ -306,21 +385,173 @@ func (client SubscriptionsClient) ListByBillingProfileNameResponder(resp *http.R return } +// listByBillingProfileNameNextResults retrieves the next set of results, if any. +func (client SubscriptionsClient) listByBillingProfileNameNextResults(ctx context.Context, lastResults SubscriptionsListResult) (result SubscriptionsListResult, err error) { + req, err := lastResults.subscriptionsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "listByBillingProfileNameNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByBillingProfileNameSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "listByBillingProfileNameNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByBillingProfileNameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "listByBillingProfileNameNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByBillingProfileNameComplete enumerates all values, automatically crossing page boundaries as required. +func (client SubscriptionsClient) ListByBillingProfileNameComplete(ctx context.Context, billingAccountName string, billingProfileName string) (result SubscriptionsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionsClient.ListByBillingProfileName") + 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.ListByBillingProfileName(ctx, billingAccountName, billingProfileName) + 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 SubscriptionsListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionsClient.ListByCustomerName") + defer func() { + sc := -1 + if result.slr.Response.Response != nil { + sc = result.slr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByCustomerNameNextResults + 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.slr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "ListByCustomerName", resp, "Failure sending request") + return + } + + result.slr, 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) { + sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + return autorest.SendWithSender(client, req, sd...) +} + +// 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 +} + +// listByCustomerNameNextResults retrieves the next set of results, if any. +func (client SubscriptionsClient) listByCustomerNameNextResults(ctx context.Context, lastResults SubscriptionsListResult) (result SubscriptionsListResult, err error) { + req, err := lastResults.subscriptionsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "listByCustomerNameNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByCustomerNameSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "listByCustomerNameNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByCustomerNameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "listByCustomerNameNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByCustomerNameComplete enumerates all values, automatically crossing page boundaries as required. +func (client SubscriptionsClient) ListByCustomerNameComplete(ctx context.Context, billingAccountName string, customerName string) (result SubscriptionsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionsClient.ListByCustomerName") + 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.ListByCustomerName(ctx, billingAccountName, customerName) + return +} + // ListByInvoiceSectionName lists billing subscription by invoice section name. // Parameters: // billingAccountName - billing Account Id. // invoiceSectionName - invoiceSection Id. -func (client SubscriptionsClient) ListByInvoiceSectionName(ctx context.Context, billingAccountName string, invoiceSectionName string) (result SubscriptionsListResult, err error) { +func (client SubscriptionsClient) ListByInvoiceSectionName(ctx context.Context, billingAccountName string, invoiceSectionName string) (result SubscriptionsListResultPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionsClient.ListByInvoiceSectionName") defer func() { sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode + if result.slr.Response.Response != nil { + sc = result.slr.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() } + result.fn = client.listByInvoiceSectionNameNextResults req, err := client.ListByInvoiceSectionNamePreparer(ctx, billingAccountName, invoiceSectionName) if err != nil { err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "ListByInvoiceSectionName", nil, "Failure preparing request") @@ -329,12 +560,12 @@ func (client SubscriptionsClient) ListByInvoiceSectionName(ctx context.Context, resp, err := client.ListByInvoiceSectionNameSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.slr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "ListByInvoiceSectionName", resp, "Failure sending request") return } - result, err = client.ListByInvoiceSectionNameResponder(resp) + result.slr, err = client.ListByInvoiceSectionNameResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "ListByInvoiceSectionName", resp, "Failure responding to request") } @@ -382,6 +613,43 @@ func (client SubscriptionsClient) ListByInvoiceSectionNameResponder(resp *http.R return } +// listByInvoiceSectionNameNextResults retrieves the next set of results, if any. +func (client SubscriptionsClient) listByInvoiceSectionNameNextResults(ctx context.Context, lastResults SubscriptionsListResult) (result SubscriptionsListResult, err error) { + req, err := lastResults.subscriptionsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "listByInvoiceSectionNameNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByInvoiceSectionNameSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "listByInvoiceSectionNameNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByInvoiceSectionNameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.SubscriptionsClient", "listByInvoiceSectionNameNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByInvoiceSectionNameComplete enumerates all values, automatically crossing page boundaries as required. +func (client SubscriptionsClient) ListByInvoiceSectionNameComplete(ctx context.Context, billingAccountName string, invoiceSectionName string) (result SubscriptionsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SubscriptionsClient.ListByInvoiceSectionName") + 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.ListByInvoiceSectionName(ctx, billingAccountName, invoiceSectionName) + return +} + // Transfer transfers the subscription from one invoice section to another within a billing account. // Parameters: // billingAccountName - billing Account Id. 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 9ad8dc62afb3..699fa5f89b5a 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 @@ -171,17 +171,18 @@ func (client TransactionsClient) ListByBillingAccountNameComplete(ctx context.Co // 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) ListByBillingProfileName(ctx context.Context, billingAccountName string, billingProfileName string, startDate string, endDate string, filter string) (result TransactionsListResult, err error) { +func (client TransactionsClient) ListByBillingProfileName(ctx context.Context, billingAccountName string, billingProfileName string, startDate string, endDate string, filter string) (result TransactionsListResultPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/TransactionsClient.ListByBillingProfileName") defer func() { sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode + if result.tlr.Response.Response != nil { + sc = result.tlr.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() } + result.fn = client.listByBillingProfileNameNextResults req, err := client.ListByBillingProfileNamePreparer(ctx, billingAccountName, billingProfileName, startDate, endDate, filter) if err != nil { err = autorest.NewErrorWithError(err, "billing.TransactionsClient", "ListByBillingProfileName", nil, "Failure preparing request") @@ -190,12 +191,12 @@ func (client TransactionsClient) ListByBillingProfileName(ctx context.Context, b resp, err := client.ListByBillingProfileNameSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.tlr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "billing.TransactionsClient", "ListByBillingProfileName", resp, "Failure sending request") return } - result, err = client.ListByBillingProfileNameResponder(resp) + result.tlr, err = client.ListByBillingProfileNameResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "billing.TransactionsClient", "ListByBillingProfileName", resp, "Failure responding to request") } @@ -248,6 +249,167 @@ func (client TransactionsClient) ListByBillingProfileNameResponder(resp *http.Re return } +// listByBillingProfileNameNextResults retrieves the next set of results, if any. +func (client TransactionsClient) listByBillingProfileNameNextResults(ctx context.Context, lastResults TransactionsListResult) (result TransactionsListResult, err error) { + req, err := lastResults.transactionsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.TransactionsClient", "listByBillingProfileNameNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByBillingProfileNameSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.TransactionsClient", "listByBillingProfileNameNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByBillingProfileNameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.TransactionsClient", "listByBillingProfileNameNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByBillingProfileNameComplete enumerates all values, automatically crossing page boundaries as required. +func (client TransactionsClient) ListByBillingProfileNameComplete(ctx context.Context, billingAccountName string, billingProfileName string, startDate string, endDate string, filter string) (result TransactionsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TransactionsClient.ListByBillingProfileName") + 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.ListByBillingProfileName(ctx, billingAccountName, billingProfileName, startDate, endDate, filter) + 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 TransactionsListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TransactionsClient.ListByCustomerName") + defer func() { + sc := -1 + if result.tlr.Response.Response != nil { + sc = result.tlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByCustomerNameNextResults + 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.tlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.TransactionsClient", "ListByCustomerName", resp, "Failure sending request") + return + } + + result.tlr, 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) { + sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + return autorest.SendWithSender(client, req, sd...) +} + +// 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 +} + +// listByCustomerNameNextResults retrieves the next set of results, if any. +func (client TransactionsClient) listByCustomerNameNextResults(ctx context.Context, lastResults TransactionsListResult) (result TransactionsListResult, err error) { + req, err := lastResults.transactionsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.TransactionsClient", "listByCustomerNameNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByCustomerNameSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.TransactionsClient", "listByCustomerNameNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByCustomerNameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.TransactionsClient", "listByCustomerNameNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByCustomerNameComplete enumerates all values, automatically crossing page boundaries as required. +func (client TransactionsClient) ListByCustomerNameComplete(ctx context.Context, billingAccountName string, customerName string, startDate string, endDate string, filter string) (result TransactionsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TransactionsClient.ListByCustomerName") + 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.ListByCustomerName(ctx, billingAccountName, customerName, startDate, endDate, filter) + return +} + // ListByInvoiceSectionName lists the transactions by invoice section name for given start date and end date. // Parameters: // billingAccountName - billing Account Id. @@ -257,17 +419,18 @@ func (client TransactionsClient) ListByBillingProfileNameResponder(resp *http.Re // 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) ListByInvoiceSectionName(ctx context.Context, billingAccountName string, invoiceSectionName string, startDate string, endDate string, filter string) (result TransactionsListResult, err error) { +func (client TransactionsClient) ListByInvoiceSectionName(ctx context.Context, billingAccountName string, invoiceSectionName string, startDate string, endDate string, filter string) (result TransactionsListResultPage, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/TransactionsClient.ListByInvoiceSectionName") defer func() { sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode + if result.tlr.Response.Response != nil { + sc = result.tlr.Response.Response.StatusCode } tracing.EndSpan(ctx, sc, err) }() } + result.fn = client.listByInvoiceSectionNameNextResults req, err := client.ListByInvoiceSectionNamePreparer(ctx, billingAccountName, invoiceSectionName, startDate, endDate, filter) if err != nil { err = autorest.NewErrorWithError(err, "billing.TransactionsClient", "ListByInvoiceSectionName", nil, "Failure preparing request") @@ -276,12 +439,12 @@ func (client TransactionsClient) ListByInvoiceSectionName(ctx context.Context, b resp, err := client.ListByInvoiceSectionNameSender(req) if err != nil { - result.Response = autorest.Response{Response: resp} + result.tlr.Response = autorest.Response{Response: resp} err = autorest.NewErrorWithError(err, "billing.TransactionsClient", "ListByInvoiceSectionName", resp, "Failure sending request") return } - result, err = client.ListByInvoiceSectionNameResponder(resp) + result.tlr, err = client.ListByInvoiceSectionNameResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "billing.TransactionsClient", "ListByInvoiceSectionName", resp, "Failure responding to request") } @@ -333,3 +496,40 @@ func (client TransactionsClient) ListByInvoiceSectionNameResponder(resp *http.Re result.Response = autorest.Response{Response: resp} return } + +// listByInvoiceSectionNameNextResults retrieves the next set of results, if any. +func (client TransactionsClient) listByInvoiceSectionNameNextResults(ctx context.Context, lastResults TransactionsListResult) (result TransactionsListResult, err error) { + req, err := lastResults.transactionsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.TransactionsClient", "listByInvoiceSectionNameNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByInvoiceSectionNameSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "billing.TransactionsClient", "listByInvoiceSectionNameNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByInvoiceSectionNameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.TransactionsClient", "listByInvoiceSectionNameNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByInvoiceSectionNameComplete enumerates all values, automatically crossing page boundaries as required. +func (client TransactionsClient) ListByInvoiceSectionNameComplete(ctx context.Context, billingAccountName string, invoiceSectionName string, startDate string, endDate string, filter string) (result TransactionsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TransactionsClient.ListByInvoiceSectionName") + 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.ListByInvoiceSectionName(ctx, billingAccountName, invoiceSectionName, startDate, endDate, filter) + return +}