diff --git a/profiles/preview/preview/billing/mgmt/billing/billingapi/models.go b/profiles/preview/preview/billing/mgmt/billing/billingapi/models.go index 133b14bbd6bc..fc6833b52934 100644 --- a/profiles/preview/preview/billing/mgmt/billing/billingapi/models.go +++ b/profiles/preview/preview/billing/mgmt/billing/billingapi/models.go @@ -22,6 +22,7 @@ package billingapi import original "github.com/Azure/azure-sdk-for-go/services/preview/billing/mgmt/2018-11-01-preview/billing/billingapi" type AccountsClientAPI = original.AccountsClientAPI +type AccountsValidateAddressClientAPI = original.AccountsValidateAddressClientAPI type AgreementsClientAPI = original.AgreementsClientAPI type AvailableBalancesClientAPI = original.AvailableBalancesClientAPI type DepartmentsClientAPI = original.DepartmentsClientAPI diff --git a/profiles/preview/preview/billing/mgmt/billing/models.go b/profiles/preview/preview/billing/mgmt/billing/models.go index 055b44493e6e..e3ed13880e3a 100644 --- a/profiles/preview/preview/billing/mgmt/billing/models.go +++ b/profiles/preview/preview/billing/mgmt/billing/models.go @@ -36,6 +36,13 @@ const ( AccountTypeOrganization AccountType = original.AccountTypeOrganization ) +type AddressValidationStatus = original.AddressValidationStatus + +const ( + Invalid AddressValidationStatus = original.Invalid + Valid AddressValidationStatus = original.Valid +) + type EligibleProductType = original.EligibleProductType const ( @@ -154,7 +161,10 @@ type AcceptTransferRequest = original.AcceptTransferRequest type Account = original.Account type AccountListResult = original.AccountListResult type AccountProperties = original.AccountProperties +type AccountUpdateProperties = original.AccountUpdateProperties type AccountsClient = original.AccountsClient +type AccountsUpdateFuture = original.AccountsUpdateFuture +type AccountsValidateAddressClient = original.AccountsValidateAddressClient type Address = original.Address type Agreement = original.Agreement type AgreementListResult = original.AgreementListResult @@ -276,6 +286,7 @@ type TransfersClient = original.TransfersClient type UpdateAutoRenewOperationSummary = original.UpdateAutoRenewOperationSummary type UpdateAutoRenewOperationSummaryProperties = original.UpdateAutoRenewOperationSummaryProperties type UpdateAutoRenewRequest = original.UpdateAutoRenewRequest +type ValidateAddressResponse = original.ValidateAddressResponse func New(subscriptionID string) BaseClient { return original.New(subscriptionID) @@ -286,6 +297,12 @@ func NewAccountsClient(subscriptionID string) AccountsClient { func NewAccountsClientWithBaseURI(baseURI string, subscriptionID string) AccountsClient { return original.NewAccountsClientWithBaseURI(baseURI, subscriptionID) } +func NewAccountsValidateAddressClient(subscriptionID string) AccountsValidateAddressClient { + return original.NewAccountsValidateAddressClient(subscriptionID) +} +func NewAccountsValidateAddressClientWithBaseURI(baseURI string, subscriptionID string) AccountsValidateAddressClient { + return original.NewAccountsValidateAddressClientWithBaseURI(baseURI, subscriptionID) +} func NewAgreementsClient(subscriptionID string) AgreementsClient { return original.NewAgreementsClient(subscriptionID) } @@ -454,6 +471,9 @@ func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { func PossibleAccountTypeValues() []AccountType { return original.PossibleAccountTypeValues() } +func PossibleAddressValidationStatusValues() []AddressValidationStatus { + return original.PossibleAddressValidationStatusValues() +} func PossibleEligibleProductTypeValues() []EligibleProductType { return original.PossibleEligibleProductTypeValues() } 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 605447199594..4ae7a3680fbe 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 @@ -190,3 +190,80 @@ func (client AccountsClient) ListResponder(resp *http.Response) (result AccountL result.Response = autorest.Response{Response: resp} return } + +// Update the operation to update a billing account. +// Parameters: +// billingAccountName - billing Account Id. +// parameters - parameters supplied to the update billing account operation. +func (client AccountsClient) Update(ctx context.Context, billingAccountName string, parameters AccountUpdateProperties) (result AccountsUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccountsClient.Update") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, billingAccountName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AccountsClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AccountsClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client AccountsClient) UpdatePreparer(ctx context.Context, billingAccountName string, parameters AccountUpdateProperties) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + } + + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client AccountsClient) UpdateSender(req *http.Request) (future AccountsUpdateFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client AccountsClient) UpdateResponder(resp *http.Response) (result Account, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/accountsvalidateaddress.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/accountsvalidateaddress.go new file mode 100644 index 000000000000..b87e8a2701c7 --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/accountsvalidateaddress.go @@ -0,0 +1,117 @@ +package billing + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// AccountsValidateAddressClient is the billing client provides access to billing resources for Azure subscriptions. +type AccountsValidateAddressClient struct { + BaseClient +} + +// NewAccountsValidateAddressClient creates an instance of the AccountsValidateAddressClient client. +func NewAccountsValidateAddressClient(subscriptionID string) AccountsValidateAddressClient { + return NewAccountsValidateAddressClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAccountsValidateAddressClientWithBaseURI creates an instance of the AccountsValidateAddressClient client. +func NewAccountsValidateAddressClientWithBaseURI(baseURI string, subscriptionID string) AccountsValidateAddressClient { + return AccountsValidateAddressClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Post validates the address. +// Parameters: +// billingAccountName - billing Account Id. +func (client AccountsValidateAddressClient) Post(ctx context.Context, billingAccountName string, address Address) (result ValidateAddressResponse, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AccountsValidateAddressClient.Post") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.PostPreparer(ctx, billingAccountName, address) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AccountsValidateAddressClient", "Post", nil, "Failure preparing request") + return + } + + resp, err := client.PostSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.AccountsValidateAddressClient", "Post", resp, "Failure sending request") + return + } + + result, err = client.PostResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AccountsValidateAddressClient", "Post", resp, "Failure responding to request") + } + + return +} + +// PostPreparer prepares the Post request. +func (client AccountsValidateAddressClient) PostPreparer(ctx context.Context, billingAccountName string, address Address) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "billingAccountName": autorest.Encode("path", billingAccountName), + } + + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/validateAddress", pathParameters), + autorest.WithJSON(address), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// PostSender sends the Post request. The method will close the +// http.Response Body if it receives an error. +func (client AccountsValidateAddressClient) PostSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// PostResponder handles the response to the Post request. The method always +// closes the http.Response Body. +func (client AccountsValidateAddressClient) PostResponder(resp *http.Response) (result ValidateAddressResponse, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/billingapi/interfaces.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/billingapi/interfaces.go index db380f4da2ac..b977a07f3aa1 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 @@ -27,24 +27,33 @@ import ( 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) + Update(ctx context.Context, billingAccountName string, parameters billing.AccountUpdateProperties) (result billing.AccountsUpdateFuture, err error) } 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) +// AccountsValidateAddressClientAPI contains the set of methods on the AccountsValidateAddressClient type. +type AccountsValidateAddressClientAPI interface { + Post(ctx context.Context, billingAccountName string, address billing.Address) (result billing.ValidateAddressResponse, err error) +} + +var _ AccountsValidateAddressClientAPI = (*billing.AccountsValidateAddressClient)(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/models.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/models.go index 25d11d9c3472..f55fea8ef474 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 @@ -47,6 +47,21 @@ func PossibleAccountTypeValues() []AccountType { return []AccountType{AccountTypeEnrollment, AccountTypeOrganization} } +// AddressValidationStatus enumerates the values for address validation status. +type AddressValidationStatus string + +const ( + // Invalid ... + Invalid AddressValidationStatus = "Invalid" + // Valid ... + Valid AddressValidationStatus = "Valid" +) + +// PossibleAddressValidationStatusValues returns an array of possible values for the AddressValidationStatus const type. +func PossibleAddressValidationStatusValues() []AddressValidationStatus { + return []AddressValidationStatus{Invalid, Valid} +} + // EligibleProductType enumerates the values for eligible product type. type EligibleProductType string @@ -439,6 +454,74 @@ type AccountProperties struct { HasReadAccess *bool `json:"hasReadAccess,omitempty"` } +// AccountsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type AccountsUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *AccountsUpdateFuture) Result(client AccountsClient) (a Account, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AccountsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("billing.AccountsUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if a.Response.Response, err = future.GetResult(sender); err == nil && a.Response.Response.StatusCode != http.StatusNoContent { + a, err = client.UpdateResponder(a.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AccountsUpdateFuture", "Result", a.Response.Response, "Failure responding to request") + } + } + return +} + +// AccountUpdateProperties the properties of the billing account that can be updated. +type AccountUpdateProperties struct { + // AccountProperties - A billing property. + *AccountProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for AccountUpdateProperties. +func (aup AccountUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if aup.AccountProperties != nil { + objectMap["properties"] = aup.AccountProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for AccountUpdateProperties struct. +func (aup *AccountUpdateProperties) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var accountProperties AccountProperties + err = json.Unmarshal(*v, &accountProperties) + if err != nil { + return err + } + aup.AccountProperties = &accountProperties + } + } + } + + return nil +} + // Address address details. type Address struct { // FirstName - First Name. @@ -3658,3 +3741,14 @@ type UpdateAutoRenewRequest struct { // AutoRenew - Request parameters to update auto renew policy a product. Possible values include: 'True', 'False' AutoRenew UpdateAutoRenew `json:"autoRenew,omitempty"` } + +// ValidateAddressResponse result of the address validation +type ValidateAddressResponse struct { + autorest.Response `json:"-"` + // Status - status of the address validation. Possible values include: 'Valid', 'Invalid' + Status AddressValidationStatus `json:"status,omitempty"` + // SuggestedAddresses - list of suggested addresses. + SuggestedAddresses *[]Address `json:"suggestedAddresses,omitempty"` + // ValidationMessage - Validation error message. + ValidationMessage *string `json:"validationMessage,omitempty"` +} 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.