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 db380f4da2ac..9a007dfed1a1 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 @@ -31,20 +31,21 @@ type AccountsClientAPI interface { var _ AccountsClientAPI = (*billing.AccountsClient)(nil) -// AvailableBalancesClientAPI contains the set of methods on the AvailableBalancesClient type. -type AvailableBalancesClientAPI interface { - GetByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string) (result billing.AvailableBalance, err error) -} - -var _ AvailableBalancesClientAPI = (*billing.AvailableBalancesClient)(nil) - // PaymentMethodsClientAPI contains the set of methods on the PaymentMethodsClient type. type PaymentMethodsClientAPI interface { + ListByBillingAccountName(ctx context.Context, billingAccountName string) (result billing.PaymentMethodsListResultPage, err error) ListByBillingProfileName(ctx context.Context, billingAccountName string, billingProfileName string) (result billing.PaymentMethodsListResultPage, err error) } var _ PaymentMethodsClientAPI = (*billing.PaymentMethodsClient)(nil) +// AvailableBalancesClientAPI contains the set of methods on the AvailableBalancesClient type. +type AvailableBalancesClientAPI interface { + GetByBillingProfile(ctx context.Context, billingAccountName string, billingProfileName string) (result billing.AvailableBalance, err error) +} + +var _ AvailableBalancesClientAPI = (*billing.AvailableBalancesClient)(nil) + // ProfilesClientAPI contains the set of methods on the ProfilesClient type. type ProfilesClientAPI interface { Get(ctx context.Context, billingAccountName string, billingProfileName string, expand string) (result billing.Profile, err error) diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/paymentmethods.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/paymentmethods.go index 3bb9ed775c69..fd4853dfce22 100644 --- a/services/preview/billing/mgmt/2018-11-01-preview/billing/paymentmethods.go +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/paymentmethods.go @@ -40,6 +40,118 @@ func NewPaymentMethodsClientWithBaseURI(baseURI string, subscriptionID string) P return PaymentMethodsClient{NewWithBaseURI(baseURI, subscriptionID)} } +// ListByBillingAccountName lists the Payment Methods by billing account Id. +// Parameters: +// billingAccountName - billing Account Id. +func (client PaymentMethodsClient) ListByBillingAccountName(ctx context.Context, billingAccountName string) (result PaymentMethodsListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PaymentMethodsClient.ListByBillingAccountName") + defer func() { + sc := -1 + if result.pmlr.Response.Response != nil { + sc = result.pmlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByBillingAccountNameNextResults + req, err := client.ListByBillingAccountNamePreparer(ctx, billingAccountName) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PaymentMethodsClient", "ListByBillingAccountName", nil, "Failure preparing request") + return + } + + resp, err := client.ListByBillingAccountNameSender(req) + if err != nil { + result.pmlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.PaymentMethodsClient", "ListByBillingAccountName", resp, "Failure sending request") + return + } + + result.pmlr, err = client.ListByBillingAccountNameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PaymentMethodsClient", "ListByBillingAccountName", resp, "Failure responding to request") + } + + return +} + +// ListByBillingAccountNamePreparer prepares the ListByBillingAccountName request. +func (client PaymentMethodsClient) ListByBillingAccountNamePreparer(ctx context.Context, billingAccountName 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, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/paymentMethods", 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 PaymentMethodsClient) ListByBillingAccountNameSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListByBillingAccountNameResponder handles the response to the ListByBillingAccountName request. The method always +// closes the http.Response Body. +func (client PaymentMethodsClient) ListByBillingAccountNameResponder(resp *http.Response) (result PaymentMethodsListResult, 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 PaymentMethodsClient) listByBillingAccountNameNextResults(ctx context.Context, lastResults PaymentMethodsListResult) (result PaymentMethodsListResult, err error) { + req, err := lastResults.paymentMethodsListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "billing.PaymentMethodsClient", "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.PaymentMethodsClient", "listByBillingAccountNameNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByBillingAccountNameResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.PaymentMethodsClient", "listByBillingAccountNameNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByBillingAccountNameComplete enumerates all values, automatically crossing page boundaries as required. +func (client PaymentMethodsClient) ListByBillingAccountNameComplete(ctx context.Context, billingAccountName string) (result PaymentMethodsListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PaymentMethodsClient.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) + return +} + // ListByBillingProfileName lists the Payment Methods by billing profile Id. // Parameters: // billingAccountName - billing Account Id.