diff --git a/profiles/preview/preview/billing/mgmt/billing/billingapi/models.go b/profiles/preview/preview/billing/mgmt/billing/billingapi/models.go index 133b14bbd6bc..c09bfeb234ca 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 AddressesClientAPI = original.AddressesClientAPI 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..771bd11f7862 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 ( @@ -156,6 +163,7 @@ type AccountListResult = original.AccountListResult type AccountProperties = original.AccountProperties type AccountsClient = original.AccountsClient type Address = original.Address +type AddressesClient = original.AddressesClient type Agreement = original.Agreement type AgreementListResult = original.AgreementListResult type AgreementProperties = original.AgreementProperties @@ -276,6 +284,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 +295,12 @@ func NewAccountsClient(subscriptionID string) AccountsClient { func NewAccountsClientWithBaseURI(baseURI string, subscriptionID string) AccountsClient { return original.NewAccountsClientWithBaseURI(baseURI, subscriptionID) } +func NewAddressesClient(subscriptionID string) AddressesClient { + return original.NewAddressesClient(subscriptionID) +} +func NewAddressesClientWithBaseURI(baseURI string, subscriptionID string) AddressesClient { + return original.NewAddressesClientWithBaseURI(baseURI, subscriptionID) +} func NewAgreementsClient(subscriptionID string) AgreementsClient { return original.NewAgreementsClient(subscriptionID) } @@ -454,6 +469,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/addresses.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/addresses.go new file mode 100644 index 000000000000..56333fe01201 --- /dev/null +++ b/services/preview/billing/mgmt/2018-11-01-preview/billing/addresses.go @@ -0,0 +1,111 @@ +package billing + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// AddressesClient is the billing client provides access to billing resources for Azure subscriptions. +type AddressesClient struct { + BaseClient +} + +// NewAddressesClient creates an instance of the AddressesClient client. +func NewAddressesClient(subscriptionID string) AddressesClient { + return NewAddressesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAddressesClientWithBaseURI creates an instance of the AddressesClient client. +func NewAddressesClientWithBaseURI(baseURI string, subscriptionID string) AddressesClient { + return AddressesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Validate validates the address. +func (client AddressesClient) Validate(ctx context.Context, address Address) (result ValidateAddressResponse, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/AddressesClient.Validate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ValidatePreparer(ctx, address) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AddressesClient", "Validate", nil, "Failure preparing request") + return + } + + resp, err := client.ValidateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "billing.AddressesClient", "Validate", resp, "Failure sending request") + return + } + + result, err = client.ValidateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "billing.AddressesClient", "Validate", resp, "Failure responding to request") + } + + return +} + +// ValidatePreparer prepares the Validate request. +func (client AddressesClient) ValidatePreparer(ctx context.Context, address Address) (*http.Request, error) { + const APIVersion = "2018-11-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Billing/validateAddress"), + autorest.WithJSON(address), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ValidateSender sends the Validate request. The method will close the +// http.Response Body if it receives an error. +func (client AddressesClient) ValidateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ValidateResponder handles the response to the Validate request. The method always +// closes the http.Response Body. +func (client AddressesClient) ValidateResponder(resp *http.Response) (result ValidateAddressResponse, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/services/preview/billing/mgmt/2018-11-01-preview/billing/billingapi/interfaces.go b/services/preview/billing/mgmt/2018-11-01-preview/billing/billingapi/interfaces.go index 9a007dfed1a1..3407e8d8397e 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 @@ -39,6 +39,13 @@ type PaymentMethodsClientAPI interface { var _ PaymentMethodsClientAPI = (*billing.PaymentMethodsClient)(nil) +// AddressesClientAPI contains the set of methods on the AddressesClient type. +type AddressesClientAPI interface { + Validate(ctx context.Context, address billing.Address) (result billing.ValidateAddressResponse, err error) +} + +var _ AddressesClientAPI = (*billing.AddressesClient)(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) 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..e7e1fad0c2cb 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 @@ -3658,3 +3673,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"` +}