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..d04e5f0d8297 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 @@ -34,6 +35,7 @@ from .operations.billing_role_definitions_operations import BillingRoleDefinitionsOperations from .operations.billing_role_assignments_operations import BillingRoleAssignmentsOperations from .operations.agreements_operations import AgreementsOperations +from .operations.line_of_credits_operations import LineOfCreditsOperations from . import models @@ -79,6 +81,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 @@ -117,6 +121,8 @@ class BillingManagementClient(SDKClient): :vartype billing_role_assignments: azure.mgmt.billing.operations.BillingRoleAssignmentsOperations :ivar agreements: Agreements operations :vartype agreements: azure.mgmt.billing.operations.AgreementsOperations + :ivar line_of_credits: LineOfCredits operations + :vartype line_of_credits: azure.mgmt.billing.operations.LineOfCreditsOperations :param credentials: Credentials needed for the client to connect to Azure. :type credentials: :mod:`A msrestazure Credentials @@ -141,6 +147,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( @@ -179,3 +187,5 @@ def __init__( self._client, self.config, self._serialize, self._deserialize) self.agreements = AgreementsOperations( self._client, self.config, self._serialize, self._deserialize) + self.line_of_credits = LineOfCreditsOperations( + self._client, self.config, self._serialize, self._deserialize) 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..143fd913aff6 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 @@ -71,8 +72,12 @@ from .participants_py3 import Participants from .agreement_py3 import Agreement from .agreement_list_result_py3 import AgreementListResult + from .line_of_credit_py3 import LineOfCredit + from .increase_line_of_credit_request_properties_py3 import IncreaseLineOfCreditRequestProperties 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 +89,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 @@ -133,6 +137,8 @@ from .participants import Participants from .agreement import Agreement from .agreement_list_result import AgreementListResult + from .line_of_credit import LineOfCredit + from .increase_line_of_credit_request_properties import IncreaseLineOfCreditRequestProperties from .payment_method_paged import PaymentMethodPaged from .billing_subscription_summary_paged import BillingSubscriptionSummaryPaged from .product_summary_paged import ProductSummaryPaged @@ -141,6 +147,7 @@ from .recipient_transfer_details_paged import RecipientTransferDetailsPaged from .operation_paged import OperationPaged from .billing_management_client_enums import ( + AddressValidationStatus, ProductType, TransferStatus, ProductTransferStatus, @@ -152,10 +159,13 @@ ReservationType, PaymentMethodType, UpdateAutoRenew, + Status, ) __all__ = [ 'InitiateTransferRequest', + 'Address', + 'ValidateAddressResponse', 'ProductDetails', 'AcceptTransferRequest', 'Error', @@ -167,7 +177,6 @@ 'TransferBillingSubscriptionRequestProperties', 'TransferBillingSubscriptionRequest', 'UpdateAutoRenewOperationSummary', - 'Address', 'EnabledAzureSKUs', 'BillingProfile', 'InvoiceSectionProperties', @@ -216,6 +225,8 @@ 'Participants', 'Agreement', 'AgreementListResult', + 'LineOfCredit', + 'IncreaseLineOfCreditRequestProperties', 'PaymentMethodPaged', 'BillingSubscriptionSummaryPaged', 'ProductSummaryPaged', @@ -223,6 +234,7 @@ 'TransferDetailsPaged', 'RecipientTransferDetailsPaged', 'OperationPaged', + 'AddressValidationStatus', 'ProductType', 'TransferStatus', 'ProductTransferStatus', @@ -234,4 +246,5 @@ 'ReservationType', 'PaymentMethodType', 'UpdateAutoRenew', + 'Status', ] 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..99813d1714b1 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" @@ -94,3 +100,9 @@ class UpdateAutoRenew(str, Enum): true = "true" false = "false" + + +class Status(str, Enum): + + approved = "Approved" + rejected = "Rejected" diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/models/increase_line_of_credit_request_properties.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/models/increase_line_of_credit_request_properties.py new file mode 100644 index 000000000000..85681b738b8f --- /dev/null +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/models/increase_line_of_credit_request_properties.py @@ -0,0 +1,28 @@ +# 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 IncreaseLineOfCreditRequestProperties(Model): + """Request parameters to increase line of credit. + + :param desired_credit_limit: The desired credit limit. + :type desired_credit_limit: float + """ + + _attribute_map = { + 'desired_credit_limit': {'key': 'desiredCreditLimit', 'type': 'float'}, + } + + def __init__(self, **kwargs): + super(IncreaseLineOfCreditRequestProperties, self).__init__(**kwargs) + self.desired_credit_limit = kwargs.get('desired_credit_limit', None) diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/models/increase_line_of_credit_request_properties_py3.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/models/increase_line_of_credit_request_properties_py3.py new file mode 100644 index 000000000000..ffc46288e55b --- /dev/null +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/models/increase_line_of_credit_request_properties_py3.py @@ -0,0 +1,28 @@ +# 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 IncreaseLineOfCreditRequestProperties(Model): + """Request parameters to increase line of credit. + + :param desired_credit_limit: The desired credit limit. + :type desired_credit_limit: float + """ + + _attribute_map = { + 'desired_credit_limit': {'key': 'desiredCreditLimit', 'type': 'float'}, + } + + def __init__(self, *, desired_credit_limit: float=None, **kwargs) -> None: + super(IncreaseLineOfCreditRequestProperties, self).__init__(**kwargs) + self.desired_credit_limit = desired_credit_limit diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/models/line_of_credit.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/models/line_of_credit.py new file mode 100644 index 000000000000..90cd13910903 --- /dev/null +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/models/line_of_credit.py @@ -0,0 +1,62 @@ +# 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 .resource import Resource + + +class LineOfCredit(Resource): + """Line of credit resource. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar credit_limit: The current credit limit. + :vartype credit_limit: ~azure.mgmt.billing.models.Amount + :ivar reason: The reason for the line of credit status when not approved. + :vartype reason: str + :ivar remaining_balance: Remaining balance. + :vartype remaining_balance: ~azure.mgmt.billing.models.Amount + :param status: The line of credit status. Possible values include: + 'Approved', 'Rejected' + :type status: str or ~azure.mgmt.billing.models.Status + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'credit_limit': {'readonly': True}, + 'reason': {'readonly': True}, + 'remaining_balance': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'credit_limit': {'key': 'properties.creditLimit', 'type': 'Amount'}, + 'reason': {'key': 'properties.reason', 'type': 'str'}, + 'remaining_balance': {'key': 'properties.remainingBalance', 'type': 'Amount'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(LineOfCredit, self).__init__(**kwargs) + self.credit_limit = None + self.reason = None + self.remaining_balance = None + self.status = kwargs.get('status', None) diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/models/line_of_credit_py3.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/models/line_of_credit_py3.py new file mode 100644 index 000000000000..714701ecd222 --- /dev/null +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/models/line_of_credit_py3.py @@ -0,0 +1,62 @@ +# 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 .resource_py3 import Resource + + +class LineOfCredit(Resource): + """Line of credit resource. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar credit_limit: The current credit limit. + :vartype credit_limit: ~azure.mgmt.billing.models.Amount + :ivar reason: The reason for the line of credit status when not approved. + :vartype reason: str + :ivar remaining_balance: Remaining balance. + :vartype remaining_balance: ~azure.mgmt.billing.models.Amount + :param status: The line of credit status. Possible values include: + 'Approved', 'Rejected' + :type status: str or ~azure.mgmt.billing.models.Status + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'credit_limit': {'readonly': True}, + 'reason': {'readonly': True}, + 'remaining_balance': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'credit_limit': {'key': 'properties.creditLimit', 'type': 'Amount'}, + 'reason': {'key': 'properties.reason', 'type': 'str'}, + 'remaining_balance': {'key': 'properties.remainingBalance', 'type': 'Amount'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + } + + def __init__(self, *, status=None, **kwargs) -> None: + super(LineOfCredit, self).__init__(**kwargs) + self.credit_limit = None + self.reason = None + self.remaining_balance = None + self.status = status 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..d9a2ca49fe76 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 @@ -30,10 +31,12 @@ from .billing_role_definitions_operations import BillingRoleDefinitionsOperations from .billing_role_assignments_operations import BillingRoleAssignmentsOperations from .agreements_operations import AgreementsOperations +from .line_of_credits_operations import LineOfCreditsOperations __all__ = [ 'BillingAccountsOperations', 'PaymentMethodsOperations', + 'BillingAccountsValidateAddressOperations', 'AvailableBalancesOperations', 'BillingProfilesOperations', 'InvoiceSectionsOperations', @@ -53,4 +56,5 @@ 'BillingRoleDefinitionsOperations', 'BillingRoleAssignmentsOperations', 'AgreementsOperations', + 'LineOfCreditsOperations', ] 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'} diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/line_of_credits_operations.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/line_of_credits_operations.py new file mode 100644 index 000000000000..d0c5d8cc5409 --- /dev/null +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/line_of_credits_operations.py @@ -0,0 +1,200 @@ +# 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 msrest.polling import LROPoller, NoPolling +from msrestazure.polling.arm_polling import ARMPolling + +from .. import models + + +class LineOfCreditsOperations(object): + """LineOfCreditsOperations 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 get( + self, custom_headers=None, raw=False, **operation_config): + """Get the current line of credit. + + :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: LineOfCredit or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.billing.models.LineOfCredit or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + # Construct URL + url = self.get.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, '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' + 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 and send request + request = self._client.get(url, query_parameters, header_parameters) + 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('LineOfCredit', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingAccounts/default/lineOfCredit/default'} + + + def _increase_initial( + self, desired_credit_limit=None, custom_headers=None, raw=False, **operation_config): + parameters = models.IncreaseLineOfCreditRequestProperties(desired_credit_limit=desired_credit_limit) + + # Construct URL + url = self.increase.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, '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(parameters, 'IncreaseLineOfCreditRequestProperties') + + # 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, 202]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + header_dict = {} + + if response.status_code == 200: + deserialized = self._deserialize('LineOfCredit', response) + header_dict = { + 'Location': 'str', + 'Retry-After': 'int', + 'Azure-AsyncOperation': 'str', + } + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + client_raw_response.add_headers(header_dict) + return client_raw_response + + return deserialized + + def increase( + self, desired_credit_limit=None, custom_headers=None, raw=False, polling=True, **operation_config): + """Increase the current line of credit. + + :param desired_credit_limit: The desired credit limit. + :type desired_credit_limit: float + :param dict custom_headers: headers that will be added to the request + :param bool raw: The poller return type is ClientRawResponse, the + direct response alongside the deserialized response + :param polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :return: An instance of LROPoller that returns LineOfCredit or + ClientRawResponse if raw==True + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.billing.models.LineOfCredit] + or + ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.billing.models.LineOfCredit]] + :raises: + :class:`ErrorResponseException` + """ + raw_result = self._increase_initial( + desired_credit_limit=desired_credit_limit, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + + def get_long_running_output(response): + header_dict = { + 'Location': 'str', + 'Retry-After': 'int', + 'Azure-AsyncOperation': 'str', + } + deserialized = self._deserialize('LineOfCredit', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + client_raw_response.add_headers(header_dict) + return client_raw_response + + return deserialized + + lro_delay = operation_config.get( + 'long_running_operation_timeout', + self.config.long_running_operation_timeout) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **operation_config) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + increase.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingAccounts/default/lineOfCredit/default/increase'}