From f4c56889b905dc0b1ce1abcf1e9a47d1b9789423 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Wed, 15 May 2019 01:21:49 +0000 Subject: [PATCH 1/2] Generated from cc875aebe1efd67ba56af822214fe182869bc23a adding swagger for create billing profile --- .../azure/mgmt/billing/models/__init__.py | 3 + .../billing_profile_creation_parameters.py | 56 +++++++++ ...billing_profile_creation_parameters_py3.py | 56 +++++++++ .../operations/billing_profiles_operations.py | 109 ++++++++++++++++++ 4 files changed, 224 insertions(+) create mode 100644 azure-mgmt-billing/azure/mgmt/billing/models/billing_profile_creation_parameters.py create mode 100644 azure-mgmt-billing/azure/mgmt/billing/models/billing_profile_creation_parameters_py3.py diff --git a/azure-mgmt-billing/azure/mgmt/billing/models/__init__.py b/azure-mgmt-billing/azure/mgmt/billing/models/__init__.py index 140c186dbd06..f5f105645501 100644 --- a/azure-mgmt-billing/azure/mgmt/billing/models/__init__.py +++ b/azure-mgmt-billing/azure/mgmt/billing/models/__init__.py @@ -37,6 +37,7 @@ from .department_list_result_py3 import DepartmentListResult from .enrollment_account_list_result_py3 import EnrollmentAccountListResult from .billing_profile_list_result_py3 import BillingProfileListResult + from .billing_profile_creation_parameters_py3 import BillingProfileCreationParameters from .invoice_section_list_result_py3 import InvoiceSectionListResult from .operation_status_py3 import OperationStatus from .download_url_py3 import DownloadUrl @@ -99,6 +100,7 @@ from .department_list_result import DepartmentListResult from .enrollment_account_list_result import EnrollmentAccountListResult from .billing_profile_list_result import BillingProfileListResult + from .billing_profile_creation_parameters import BillingProfileCreationParameters from .invoice_section_list_result import InvoiceSectionListResult from .operation_status import OperationStatus from .download_url import DownloadUrl @@ -182,6 +184,7 @@ 'DepartmentListResult', 'EnrollmentAccountListResult', 'BillingProfileListResult', + 'BillingProfileCreationParameters', 'InvoiceSectionListResult', 'OperationStatus', 'DownloadUrl', diff --git a/azure-mgmt-billing/azure/mgmt/billing/models/billing_profile_creation_parameters.py b/azure-mgmt-billing/azure/mgmt/billing/models/billing_profile_creation_parameters.py new file mode 100644 index 000000000000..7d0a4b9d5ea9 --- /dev/null +++ b/azure-mgmt-billing/azure/mgmt/billing/models/billing_profile_creation_parameters.py @@ -0,0 +1,56 @@ +# 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 BillingProfileCreationParameters(Model): + """The parameters for creating a new billing profile. + + :param display_name: The billing profile name. + :type display_name: str + :param po_number: Purchase order number. + :type po_number: str + :param address: Billing address. + :type address: ~azure.mgmt.billing.models.Address + :param invoice_email_opt_in: If the billing profile is opted in to receive + invoices via email. + :type invoice_email_opt_in: bool + :param enable_azure_sku_ids: Azure skus to enable for this billing + profile. + :type enable_azure_sku_ids: list[str] + :param create_azure_subscriptions: Create azure subscriptions when + creating this billing profile. + :type create_azure_subscriptions: bool + :param payment_instrument_id: The paymentInstrument associated with the + billing profile at creation. + :type payment_instrument_id: str + """ + + _attribute_map = { + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'po_number': {'key': 'poNumber', 'type': 'str'}, + 'address': {'key': 'address', 'type': 'Address'}, + 'invoice_email_opt_in': {'key': 'invoiceEmailOptIn', 'type': 'bool'}, + 'enable_azure_sku_ids': {'key': 'enableAzureSkuIds', 'type': '[str]'}, + 'create_azure_subscriptions': {'key': 'createAzureSubscriptions', 'type': 'bool'}, + 'payment_instrument_id': {'key': 'paymentInstrumentId', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(BillingProfileCreationParameters, self).__init__(**kwargs) + self.display_name = kwargs.get('display_name', None) + self.po_number = kwargs.get('po_number', None) + self.address = kwargs.get('address', None) + self.invoice_email_opt_in = kwargs.get('invoice_email_opt_in', None) + self.enable_azure_sku_ids = kwargs.get('enable_azure_sku_ids', None) + self.create_azure_subscriptions = kwargs.get('create_azure_subscriptions', None) + self.payment_instrument_id = kwargs.get('payment_instrument_id', None) diff --git a/azure-mgmt-billing/azure/mgmt/billing/models/billing_profile_creation_parameters_py3.py b/azure-mgmt-billing/azure/mgmt/billing/models/billing_profile_creation_parameters_py3.py new file mode 100644 index 000000000000..b4b5ce431699 --- /dev/null +++ b/azure-mgmt-billing/azure/mgmt/billing/models/billing_profile_creation_parameters_py3.py @@ -0,0 +1,56 @@ +# 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 BillingProfileCreationParameters(Model): + """The parameters for creating a new billing profile. + + :param display_name: The billing profile name. + :type display_name: str + :param po_number: Purchase order number. + :type po_number: str + :param address: Billing address. + :type address: ~azure.mgmt.billing.models.Address + :param invoice_email_opt_in: If the billing profile is opted in to receive + invoices via email. + :type invoice_email_opt_in: bool + :param enable_azure_sku_ids: Azure skus to enable for this billing + profile. + :type enable_azure_sku_ids: list[str] + :param create_azure_subscriptions: Create azure subscriptions when + creating this billing profile. + :type create_azure_subscriptions: bool + :param payment_instrument_id: The paymentInstrument associated with the + billing profile at creation. + :type payment_instrument_id: str + """ + + _attribute_map = { + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'po_number': {'key': 'poNumber', 'type': 'str'}, + 'address': {'key': 'address', 'type': 'Address'}, + 'invoice_email_opt_in': {'key': 'invoiceEmailOptIn', 'type': 'bool'}, + 'enable_azure_sku_ids': {'key': 'enableAzureSkuIds', 'type': '[str]'}, + 'create_azure_subscriptions': {'key': 'createAzureSubscriptions', 'type': 'bool'}, + 'payment_instrument_id': {'key': 'paymentInstrumentId', 'type': 'str'}, + } + + def __init__(self, *, display_name: str=None, po_number: str=None, address=None, invoice_email_opt_in: bool=None, enable_azure_sku_ids=None, create_azure_subscriptions: bool=None, payment_instrument_id: str=None, **kwargs) -> None: + super(BillingProfileCreationParameters, self).__init__(**kwargs) + self.display_name = display_name + self.po_number = po_number + self.address = address + self.invoice_email_opt_in = invoice_email_opt_in + self.enable_azure_sku_ids = enable_azure_sku_ids + self.create_azure_subscriptions = create_azure_subscriptions + self.payment_instrument_id = payment_instrument_id diff --git a/azure-mgmt-billing/azure/mgmt/billing/operations/billing_profiles_operations.py b/azure-mgmt-billing/azure/mgmt/billing/operations/billing_profiles_operations.py index d98add3bbe9f..869fa49ece30 100644 --- a/azure-mgmt-billing/azure/mgmt/billing/operations/billing_profiles_operations.py +++ b/azure-mgmt-billing/azure/mgmt/billing/operations/billing_profiles_operations.py @@ -99,6 +99,115 @@ def list_by_billing_account_name( return deserialized list_by_billing_account_name.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles'} + + def _create_initial( + self, billing_account_name, parameters, custom_headers=None, raw=False, **operation_config): + # Construct URL + url = self.create.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(parameters, 'BillingProfileCreationParameters') + + # 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('BillingProfile', 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 create( + self, billing_account_name, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + """The operation to create a BillingProfile. + + :param billing_account_name: billing Account Id. + :type billing_account_name: str + :param parameters: Parameters supplied to the Create BillingProfile + operation. + :type parameters: + ~azure.mgmt.billing.models.BillingProfileCreationParameters + :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 BillingProfile or + ClientRawResponse if raw==True + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.billing.models.BillingProfile] + or + ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.billing.models.BillingProfile]] + :raises: + :class:`ErrorResponseException` + """ + raw_result = self._create_initial( + billing_account_name=billing_account_name, + parameters=parameters, + 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('BillingProfile', 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, **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) + create.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles'} + def get( self, billing_account_name, billing_profile_name, expand=None, custom_headers=None, raw=False, **operation_config): """Get the billing profile by id. From 34af4037dddfae98d2b143fd41b81d645b2039f6 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Thu, 16 May 2019 21:11:05 +0000 Subject: [PATCH 2/2] Generated from 697ed2c812bcecb58bcbafb63cf875b12a41efd8 updates based on feedback. --- .../billing_profile_creation_parameters.py | 15 +++++---------- .../billing_profile_creation_parameters_py3.py | 17 ++++++----------- 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/azure-mgmt-billing/azure/mgmt/billing/models/billing_profile_creation_parameters.py b/azure-mgmt-billing/azure/mgmt/billing/models/billing_profile_creation_parameters.py index 7d0a4b9d5ea9..04b493139675 100644 --- a/azure-mgmt-billing/azure/mgmt/billing/models/billing_profile_creation_parameters.py +++ b/azure-mgmt-billing/azure/mgmt/billing/models/billing_profile_creation_parameters.py @@ -24,15 +24,12 @@ class BillingProfileCreationParameters(Model): :param invoice_email_opt_in: If the billing profile is opted in to receive invoices via email. :type invoice_email_opt_in: bool - :param enable_azure_sku_ids: Azure skus to enable for this billing - profile. - :type enable_azure_sku_ids: list[str] + :param enable_azure_sk_us: Azure skus to enable for this billing profile.. + :type enable_azure_sk_us: + list[~azure.mgmt.billing.models.EnabledAzureSKUs] :param create_azure_subscriptions: Create azure subscriptions when creating this billing profile. :type create_azure_subscriptions: bool - :param payment_instrument_id: The paymentInstrument associated with the - billing profile at creation. - :type payment_instrument_id: str """ _attribute_map = { @@ -40,9 +37,8 @@ class BillingProfileCreationParameters(Model): 'po_number': {'key': 'poNumber', 'type': 'str'}, 'address': {'key': 'address', 'type': 'Address'}, 'invoice_email_opt_in': {'key': 'invoiceEmailOptIn', 'type': 'bool'}, - 'enable_azure_sku_ids': {'key': 'enableAzureSkuIds', 'type': '[str]'}, + 'enable_azure_sk_us': {'key': 'enableAzureSKUs', 'type': '[EnabledAzureSKUs]'}, 'create_azure_subscriptions': {'key': 'createAzureSubscriptions', 'type': 'bool'}, - 'payment_instrument_id': {'key': 'paymentInstrumentId', 'type': 'str'}, } def __init__(self, **kwargs): @@ -51,6 +47,5 @@ def __init__(self, **kwargs): self.po_number = kwargs.get('po_number', None) self.address = kwargs.get('address', None) self.invoice_email_opt_in = kwargs.get('invoice_email_opt_in', None) - self.enable_azure_sku_ids = kwargs.get('enable_azure_sku_ids', None) + self.enable_azure_sk_us = kwargs.get('enable_azure_sk_us', None) self.create_azure_subscriptions = kwargs.get('create_azure_subscriptions', None) - self.payment_instrument_id = kwargs.get('payment_instrument_id', None) diff --git a/azure-mgmt-billing/azure/mgmt/billing/models/billing_profile_creation_parameters_py3.py b/azure-mgmt-billing/azure/mgmt/billing/models/billing_profile_creation_parameters_py3.py index b4b5ce431699..6ed97478440d 100644 --- a/azure-mgmt-billing/azure/mgmt/billing/models/billing_profile_creation_parameters_py3.py +++ b/azure-mgmt-billing/azure/mgmt/billing/models/billing_profile_creation_parameters_py3.py @@ -24,15 +24,12 @@ class BillingProfileCreationParameters(Model): :param invoice_email_opt_in: If the billing profile is opted in to receive invoices via email. :type invoice_email_opt_in: bool - :param enable_azure_sku_ids: Azure skus to enable for this billing - profile. - :type enable_azure_sku_ids: list[str] + :param enable_azure_sk_us: Azure skus to enable for this billing profile.. + :type enable_azure_sk_us: + list[~azure.mgmt.billing.models.EnabledAzureSKUs] :param create_azure_subscriptions: Create azure subscriptions when creating this billing profile. :type create_azure_subscriptions: bool - :param payment_instrument_id: The paymentInstrument associated with the - billing profile at creation. - :type payment_instrument_id: str """ _attribute_map = { @@ -40,17 +37,15 @@ class BillingProfileCreationParameters(Model): 'po_number': {'key': 'poNumber', 'type': 'str'}, 'address': {'key': 'address', 'type': 'Address'}, 'invoice_email_opt_in': {'key': 'invoiceEmailOptIn', 'type': 'bool'}, - 'enable_azure_sku_ids': {'key': 'enableAzureSkuIds', 'type': '[str]'}, + 'enable_azure_sk_us': {'key': 'enableAzureSKUs', 'type': '[EnabledAzureSKUs]'}, 'create_azure_subscriptions': {'key': 'createAzureSubscriptions', 'type': 'bool'}, - 'payment_instrument_id': {'key': 'paymentInstrumentId', 'type': 'str'}, } - def __init__(self, *, display_name: str=None, po_number: str=None, address=None, invoice_email_opt_in: bool=None, enable_azure_sku_ids=None, create_azure_subscriptions: bool=None, payment_instrument_id: str=None, **kwargs) -> None: + def __init__(self, *, display_name: str=None, po_number: str=None, address=None, invoice_email_opt_in: bool=None, enable_azure_sk_us=None, create_azure_subscriptions: bool=None, **kwargs) -> None: super(BillingProfileCreationParameters, self).__init__(**kwargs) self.display_name = display_name self.po_number = po_number self.address = address self.invoice_email_opt_in = invoice_email_opt_in - self.enable_azure_sku_ids = enable_azure_sku_ids + self.enable_azure_sk_us = enable_azure_sk_us self.create_azure_subscriptions = create_azure_subscriptions - self.payment_instrument_id = payment_instrument_id