diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/billing_management_client.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/billing_management_client.py index 486e6ac5d4e0..7fc2d1222e12 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/billing_management_client.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/billing_management_client.py @@ -15,6 +15,7 @@ from .version import VERSION from .operations.billing_accounts_operations import BillingAccountsOperations from .operations.payment_methods_operations import PaymentMethodsOperations +from .operations.billing_accounts_validate_address_operations import BillingAccountsValidateAddressOperations from .operations.available_balances_operations import AvailableBalancesOperations from .operations.billing_profiles_operations import BillingProfilesOperations from .operations.invoice_sections_operations import InvoiceSectionsOperations @@ -79,6 +80,8 @@ class BillingManagementClient(SDKClient): :vartype billing_accounts: azure.mgmt.billing.operations.BillingAccountsOperations :ivar payment_methods: PaymentMethods operations :vartype payment_methods: azure.mgmt.billing.operations.PaymentMethodsOperations + :ivar billing_accounts_validate_address: BillingAccountsValidateAddress operations + :vartype billing_accounts_validate_address: azure.mgmt.billing.operations.BillingAccountsValidateAddressOperations :ivar available_balances: AvailableBalances operations :vartype available_balances: azure.mgmt.billing.operations.AvailableBalancesOperations :ivar billing_profiles: BillingProfiles operations @@ -141,6 +144,8 @@ def __init__( self._client, self.config, self._serialize, self._deserialize) self.payment_methods = PaymentMethodsOperations( self._client, self.config, self._serialize, self._deserialize) + self.billing_accounts_validate_address = BillingAccountsValidateAddressOperations( + self._client, self.config, self._serialize, self._deserialize) self.available_balances = AvailableBalancesOperations( self._client, self.config, self._serialize, self._deserialize) self.billing_profiles = BillingProfilesOperations( diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/models/__init__.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/models/__init__.py index 140c186dbd06..09171ab8b99c 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/models/__init__.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/models/__init__.py @@ -11,6 +11,8 @@ try: from .initiate_transfer_request_py3 import InitiateTransferRequest + from .address_py3 import Address + from .validate_address_response_py3 import ValidateAddressResponse from .product_details_py3 import ProductDetails from .accept_transfer_request_py3 import AcceptTransferRequest from .error_py3 import Error @@ -22,7 +24,6 @@ from .transfer_billing_subscription_request_properties_py3 import TransferBillingSubscriptionRequestProperties from .transfer_billing_subscription_request_py3 import TransferBillingSubscriptionRequest from .update_auto_renew_operation_summary_py3 import UpdateAutoRenewOperationSummary - from .address_py3 import Address from .enabled_azure_sk_us_py3 import EnabledAzureSKUs from .billing_profile_py3 import BillingProfile from .invoice_section_properties_py3 import InvoiceSectionProperties @@ -73,6 +74,8 @@ from .agreement_list_result_py3 import AgreementListResult except (SyntaxError, ImportError): from .initiate_transfer_request import InitiateTransferRequest + from .address import Address + from .validate_address_response import ValidateAddressResponse from .product_details import ProductDetails from .accept_transfer_request import AcceptTransferRequest from .error import Error @@ -84,7 +87,6 @@ from .transfer_billing_subscription_request_properties import TransferBillingSubscriptionRequestProperties from .transfer_billing_subscription_request import TransferBillingSubscriptionRequest from .update_auto_renew_operation_summary import UpdateAutoRenewOperationSummary - from .address import Address from .enabled_azure_sk_us import EnabledAzureSKUs from .billing_profile import BillingProfile from .invoice_section_properties import InvoiceSectionProperties @@ -141,6 +143,7 @@ from .recipient_transfer_details_paged import RecipientTransferDetailsPaged from .operation_paged import OperationPaged from .billing_management_client_enums import ( + AddressValidationStatus, ProductType, TransferStatus, ProductTransferStatus, @@ -156,6 +159,8 @@ __all__ = [ 'InitiateTransferRequest', + 'Address', + 'ValidateAddressResponse', 'ProductDetails', 'AcceptTransferRequest', 'Error', @@ -167,7 +172,6 @@ 'TransferBillingSubscriptionRequestProperties', 'TransferBillingSubscriptionRequest', 'UpdateAutoRenewOperationSummary', - 'Address', 'EnabledAzureSKUs', 'BillingProfile', 'InvoiceSectionProperties', @@ -223,6 +227,7 @@ 'TransferDetailsPaged', 'RecipientTransferDetailsPaged', 'OperationPaged', + 'AddressValidationStatus', 'ProductType', 'TransferStatus', 'ProductTransferStatus', diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/models/billing_management_client_enums.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/models/billing_management_client_enums.py index 39ace87835df..ac825bb2de95 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/models/billing_management_client_enums.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/models/billing_management_client_enums.py @@ -12,6 +12,12 @@ from enum import Enum +class AddressValidationStatus(str, Enum): + + valid = "Valid" + invalid = "Invalid" + + class ProductType(str, Enum): azure_subscription = "AzureSubscription" diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/models/validate_address_response.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/models/validate_address_response.py new file mode 100644 index 000000000000..387605d5e931 --- /dev/null +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/models/validate_address_response.py @@ -0,0 +1,37 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class ValidateAddressResponse(Model): + """Result of the address validation. + + :param status: status of the address validation. Possible values include: + 'Valid', 'Invalid' + :type status: str or ~azure.mgmt.billing.models.AddressValidationStatus + :param suggested_addresses: list of suggested addresses. + :type suggested_addresses: list[~azure.mgmt.billing.models.Address] + :param validation_message: Validation error message. + :type validation_message: str + """ + + _attribute_map = { + 'status': {'key': 'status', 'type': 'str'}, + 'suggested_addresses': {'key': 'suggestedAddresses', 'type': '[Address]'}, + 'validation_message': {'key': 'validationMessage', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(ValidateAddressResponse, self).__init__(**kwargs) + self.status = kwargs.get('status', None) + self.suggested_addresses = kwargs.get('suggested_addresses', None) + self.validation_message = kwargs.get('validation_message', None) diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/models/validate_address_response_py3.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/models/validate_address_response_py3.py new file mode 100644 index 000000000000..9e01d7871ec4 --- /dev/null +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/models/validate_address_response_py3.py @@ -0,0 +1,37 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class ValidateAddressResponse(Model): + """Result of the address validation. + + :param status: status of the address validation. Possible values include: + 'Valid', 'Invalid' + :type status: str or ~azure.mgmt.billing.models.AddressValidationStatus + :param suggested_addresses: list of suggested addresses. + :type suggested_addresses: list[~azure.mgmt.billing.models.Address] + :param validation_message: Validation error message. + :type validation_message: str + """ + + _attribute_map = { + 'status': {'key': 'status', 'type': 'str'}, + 'suggested_addresses': {'key': 'suggestedAddresses', 'type': '[Address]'}, + 'validation_message': {'key': 'validationMessage', 'type': 'str'}, + } + + def __init__(self, *, status=None, suggested_addresses=None, validation_message: str=None, **kwargs) -> None: + super(ValidateAddressResponse, self).__init__(**kwargs) + self.status = status + self.suggested_addresses = suggested_addresses + self.validation_message = validation_message diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/__init__.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/__init__.py index db4077cbc9c5..859e3eefb3a7 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/__init__.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/__init__.py @@ -11,6 +11,7 @@ from .billing_accounts_operations import BillingAccountsOperations from .payment_methods_operations import PaymentMethodsOperations +from .billing_accounts_validate_address_operations import BillingAccountsValidateAddressOperations from .available_balances_operations import AvailableBalancesOperations from .billing_profiles_operations import BillingProfilesOperations from .invoice_sections_operations import InvoiceSectionsOperations @@ -34,6 +35,7 @@ __all__ = [ 'BillingAccountsOperations', 'PaymentMethodsOperations', + 'BillingAccountsValidateAddressOperations', 'AvailableBalancesOperations', 'BillingProfilesOperations', 'InvoiceSectionsOperations', diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/billing_accounts_validate_address_operations.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/billing_accounts_validate_address_operations.py new file mode 100644 index 000000000000..d9d42f694909 --- /dev/null +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/billing_accounts_validate_address_operations.py @@ -0,0 +1,100 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +import uuid +from msrest.pipeline import ClientRawResponse + +from .. import models + + +class BillingAccountsValidateAddressOperations(object): + """BillingAccountsValidateAddressOperations operations. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + :ivar api_version: Version of the API to be used with the client request. The current version is 2018-11-01-preview. Constant value: "2018-11-01-preview". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2018-11-01-preview" + + self.config = config + + def post( + self, billing_account_name, address, custom_headers=None, raw=False, **operation_config): + """Validates the address. + + :param billing_account_name: billing Account Id. + :type billing_account_name: str + :param address: + :type address: ~azure.mgmt.billing.models.Address + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: ValidateAddressResponse or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.billing.models.ValidateAddressResponse or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.post.metadata['url'] + path_format_arguments = { + 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(address, 'Address') + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('ValidateAddressResponse', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + post.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/validateAddress'}