diff --git a/sdk/billing/azure-mgmt-billing/_meta.json b/sdk/billing/azure-mgmt-billing/_meta.json index 111c7a0612e3..cd7f3e927a02 100644 --- a/sdk/billing/azure-mgmt-billing/_meta.json +++ b/sdk/billing/azure-mgmt-billing/_meta.json @@ -1,8 +1,11 @@ { - "autorest": "3.3.0", - "use": "@autorest/python@5.6.6", - "commit": "1e43e60cfb0bb2829ff8d57a9ba06a2410f0b3c0", + "autorest": "3.7.2", + "use": [ + "@autorest/python@5.12.0", + "@autorest/modelerfour@4.19.3" + ], + "commit": "80e0bf225d3bb42a87d04696481b5c5ec4bef08a", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/billing/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.6.6 --version=3.3.0", + "autorest_command": "autorest specification/billing/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", "readme": "specification/billing/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/__init__.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/__init__.py index bfbe5e3f54d0..1889a18e1262 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/__init__.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['BillingManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() 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 a1e2d429dd3b..fd182a23844a 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 @@ -6,44 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import BillingManagementClientConfiguration +from .operations import AddressOperations, AgreementsOperations, AvailableBalancesOperations, BillingAccountsOperations, BillingPeriodsOperations, BillingPermissionsOperations, BillingProfilesOperations, BillingPropertyOperations, BillingRoleAssignmentsOperations, BillingRoleDefinitionsOperations, BillingSubscriptionsOperations, CustomersOperations, EnrollmentAccountsOperations, InstructionsOperations, InvoiceSectionsOperations, InvoicesOperations, Operations, PoliciesOperations, ProductsOperations, ReservationsOperations, TransactionsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import BillingManagementClientConfiguration -from .operations import BillingAccountsOperations -from .operations import AddressOperations -from .operations import AvailableBalancesOperations -from .operations import InstructionsOperations -from .operations import BillingProfilesOperations -from .operations import CustomersOperations -from .operations import InvoiceSectionsOperations -from .operations import BillingPermissionsOperations -from .operations import BillingSubscriptionsOperations -from .operations import ProductsOperations -from .operations import InvoicesOperations -from .operations import TransactionsOperations -from .operations import PoliciesOperations -from .operations import BillingPropertyOperations -from .operations import Operations -from .operations import BillingRoleDefinitionsOperations -from .operations import BillingRoleAssignmentsOperations -from .operations import AgreementsOperations -from .operations import ReservationsOperations -from .operations import EnrollmentAccountsOperations -from .operations import BillingPeriodsOperations -from . import models - -class BillingManagementClient(object): +class BillingManagementClient: """Billing client provides access to billing resources for Azure subscriptions. :ivar billing_accounts: BillingAccountsOperations operations @@ -77,9 +55,11 @@ class BillingManagementClient(object): :ivar operations: Operations operations :vartype operations: azure.mgmt.billing.operations.Operations :ivar billing_role_definitions: BillingRoleDefinitionsOperations operations - :vartype billing_role_definitions: azure.mgmt.billing.operations.BillingRoleDefinitionsOperations + :vartype billing_role_definitions: + azure.mgmt.billing.operations.BillingRoleDefinitionsOperations :ivar billing_role_assignments: BillingRoleAssignmentsOperations operations - :vartype billing_role_assignments: azure.mgmt.billing.operations.BillingRoleAssignmentsOperations + :vartype billing_role_assignments: + azure.mgmt.billing.operations.BillingRoleAssignmentsOperations :ivar agreements: AgreementsOperations operations :vartype agreements: azure.mgmt.billing.operations.AgreementsOperations :ivar reservations: ReservationsOperations operations @@ -92,88 +72,74 @@ class BillingManagementClient(object): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID that uniquely identifies an Azure subscription. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = BillingManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = BillingManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - - self.billing_accounts = BillingAccountsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.address = AddressOperations( - self._client, self._config, self._serialize, self._deserialize) - self.available_balances = AvailableBalancesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.instructions = InstructionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.billing_profiles = BillingProfilesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.customers = CustomersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.invoice_sections = InvoiceSectionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.billing_permissions = BillingPermissionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.billing_subscriptions = BillingSubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.products = ProductsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.invoices = InvoicesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.transactions = TransactionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policies = PoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.billing_property = BillingPropertyOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.billing_role_definitions = BillingRoleDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.billing_role_assignments = BillingRoleAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.agreements = AgreementsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.reservations = ReservationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.enrollment_accounts = EnrollmentAccountsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.billing_periods = BillingPeriodsOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + self._serialize.client_side_validation = False + self.billing_accounts = BillingAccountsOperations(self._client, self._config, self._serialize, self._deserialize) + self.address = AddressOperations(self._client, self._config, self._serialize, self._deserialize) + self.available_balances = AvailableBalancesOperations(self._client, self._config, self._serialize, self._deserialize) + self.instructions = InstructionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.billing_profiles = BillingProfilesOperations(self._client, self._config, self._serialize, self._deserialize) + self.customers = CustomersOperations(self._client, self._config, self._serialize, self._deserialize) + self.invoice_sections = InvoiceSectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.billing_permissions = BillingPermissionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.billing_subscriptions = BillingSubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.products = ProductsOperations(self._client, self._config, self._serialize, self._deserialize) + self.invoices = InvoicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.transactions = TransactionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policies = PoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.billing_property = BillingPropertyOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.billing_role_definitions = BillingRoleDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.billing_role_assignments = BillingRoleAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.agreements = AgreementsOperations(self._client, self._config, self._serialize, self._deserialize) + self.reservations = ReservationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.enrollment_accounts = EnrollmentAccountsOperations(self._client, self._config, self._serialize, self._deserialize) + self.billing_periods = BillingPeriodsOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/_configuration.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/_configuration.py index fa9ff1d038d8..e507ab6c23ef 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/_configuration.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/_configuration.py @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class BillingManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(BillingManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(BillingManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -67,4 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/_metadata.json b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/_metadata.json index 7a518fc45a10..6520a2b5ac1d 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/_metadata.json +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/_metadata.json @@ -5,13 +5,13 @@ "name": "BillingManagementClient", "filename": "_billing_management_client", "description": "Billing client provides access to billing resources for Azure subscriptions.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"BillingManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"BillingManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"BillingManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"BillingManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "billing_accounts": "BillingAccountsOperations", diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/_patch.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/_vendor.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# 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 azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/_version.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/_version.py index caf312bd2d0b..92721eef7dd5 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/_version.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "6.0.0" +VERSION = "0.3.0" diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/__init__.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/__init__.py index f07d4ec74555..7acf1e9a50f7 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/__init__.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/__init__.py @@ -8,3 +8,8 @@ from ._billing_management_client import BillingManagementClient __all__ = ['BillingManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/_billing_management_client.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/_billing_management_client.py index dfa4bc08b5e9..a94ca1ef22e6 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/_billing_management_client.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/_billing_management_client.py @@ -6,42 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import BillingManagementClientConfiguration +from .operations import AddressOperations, AgreementsOperations, AvailableBalancesOperations, BillingAccountsOperations, BillingPeriodsOperations, BillingPermissionsOperations, BillingProfilesOperations, BillingPropertyOperations, BillingRoleAssignmentsOperations, BillingRoleDefinitionsOperations, BillingSubscriptionsOperations, CustomersOperations, EnrollmentAccountsOperations, InstructionsOperations, InvoiceSectionsOperations, InvoicesOperations, Operations, PoliciesOperations, ProductsOperations, ReservationsOperations, TransactionsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import BillingManagementClientConfiguration -from .operations import BillingAccountsOperations -from .operations import AddressOperations -from .operations import AvailableBalancesOperations -from .operations import InstructionsOperations -from .operations import BillingProfilesOperations -from .operations import CustomersOperations -from .operations import InvoiceSectionsOperations -from .operations import BillingPermissionsOperations -from .operations import BillingSubscriptionsOperations -from .operations import ProductsOperations -from .operations import InvoicesOperations -from .operations import TransactionsOperations -from .operations import PoliciesOperations -from .operations import BillingPropertyOperations -from .operations import Operations -from .operations import BillingRoleDefinitionsOperations -from .operations import BillingRoleAssignmentsOperations -from .operations import AgreementsOperations -from .operations import ReservationsOperations -from .operations import EnrollmentAccountsOperations -from .operations import BillingPeriodsOperations -from .. import models - - -class BillingManagementClient(object): +class BillingManagementClient: """Billing client provides access to billing resources for Azure subscriptions. :ivar billing_accounts: BillingAccountsOperations operations @@ -61,7 +41,8 @@ class BillingManagementClient(object): :ivar billing_permissions: BillingPermissionsOperations operations :vartype billing_permissions: azure.mgmt.billing.aio.operations.BillingPermissionsOperations :ivar billing_subscriptions: BillingSubscriptionsOperations operations - :vartype billing_subscriptions: azure.mgmt.billing.aio.operations.BillingSubscriptionsOperations + :vartype billing_subscriptions: + azure.mgmt.billing.aio.operations.BillingSubscriptionsOperations :ivar products: ProductsOperations operations :vartype products: azure.mgmt.billing.aio.operations.ProductsOperations :ivar invoices: InvoicesOperations operations @@ -75,9 +56,11 @@ class BillingManagementClient(object): :ivar operations: Operations operations :vartype operations: azure.mgmt.billing.aio.operations.Operations :ivar billing_role_definitions: BillingRoleDefinitionsOperations operations - :vartype billing_role_definitions: azure.mgmt.billing.aio.operations.BillingRoleDefinitionsOperations + :vartype billing_role_definitions: + azure.mgmt.billing.aio.operations.BillingRoleDefinitionsOperations :ivar billing_role_assignments: BillingRoleAssignmentsOperations operations - :vartype billing_role_assignments: azure.mgmt.billing.aio.operations.BillingRoleAssignmentsOperations + :vartype billing_role_assignments: + azure.mgmt.billing.aio.operations.BillingRoleAssignmentsOperations :ivar agreements: AgreementsOperations operations :vartype agreements: azure.mgmt.billing.aio.operations.AgreementsOperations :ivar reservations: ReservationsOperations operations @@ -90,86 +73,74 @@ class BillingManagementClient(object): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID that uniquely identifies an Azure subscription. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = BillingManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = BillingManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.billing_accounts = BillingAccountsOperations(self._client, self._config, self._serialize, self._deserialize) + self.address = AddressOperations(self._client, self._config, self._serialize, self._deserialize) + self.available_balances = AvailableBalancesOperations(self._client, self._config, self._serialize, self._deserialize) + self.instructions = InstructionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.billing_profiles = BillingProfilesOperations(self._client, self._config, self._serialize, self._deserialize) + self.customers = CustomersOperations(self._client, self._config, self._serialize, self._deserialize) + self.invoice_sections = InvoiceSectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.billing_permissions = BillingPermissionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.billing_subscriptions = BillingSubscriptionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.products = ProductsOperations(self._client, self._config, self._serialize, self._deserialize) + self.invoices = InvoicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.transactions = TransactionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.policies = PoliciesOperations(self._client, self._config, self._serialize, self._deserialize) + self.billing_property = BillingPropertyOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.billing_role_definitions = BillingRoleDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.billing_role_assignments = BillingRoleAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.agreements = AgreementsOperations(self._client, self._config, self._serialize, self._deserialize) + self.reservations = ReservationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.enrollment_accounts = EnrollmentAccountsOperations(self._client, self._config, self._serialize, self._deserialize) + self.billing_periods = BillingPeriodsOperations(self._client, self._config, self._serialize, self._deserialize) + - self.billing_accounts = BillingAccountsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.address = AddressOperations( - self._client, self._config, self._serialize, self._deserialize) - self.available_balances = AvailableBalancesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.instructions = InstructionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.billing_profiles = BillingProfilesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.customers = CustomersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.invoice_sections = InvoiceSectionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.billing_permissions = BillingPermissionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.billing_subscriptions = BillingSubscriptionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.products = ProductsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.invoices = InvoicesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.transactions = TransactionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.policies = PoliciesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.billing_property = BillingPropertyOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.billing_role_definitions = BillingRoleDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.billing_role_assignments = BillingRoleAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.agreements = AgreementsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.reservations = ReservationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.enrollment_accounts = EnrollmentAccountsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.billing_periods = BillingPeriodsOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/_configuration.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/_configuration.py index 070bbfe02425..6b450fda04e6 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/_configuration.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(BillingManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(BillingManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -63,4 +63,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/_patch.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_address_operations.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_address_operations.py index 37a5150ec00f..5a682234046e 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_address_operations.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_address_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._address_operations import build_validate_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,10 +44,11 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def validate( self, address: "_models.AddressDetails", - **kwargs + **kwargs: Any ) -> "_models.ValidateAddressResponse": """Validates an address. Use the operation to validate an address before using it as soldTo or a billTo address. @@ -60,32 +65,25 @@ async def validate( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(address, 'AddressDetails') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(address, 'AddressDetails') + + request = build_validate_request( + content_type=content_type, + json=_json, + template_url=self.validate.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ValidateAddressResponse', pipeline_response) @@ -94,4 +92,6 @@ async def validate( return cls(pipeline_response, deserialized, {}) return deserialized + validate.metadata = {'url': '/providers/Microsoft.Billing/validateAddress'} # type: ignore + diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_agreements_operations.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_agreements_operations.py index 426c9a6eae96..41f5121ac4fe 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_agreements_operations.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_agreements_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._agreements_operations import build_get_request, build_list_by_billing_account_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,11 +46,12 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_billing_account( self, billing_account_name: str, expand: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.AgreementListResult"]: """Lists the agreements for a billing account. @@ -63,36 +69,31 @@ def list_by_billing_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_billing_account.metadata['url'] # type: ignore - 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 = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_account_request( + billing_account_name=billing_account_name, + expand=expand, + template_url=self.list_by_billing_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_account_request( + billing_account_name=billing_account_name, + expand=expand, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AgreementListResult', pipeline_response) + deserialized = self._deserialize("AgreementListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -105,23 +106,25 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/agreements'} # type: ignore + @distributed_trace_async async def get( self, billing_account_name: str, agreement_name: str, expand: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.Agreement": """Gets an agreement by ID. @@ -141,34 +144,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'agreementName': self._serialize.url("agreement_name", agreement_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + billing_account_name=billing_account_name, + agreement_name=agreement_name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Agreement', pipeline_response) @@ -177,4 +169,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/agreements/{agreementName}'} # type: ignore + diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_available_balances_operations.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_available_balances_operations.py index 5737f68c973c..1f22693b7e13 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_available_balances_operations.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_available_balances_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._available_balances_operations import build_get_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,11 +44,12 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, billing_account_name: str, billing_profile_name: str, - **kwargs + **kwargs: Any ) -> "_models.AvailableBalance": """The available credit balance for a billing profile. This is the balance that can be used for pay now to settle due or past due invoices. The operation is supported only for billing @@ -64,32 +69,22 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AvailableBalance', pipeline_response) @@ -98,4 +93,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/availableBalance/default'} # type: ignore + diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_billing_accounts_operations.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_billing_accounts_operations.py index 2ec6f0568c16..bc4c57876067 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_billing_accounts_operations.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_billing_accounts_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._billing_accounts_operations import build_get_request, build_list_invoice_sections_by_create_subscription_permission_request, build_list_request, build_update_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,18 +48,21 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, expand: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.BillingAccountListResult"]: """Lists the billing accounts that a user has access to. :param expand: May be used to expand the soldTo, invoice sections and billing profiles. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BillingAccountListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.BillingAccountListResult] + :return: An iterator like instance of either BillingAccountListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.BillingAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.BillingAccountListResult"] @@ -62,32 +70,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + expand=expand, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + expand=expand, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('BillingAccountListResult', pipeline_response) + deserialized = self._deserialize("BillingAccountListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -100,22 +105,24 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts'} # type: ignore + @distributed_trace_async async def get( self, billing_account_name: str, expand: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.BillingAccount": """Gets a billing account by its ID. @@ -133,33 +140,22 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - 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 = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + billing_account_name=billing_account_name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('BillingAccount', pipeline_response) @@ -168,50 +164,41 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}'} # type: ignore + async def _update_initial( self, billing_account_name: str, parameters: "_models.BillingAccountUpdateRequest", - **kwargs + **kwargs: Any ) -> Optional["_models.BillingAccount"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.BillingAccount"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - 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 = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'BillingAccountUpdateRequest') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request_initial( + billing_account_name=billing_account_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'BillingAccountUpdateRequest') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -221,13 +208,16 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, billing_account_name: str, parameters: "_models.BillingAccountUpdateRequest", - **kwargs + **kwargs: Any ) -> AsyncLROPoller["_models.BillingAccount"]: """Updates the properties of a billing account. Currently, displayName and address can be updated. The operation is supported only for billing accounts with agreement type Microsoft Customer @@ -240,15 +230,19 @@ async def begin_update( :type parameters: ~azure.mgmt.billing.models.BillingAccountUpdateRequest :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either BillingAccount or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BillingAccount or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.billing.models.BillingAccount] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.BillingAccount"] lro_delay = kwargs.pop( 'polling_interval', @@ -259,25 +253,21 @@ async def begin_update( raw_result = await self._update_initial( billing_account_name=billing_account_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('BillingAccount', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -289,12 +279,14 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}'} # type: ignore + @distributed_trace def list_invoice_sections_by_create_subscription_permission( self, billing_account_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.InvoiceSectionListWithCreateSubPermissionResult"]: """Lists the invoice sections for which the user has permission to create Azure subscriptions. The operation is supported only for billing accounts with agreement type Microsoft Customer @@ -303,8 +295,10 @@ def list_invoice_sections_by_create_subscription_permission( :param billing_account_name: The ID that uniquely identifies a billing account. :type billing_account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either InvoiceSectionListWithCreateSubPermissionResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.InvoiceSectionListWithCreateSubPermissionResult] + :return: An iterator like instance of either InvoiceSectionListWithCreateSubPermissionResult or + the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.InvoiceSectionListWithCreateSubPermissionResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.InvoiceSectionListWithCreateSubPermissionResult"] @@ -312,34 +306,29 @@ def list_invoice_sections_by_create_subscription_permission( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_invoice_sections_by_create_subscription_permission.metadata['url'] # type: ignore - 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 = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.post(url, query_parameters, header_parameters) + + request = build_list_invoice_sections_by_create_subscription_permission_request( + billing_account_name=billing_account_name, + template_url=self.list_invoice_sections_by_create_subscription_permission.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_invoice_sections_by_create_subscription_permission_request( + billing_account_name=billing_account_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('InvoiceSectionListWithCreateSubPermissionResult', pipeline_response) + deserialized = self._deserialize("InvoiceSectionListWithCreateSubPermissionResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -352,12 +341,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_billing_periods_operations.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_billing_periods_operations.py index f3e701e6a6aa..14e4becca7b5 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_billing_periods_operations.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_billing_periods_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._billing_periods_operations import build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,12 +46,13 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, filter: Optional[str] = None, skiptoken: Optional[str] = None, top: Optional[int] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.BillingPeriodsListResult"]: """Lists the available billing periods for a subscription in reverse chronological order. This is only supported for Azure Web-Direct subscriptions. Other subscription types which were not @@ -63,8 +69,10 @@ def list( :param top: May be used to limit the number of results to the most recent N billing periods. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BillingPeriodsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.BillingPeriodsListResult] + :return: An iterator like instance of either BillingPeriodsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.BillingPeriodsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.BillingPeriodsListResult"] @@ -72,40 +80,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - 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 = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if skiptoken is not None: - query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=100, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + filter=filter, + skiptoken=skiptoken, + top=top, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + filter=filter, + skiptoken=skiptoken, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('BillingPeriodsListResult', pipeline_response) + deserialized = self._deserialize("BillingPeriodsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -118,21 +121,23 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingPeriods'} # type: ignore + @distributed_trace_async async def get( self, billing_period_name: str, - **kwargs + **kwargs: Any ) -> "_models.BillingPeriod": """Gets a named billing period. This is only supported for Azure Web-Direct subscriptions. Other subscription types which were not purchased directly through the Azure web portal are not @@ -150,32 +155,22 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'billingPeriodName': self._serialize.url("billing_period_name", billing_period_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + billing_period_name=billing_period_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('BillingPeriod', pipeline_response) @@ -184,4 +179,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}'} # type: ignore + diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_billing_permissions_operations.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_billing_permissions_operations.py index 613e0189287e..dce1db680d35 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_billing_permissions_operations.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_billing_permissions_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._billing_permissions_operations import build_list_by_billing_account_request, build_list_by_billing_profile_request, build_list_by_customer_request, build_list_by_invoice_sections_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,11 +46,12 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_customer( self, billing_account_name: str, customer_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.BillingPermissionsListResult"]: """Lists the billing permissions the caller has for a customer. @@ -54,8 +60,10 @@ def list_by_customer( :param customer_name: The ID that uniquely identifies a customer. :type customer_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BillingPermissionsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.BillingPermissionsListResult] + :return: An iterator like instance of either BillingPermissionsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.BillingPermissionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.BillingPermissionsListResult"] @@ -63,35 +71,31 @@ def list_by_customer( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_customer.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'customerName': self._serialize.url("customer_name", customer_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_customer_request( + billing_account_name=billing_account_name, + customer_name=customer_name, + template_url=self.list_by_customer.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_customer_request( + billing_account_name=billing_account_name, + customer_name=customer_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('BillingPermissionsListResult', pipeline_response) + deserialized = self._deserialize("BillingPermissionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -104,29 +108,33 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_customer.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/billingPermissions'} # type: ignore + @distributed_trace def list_by_billing_account( self, billing_account_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.BillingPermissionsListResult"]: """Lists the billing permissions the caller has on a billing account. :param billing_account_name: The ID that uniquely identifies a billing account. :type billing_account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BillingPermissionsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.BillingPermissionsListResult] + :return: An iterator like instance of either BillingPermissionsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.BillingPermissionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.BillingPermissionsListResult"] @@ -134,34 +142,29 @@ def list_by_billing_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_billing_account.metadata['url'] # type: ignore - 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 = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_account_request( + billing_account_name=billing_account_name, + template_url=self.list_by_billing_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_account_request( + billing_account_name=billing_account_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('BillingPermissionsListResult', pipeline_response) + deserialized = self._deserialize("BillingPermissionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -174,23 +177,25 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingPermissions'} # type: ignore + @distributed_trace def list_by_invoice_sections( self, billing_account_name: str, billing_profile_name: str, invoice_section_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.BillingPermissionsListResult"]: """Lists the billing permissions the caller has on an invoice section. @@ -201,8 +206,10 @@ def list_by_invoice_sections( :param invoice_section_name: The ID that uniquely identifies an invoice section. :type invoice_section_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BillingPermissionsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.BillingPermissionsListResult] + :return: An iterator like instance of either BillingPermissionsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.BillingPermissionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.BillingPermissionsListResult"] @@ -210,36 +217,33 @@ def list_by_invoice_sections( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_invoice_sections.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - 'invoiceSectionName': self._serialize.url("invoice_section_name", invoice_section_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_invoice_sections_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + template_url=self.list_by_invoice_sections.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_invoice_sections_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('BillingPermissionsListResult', pipeline_response) + deserialized = self._deserialize("BillingPermissionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -252,22 +256,24 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_invoice_sections.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingPermissions'} # type: ignore + @distributed_trace def list_by_billing_profile( self, billing_account_name: str, billing_profile_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.BillingPermissionsListResult"]: """Lists the billing permissions the caller has on a billing profile. @@ -276,8 +282,10 @@ def list_by_billing_profile( :param billing_profile_name: The ID that uniquely identifies a billing profile. :type billing_profile_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BillingPermissionsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.BillingPermissionsListResult] + :return: An iterator like instance of either BillingPermissionsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.BillingPermissionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.BillingPermissionsListResult"] @@ -285,35 +293,31 @@ def list_by_billing_profile( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_billing_profile.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + template_url=self.list_by_billing_profile.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('BillingPermissionsListResult', pipeline_response) + deserialized = self._deserialize("BillingPermissionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -326,12 +330,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_billing_profiles_operations.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_billing_profiles_operations.py index 0c7eaffb8d05..31571be46be5 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_billing_profiles_operations.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_billing_profiles_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._billing_profiles_operations import build_create_or_update_request_initial, build_get_request, build_list_by_billing_account_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,11 +48,12 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_billing_account( self, billing_account_name: str, expand: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.BillingProfileListResult"]: """Lists the billing profiles that a user has access to. The operation is supported for billing accounts with agreement type Microsoft Customer Agreement or Microsoft Partner Agreement. @@ -57,8 +63,10 @@ def list_by_billing_account( :param expand: May be used to expand the invoice sections. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BillingProfileListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.BillingProfileListResult] + :return: An iterator like instance of either BillingProfileListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.BillingProfileListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.BillingProfileListResult"] @@ -66,36 +74,31 @@ def list_by_billing_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_billing_account.metadata['url'] # type: ignore - 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 = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_account_request( + billing_account_name=billing_account_name, + expand=expand, + template_url=self.list_by_billing_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_account_request( + billing_account_name=billing_account_name, + expand=expand, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('BillingProfileListResult', pipeline_response) + deserialized = self._deserialize("BillingProfileListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -108,23 +111,25 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles'} # type: ignore + @distributed_trace_async async def get( self, billing_account_name: str, billing_profile_name: str, expand: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.BillingProfile": """Gets a billing profile by its ID. The operation is supported for billing accounts with agreement type Microsoft Customer Agreement or Microsoft Partner Agreement. @@ -145,34 +150,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('BillingProfile', pipeline_response) @@ -181,74 +175,69 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}'} # type: ignore + async def _create_or_update_initial( self, billing_account_name: str, billing_profile_name: str, parameters: "_models.BillingProfile", - **kwargs + **kwargs: Any ) -> Optional["_models.BillingProfile"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.BillingProfile"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'BillingProfile') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'BillingProfile') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('BillingProfile', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _create_or_update_initial.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, billing_account_name: str, billing_profile_name: str, parameters: "_models.BillingProfile", - **kwargs + **kwargs: Any ) -> AsyncLROPoller["_models.BillingProfile"]: """Creates or updates a billing profile. The operation is supported for billing accounts with agreement type Microsoft Customer Agreement or Microsoft Partner Agreement. @@ -261,15 +250,19 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.billing.models.BillingProfile :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either BillingProfile or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BillingProfile or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.billing.models.BillingProfile] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.BillingProfile"] lro_delay = kwargs.pop( 'polling_interval', @@ -281,26 +274,21 @@ async def begin_create_or_update( billing_account_name=billing_account_name, billing_profile_name=billing_profile_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('BillingProfile', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -312,4 +300,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}'} # type: ignore diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_billing_property_operations.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_billing_property_operations.py index f54dfc955f5a..ea177ef217e3 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_billing_property_operations.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_billing_property_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._billing_property_operations import build_get_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,9 +44,10 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, - **kwargs + **kwargs: Any ) -> "_models.BillingProperty": """Get the billing properties for a subscription. This operation is not supported for billing accounts with agreement type Enterprise Agreement. @@ -57,31 +62,21 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - 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 = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('BillingProperty', pipeline_response) @@ -90,12 +85,15 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingProperty/default'} # type: ignore + + @distributed_trace_async async def update( self, parameters: "_models.BillingProperty", - **kwargs + **kwargs: Any ) -> "_models.BillingProperty": """Updates the billing property of a subscription. Currently, cost center can be updated. The operation is supported only for billing accounts with agreement type Microsoft Customer @@ -114,36 +112,26 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - 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 = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'BillingProperty') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'BillingProperty') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('BillingProperty', pipeline_response) @@ -152,4 +140,6 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingProperty/default'} # type: ignore + diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_billing_role_assignments_operations.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_billing_role_assignments_operations.py index 342d85b97e5f..9490cc9bc394 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_billing_role_assignments_operations.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_billing_role_assignments_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._billing_role_assignments_operations import build_delete_by_billing_account_request, build_delete_by_billing_profile_request, build_delete_by_invoice_section_request, build_get_by_billing_account_request, build_get_by_billing_profile_request, build_get_by_invoice_section_request, build_list_by_billing_account_request, build_list_by_billing_profile_request, build_list_by_invoice_section_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,11 +46,12 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get_by_billing_account( self, billing_account_name: str, billing_role_assignment_name: str, - **kwargs + **kwargs: Any ) -> "_models.BillingRoleAssignment": """Gets a role assignment for the caller on a billing account. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer @@ -65,32 +71,22 @@ async def get_by_billing_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.get_by_billing_account.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingRoleAssignmentName': self._serialize.url("billing_role_assignment_name", billing_role_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_billing_account_request( + billing_account_name=billing_account_name, + billing_role_assignment_name=billing_role_assignment_name, + template_url=self.get_by_billing_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('BillingRoleAssignment', pipeline_response) @@ -99,13 +95,16 @@ async def get_by_billing_account( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleAssignments/{billingRoleAssignmentName}'} # type: ignore + + @distributed_trace_async async def delete_by_billing_account( self, billing_account_name: str, billing_role_assignment_name: str, - **kwargs + **kwargs: Any ) -> "_models.BillingRoleAssignment": """Deletes a role assignment for the caller on a billing account. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer @@ -125,32 +124,22 @@ async def delete_by_billing_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.delete_by_billing_account.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingRoleAssignmentName': self._serialize.url("billing_role_assignment_name", billing_role_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_billing_account_request( + billing_account_name=billing_account_name, + billing_role_assignment_name=billing_role_assignment_name, + template_url=self.delete_by_billing_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('BillingRoleAssignment', pipeline_response) @@ -159,15 +148,18 @@ async def delete_by_billing_account( return cls(pipeline_response, deserialized, {}) return deserialized + delete_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleAssignments/{billingRoleAssignmentName}'} # type: ignore + + @distributed_trace_async async def get_by_invoice_section( self, billing_account_name: str, billing_profile_name: str, invoice_section_name: str, billing_role_assignment_name: str, - **kwargs + **kwargs: Any ) -> "_models.BillingRoleAssignment": """Gets a role assignment for the caller on an invoice section. The operation is supported for billing accounts with agreement type Microsoft Customer Agreement. @@ -190,34 +182,24 @@ async def get_by_invoice_section( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.get_by_invoice_section.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - 'invoiceSectionName': self._serialize.url("invoice_section_name", invoice_section_name, 'str'), - 'billingRoleAssignmentName': self._serialize.url("billing_role_assignment_name", billing_role_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_invoice_section_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + billing_role_assignment_name=billing_role_assignment_name, + template_url=self.get_by_invoice_section.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('BillingRoleAssignment', pipeline_response) @@ -226,15 +208,18 @@ async def get_by_invoice_section( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_invoice_section.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRoleAssignments/{billingRoleAssignmentName}'} # type: ignore + + @distributed_trace_async async def delete_by_invoice_section( self, billing_account_name: str, billing_profile_name: str, invoice_section_name: str, billing_role_assignment_name: str, - **kwargs + **kwargs: Any ) -> "_models.BillingRoleAssignment": """Deletes a role assignment for the caller on an invoice section. The operation is supported for billing accounts with agreement type Microsoft Customer Agreement. @@ -257,34 +242,24 @@ async def delete_by_invoice_section( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.delete_by_invoice_section.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - 'invoiceSectionName': self._serialize.url("invoice_section_name", invoice_section_name, 'str'), - 'billingRoleAssignmentName': self._serialize.url("billing_role_assignment_name", billing_role_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_invoice_section_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + billing_role_assignment_name=billing_role_assignment_name, + template_url=self.delete_by_invoice_section.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('BillingRoleAssignment', pipeline_response) @@ -293,14 +268,17 @@ async def delete_by_invoice_section( return cls(pipeline_response, deserialized, {}) return deserialized + delete_by_invoice_section.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRoleAssignments/{billingRoleAssignmentName}'} # type: ignore + + @distributed_trace_async async def get_by_billing_profile( self, billing_account_name: str, billing_profile_name: str, billing_role_assignment_name: str, - **kwargs + **kwargs: Any ) -> "_models.BillingRoleAssignment": """Gets a role assignment for the caller on a billing profile. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer @@ -322,33 +300,23 @@ async def get_by_billing_profile( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.get_by_billing_profile.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - 'billingRoleAssignmentName': self._serialize.url("billing_role_assignment_name", billing_role_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + billing_role_assignment_name=billing_role_assignment_name, + template_url=self.get_by_billing_profile.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('BillingRoleAssignment', pipeline_response) @@ -357,14 +325,17 @@ async def get_by_billing_profile( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRoleAssignments/{billingRoleAssignmentName}'} # type: ignore + + @distributed_trace_async async def delete_by_billing_profile( self, billing_account_name: str, billing_profile_name: str, billing_role_assignment_name: str, - **kwargs + **kwargs: Any ) -> "_models.BillingRoleAssignment": """Deletes a role assignment for the caller on a billing profile. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer @@ -386,33 +357,23 @@ async def delete_by_billing_profile( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.delete_by_billing_profile.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - 'billingRoleAssignmentName': self._serialize.url("billing_role_assignment_name", billing_role_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + billing_role_assignment_name=billing_role_assignment_name, + template_url=self.delete_by_billing_profile.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('BillingRoleAssignment', pipeline_response) @@ -421,12 +382,15 @@ async def delete_by_billing_profile( return cls(pipeline_response, deserialized, {}) return deserialized + delete_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRoleAssignments/{billingRoleAssignmentName}'} # type: ignore + + @distributed_trace def list_by_billing_account( self, billing_account_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.BillingRoleAssignmentListResult"]: """Lists the role assignments for the caller on a billing account. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer @@ -435,8 +399,10 @@ def list_by_billing_account( :param billing_account_name: The ID that uniquely identifies a billing account. :type billing_account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BillingRoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.BillingRoleAssignmentListResult] + :return: An iterator like instance of either BillingRoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.BillingRoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.BillingRoleAssignmentListResult"] @@ -444,34 +410,29 @@ def list_by_billing_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_billing_account.metadata['url'] # type: ignore - 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 = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_account_request( + billing_account_name=billing_account_name, + template_url=self.list_by_billing_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_account_request( + billing_account_name=billing_account_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('BillingRoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("BillingRoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -484,23 +445,25 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleAssignments'} # type: ignore + @distributed_trace def list_by_invoice_section( self, billing_account_name: str, billing_profile_name: str, invoice_section_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.BillingRoleAssignmentListResult"]: """Lists the role assignments for the caller on an invoice section. The operation is supported for billing accounts with agreement type Microsoft Customer Agreement. @@ -512,8 +475,10 @@ def list_by_invoice_section( :param invoice_section_name: The ID that uniquely identifies an invoice section. :type invoice_section_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BillingRoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.BillingRoleAssignmentListResult] + :return: An iterator like instance of either BillingRoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.BillingRoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.BillingRoleAssignmentListResult"] @@ -521,36 +486,33 @@ def list_by_invoice_section( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_invoice_section.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - 'invoiceSectionName': self._serialize.url("invoice_section_name", invoice_section_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_invoice_section_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + template_url=self.list_by_invoice_section.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_invoice_section_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('BillingRoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("BillingRoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -563,22 +525,24 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_invoice_section.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRoleAssignments'} # type: ignore + @distributed_trace def list_by_billing_profile( self, billing_account_name: str, billing_profile_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.BillingRoleAssignmentListResult"]: """Lists the role assignments for the caller on a billing profile. The operation is supported for billing accounts with agreement type Microsoft Customer Agreement. @@ -588,8 +552,10 @@ def list_by_billing_profile( :param billing_profile_name: The ID that uniquely identifies a billing profile. :type billing_profile_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BillingRoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.BillingRoleAssignmentListResult] + :return: An iterator like instance of either BillingRoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.BillingRoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.BillingRoleAssignmentListResult"] @@ -597,35 +563,31 @@ def list_by_billing_profile( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_billing_profile.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + template_url=self.list_by_billing_profile.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('BillingRoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("BillingRoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -638,12 +600,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_billing_role_definitions_operations.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_billing_role_definitions_operations.py index 1ed6da928727..bc9b92f49418 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_billing_role_definitions_operations.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_billing_role_definitions_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._billing_role_definitions_operations import build_get_by_billing_account_request, build_get_by_billing_profile_request, build_get_by_invoice_section_request, build_list_by_billing_account_request, build_list_by_billing_profile_request, build_list_by_invoice_section_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,11 +46,12 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get_by_billing_account( self, billing_account_name: str, billing_role_definition_name: str, - **kwargs + **kwargs: Any ) -> "_models.BillingRoleDefinition": """Gets the definition for a role on a billing account. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. @@ -64,32 +70,22 @@ async def get_by_billing_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.get_by_billing_account.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingRoleDefinitionName': self._serialize.url("billing_role_definition_name", billing_role_definition_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_billing_account_request( + billing_account_name=billing_account_name, + billing_role_definition_name=billing_role_definition_name, + template_url=self.get_by_billing_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('BillingRoleDefinition', pipeline_response) @@ -98,15 +94,18 @@ async def get_by_billing_account( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleDefinitions/{billingRoleDefinitionName}'} # type: ignore + + @distributed_trace_async async def get_by_invoice_section( self, billing_account_name: str, billing_profile_name: str, invoice_section_name: str, billing_role_definition_name: str, - **kwargs + **kwargs: Any ) -> "_models.BillingRoleDefinition": """Gets the definition for a role on an invoice section. The operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. @@ -129,34 +128,24 @@ async def get_by_invoice_section( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.get_by_invoice_section.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - 'invoiceSectionName': self._serialize.url("invoice_section_name", invoice_section_name, 'str'), - 'billingRoleDefinitionName': self._serialize.url("billing_role_definition_name", billing_role_definition_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_invoice_section_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + billing_role_definition_name=billing_role_definition_name, + template_url=self.get_by_invoice_section.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('BillingRoleDefinition', pipeline_response) @@ -165,14 +154,17 @@ async def get_by_invoice_section( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_invoice_section.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRoleDefinitions/{billingRoleDefinitionName}'} # type: ignore + + @distributed_trace_async async def get_by_billing_profile( self, billing_account_name: str, billing_profile_name: str, billing_role_definition_name: str, - **kwargs + **kwargs: Any ) -> "_models.BillingRoleDefinition": """Gets the definition for a role on a billing profile. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. @@ -193,33 +185,23 @@ async def get_by_billing_profile( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.get_by_billing_profile.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - 'billingRoleDefinitionName': self._serialize.url("billing_role_definition_name", billing_role_definition_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + billing_role_definition_name=billing_role_definition_name, + template_url=self.get_by_billing_profile.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('BillingRoleDefinition', pipeline_response) @@ -228,12 +210,15 @@ async def get_by_billing_profile( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRoleDefinitions/{billingRoleDefinitionName}'} # type: ignore + + @distributed_trace def list_by_billing_account( self, billing_account_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.BillingRoleDefinitionListResult"]: """Lists the role definitions for a billing account. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. @@ -241,8 +226,10 @@ def list_by_billing_account( :param billing_account_name: The ID that uniquely identifies a billing account. :type billing_account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BillingRoleDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.BillingRoleDefinitionListResult] + :return: An iterator like instance of either BillingRoleDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.BillingRoleDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.BillingRoleDefinitionListResult"] @@ -250,34 +237,29 @@ def list_by_billing_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_billing_account.metadata['url'] # type: ignore - 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 = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_account_request( + billing_account_name=billing_account_name, + template_url=self.list_by_billing_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_account_request( + billing_account_name=billing_account_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('BillingRoleDefinitionListResult', pipeline_response) + deserialized = self._deserialize("BillingRoleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -290,23 +272,25 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleDefinitions'} # type: ignore + @distributed_trace def list_by_invoice_section( self, billing_account_name: str, billing_profile_name: str, invoice_section_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.BillingRoleDefinitionListResult"]: """Lists the role definitions for an invoice section. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. @@ -318,8 +302,10 @@ def list_by_invoice_section( :param invoice_section_name: The ID that uniquely identifies an invoice section. :type invoice_section_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BillingRoleDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.BillingRoleDefinitionListResult] + :return: An iterator like instance of either BillingRoleDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.BillingRoleDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.BillingRoleDefinitionListResult"] @@ -327,36 +313,33 @@ def list_by_invoice_section( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_invoice_section.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - 'invoiceSectionName': self._serialize.url("invoice_section_name", invoice_section_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_invoice_section_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + template_url=self.list_by_invoice_section.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_invoice_section_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('BillingRoleDefinitionListResult', pipeline_response) + deserialized = self._deserialize("BillingRoleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -369,22 +352,24 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_invoice_section.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRoleDefinitions'} # type: ignore + @distributed_trace def list_by_billing_profile( self, billing_account_name: str, billing_profile_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.BillingRoleDefinitionListResult"]: """Lists the role definitions for a billing profile. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. @@ -394,8 +379,10 @@ def list_by_billing_profile( :param billing_profile_name: The ID that uniquely identifies a billing profile. :type billing_profile_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BillingRoleDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.BillingRoleDefinitionListResult] + :return: An iterator like instance of either BillingRoleDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.BillingRoleDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.BillingRoleDefinitionListResult"] @@ -403,35 +390,31 @@ def list_by_billing_profile( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_billing_profile.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + template_url=self.list_by_billing_profile.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('BillingRoleDefinitionListResult', pipeline_response) + deserialized = self._deserialize("BillingRoleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -444,12 +427,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_billing_subscriptions_operations.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_billing_subscriptions_operations.py index a147b51fbca7..c1f1f3ea6322 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_billing_subscriptions_operations.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_billing_subscriptions_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._billing_subscriptions_operations import build_get_request, build_list_by_billing_account_request, build_list_by_billing_profile_request, build_list_by_customer_request, build_list_by_invoice_section_request, build_move_request_initial, build_update_request, build_validate_move_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,11 +48,12 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_customer( self, billing_account_name: str, customer_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.BillingSubscriptionsListResult"]: """Lists the subscriptions for a customer. The operation is supported only for billing accounts with agreement type Microsoft Partner Agreement. @@ -57,8 +63,10 @@ def list_by_customer( :param customer_name: The ID that uniquely identifies a customer. :type customer_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BillingSubscriptionsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.BillingSubscriptionsListResult] + :return: An iterator like instance of either BillingSubscriptionsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.BillingSubscriptionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.BillingSubscriptionsListResult"] @@ -66,35 +74,31 @@ def list_by_customer( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_customer.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'customerName': self._serialize.url("customer_name", customer_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_customer_request( + billing_account_name=billing_account_name, + customer_name=customer_name, + template_url=self.list_by_customer.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_customer_request( + billing_account_name=billing_account_name, + customer_name=customer_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('BillingSubscriptionsListResult', pipeline_response) + deserialized = self._deserialize("BillingSubscriptionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -107,21 +111,23 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_customer.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/billingSubscriptions'} # type: ignore + @distributed_trace def list_by_billing_account( self, billing_account_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.BillingSubscriptionsListResult"]: """Lists the subscriptions for a billing account. The operation is supported for billing accounts with agreement type Microsoft Customer Agreement or Microsoft Partner Agreement. @@ -129,8 +135,10 @@ def list_by_billing_account( :param billing_account_name: The ID that uniquely identifies a billing account. :type billing_account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BillingSubscriptionsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.BillingSubscriptionsListResult] + :return: An iterator like instance of either BillingSubscriptionsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.BillingSubscriptionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.BillingSubscriptionsListResult"] @@ -138,34 +146,29 @@ def list_by_billing_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_billing_account.metadata['url'] # type: ignore - 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 = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_account_request( + billing_account_name=billing_account_name, + template_url=self.list_by_billing_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_account_request( + billing_account_name=billing_account_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('BillingSubscriptionsListResult', pipeline_response) + deserialized = self._deserialize("BillingSubscriptionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -178,22 +181,24 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions'} # type: ignore + @distributed_trace def list_by_billing_profile( self, billing_account_name: str, billing_profile_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.BillingSubscriptionsListResult"]: """Lists the subscriptions that are billed to a billing profile. The operation is supported for billing accounts with agreement type Microsoft Customer Agreement or Microsoft Partner @@ -204,8 +209,10 @@ def list_by_billing_profile( :param billing_profile_name: The ID that uniquely identifies a billing profile. :type billing_profile_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BillingSubscriptionsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.BillingSubscriptionsListResult] + :return: An iterator like instance of either BillingSubscriptionsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.BillingSubscriptionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.BillingSubscriptionsListResult"] @@ -213,35 +220,31 @@ def list_by_billing_profile( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_billing_profile.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + template_url=self.list_by_billing_profile.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('BillingSubscriptionsListResult', pipeline_response) + deserialized = self._deserialize("BillingSubscriptionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -254,23 +257,25 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingSubscriptions'} # type: ignore + @distributed_trace def list_by_invoice_section( self, billing_account_name: str, billing_profile_name: str, invoice_section_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.BillingSubscriptionsListResult"]: """Lists the subscriptions that are billed to an invoice section. The operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. @@ -282,8 +287,10 @@ def list_by_invoice_section( :param invoice_section_name: The ID that uniquely identifies an invoice section. :type invoice_section_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BillingSubscriptionsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.BillingSubscriptionsListResult] + :return: An iterator like instance of either BillingSubscriptionsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.BillingSubscriptionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.BillingSubscriptionsListResult"] @@ -291,36 +298,33 @@ def list_by_invoice_section( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_invoice_section.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - 'invoiceSectionName': self._serialize.url("invoice_section_name", invoice_section_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_invoice_section_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + template_url=self.list_by_invoice_section.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_invoice_section_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('BillingSubscriptionsListResult', pipeline_response) + deserialized = self._deserialize("BillingSubscriptionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -333,21 +337,23 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_invoice_section.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingSubscriptions'} # type: ignore + @distributed_trace_async async def get( self, billing_account_name: str, - **kwargs + **kwargs: Any ) -> "_models.BillingSubscription": """Gets a subscription by its ID. The operation is supported for billing accounts with agreement type Microsoft Customer Agreement and Microsoft Partner Agreement. @@ -364,32 +370,22 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - '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 = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + billing_account_name=billing_account_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('BillingSubscription', pipeline_response) @@ -398,13 +394,16 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{subscriptionId}'} # type: ignore + + @distributed_trace_async async def update( self, billing_account_name: str, parameters: "_models.BillingSubscription", - **kwargs + **kwargs: Any ) -> "_models.BillingSubscription": """Updates the properties of a billing subscription. Currently, cost center can be updated. The operation is supported only for billing accounts with agreement type Microsoft Customer @@ -425,37 +424,27 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - '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 = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'BillingSubscription') + + request = build_update_request( + billing_account_name=billing_account_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'BillingSubscription') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('BillingSubscription', pipeline_response) @@ -464,72 +453,67 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{subscriptionId}'} # type: ignore + async def _move_initial( self, billing_account_name: str, parameters: "_models.TransferBillingSubscriptionRequestProperties", - **kwargs + **kwargs: Any ) -> Optional["_models.BillingSubscription"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.BillingSubscription"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._move_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - '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 = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'TransferBillingSubscriptionRequestProperties') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_move_request_initial( + billing_account_name=billing_account_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._move_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TransferBillingSubscriptionRequestProperties') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('BillingSubscription', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _move_initial.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{subscriptionId}/move'} # type: ignore + + @distributed_trace_async async def begin_move( self, billing_account_name: str, parameters: "_models.TransferBillingSubscriptionRequestProperties", - **kwargs + **kwargs: Any ) -> AsyncLROPoller["_models.BillingSubscription"]: """Moves a subscription's charges to a new invoice section. The new invoice section must belong to the same billing profile as the existing invoice section. This operation is supported for @@ -541,15 +525,19 @@ async def begin_move( :type parameters: ~azure.mgmt.billing.models.TransferBillingSubscriptionRequestProperties :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either BillingSubscription or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either BillingSubscription or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.billing.models.BillingSubscription] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.BillingSubscription"] lro_delay = kwargs.pop( 'polling_interval', @@ -560,26 +548,21 @@ async def begin_move( raw_result = await self._move_initial( billing_account_name=billing_account_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('BillingSubscription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -591,13 +574,15 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_move.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{subscriptionId}/move'} # type: ignore + @distributed_trace_async async def validate_move( self, billing_account_name: str, parameters: "_models.TransferBillingSubscriptionRequestProperties", - **kwargs + **kwargs: Any ) -> "_models.ValidateSubscriptionTransferEligibilityResult": """Validates if a subscription's charges can be moved to a new invoice section. This operation is supported for billing accounts with agreement type Microsoft Customer Agreement. @@ -617,37 +602,27 @@ async def validate_move( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate_move.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - '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 = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'TransferBillingSubscriptionRequestProperties') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_move_request( + billing_account_name=billing_account_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.validate_move.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TransferBillingSubscriptionRequestProperties') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ValidateSubscriptionTransferEligibilityResult', pipeline_response) @@ -656,4 +631,6 @@ async def validate_move( return cls(pipeline_response, deserialized, {}) return deserialized + validate_move.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{subscriptionId}/validateMoveEligibility'} # type: ignore + diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_customers_operations.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_customers_operations.py index a8635fd4abb1..cb31b2156945 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_customers_operations.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_customers_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._customers_operations import build_get_request, build_list_by_billing_account_request, build_list_by_billing_profile_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,13 +46,14 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_billing_profile( self, billing_account_name: str, billing_profile_name: str, search: Optional[str] = None, filter: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.CustomerListResult"]: """Lists the customers that are billed to a billing profile. The operation is supported only for billing accounts with agreement type Microsoft Partner Agreement. @@ -71,39 +77,35 @@ def list_by_billing_profile( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_billing_profile.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if search is not None: - query_parameters['$search'] = self._serialize.query("search", search, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + search=search, + filter=filter, + template_url=self.list_by_billing_profile.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + search=search, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('CustomerListResult', pipeline_response) + deserialized = self._deserialize("CustomerListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -116,23 +118,25 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers'} # type: ignore + @distributed_trace def list_by_billing_account( self, billing_account_name: str, search: Optional[str] = None, filter: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.CustomerListResult"]: """Lists the customers that are billed to a billing account. The operation is supported only for billing accounts with agreement type Microsoft Partner Agreement. @@ -154,38 +158,33 @@ def list_by_billing_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_billing_account.metadata['url'] # type: ignore - 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 = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if search is not None: - query_parameters['$search'] = self._serialize.query("search", search, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_account_request( + billing_account_name=billing_account_name, + search=search, + filter=filter, + template_url=self.list_by_billing_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_account_request( + billing_account_name=billing_account_name, + search=search, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('CustomerListResult', pipeline_response) + deserialized = self._deserialize("CustomerListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -198,23 +197,25 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers'} # type: ignore + @distributed_trace_async async def get( self, billing_account_name: str, customer_name: str, expand: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.Customer": """Gets a customer by its ID. The operation is supported only for billing accounts with agreement type Microsoft Partner Agreement. @@ -235,34 +236,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'customerName': self._serialize.url("customer_name", customer_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + billing_account_name=billing_account_name, + customer_name=customer_name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Customer', pipeline_response) @@ -271,4 +261,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}'} # type: ignore + diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_enrollment_accounts_operations.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_enrollment_accounts_operations.py index 6d32fb128cef..cd70abecfbf0 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_enrollment_accounts_operations.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_enrollment_accounts_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._enrollment_accounts_operations import build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,15 +46,18 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.EnrollmentAccountListResult"]: """Lists the enrollment accounts the caller has access to. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EnrollmentAccountListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.EnrollmentAccountListResult] + :return: An iterator like instance of either EnrollmentAccountListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.EnrollmentAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EnrollmentAccountListResult"] @@ -57,30 +65,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('EnrollmentAccountListResult', pipeline_response) + deserialized = self._deserialize("EnrollmentAccountListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -93,21 +98,23 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/providers/Microsoft.Billing/enrollmentAccounts'} # type: ignore + @distributed_trace_async async def get( self, name: str, - **kwargs + **kwargs: Any ) -> "_models.EnrollmentAccountSummary": """Gets a enrollment account by name. @@ -123,31 +130,21 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + name=name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EnrollmentAccountSummary', pipeline_response) @@ -156,4 +153,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/Microsoft.Billing/enrollmentAccounts/{name}'} # type: ignore + diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_instructions_operations.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_instructions_operations.py index f5b457ab7aba..f48c3aa3e21f 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_instructions_operations.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_instructions_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._instructions_operations import build_get_request, build_list_by_billing_profile_request, build_put_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,11 +46,12 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_billing_profile( self, billing_account_name: str, billing_profile_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.InstructionListResult"]: """Lists the instructions by billing profile id. @@ -54,8 +60,10 @@ def list_by_billing_profile( :param billing_profile_name: The ID that uniquely identifies a billing profile. :type billing_profile_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either InstructionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.InstructionListResult] + :return: An iterator like instance of either InstructionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.InstructionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.InstructionListResult"] @@ -63,35 +71,31 @@ def list_by_billing_profile( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_billing_profile.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + template_url=self.list_by_billing_profile.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('InstructionListResult', pipeline_response) + deserialized = self._deserialize("InstructionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -104,23 +108,25 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/instructions'} # type: ignore + @distributed_trace_async async def get( self, billing_account_name: str, billing_profile_name: str, instruction_name: str, - **kwargs + **kwargs: Any ) -> "_models.Instruction": """Get the instruction by name. These are custom billing instructions and are only applicable for certain customers. @@ -141,33 +147,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - 'instructionName': self._serialize.url("instruction_name", instruction_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + instruction_name=instruction_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Instruction', pipeline_response) @@ -176,15 +172,18 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/instructions/{instructionName}'} # type: ignore + + @distributed_trace_async async def put( self, billing_account_name: str, billing_profile_name: str, instruction_name: str, parameters: "_models.Instruction", - **kwargs + **kwargs: Any ) -> "_models.Instruction": """Creates or updates an instruction. These are custom billing instructions and are only applicable for certain customers. @@ -207,38 +206,28 @@ async def put( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - 'instructionName': self._serialize.url("instruction_name", instruction_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Instruction') + + request = build_put_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + instruction_name=instruction_name, + content_type=content_type, + json=_json, + template_url=self.put.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Instruction') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Instruction', pipeline_response) @@ -247,4 +236,6 @@ async def put( return cls(pipeline_response, deserialized, {}) return deserialized + put.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/instructions/{instructionName}'} # type: ignore + diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_invoice_sections_operations.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_invoice_sections_operations.py index ffca6262fe47..4fefe89f6312 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_invoice_sections_operations.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_invoice_sections_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._invoice_sections_operations import build_create_or_update_request_initial, build_get_request, build_list_by_billing_profile_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,11 +48,12 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_billing_profile( self, billing_account_name: str, billing_profile_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.InvoiceSectionListResult"]: """Lists the invoice sections that a user has access to. The operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. @@ -57,8 +63,10 @@ def list_by_billing_profile( :param billing_profile_name: The ID that uniquely identifies a billing profile. :type billing_profile_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either InvoiceSectionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.InvoiceSectionListResult] + :return: An iterator like instance of either InvoiceSectionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.InvoiceSectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.InvoiceSectionListResult"] @@ -66,35 +74,31 @@ def list_by_billing_profile( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_billing_profile.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + template_url=self.list_by_billing_profile.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('InvoiceSectionListResult', pipeline_response) + deserialized = self._deserialize("InvoiceSectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -107,23 +111,25 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections'} # type: ignore + @distributed_trace_async async def get( self, billing_account_name: str, billing_profile_name: str, invoice_section_name: str, - **kwargs + **kwargs: Any ) -> "_models.InvoiceSection": """Gets an invoice section by its ID. The operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. @@ -144,33 +150,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - 'invoiceSectionName': self._serialize.url("invoice_section_name", invoice_section_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('InvoiceSection', pipeline_response) @@ -179,77 +175,72 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}'} # type: ignore + async def _create_or_update_initial( self, billing_account_name: str, billing_profile_name: str, invoice_section_name: str, parameters: "_models.InvoiceSection", - **kwargs + **kwargs: Any ) -> Optional["_models.InvoiceSection"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.InvoiceSection"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - 'invoiceSectionName': self._serialize.url("invoice_section_name", invoice_section_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'InvoiceSection') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request_initial( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'InvoiceSection') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('InvoiceSection', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _create_or_update_initial.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, billing_account_name: str, billing_profile_name: str, invoice_section_name: str, parameters: "_models.InvoiceSection", - **kwargs + **kwargs: Any ) -> AsyncLROPoller["_models.InvoiceSection"]: """Creates or updates an invoice section. The operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. @@ -264,15 +255,19 @@ async def begin_create_or_update( :type parameters: ~azure.mgmt.billing.models.InvoiceSection :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either InvoiceSection or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either InvoiceSection or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.billing.models.InvoiceSection] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.InvoiceSection"] lro_delay = kwargs.pop( 'polling_interval', @@ -285,27 +280,21 @@ async def begin_create_or_update( billing_profile_name=billing_profile_name, invoice_section_name=invoice_section_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('InvoiceSection', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - 'invoiceSectionName': self._serialize.url("invoice_section_name", invoice_section_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -317,4 +306,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}'} # type: ignore diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_invoices_operations.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_invoices_operations.py index ac7fe13b4d95..748a3095a158 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_invoices_operations.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_invoices_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, List, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._invoices_operations import build_download_billing_subscription_invoice_request_initial, build_download_invoice_request_initial, build_download_multiple_billing_profile_invoices_request_initial, build_download_multiple_billing_subscription_invoices_request_initial, build_get_by_id_request, build_get_by_subscription_and_invoice_id_request, build_get_request, build_list_by_billing_account_request, build_list_by_billing_profile_request, build_list_by_billing_subscription_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,12 +48,13 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_billing_account( self, billing_account_name: str, period_start_date: str, period_end_date: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.InvoiceListResult"]: """Lists the invoices for a billing account for a given start date and end date. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft @@ -72,36 +78,33 @@ def list_by_billing_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_billing_account.metadata['url'] # type: ignore - 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 = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - query_parameters['periodStartDate'] = self._serialize.query("period_start_date", period_start_date, 'str') - query_parameters['periodEndDate'] = self._serialize.query("period_end_date", period_end_date, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_account_request( + billing_account_name=billing_account_name, + period_start_date=period_start_date, + period_end_date=period_end_date, + template_url=self.list_by_billing_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_account_request( + billing_account_name=billing_account_name, + period_start_date=period_start_date, + period_end_date=period_end_date, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('InvoiceListResult', pipeline_response) + deserialized = self._deserialize("InvoiceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -114,24 +117,26 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices'} # type: ignore + @distributed_trace def list_by_billing_profile( self, billing_account_name: str, billing_profile_name: str, period_start_date: str, period_end_date: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.InvoiceListResult"]: """Lists the invoices for a billing profile for a given start date and end date. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft @@ -157,37 +162,35 @@ def list_by_billing_profile( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_billing_profile.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - query_parameters['periodStartDate'] = self._serialize.query("period_start_date", period_start_date, 'str') - query_parameters['periodEndDate'] = self._serialize.query("period_end_date", period_end_date, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + period_start_date=period_start_date, + period_end_date=period_end_date, + template_url=self.list_by_billing_profile.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + period_start_date=period_start_date, + period_end_date=period_end_date, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('InvoiceListResult', pipeline_response) + deserialized = self._deserialize("InvoiceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -200,22 +203,24 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoices'} # type: ignore + @distributed_trace_async async def get( self, billing_account_name: str, invoice_name: str, - **kwargs + **kwargs: Any ) -> "_models.Invoice": """Gets an invoice by billing account name and ID. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. @@ -234,32 +239,22 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'invoiceName': self._serialize.url("invoice_name", invoice_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + billing_account_name=billing_account_name, + invoice_name=invoice_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Invoice', pipeline_response) @@ -268,12 +263,15 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/{invoiceName}'} # type: ignore + + @distributed_trace_async async def get_by_id( self, invoice_name: str, - **kwargs + **kwargs: Any ) -> "_models.Invoice": """Gets an invoice by ID. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. @@ -290,31 +288,21 @@ async def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'invoiceName': self._serialize.url("invoice_name", invoice_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + invoice_name=invoice_name, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Invoice', pipeline_response) @@ -323,70 +311,65 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/default/invoices/{invoiceName}'} # type: ignore + async def _download_invoice_initial( self, billing_account_name: str, invoice_name: str, download_token: str, - **kwargs + **kwargs: Any ) -> Optional["_models.DownloadUrl"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DownloadUrl"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self._download_invoice_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'invoiceName': self._serialize.url("invoice_name", invoice_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - query_parameters['downloadToken'] = self._serialize.query("download_token", download_token, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_download_invoice_request_initial( + billing_account_name=billing_account_name, + invoice_name=invoice_name, + download_token=download_token, + template_url=self._download_invoice_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('DownloadUrl', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _download_invoice_initial.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/{invoiceName}/download'} # type: ignore + + @distributed_trace_async async def begin_download_invoice( self, billing_account_name: str, invoice_name: str, download_token: str, - **kwargs + **kwargs: Any ) -> AsyncLROPoller["_models.DownloadUrl"]: """Gets a URL to download an invoice. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. @@ -399,15 +382,18 @@ async def begin_download_invoice( :type download_token: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DownloadUrl or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DownloadUrl or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.billing.models.DownloadUrl] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DownloadUrl"] lro_delay = kwargs.pop( 'polling_interval', @@ -422,23 +408,17 @@ async def begin_download_invoice( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DownloadUrl', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'invoiceName': self._serialize.url("invoice_name", invoice_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -450,71 +430,65 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_download_invoice.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/{invoiceName}/download'} # type: ignore async def _download_multiple_billing_profile_invoices_initial( self, billing_account_name: str, download_urls: List[str], - **kwargs + **kwargs: Any ) -> Optional["_models.DownloadUrl"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DownloadUrl"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._download_multiple_billing_profile_invoices_initial.metadata['url'] # type: ignore - 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 = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(download_urls, '[str]') + + request = build_download_multiple_billing_profile_invoices_request_initial( + billing_account_name=billing_account_name, + content_type=content_type, + json=_json, + template_url=self._download_multiple_billing_profile_invoices_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(download_urls, '[str]') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('DownloadUrl', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _download_multiple_billing_profile_invoices_initial.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/downloadDocuments'} # type: ignore + + @distributed_trace_async async def begin_download_multiple_billing_profile_invoices( self, billing_account_name: str, download_urls: List[str], - **kwargs + **kwargs: Any ) -> AsyncLROPoller["_models.DownloadUrl"]: """Gets a URL to download multiple invoice documents (invoice pdf, tax receipts, credit notes) as a zip file. The operation is supported for billing accounts with agreement type Microsoft @@ -526,15 +500,19 @@ async def begin_download_multiple_billing_profile_invoices( :type download_urls: list[str] :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DownloadUrl or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DownloadUrl or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.billing.models.DownloadUrl] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DownloadUrl"] lro_delay = kwargs.pop( 'polling_interval', @@ -545,25 +523,21 @@ async def begin_download_multiple_billing_profile_invoices( raw_result = await self._download_multiple_billing_profile_invoices_initial( billing_account_name=billing_account_name, download_urls=download_urls, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DownloadUrl', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -575,13 +549,15 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_download_multiple_billing_profile_invoices.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/downloadDocuments'} # type: ignore + @distributed_trace def list_by_billing_subscription( self, period_start_date: str, period_end_date: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.InvoiceListResult"]: """Lists the invoices for a subscription. @@ -599,36 +575,33 @@ def list_by_billing_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_billing_subscription.metadata['url'] # type: ignore - 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 = {} # type: Dict[str, Any] - query_parameters['periodStartDate'] = self._serialize.query("period_start_date", period_start_date, 'str') - query_parameters['periodEndDate'] = self._serialize.query("period_end_date", period_end_date, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_subscription_request( + subscription_id=self._config.subscription_id, + period_start_date=period_start_date, + period_end_date=period_end_date, + template_url=self.list_by_billing_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_subscription_request( + subscription_id=self._config.subscription_id, + period_start_date=period_start_date, + period_end_date=period_end_date, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('InvoiceListResult', pipeline_response) + deserialized = self._deserialize("InvoiceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -641,21 +614,23 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_billing_subscription.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/{subscriptionId}/invoices'} # type: ignore + @distributed_trace_async async def get_by_subscription_and_invoice_id( self, invoice_name: str, - **kwargs + **kwargs: Any ) -> "_models.Invoice": """Gets an invoice by subscription ID and invoice ID. @@ -671,32 +646,22 @@ async def get_by_subscription_and_invoice_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.get_by_subscription_and_invoice_id.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'invoiceName': self._serialize.url("invoice_name", invoice_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_subscription_and_invoice_id_request( + subscription_id=self._config.subscription_id, + invoice_name=invoice_name, + template_url=self.get_by_subscription_and_invoice_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Invoice', pipeline_response) @@ -705,68 +670,63 @@ async def get_by_subscription_and_invoice_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_subscription_and_invoice_id.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/{subscriptionId}/invoices/{invoiceName}'} # type: ignore + async def _download_billing_subscription_invoice_initial( self, invoice_name: str, download_token: str, - **kwargs + **kwargs: Any ) -> Optional["_models.DownloadUrl"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DownloadUrl"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self._download_billing_subscription_invoice_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'invoiceName': self._serialize.url("invoice_name", invoice_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - query_parameters['downloadToken'] = self._serialize.query("download_token", download_token, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_download_billing_subscription_invoice_request_initial( + subscription_id=self._config.subscription_id, + invoice_name=invoice_name, + download_token=download_token, + template_url=self._download_billing_subscription_invoice_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('DownloadUrl', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _download_billing_subscription_invoice_initial.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/{subscriptionId}/invoices/{invoiceName}/download'} # type: ignore + + @distributed_trace_async async def begin_download_billing_subscription_invoice( self, invoice_name: str, download_token: str, - **kwargs + **kwargs: Any ) -> AsyncLROPoller["_models.DownloadUrl"]: """Gets a URL to download an invoice. @@ -776,15 +736,18 @@ async def begin_download_billing_subscription_invoice( :type download_token: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DownloadUrl or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DownloadUrl or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.billing.models.DownloadUrl] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DownloadUrl"] lro_delay = kwargs.pop( 'polling_interval', @@ -798,23 +761,17 @@ async def begin_download_billing_subscription_invoice( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DownloadUrl', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'invoiceName': self._serialize.url("invoice_name", invoice_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -826,69 +783,63 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_download_billing_subscription_invoice.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/{subscriptionId}/invoices/{invoiceName}/download'} # type: ignore async def _download_multiple_billing_subscription_invoices_initial( self, download_urls: List[str], - **kwargs + **kwargs: Any ) -> Optional["_models.DownloadUrl"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DownloadUrl"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._download_multiple_billing_subscription_invoices_initial.metadata['url'] # type: ignore - 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 = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(download_urls, '[str]') + + request = build_download_multiple_billing_subscription_invoices_request_initial( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._download_multiple_billing_subscription_invoices_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(download_urls, '[str]') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('DownloadUrl', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _download_multiple_billing_subscription_invoices_initial.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/{subscriptionId}/downloadDocuments'} # type: ignore + + @distributed_trace_async async def begin_download_multiple_billing_subscription_invoices( self, download_urls: List[str], - **kwargs + **kwargs: Any ) -> AsyncLROPoller["_models.DownloadUrl"]: """Gets a URL to download multiple invoice documents (invoice pdf, tax receipts, credit notes) as a zip file. @@ -897,15 +848,19 @@ async def begin_download_multiple_billing_subscription_invoices( :type download_urls: list[str] :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the AsyncARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either DownloadUrl or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either DownloadUrl or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.billing.models.DownloadUrl] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DownloadUrl"] lro_delay = kwargs.pop( 'polling_interval', @@ -915,25 +870,21 @@ async def begin_download_multiple_billing_subscription_invoices( if cont_token is None: raw_result = await self._download_multiple_billing_subscription_invoices_initial( download_urls=download_urls, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DownloadUrl', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -945,4 +896,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_download_multiple_billing_subscription_invoices.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/{subscriptionId}/downloadDocuments'} # type: ignore diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_operations.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_operations.py index 4ed3179d761e..340c1f4344cc 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_operations.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,9 +46,10 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.OperationListResult"]: """Lists the available billing REST API operations. @@ -57,30 +63,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -93,12 +96,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_policies_operations.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_policies_operations.py index 4a328375a609..66a66e17c313 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_policies_operations.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_policies_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._policies_operations import build_get_by_billing_profile_request, build_get_by_customer_request, build_update_customer_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,11 +44,12 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get_by_billing_profile( self, billing_account_name: str, billing_profile_name: str, - **kwargs + **kwargs: Any ) -> "_models.Policy": """Lists the policies for a billing profile. This operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. @@ -63,32 +68,22 @@ async def get_by_billing_profile( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.get_by_billing_profile.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + template_url=self.get_by_billing_profile.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Policy', pipeline_response) @@ -97,14 +92,17 @@ async def get_by_billing_profile( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/policies/default'} # type: ignore + + @distributed_trace_async async def update( self, billing_account_name: str, billing_profile_name: str, parameters: "_models.Policy", - **kwargs + **kwargs: Any ) -> "_models.Policy": """Updates the policies for a billing profile. This operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. @@ -125,37 +123,27 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Policy') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Policy') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Policy', pipeline_response) @@ -164,13 +152,16 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/policies/default'} # type: ignore + + @distributed_trace_async async def get_by_customer( self, billing_account_name: str, customer_name: str, - **kwargs + **kwargs: Any ) -> "_models.CustomerPolicy": """Lists the policies for a customer. This operation is supported only for billing accounts with agreement type Microsoft Partner Agreement. @@ -189,32 +180,22 @@ async def get_by_customer( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.get_by_customer.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'customerName': self._serialize.url("customer_name", customer_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_customer_request( + billing_account_name=billing_account_name, + customer_name=customer_name, + template_url=self.get_by_customer.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CustomerPolicy', pipeline_response) @@ -223,14 +204,17 @@ async def get_by_customer( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_customer.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/policies/default'} # type: ignore + + @distributed_trace_async async def update_customer( self, billing_account_name: str, customer_name: str, parameters: "_models.CustomerPolicy", - **kwargs + **kwargs: Any ) -> "_models.CustomerPolicy": """Updates the policies for a customer. This operation is supported only for billing accounts with agreement type Microsoft Partner Agreement. @@ -251,37 +235,27 @@ async def update_customer( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_customer.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'customerName': self._serialize.url("customer_name", customer_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'CustomerPolicy') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_customer_request( + billing_account_name=billing_account_name, + customer_name=customer_name, + content_type=content_type, + json=_json, + template_url=self.update_customer.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CustomerPolicy') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CustomerPolicy', pipeline_response) @@ -290,4 +264,6 @@ async def update_customer( return cls(pipeline_response, deserialized, {}) return deserialized + update_customer.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/policies/default'} # type: ignore + diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_products_operations.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_products_operations.py index 1d172ed50a34..ba5009f342fd 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_products_operations.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_products_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._products_operations import build_get_request, build_list_by_billing_account_request, build_list_by_billing_profile_request, build_list_by_customer_request, build_list_by_invoice_section_request, build_move_request, build_update_request, build_validate_move_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,11 +46,12 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_customer( self, billing_account_name: str, customer_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ProductsListResult"]: """Lists the products for a customer. These don't include products billed based on usage.The operation is supported only for billing accounts with agreement type Microsoft Partner @@ -65,35 +71,31 @@ def list_by_customer( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_customer.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'customerName': self._serialize.url("customer_name", customer_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_customer_request( + billing_account_name=billing_account_name, + customer_name=customer_name, + template_url=self.list_by_customer.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_customer_request( + billing_account_name=billing_account_name, + customer_name=customer_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ProductsListResult', pipeline_response) + deserialized = self._deserialize("ProductsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -106,22 +108,24 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_customer.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/products'} # type: ignore + @distributed_trace def list_by_billing_account( self, billing_account_name: str, filter: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ProductsListResult"]: """Lists the products for a billing account. These don't include products billed based on usage. The operation is supported for billing accounts with agreement type Microsoft Customer @@ -143,36 +147,31 @@ def list_by_billing_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_billing_account.metadata['url'] # type: ignore - 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 = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_account_request( + billing_account_name=billing_account_name, + filter=filter, + template_url=self.list_by_billing_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_account_request( + billing_account_name=billing_account_name, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ProductsListResult', pipeline_response) + deserialized = self._deserialize("ProductsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -185,23 +184,25 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/products'} # type: ignore + @distributed_trace def list_by_billing_profile( self, billing_account_name: str, billing_profile_name: str, filter: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ProductsListResult"]: """Lists the products for a billing profile. These don't include products billed based on usage. The operation is supported for billing accounts with agreement type Microsoft Customer @@ -225,37 +226,33 @@ def list_by_billing_profile( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_billing_profile.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + filter=filter, + template_url=self.list_by_billing_profile.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ProductsListResult', pipeline_response) + deserialized = self._deserialize("ProductsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -268,24 +265,26 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/products'} # type: ignore + @distributed_trace def list_by_invoice_section( self, billing_account_name: str, billing_profile_name: str, invoice_section_name: str, filter: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ProductsListResult"]: """Lists the products for an invoice section. These don't include products billed based on usage. The operation is supported only for billing accounts with agreement type Microsoft Customer @@ -311,38 +310,35 @@ def list_by_invoice_section( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_invoice_section.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - 'invoiceSectionName': self._serialize.url("invoice_section_name", invoice_section_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_invoice_section_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + filter=filter, + template_url=self.list_by_invoice_section.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_invoice_section_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ProductsListResult', pipeline_response) + deserialized = self._deserialize("ProductsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -355,22 +351,24 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_invoice_section.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/products'} # type: ignore + @distributed_trace_async async def get( self, billing_account_name: str, product_name: str, - **kwargs + **kwargs: Any ) -> "_models.Product": """Gets a product by ID. The operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. @@ -389,32 +387,22 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'productName': self._serialize.url("product_name", product_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + billing_account_name=billing_account_name, + product_name=product_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Product', pipeline_response) @@ -423,14 +411,17 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/products/{productName}'} # type: ignore + + @distributed_trace_async async def update( self, billing_account_name: str, product_name: str, parameters: "_models.Product", - **kwargs + **kwargs: Any ) -> "_models.Product": """Updates the properties of a Product. Currently, auto renew can be updated. The operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. @@ -451,37 +442,27 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'productName': self._serialize.url("product_name", product_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Product') + + request = build_update_request( + billing_account_name=billing_account_name, + product_name=product_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Product') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Product', pipeline_response) @@ -490,14 +471,17 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/products/{productName}'} # type: ignore + + @distributed_trace_async async def move( self, billing_account_name: str, product_name: str, parameters: "_models.TransferProductRequestProperties", - **kwargs + **kwargs: Any ) -> Optional["_models.Product"]: """Moves a product's charges to a new invoice section. The new invoice section must belong to the same billing profile as the existing invoice section. This operation is supported only for @@ -520,60 +504,54 @@ async def move( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.move.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'productName': self._serialize.url("product_name", product_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'TransferProductRequestProperties') + + request = build_move_request( + billing_account_name=billing_account_name, + product_name=product_name, + content_type=content_type, + json=_json, + template_url=self.move.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TransferProductRequestProperties') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('Product', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + move.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/products/{productName}/move'} # type: ignore + + @distributed_trace_async async def validate_move( self, billing_account_name: str, product_name: str, parameters: "_models.TransferProductRequestProperties", - **kwargs + **kwargs: Any ) -> "_models.ValidateProductTransferEligibilityResult": """Validates if a product's charges can be moved to a new invoice section. This operation is supported only for products that are purchased with a recurring charge and for billing accounts @@ -596,37 +574,27 @@ async def validate_move( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate_move.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'productName': self._serialize.url("product_name", product_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'TransferProductRequestProperties') + + request = build_validate_move_request( + billing_account_name=billing_account_name, + product_name=product_name, + content_type=content_type, + json=_json, + template_url=self.validate_move.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TransferProductRequestProperties') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ValidateProductTransferEligibilityResult', pipeline_response) @@ -635,4 +603,6 @@ async def validate_move( return cls(pipeline_response, deserialized, {}) return deserialized + validate_move.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/products/{productName}/validateMoveEligibility'} # type: ignore + diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_reservations_operations.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_reservations_operations.py index f18d918e8450..6680689c36df 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_reservations_operations.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_reservations_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._reservations_operations import build_list_by_billing_account_request, build_list_by_billing_profile_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_billing_account( self, billing_account_name: str, @@ -48,7 +54,7 @@ def list_by_billing_account( orderby: Optional[str] = None, refresh_summary: Optional[str] = None, selected_state: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ReservationsListResult"]: """Lists the reservations for a billing account and the roll up counts of reservations group by provisioning states. @@ -66,8 +72,10 @@ def list_by_billing_account( :param selected_state: The selected provisioning state. :type selected_state: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReservationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.ReservationsListResult] + :return: An iterator like instance of either ReservationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.ReservationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationsListResult"] @@ -75,42 +83,37 @@ def list_by_billing_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_billing_account.metadata['url'] # type: ignore - 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 = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - if refresh_summary is not None: - query_parameters['refreshSummary'] = self._serialize.query("refresh_summary", refresh_summary, 'str') - if selected_state is not None: - query_parameters['selectedState'] = self._serialize.query("selected_state", selected_state, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_account_request( + billing_account_name=billing_account_name, + filter=filter, + orderby=orderby, + refresh_summary=refresh_summary, + selected_state=selected_state, + template_url=self.list_by_billing_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_account_request( + billing_account_name=billing_account_name, + filter=filter, + orderby=orderby, + refresh_summary=refresh_summary, + selected_state=selected_state, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ReservationsListResult', pipeline_response) + deserialized = self._deserialize("ReservationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -123,17 +126,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/reservations'} # type: ignore + @distributed_trace def list_by_billing_profile( self, billing_account_name: str, @@ -142,7 +147,7 @@ def list_by_billing_profile( orderby: Optional[str] = None, refresh_summary: Optional[str] = None, selected_state: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ReservationsListResult"]: """Lists the reservations for a billing profile and the roll up counts of reservations group by provisioning state. @@ -162,8 +167,10 @@ def list_by_billing_profile( :param selected_state: The selected provisioning state. :type selected_state: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReservationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.ReservationsListResult] + :return: An iterator like instance of either ReservationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.ReservationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationsListResult"] @@ -171,43 +178,39 @@ def list_by_billing_profile( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_billing_profile.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - if refresh_summary is not None: - query_parameters['refreshSummary'] = self._serialize.query("refresh_summary", refresh_summary, 'str') - if selected_state is not None: - query_parameters['selectedState'] = self._serialize.query("selected_state", selected_state, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + filter=filter, + orderby=orderby, + refresh_summary=refresh_summary, + selected_state=selected_state, + template_url=self.list_by_billing_profile.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + filter=filter, + orderby=orderby, + refresh_summary=refresh_summary, + selected_state=selected_state, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ReservationsListResult', pipeline_response) + deserialized = self._deserialize("ReservationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -220,12 +223,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_transactions_operations.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_transactions_operations.py index 0d7a9a582c6d..0dcf0a3b8e69 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_transactions_operations.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/aio/operations/_transactions_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._transactions_operations import build_list_by_invoice_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,11 +46,12 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_invoice( self, billing_account_name: str, invoice_name: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.TransactionListResult"]: """Lists the transactions for an invoice. Transactions include purchases, refunds and Azure usage charges. @@ -55,8 +61,10 @@ def list_by_invoice( :param invoice_name: The ID that uniquely identifies an invoice. :type invoice_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TransactionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.TransactionListResult] + :return: An iterator like instance of either TransactionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.billing.models.TransactionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.TransactionListResult"] @@ -64,35 +72,31 @@ def list_by_invoice( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_invoice.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'invoiceName': self._serialize.url("invoice_name", invoice_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_invoice_request( + billing_account_name=billing_account_name, + invoice_name=invoice_name, + template_url=self.list_by_invoice.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_invoice_request( + billing_account_name=billing_account_name, + invoice_name=invoice_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('TransactionListResult', pipeline_response) + deserialized = self._deserialize("TransactionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -105,12 +109,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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 6f8996b88ee9..dcf2b5db0fb3 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 @@ -6,160 +6,84 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import AddressDetails - from ._models_py3 import Agreement - from ._models_py3 import AgreementListResult - from ._models_py3 import Amount - from ._models_py3 import AvailableBalance - from ._models_py3 import AzurePlan - from ._models_py3 import BillingAccount - from ._models_py3 import BillingAccountListResult - from ._models_py3 import BillingAccountUpdateRequest - from ._models_py3 import BillingPeriod - from ._models_py3 import BillingPeriodsListResult - from ._models_py3 import BillingPermissionsListResult - from ._models_py3 import BillingPermissionsProperties - from ._models_py3 import BillingProfile - from ._models_py3 import BillingProfileCreationRequest - from ._models_py3 import BillingProfileListResult - from ._models_py3 import BillingProfilesOnExpand - from ._models_py3 import BillingProperty - from ._models_py3 import BillingRoleAssignment - from ._models_py3 import BillingRoleAssignmentListResult - from ._models_py3 import BillingRoleDefinition - from ._models_py3 import BillingRoleDefinitionListResult - from ._models_py3 import BillingSubscription - from ._models_py3 import BillingSubscriptionsListResult - from ._models_py3 import Customer - from ._models_py3 import CustomerListResult - from ._models_py3 import CustomerPolicy - from ._models_py3 import Department - from ._models_py3 import Document - from ._models_py3 import DownloadUrl - from ._models_py3 import Enrollment - from ._models_py3 import EnrollmentAccount - from ._models_py3 import EnrollmentAccountContext - from ._models_py3 import EnrollmentAccountListResult - from ._models_py3 import EnrollmentAccountSummary - from ._models_py3 import EnrollmentPolicies - from ._models_py3 import ErrorDetails - from ._models_py3 import ErrorResponse - from ._models_py3 import ErrorSubDetailsItem - from ._models_py3 import IndirectRelationshipInfo - from ._models_py3 import Instruction - from ._models_py3 import InstructionListResult - from ._models_py3 import Invoice - from ._models_py3 import InvoiceListResult - from ._models_py3 import InvoiceSection - from ._models_py3 import InvoiceSectionCreationRequest - from ._models_py3 import InvoiceSectionListResult - from ._models_py3 import InvoiceSectionListWithCreateSubPermissionResult - from ._models_py3 import InvoiceSectionWithCreateSubPermission - from ._models_py3 import InvoiceSectionsOnExpand - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationListResult - from ._models_py3 import Participants - from ._models_py3 import PaymentProperties - from ._models_py3 import Policy - from ._models_py3 import Product - from ._models_py3 import ProductsListResult - from ._models_py3 import RebillDetails - from ._models_py3 import Reseller - from ._models_py3 import Reservation - from ._models_py3 import ReservationPropertyUtilization - from ._models_py3 import ReservationSkuProperty - from ._models_py3 import ReservationSummary - from ._models_py3 import ReservationUtilizationAggregates - from ._models_py3 import ReservationsListResult - from ._models_py3 import Resource - from ._models_py3 import Transaction - from ._models_py3 import TransactionListResult - from ._models_py3 import TransferBillingSubscriptionRequestProperties - from ._models_py3 import TransferProductRequestProperties - from ._models_py3 import ValidateAddressResponse - from ._models_py3 import ValidateProductTransferEligibilityError - from ._models_py3 import ValidateProductTransferEligibilityResult - from ._models_py3 import ValidateSubscriptionTransferEligibilityError - from ._models_py3 import ValidateSubscriptionTransferEligibilityResult -except (SyntaxError, ImportError): - from ._models import AddressDetails # type: ignore - from ._models import Agreement # type: ignore - from ._models import AgreementListResult # type: ignore - from ._models import Amount # type: ignore - from ._models import AvailableBalance # type: ignore - from ._models import AzurePlan # type: ignore - from ._models import BillingAccount # type: ignore - from ._models import BillingAccountListResult # type: ignore - from ._models import BillingAccountUpdateRequest # type: ignore - from ._models import BillingPeriod # type: ignore - from ._models import BillingPeriodsListResult # type: ignore - from ._models import BillingPermissionsListResult # type: ignore - from ._models import BillingPermissionsProperties # type: ignore - from ._models import BillingProfile # type: ignore - from ._models import BillingProfileCreationRequest # type: ignore - from ._models import BillingProfileListResult # type: ignore - from ._models import BillingProfilesOnExpand # type: ignore - from ._models import BillingProperty # type: ignore - from ._models import BillingRoleAssignment # type: ignore - from ._models import BillingRoleAssignmentListResult # type: ignore - from ._models import BillingRoleDefinition # type: ignore - from ._models import BillingRoleDefinitionListResult # type: ignore - from ._models import BillingSubscription # type: ignore - from ._models import BillingSubscriptionsListResult # type: ignore - from ._models import Customer # type: ignore - from ._models import CustomerListResult # type: ignore - from ._models import CustomerPolicy # type: ignore - from ._models import Department # type: ignore - from ._models import Document # type: ignore - from ._models import DownloadUrl # type: ignore - from ._models import Enrollment # type: ignore - from ._models import EnrollmentAccount # type: ignore - from ._models import EnrollmentAccountContext # type: ignore - from ._models import EnrollmentAccountListResult # type: ignore - from ._models import EnrollmentAccountSummary # type: ignore - from ._models import EnrollmentPolicies # type: ignore - from ._models import ErrorDetails # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import ErrorSubDetailsItem # type: ignore - from ._models import IndirectRelationshipInfo # type: ignore - from ._models import Instruction # type: ignore - from ._models import InstructionListResult # type: ignore - from ._models import Invoice # type: ignore - from ._models import InvoiceListResult # type: ignore - from ._models import InvoiceSection # type: ignore - from ._models import InvoiceSectionCreationRequest # type: ignore - from ._models import InvoiceSectionListResult # type: ignore - from ._models import InvoiceSectionListWithCreateSubPermissionResult # type: ignore - from ._models import InvoiceSectionWithCreateSubPermission # type: ignore - from ._models import InvoiceSectionsOnExpand # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationListResult # type: ignore - from ._models import Participants # type: ignore - from ._models import PaymentProperties # type: ignore - from ._models import Policy # type: ignore - from ._models import Product # type: ignore - from ._models import ProductsListResult # type: ignore - from ._models import RebillDetails # type: ignore - from ._models import Reseller # type: ignore - from ._models import Reservation # type: ignore - from ._models import ReservationPropertyUtilization # type: ignore - from ._models import ReservationSkuProperty # type: ignore - from ._models import ReservationSummary # type: ignore - from ._models import ReservationUtilizationAggregates # type: ignore - from ._models import ReservationsListResult # type: ignore - from ._models import Resource # type: ignore - from ._models import Transaction # type: ignore - from ._models import TransactionListResult # type: ignore - from ._models import TransferBillingSubscriptionRequestProperties # type: ignore - from ._models import TransferProductRequestProperties # type: ignore - from ._models import ValidateAddressResponse # type: ignore - from ._models import ValidateProductTransferEligibilityError # type: ignore - from ._models import ValidateProductTransferEligibilityResult # type: ignore - from ._models import ValidateSubscriptionTransferEligibilityError # type: ignore - from ._models import ValidateSubscriptionTransferEligibilityResult # type: ignore +from ._models_py3 import AddressDetails +from ._models_py3 import Agreement +from ._models_py3 import AgreementListResult +from ._models_py3 import Amount +from ._models_py3 import AvailableBalance +from ._models_py3 import AzurePlan +from ._models_py3 import BillingAccount +from ._models_py3 import BillingAccountListResult +from ._models_py3 import BillingAccountUpdateRequest +from ._models_py3 import BillingPeriod +from ._models_py3 import BillingPeriodsListResult +from ._models_py3 import BillingPermissionsListResult +from ._models_py3 import BillingPermissionsProperties +from ._models_py3 import BillingProfile +from ._models_py3 import BillingProfileCreationRequest +from ._models_py3 import BillingProfileInfo +from ._models_py3 import BillingProfileListResult +from ._models_py3 import BillingProfilesOnExpand +from ._models_py3 import BillingProperty +from ._models_py3 import BillingRoleAssignment +from ._models_py3 import BillingRoleAssignmentListResult +from ._models_py3 import BillingRoleDefinition +from ._models_py3 import BillingRoleDefinitionListResult +from ._models_py3 import BillingSubscription +from ._models_py3 import BillingSubscriptionsListResult +from ._models_py3 import Customer +from ._models_py3 import CustomerListResult +from ._models_py3 import CustomerPolicy +from ._models_py3 import Department +from ._models_py3 import Document +from ._models_py3 import DownloadUrl +from ._models_py3 import Enrollment +from ._models_py3 import EnrollmentAccount +from ._models_py3 import EnrollmentAccountContext +from ._models_py3 import EnrollmentAccountListResult +from ._models_py3 import EnrollmentAccountSummary +from ._models_py3 import EnrollmentPolicies +from ._models_py3 import ErrorDetails +from ._models_py3 import ErrorResponse +from ._models_py3 import ErrorSubDetailsItem +from ._models_py3 import IndirectRelationshipInfo +from ._models_py3 import Instruction +from ._models_py3 import InstructionListResult +from ._models_py3 import Invoice +from ._models_py3 import InvoiceListResult +from ._models_py3 import InvoiceSection +from ._models_py3 import InvoiceSectionCreationRequest +from ._models_py3 import InvoiceSectionListResult +from ._models_py3 import InvoiceSectionListWithCreateSubPermissionResult +from ._models_py3 import InvoiceSectionWithCreateSubPermission +from ._models_py3 import InvoiceSectionsOnExpand +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult +from ._models_py3 import Participants +from ._models_py3 import PaymentProperties +from ._models_py3 import Policy +from ._models_py3 import Product +from ._models_py3 import ProductsListResult +from ._models_py3 import RebillDetails +from ._models_py3 import Reseller +from ._models_py3 import Reservation +from ._models_py3 import ReservationPropertyUtilization +from ._models_py3 import ReservationSkuProperty +from ._models_py3 import ReservationSummary +from ._models_py3 import ReservationUtilizationAggregates +from ._models_py3 import ReservationsListResult +from ._models_py3 import Resource +from ._models_py3 import Transaction +from ._models_py3 import TransactionListResult +from ._models_py3 import TransferBillingSubscriptionRequestProperties +from ._models_py3 import TransferProductRequestProperties +from ._models_py3 import ValidateAddressResponse +from ._models_py3 import ValidateProductTransferEligibilityError +from ._models_py3 import ValidateProductTransferEligibilityResult +from ._models_py3 import ValidateSubscriptionTransferEligibilityError +from ._models_py3 import ValidateSubscriptionTransferEligibilityResult + from ._billing_management_client_enums import ( AcceptanceMode, @@ -214,6 +138,7 @@ 'BillingPermissionsProperties', 'BillingProfile', 'BillingProfileCreationRequest', + 'BillingProfileInfo', 'BillingProfileListResult', 'BillingProfilesOnExpand', 'BillingProperty', 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 336add87266a..a0620bb6dc32 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 @@ -6,27 +6,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class AcceptanceMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AcceptanceMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The mode of acceptance for an agreement. """ @@ -34,7 +19,7 @@ class AcceptanceMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): E_SIGN_EMBEDDED = "ESignEmbedded" E_SIGN_OFFLINE = "ESignOffline" -class AccountStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccountStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The current status of the billing account. """ @@ -46,7 +31,7 @@ class AccountStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): EXTENDED = "Extended" TERMINATED = "Terminated" -class AccountType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccountType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of customer. """ @@ -54,14 +39,14 @@ class AccountType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): INDIVIDUAL = "Individual" PARTNER = "Partner" -class AddressValidationStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AddressValidationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Status of the address validation. """ VALID = "Valid" INVALID = "Invalid" -class AgreementType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AgreementType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of agreement. """ @@ -70,14 +55,14 @@ class AgreementType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MICROSOFT_ONLINE_SERVICES_PROGRAM = "MicrosoftOnlineServicesProgram" MICROSOFT_PARTNER_AGREEMENT = "MicrosoftPartnerAgreement" -class AutoRenew(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AutoRenew(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Indicates whether auto renewal is turned on or off for a product. """ OFF = "Off" ON = "On" -class BillingFrequency(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class BillingFrequency(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The frequency at which the product will be billed. """ @@ -85,14 +70,14 @@ class BillingFrequency(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MONTHLY = "Monthly" USAGE_BASED = "UsageBased" -class BillingProfileSpendingLimit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class BillingProfileSpendingLimit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The billing profile spending limit. """ OFF = "Off" ON = "On" -class BillingProfileStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class BillingProfileStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The status of the billing profile. """ @@ -100,7 +85,7 @@ class BillingProfileStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DISABLED = "Disabled" WARNED = "Warned" -class BillingProfileStatusReasonCode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class BillingProfileStatusReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Reason for the specified billing profile status. """ @@ -108,7 +93,7 @@ class BillingProfileStatusReasonCode(with_metaclass(_CaseInsensitiveEnumMeta, st SPENDING_LIMIT_REACHED = "SpendingLimitReached" SPENDING_LIMIT_EXPIRED = "SpendingLimitExpired" -class BillingRelationshipType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class BillingRelationshipType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Identifies which services and purchases are paid by a billing profile. """ @@ -117,7 +102,7 @@ class BillingRelationshipType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum INDIRECT_PARTNER = "IndirectPartner" CSP_PARTNER = "CSPPartner" -class BillingSubscriptionStatusType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class BillingSubscriptionStatusType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The current billing status of the subscription. """ @@ -127,7 +112,7 @@ class BillingSubscriptionStatusType(with_metaclass(_CaseInsensitiveEnumMeta, str DELETED = "Deleted" WARNING = "Warning" -class Category(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Category(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The category of the agreement signed by a customer. """ @@ -135,14 +120,14 @@ class Category(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): AFFILIATE_PURCHASE_TERMS = "AffiliatePurchaseTerms" OTHER = "Other" -class DocumentSource(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DocumentSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The source of the document. ENF for Brazil and DRS for rest of the world. """ DRS = "DRS" ENF = "ENF" -class DocumentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DocumentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the document. """ @@ -151,21 +136,21 @@ class DocumentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): TAX_RECEIPT = "TaxReceipt" CREDIT_NOTE = "CreditNote" -class InvoiceDocumentType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class InvoiceDocumentType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the document. """ INVOICE = "Invoice" CREDIT_NOTE = "CreditNote" -class InvoiceSectionState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class InvoiceSectionState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Identifies the state of an invoice section. """ ACTIVE = "Active" RESTRICTED = "Restricted" -class InvoiceStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class InvoiceStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The current status of the invoice. """ @@ -174,7 +159,7 @@ class InvoiceStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PAID = "Paid" VOID = "Void" -class InvoiceType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class InvoiceType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Invoice type. """ @@ -182,7 +167,7 @@ class InvoiceType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): AZURE_MARKETPLACE = "AzureMarketplace" AZURE_SUPPORT = "AzureSupport" -class MarketplacePurchasesPolicy(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class MarketplacePurchasesPolicy(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The policy that controls whether Azure marketplace purchases are allowed for a billing profile. """ @@ -190,7 +175,7 @@ class MarketplacePurchasesPolicy(with_metaclass(_CaseInsensitiveEnumMeta, str, E ONLY_FREE_ALLOWED = "OnlyFreeAllowed" NOT_ALLOWED = "NotAllowed" -class PaymentMethodFamily(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PaymentMethodFamily(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The family of payment method. """ @@ -199,7 +184,7 @@ class PaymentMethodFamily(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): CREDIT_CARD = "CreditCard" NONE = "None" -class ProductStatusType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ProductStatusType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The current status of the product. """ @@ -212,7 +197,7 @@ class ProductStatusType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): CANCELLED = "Cancelled" AUTO_RENEW = "AutoRenew" -class ProductTransferValidationErrorCode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ProductTransferValidationErrorCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Error code of the transfer validation response. """ @@ -226,35 +211,35 @@ class ProductTransferValidationErrorCode(with_metaclass(_CaseInsensitiveEnumMeta NOT_AVAILABLE_FOR_DESTINATION_MARKET = "NotAvailableForDestinationMarket" ONE_TIME_PURCHASE_PRODUCT_TRANSFER_NOT_ALLOWED = "OneTimePurchaseProductTransferNotAllowed" -class ReservationPurchasesPolicy(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ReservationPurchasesPolicy(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The policy that controls whether Azure reservation purchases are allowed for a billing profile. """ ALLOWED = "Allowed" NOT_ALLOWED = "NotAllowed" -class ReservationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ReservationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of transaction. """ PURCHASE = "Purchase" USAGE_CHARGE = "Usage Charge" -class SpendingLimit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SpendingLimit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The billing profile spending limit. """ OFF = "Off" ON = "On" -class SpendingLimitForBillingProfile(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SpendingLimitForBillingProfile(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The billing profile spending limit. """ OFF = "Off" ON = "On" -class StatusReasonCode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class StatusReasonCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Reason for the specified billing profile status. """ @@ -262,7 +247,7 @@ class StatusReasonCode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SPENDING_LIMIT_REACHED = "SpendingLimitReached" SPENDING_LIMIT_EXPIRED = "SpendingLimitExpired" -class StatusReasonCodeForBillingProfile(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class StatusReasonCodeForBillingProfile(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Reason for the specified billing profile status. """ @@ -270,7 +255,7 @@ class StatusReasonCodeForBillingProfile(with_metaclass(_CaseInsensitiveEnumMeta, SPENDING_LIMIT_REACHED = "SpendingLimitReached" SPENDING_LIMIT_EXPIRED = "SpendingLimitExpired" -class SubscriptionTransferValidationErrorCode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SubscriptionTransferValidationErrorCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Error code of the transfer validation response. """ @@ -295,7 +280,7 @@ class SubscriptionTransferValidationErrorCode(with_metaclass(_CaseInsensitiveEnu SUBSCRIPTION_NOT_ACTIVE = "SubscriptionNotActive" SUBSCRIPTION_TYPE_NOT_SUPPORTED = "SubscriptionTypeNotSupported" -class TargetCloud(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class TargetCloud(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Possible cloud environments. """ @@ -303,14 +288,14 @@ class TargetCloud(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): US_NAT = "USNat" US_SEC = "USSec" -class TransactionTypeKind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class TransactionTypeKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The kind of transaction. Options are all or reservation. """ ALL = "all" RESERVATION = "reservation" -class ViewCharges(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ViewCharges(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The policy that controls whether the users in customer's organization can view charges at pay-as-you-go prices. """ @@ -318,7 +303,7 @@ class ViewCharges(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): ALLOWED = "Allowed" NOT_ALLOWED = "NotAllowed" -class ViewChargesPolicy(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ViewChargesPolicy(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The policy that controls whether users with Azure RBAC access to a subscription can view its charges. """ diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/models/_models.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/models/_models.py deleted file mode 100644 index 993bca9cbfaa..000000000000 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/models/_models.py +++ /dev/null @@ -1,3722 +0,0 @@ -# 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 azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class AddressDetails(msrest.serialization.Model): - """Address details. - - All required parameters must be populated in order to send to Azure. - - :param first_name: First name. - :type first_name: str - :param middle_name: Middle name. - :type middle_name: str - :param last_name: Last name. - :type last_name: str - :param company_name: Company name. - :type company_name: str - :param address_line1: Required. Address line 1. - :type address_line1: str - :param address_line2: Address line 2. - :type address_line2: str - :param address_line3: Address line 3. - :type address_line3: str - :param city: Address city. - :type city: str - :param district: Address district. - :type district: str - :param region: Address region. - :type region: str - :param country: Required. Country code uses ISO2, 2-digit format. - :type country: str - :param postal_code: Postal code. - :type postal_code: str - :param email: Email address. - :type email: str - :param phone_number: Phone number. - :type phone_number: str - """ - - _validation = { - 'address_line1': {'required': True}, - 'country': {'required': True}, - } - - _attribute_map = { - 'first_name': {'key': 'firstName', 'type': 'str'}, - 'middle_name': {'key': 'middleName', 'type': 'str'}, - 'last_name': {'key': 'lastName', 'type': 'str'}, - 'company_name': {'key': 'companyName', 'type': 'str'}, - 'address_line1': {'key': 'addressLine1', 'type': 'str'}, - 'address_line2': {'key': 'addressLine2', 'type': 'str'}, - 'address_line3': {'key': 'addressLine3', 'type': 'str'}, - 'city': {'key': 'city', 'type': 'str'}, - 'district': {'key': 'district', 'type': 'str'}, - 'region': {'key': 'region', 'type': 'str'}, - 'country': {'key': 'country', 'type': 'str'}, - 'postal_code': {'key': 'postalCode', 'type': 'str'}, - 'email': {'key': 'email', 'type': 'str'}, - 'phone_number': {'key': 'phoneNumber', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AddressDetails, self).__init__(**kwargs) - self.first_name = kwargs.get('first_name', None) - self.middle_name = kwargs.get('middle_name', None) - self.last_name = kwargs.get('last_name', None) - self.company_name = kwargs.get('company_name', None) - self.address_line1 = kwargs['address_line1'] - self.address_line2 = kwargs.get('address_line2', None) - self.address_line3 = kwargs.get('address_line3', None) - self.city = kwargs.get('city', None) - self.district = kwargs.get('district', None) - self.region = kwargs.get('region', None) - self.country = kwargs['country'] - self.postal_code = kwargs.get('postal_code', None) - self.email = kwargs.get('email', None) - self.phone_number = kwargs.get('phone_number', None) - - -class Resource(msrest.serialization.Model): - """The Resource model definition. - - 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 - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class Agreement(Resource): - """An agreement. - - 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 agreement_link: The URL to download the agreement. - :vartype agreement_link: str - :ivar category: The category of the agreement signed by a customer. Possible values include: - "MicrosoftCustomerAgreement", "AffiliatePurchaseTerms", "Other". - :vartype category: str or ~azure.mgmt.billing.models.Category - :ivar acceptance_mode: The mode of acceptance for an agreement. Possible values include: - "ClickToAccept", "ESignEmbedded", "ESignOffline". - :vartype acceptance_mode: str or ~azure.mgmt.billing.models.AcceptanceMode - :ivar effective_date: The date from which the agreement is effective. - :vartype effective_date: ~datetime.datetime - :ivar expiration_date: The date when the agreement expires. - :vartype expiration_date: ~datetime.datetime - :param participants: The list of participants that participates in acceptance of an agreement. - :type participants: list[~azure.mgmt.billing.models.Participants] - :ivar status: The current status of the agreement. - :vartype status: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'agreement_link': {'readonly': True}, - 'category': {'readonly': True}, - 'acceptance_mode': {'readonly': True}, - 'effective_date': {'readonly': True}, - 'expiration_date': {'readonly': True}, - 'status': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'agreement_link': {'key': 'properties.agreementLink', 'type': 'str'}, - 'category': {'key': 'properties.category', 'type': 'str'}, - 'acceptance_mode': {'key': 'properties.acceptanceMode', 'type': 'str'}, - 'effective_date': {'key': 'properties.effectiveDate', 'type': 'iso-8601'}, - 'expiration_date': {'key': 'properties.expirationDate', 'type': 'iso-8601'}, - 'participants': {'key': 'properties.participants', 'type': '[Participants]'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Agreement, self).__init__(**kwargs) - self.agreement_link = None - self.category = None - self.acceptance_mode = None - self.effective_date = None - self.expiration_date = None - self.participants = kwargs.get('participants', None) - self.status = None - - -class AgreementListResult(msrest.serialization.Model): - """Result of listing agreements. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of agreements. - :vartype value: list[~azure.mgmt.billing.models.Agreement] - :ivar next_link: The link (url) to the next page of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Agreement]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AgreementListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class Amount(msrest.serialization.Model): - """The amount. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar currency: The currency for the amount value. - :vartype currency: str - :param value: Amount value. - :type value: float - """ - - _validation = { - 'currency': {'readonly': True}, - } - - _attribute_map = { - 'currency': {'key': 'currency', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - super(Amount, self).__init__(**kwargs) - self.currency = None - self.value = kwargs.get('value', None) - - -class AvailableBalance(Resource): - """The latest Azure credit balance. This is the balance available for pay now. - - 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 amount: Balance amount. - :vartype amount: ~azure.mgmt.billing.models.Amount - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'amount': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'amount': {'key': 'properties.amount', 'type': 'Amount'}, - } - - def __init__( - self, - **kwargs - ): - super(AvailableBalance, self).__init__(**kwargs) - self.amount = None - - -class AzurePlan(msrest.serialization.Model): - """Details of the Azure plan. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param sku_id: The sku id. - :type sku_id: str - :ivar sku_description: The sku description. - :vartype sku_description: str - """ - - _validation = { - 'sku_description': {'readonly': True}, - } - - _attribute_map = { - 'sku_id': {'key': 'skuId', 'type': 'str'}, - 'sku_description': {'key': 'skuDescription', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AzurePlan, self).__init__(**kwargs) - self.sku_id = kwargs.get('sku_id', None) - self.sku_description = None - - -class BillingAccount(Resource): - """A billing account. - - 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 - :param display_name: The billing account name. - :type display_name: str - :param sold_to: The address of the individual or organization that is responsible for the - billing account. - :type sold_to: ~azure.mgmt.billing.models.AddressDetails - :ivar agreement_type: The type of agreement. Possible values include: - "MicrosoftCustomerAgreement", "EnterpriseAgreement", "MicrosoftOnlineServicesProgram", - "MicrosoftPartnerAgreement". - :vartype agreement_type: str or ~azure.mgmt.billing.models.AgreementType - :ivar account_type: The type of customer. Possible values include: "Enterprise", "Individual", - "Partner". - :vartype account_type: str or ~azure.mgmt.billing.models.AccountType - :ivar account_status: The current status of the billing account. Possible values include: - "Active", "Deleted", "Disabled", "Expired", "Transferred", "Extended", "Terminated". - :vartype account_status: str or ~azure.mgmt.billing.models.AccountStatus - :param billing_profiles: The billing profiles associated with the billing account. By default - this is not populated, unless it's specified in $expand. - :type billing_profiles: ~azure.mgmt.billing.models.BillingProfilesOnExpand - :ivar enrollment_details: The details about the associated legacy enrollment. By default this - is not populated, unless it's specified in $expand. - :vartype enrollment_details: ~azure.mgmt.billing.models.Enrollment - :param departments: The departments associated to the enrollment. - :type departments: list[~azure.mgmt.billing.models.Department] - :param enrollment_accounts: The accounts associated to the enrollment. - :type enrollment_accounts: list[~azure.mgmt.billing.models.EnrollmentAccount] - :ivar has_read_access: Indicates whether user has read access to the billing account. - :vartype has_read_access: bool - :param notification_email_address: Notification email address, only for legacy accounts. - :type notification_email_address: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'agreement_type': {'readonly': True}, - 'account_type': {'readonly': True}, - 'account_status': {'readonly': True}, - 'enrollment_details': {'readonly': True}, - 'has_read_access': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'sold_to': {'key': 'properties.soldTo', 'type': 'AddressDetails'}, - 'agreement_type': {'key': 'properties.agreementType', 'type': 'str'}, - 'account_type': {'key': 'properties.accountType', 'type': 'str'}, - 'account_status': {'key': 'properties.accountStatus', 'type': 'str'}, - 'billing_profiles': {'key': 'properties.billingProfiles', 'type': 'BillingProfilesOnExpand'}, - 'enrollment_details': {'key': 'properties.enrollmentDetails', 'type': 'Enrollment'}, - 'departments': {'key': 'properties.departments', 'type': '[Department]'}, - 'enrollment_accounts': {'key': 'properties.enrollmentAccounts', 'type': '[EnrollmentAccount]'}, - 'has_read_access': {'key': 'properties.hasReadAccess', 'type': 'bool'}, - 'notification_email_address': {'key': 'properties.notificationEmailAddress', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(BillingAccount, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) - self.sold_to = kwargs.get('sold_to', None) - self.agreement_type = None - self.account_type = None - self.account_status = None - self.billing_profiles = kwargs.get('billing_profiles', None) - self.enrollment_details = None - self.departments = kwargs.get('departments', None) - self.enrollment_accounts = kwargs.get('enrollment_accounts', None) - self.has_read_access = None - self.notification_email_address = kwargs.get('notification_email_address', None) - - -class BillingAccountListResult(msrest.serialization.Model): - """The list of billing accounts. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of billing accounts. - :vartype value: list[~azure.mgmt.billing.models.BillingAccount] - :ivar next_link: The link (url) to the next page of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[BillingAccount]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(BillingAccountListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class BillingAccountUpdateRequest(msrest.serialization.Model): - """The request properties of the billing account that can be updated. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param display_name: The billing account name. - :type display_name: str - :param sold_to: The address of the individual or organization that is responsible for the - billing account. - :type sold_to: ~azure.mgmt.billing.models.AddressDetails - :ivar agreement_type: The type of agreement. Possible values include: - "MicrosoftCustomerAgreement", "EnterpriseAgreement", "MicrosoftOnlineServicesProgram", - "MicrosoftPartnerAgreement". - :vartype agreement_type: str or ~azure.mgmt.billing.models.AgreementType - :ivar account_type: The type of customer. Possible values include: "Enterprise", "Individual", - "Partner". - :vartype account_type: str or ~azure.mgmt.billing.models.AccountType - :ivar account_status: The current status of the billing account. Possible values include: - "Active", "Deleted", "Disabled", "Expired", "Transferred", "Extended", "Terminated". - :vartype account_status: str or ~azure.mgmt.billing.models.AccountStatus - :param billing_profiles: The billing profiles associated with the billing account. By default - this is not populated, unless it's specified in $expand. - :type billing_profiles: ~azure.mgmt.billing.models.BillingProfilesOnExpand - :ivar enrollment_details: The details about the associated legacy enrollment. By default this - is not populated, unless it's specified in $expand. - :vartype enrollment_details: ~azure.mgmt.billing.models.Enrollment - :param departments: The departments associated to the enrollment. - :type departments: list[~azure.mgmt.billing.models.Department] - :param enrollment_accounts: The accounts associated to the enrollment. - :type enrollment_accounts: list[~azure.mgmt.billing.models.EnrollmentAccount] - :ivar has_read_access: Indicates whether user has read access to the billing account. - :vartype has_read_access: bool - :param notification_email_address: Notification email address, only for legacy accounts. - :type notification_email_address: str - """ - - _validation = { - 'agreement_type': {'readonly': True}, - 'account_type': {'readonly': True}, - 'account_status': {'readonly': True}, - 'enrollment_details': {'readonly': True}, - 'has_read_access': {'readonly': True}, - } - - _attribute_map = { - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'sold_to': {'key': 'properties.soldTo', 'type': 'AddressDetails'}, - 'agreement_type': {'key': 'properties.agreementType', 'type': 'str'}, - 'account_type': {'key': 'properties.accountType', 'type': 'str'}, - 'account_status': {'key': 'properties.accountStatus', 'type': 'str'}, - 'billing_profiles': {'key': 'properties.billingProfiles', 'type': 'BillingProfilesOnExpand'}, - 'enrollment_details': {'key': 'properties.enrollmentDetails', 'type': 'Enrollment'}, - 'departments': {'key': 'properties.departments', 'type': '[Department]'}, - 'enrollment_accounts': {'key': 'properties.enrollmentAccounts', 'type': '[EnrollmentAccount]'}, - 'has_read_access': {'key': 'properties.hasReadAccess', 'type': 'bool'}, - 'notification_email_address': {'key': 'properties.notificationEmailAddress', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(BillingAccountUpdateRequest, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) - self.sold_to = kwargs.get('sold_to', None) - self.agreement_type = None - self.account_type = None - self.account_status = None - self.billing_profiles = kwargs.get('billing_profiles', None) - self.enrollment_details = None - self.departments = kwargs.get('departments', None) - self.enrollment_accounts = kwargs.get('enrollment_accounts', None) - self.has_read_access = None - self.notification_email_address = kwargs.get('notification_email_address', None) - - -class BillingPeriod(Resource): - """A billing period 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 billing_period_start_date: The start of the date range covered by the billing period. - :vartype billing_period_start_date: ~datetime.date - :ivar billing_period_end_date: The end of the date range covered by the billing period. - :vartype billing_period_end_date: ~datetime.date - :ivar invoice_ids: Array of invoice ids that associated with. - :vartype invoice_ids: list[str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'billing_period_start_date': {'readonly': True}, - 'billing_period_end_date': {'readonly': True}, - 'invoice_ids': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'billing_period_start_date': {'key': 'properties.billingPeriodStartDate', 'type': 'date'}, - 'billing_period_end_date': {'key': 'properties.billingPeriodEndDate', 'type': 'date'}, - 'invoice_ids': {'key': 'properties.invoiceIds', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(BillingPeriod, self).__init__(**kwargs) - self.billing_period_start_date = None - self.billing_period_end_date = None - self.invoice_ids = None - - -class BillingPeriodsListResult(msrest.serialization.Model): - """Result of listing billing periods. It contains a list of available billing periods in reverse chronological order. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of billing periods. - :vartype value: list[~azure.mgmt.billing.models.BillingPeriod] - :ivar next_link: The link (url) to the next page of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[BillingPeriod]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(BillingPeriodsListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class BillingPermissionsListResult(msrest.serialization.Model): - """Result of list billingPermissions a caller has on a billing account. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of billingPermissions a caller has on a billing account. - :vartype value: list[~azure.mgmt.billing.models.BillingPermissionsProperties] - :ivar next_link: The link (url) to the next page of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[BillingPermissionsProperties]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(BillingPermissionsListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class BillingPermissionsProperties(msrest.serialization.Model): - """The set of allowed action and not allowed actions a caller has on a billing account. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar actions: The set of actions that the caller is allowed to perform. - :vartype actions: list[str] - :ivar not_actions: The set of actions that the caller is not allowed to perform. - :vartype not_actions: list[str] - """ - - _validation = { - 'actions': {'readonly': True}, - 'not_actions': {'readonly': True}, - } - - _attribute_map = { - 'actions': {'key': 'actions', 'type': '[str]'}, - 'not_actions': {'key': 'notActions', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(BillingPermissionsProperties, self).__init__(**kwargs) - self.actions = None - self.not_actions = None - - -class BillingProfile(Resource): - """A billing profile. - - 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 - :param display_name: The name of the billing profile. - :type display_name: str - :param po_number: The purchase order name that will appear on the invoices generated for the - billing profile. - :type po_number: str - :ivar billing_relationship_type: Identifies which services and purchases are paid by a billing - profile. Possible values include: "Direct", "IndirectCustomer", "IndirectPartner", - "CSPPartner". - :vartype billing_relationship_type: str or ~azure.mgmt.billing.models.BillingRelationshipType - :param bill_to: Billing address. - :type bill_to: ~azure.mgmt.billing.models.AddressDetails - :ivar indirect_relationship_info: Identifies the billing profile that is linked to another - billing profile in indirect purchase motion. - :vartype indirect_relationship_info: ~azure.mgmt.billing.models.IndirectRelationshipInfo - :param invoice_email_opt_in: Flag controlling whether the invoices for the billing profile are - sent through email. - :type invoice_email_opt_in: bool - :ivar invoice_day: The day of the month when the invoice for the billing profile is generated. - :vartype invoice_day: int - :ivar currency: The currency in which the charges for the billing profile are billed. - :vartype currency: str - :param enabled_azure_plans: Information about the enabled azure plans. - :type enabled_azure_plans: list[~azure.mgmt.billing.models.AzurePlan] - :param invoice_sections: The invoice sections associated to the billing profile. By default - this is not populated, unless it's specified in $expand. - :type invoice_sections: ~azure.mgmt.billing.models.InvoiceSectionsOnExpand - :ivar has_read_access: Indicates whether user has read access to the billing profile. - :vartype has_read_access: bool - :ivar system_id: The system generated unique identifier for a billing profile. - :vartype system_id: str - :ivar status: The status of the billing profile. Possible values include: "Active", "Disabled", - "Warned". - :vartype status: str or ~azure.mgmt.billing.models.BillingProfileStatus - :ivar status_reason_code: Reason for the specified billing profile status. Possible values - include: "PastDue", "SpendingLimitReached", "SpendingLimitExpired". - :vartype status_reason_code: str or ~azure.mgmt.billing.models.StatusReasonCode - :ivar spending_limit: The billing profile spending limit. Possible values include: "Off", "On". - :vartype spending_limit: str or ~azure.mgmt.billing.models.SpendingLimit - :ivar target_clouds: Identifies the cloud environments that are associated with a billing - profile. This is a system managed optional field and gets updated as the billing profile gets - associated with accounts in various clouds. - :vartype target_clouds: list[str or ~azure.mgmt.billing.models.TargetCloud] - :param tags: A set of tags. Tags of billing profiles. - :type tags: dict[str, str] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'billing_relationship_type': {'readonly': True}, - 'indirect_relationship_info': {'readonly': True}, - 'invoice_day': {'readonly': True}, - 'currency': {'readonly': True}, - 'has_read_access': {'readonly': True}, - 'system_id': {'readonly': True}, - 'status': {'readonly': True}, - 'status_reason_code': {'readonly': True}, - 'spending_limit': {'readonly': True}, - 'target_clouds': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'po_number': {'key': 'properties.poNumber', 'type': 'str'}, - 'billing_relationship_type': {'key': 'properties.billingRelationshipType', 'type': 'str'}, - 'bill_to': {'key': 'properties.billTo', 'type': 'AddressDetails'}, - 'indirect_relationship_info': {'key': 'properties.indirectRelationshipInfo', 'type': 'IndirectRelationshipInfo'}, - 'invoice_email_opt_in': {'key': 'properties.invoiceEmailOptIn', 'type': 'bool'}, - 'invoice_day': {'key': 'properties.invoiceDay', 'type': 'int'}, - 'currency': {'key': 'properties.currency', 'type': 'str'}, - 'enabled_azure_plans': {'key': 'properties.enabledAzurePlans', 'type': '[AzurePlan]'}, - 'invoice_sections': {'key': 'properties.invoiceSections', 'type': 'InvoiceSectionsOnExpand'}, - 'has_read_access': {'key': 'properties.hasReadAccess', 'type': 'bool'}, - 'system_id': {'key': 'properties.systemId', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'status_reason_code': {'key': 'properties.statusReasonCode', 'type': 'str'}, - 'spending_limit': {'key': 'properties.spendingLimit', 'type': 'str'}, - 'target_clouds': {'key': 'properties.targetClouds', 'type': '[str]'}, - 'tags': {'key': 'properties.tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(BillingProfile, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) - self.po_number = kwargs.get('po_number', None) - self.billing_relationship_type = None - self.bill_to = kwargs.get('bill_to', None) - self.indirect_relationship_info = None - self.invoice_email_opt_in = kwargs.get('invoice_email_opt_in', None) - self.invoice_day = None - self.currency = None - self.enabled_azure_plans = kwargs.get('enabled_azure_plans', None) - self.invoice_sections = kwargs.get('invoice_sections', None) - self.has_read_access = None - self.system_id = None - self.status = None - self.status_reason_code = None - self.spending_limit = None - self.target_clouds = None - self.tags = kwargs.get('tags', None) - - -class BillingProfileCreationRequest(msrest.serialization.Model): - """The request parameters for creating a new billing profile. - - :param display_name: The name of the billing profile. - :type display_name: str - :param po_number: The purchase order name that will appear on the invoices generated for the - billing profile. - :type po_number: str - :param bill_to: The address of the individual or organization that is responsible for the - billing profile. - :type bill_to: ~azure.mgmt.billing.models.AddressDetails - :param invoice_email_opt_in: Flag controlling whether the invoices for the billing profile are - sent through email. - :type invoice_email_opt_in: bool - :param enabled_azure_plans: Enabled azure plans for the billing profile. - :type enabled_azure_plans: list[~azure.mgmt.billing.models.AzurePlan] - """ - - _attribute_map = { - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'po_number': {'key': 'poNumber', 'type': 'str'}, - 'bill_to': {'key': 'billTo', 'type': 'AddressDetails'}, - 'invoice_email_opt_in': {'key': 'invoiceEmailOptIn', 'type': 'bool'}, - 'enabled_azure_plans': {'key': 'enabledAzurePlans', 'type': '[AzurePlan]'}, - } - - def __init__( - self, - **kwargs - ): - super(BillingProfileCreationRequest, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) - self.po_number = kwargs.get('po_number', None) - self.bill_to = kwargs.get('bill_to', None) - self.invoice_email_opt_in = kwargs.get('invoice_email_opt_in', None) - self.enabled_azure_plans = kwargs.get('enabled_azure_plans', None) - - -class BillingProfileListResult(msrest.serialization.Model): - """The list of billing profiles. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of billing profiles. - :vartype value: list[~azure.mgmt.billing.models.BillingProfile] - :ivar next_link: The link (url) to the next page of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[BillingProfile]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(BillingProfileListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class BillingProfilesOnExpand(msrest.serialization.Model): - """The billing profiles associated with the billing account. By default this is not populated, unless it's specified in $expand. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar has_more_results: Indicates whether there are more billing profiles than the ones listed - in this collection. The collection lists a maximum of 50 billing profiles. To get all billing - profiles, use the list billing profiles API. - :vartype has_more_results: bool - :param value: The billing profiles associated with the billing account. - :type value: list[~azure.mgmt.billing.models.BillingProfile] - """ - - _validation = { - 'has_more_results': {'readonly': True}, - } - - _attribute_map = { - 'has_more_results': {'key': 'hasMoreResults', 'type': 'bool'}, - 'value': {'key': 'value', 'type': '[BillingProfile]'}, - } - - def __init__( - self, - **kwargs - ): - super(BillingProfilesOnExpand, self).__init__(**kwargs) - self.has_more_results = None - self.value = kwargs.get('value', None) - - -class BillingProperty(Resource): - """A billing property. - - 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 account_admin_notification_email_address: The email address on which the account admin - gets all Azure notifications. - :vartype account_admin_notification_email_address: str - :ivar billing_tenant_id: The Azure AD tenant ID of the billing account for the subscription. - :vartype billing_tenant_id: str - :ivar billing_account_id: The ID of the billing account to which the subscription is billed. - :vartype billing_account_id: str - :ivar billing_account_display_name: The name of the billing account to which the subscription - is billed. - :vartype billing_account_display_name: str - :ivar billing_profile_id: The ID of the billing profile to which the subscription is billed. - :vartype billing_profile_id: str - :ivar billing_profile_display_name: The name of the billing profile to which the subscription - is billed. - :vartype billing_profile_display_name: str - :ivar billing_profile_status: The status of the billing profile. Possible values include: - "Active", "Disabled", "Warned". - :vartype billing_profile_status: str or ~azure.mgmt.billing.models.BillingProfileStatus - :ivar billing_profile_status_reason_code: Reason for the specified billing profile status. - Possible values include: "PastDue", "SpendingLimitReached", "SpendingLimitExpired". - :vartype billing_profile_status_reason_code: str or - ~azure.mgmt.billing.models.BillingProfileStatusReasonCode - :ivar billing_profile_spending_limit: The billing profile spending limit. Possible values - include: "Off", "On". - :vartype billing_profile_spending_limit: str or - ~azure.mgmt.billing.models.BillingProfileSpendingLimit - :param cost_center: The cost center applied to the subscription. - :type cost_center: str - :ivar invoice_section_id: The ID of the invoice section to which the subscription is billed. - :vartype invoice_section_id: str - :ivar invoice_section_display_name: The name of the invoice section to which the subscription - is billed. - :vartype invoice_section_display_name: str - :ivar is_account_admin: Indicates whether user is the account admin. - :vartype is_account_admin: bool - :ivar product_id: The product ID of the Azure plan. - :vartype product_id: str - :ivar product_name: The product name of the Azure plan. - :vartype product_name: str - :ivar sku_id: The sku ID of the Azure plan for the subscription. - :vartype sku_id: str - :ivar sku_description: The sku description of the Azure plan for the subscription. - :vartype sku_description: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'account_admin_notification_email_address': {'readonly': True}, - 'billing_tenant_id': {'readonly': True}, - 'billing_account_id': {'readonly': True}, - 'billing_account_display_name': {'readonly': True}, - 'billing_profile_id': {'readonly': True}, - 'billing_profile_display_name': {'readonly': True}, - 'billing_profile_status': {'readonly': True}, - 'billing_profile_status_reason_code': {'readonly': True}, - 'billing_profile_spending_limit': {'readonly': True}, - 'invoice_section_id': {'readonly': True}, - 'invoice_section_display_name': {'readonly': True}, - 'is_account_admin': {'readonly': True}, - 'product_id': {'readonly': True}, - 'product_name': {'readonly': True}, - 'sku_id': {'readonly': True}, - 'sku_description': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'account_admin_notification_email_address': {'key': 'properties.accountAdminNotificationEmailAddress', 'type': 'str'}, - 'billing_tenant_id': {'key': 'properties.billingTenantId', 'type': 'str'}, - 'billing_account_id': {'key': 'properties.billingAccountId', 'type': 'str'}, - 'billing_account_display_name': {'key': 'properties.billingAccountDisplayName', 'type': 'str'}, - 'billing_profile_id': {'key': 'properties.billingProfileId', 'type': 'str'}, - 'billing_profile_display_name': {'key': 'properties.billingProfileDisplayName', 'type': 'str'}, - 'billing_profile_status': {'key': 'properties.billingProfileStatus', 'type': 'str'}, - 'billing_profile_status_reason_code': {'key': 'properties.billingProfileStatusReasonCode', 'type': 'str'}, - 'billing_profile_spending_limit': {'key': 'properties.billingProfileSpendingLimit', 'type': 'str'}, - 'cost_center': {'key': 'properties.costCenter', 'type': 'str'}, - 'invoice_section_id': {'key': 'properties.invoiceSectionId', 'type': 'str'}, - 'invoice_section_display_name': {'key': 'properties.invoiceSectionDisplayName', 'type': 'str'}, - 'is_account_admin': {'key': 'properties.isAccountAdmin', 'type': 'bool'}, - 'product_id': {'key': 'properties.productId', 'type': 'str'}, - 'product_name': {'key': 'properties.productName', 'type': 'str'}, - 'sku_id': {'key': 'properties.skuId', 'type': 'str'}, - 'sku_description': {'key': 'properties.skuDescription', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(BillingProperty, self).__init__(**kwargs) - self.account_admin_notification_email_address = None - self.billing_tenant_id = None - self.billing_account_id = None - self.billing_account_display_name = None - self.billing_profile_id = None - self.billing_profile_display_name = None - self.billing_profile_status = None - self.billing_profile_status_reason_code = None - self.billing_profile_spending_limit = None - self.cost_center = kwargs.get('cost_center', None) - self.invoice_section_id = None - self.invoice_section_display_name = None - self.is_account_admin = None - self.product_id = None - self.product_name = None - self.sku_id = None - self.sku_description = None - - -class BillingRoleAssignment(Resource): - """The role assignment. - - 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 created_on: The date the role assignment was created. - :vartype created_on: str - :ivar created_by_principal_tenant_id: The tenant Id of the user who created the role - assignment. - :vartype created_by_principal_tenant_id: str - :ivar created_by_principal_id: The principal Id of the user who created the role assignment. - :vartype created_by_principal_id: str - :ivar created_by_user_email_address: The email address of the user who created the role - assignment. - :vartype created_by_user_email_address: str - :param principal_id: The principal id of the user to whom the role was assigned. - :type principal_id: str - :param principal_tenant_id: The principal tenant id of the user to whom the role was assigned. - :type principal_tenant_id: str - :param role_definition_id: The ID of the role definition. - :type role_definition_id: str - :ivar scope: The scope at which the role was assigned. - :vartype scope: str - :param user_authentication_type: The authentication type. - :type user_authentication_type: str - :param user_email_address: The email address of the user. - :type user_email_address: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'created_on': {'readonly': True}, - 'created_by_principal_tenant_id': {'readonly': True}, - 'created_by_principal_id': {'readonly': True}, - 'created_by_user_email_address': {'readonly': True}, - 'scope': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'created_on': {'key': 'properties.createdOn', 'type': 'str'}, - 'created_by_principal_tenant_id': {'key': 'properties.createdByPrincipalTenantId', 'type': 'str'}, - 'created_by_principal_id': {'key': 'properties.createdByPrincipalId', 'type': 'str'}, - 'created_by_user_email_address': {'key': 'properties.createdByUserEmailAddress', 'type': 'str'}, - 'principal_id': {'key': 'properties.principalId', 'type': 'str'}, - 'principal_tenant_id': {'key': 'properties.principalTenantId', 'type': 'str'}, - 'role_definition_id': {'key': 'properties.roleDefinitionId', 'type': 'str'}, - 'scope': {'key': 'properties.scope', 'type': 'str'}, - 'user_authentication_type': {'key': 'properties.userAuthenticationType', 'type': 'str'}, - 'user_email_address': {'key': 'properties.userEmailAddress', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(BillingRoleAssignment, self).__init__(**kwargs) - self.created_on = None - self.created_by_principal_tenant_id = None - self.created_by_principal_id = None - self.created_by_user_email_address = None - self.principal_id = kwargs.get('principal_id', None) - self.principal_tenant_id = kwargs.get('principal_tenant_id', None) - self.role_definition_id = kwargs.get('role_definition_id', None) - self.scope = None - self.user_authentication_type = kwargs.get('user_authentication_type', None) - self.user_email_address = kwargs.get('user_email_address', None) - - -class BillingRoleAssignmentListResult(msrest.serialization.Model): - """The list of role assignments. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of role assignments. - :vartype value: list[~azure.mgmt.billing.models.BillingRoleAssignment] - :ivar next_link: The link (url) to the next page of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[BillingRoleAssignment]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(BillingRoleAssignmentListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class BillingRoleDefinition(Resource): - """The properties of a role definition. - - 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 description: The role description. - :vartype description: str - :param permissions: The billingPermissions the role has. - :type permissions: list[~azure.mgmt.billing.models.BillingPermissionsProperties] - :ivar role_name: The name of the role. - :vartype role_name: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'description': {'readonly': True}, - 'role_name': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'permissions': {'key': 'properties.permissions', 'type': '[BillingPermissionsProperties]'}, - 'role_name': {'key': 'properties.roleName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(BillingRoleDefinition, self).__init__(**kwargs) - self.description = None - self.permissions = kwargs.get('permissions', None) - self.role_name = None - - -class BillingRoleDefinitionListResult(msrest.serialization.Model): - """The list of role definitions. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The role definitions. - :vartype value: list[~azure.mgmt.billing.models.BillingRoleDefinition] - :ivar next_link: The link (url) to the next page of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[BillingRoleDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(BillingRoleDefinitionListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class BillingSubscription(Resource): - """A billing subscription. - - 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 display_name: The name of the subscription. - :vartype display_name: str - :ivar subscription_id: The ID of the subscription. - :vartype subscription_id: str - :param subscription_billing_status: The current billing status of the subscription. Possible - values include: "Active", "Inactive", "Abandoned", "Deleted", "Warning". - :type subscription_billing_status: str or - ~azure.mgmt.billing.models.BillingSubscriptionStatusType - :ivar last_month_charges: The last month charges. - :vartype last_month_charges: ~azure.mgmt.billing.models.Amount - :ivar month_to_date_charges: The current month to date charges. - :vartype month_to_date_charges: ~azure.mgmt.billing.models.Amount - :ivar billing_profile_id: The ID of the billing profile to which the subscription is billed. - :vartype billing_profile_id: str - :ivar billing_profile_display_name: The name of the billing profile to which the subscription - is billed. - :vartype billing_profile_display_name: str - :param cost_center: The cost center applied to the subscription. - :type cost_center: str - :ivar customer_id: The ID of the customer for whom the subscription was created. The field is - applicable only for Microsoft Partner Agreement billing account. - :vartype customer_id: str - :ivar customer_display_name: The name of the customer for whom the subscription was created. - The field is applicable only for Microsoft Partner Agreement billing account. - :vartype customer_display_name: str - :ivar invoice_section_id: The ID of the invoice section to which the subscription is billed. - :vartype invoice_section_id: str - :ivar invoice_section_display_name: The name of the invoice section to which the subscription - is billed. - :vartype invoice_section_display_name: str - :ivar reseller: Reseller for this subscription. - :vartype reseller: ~azure.mgmt.billing.models.Reseller - :param sku_id: The sku ID of the Azure plan for the subscription. - :type sku_id: str - :ivar sku_description: The sku description of the Azure plan for the subscription. - :vartype sku_description: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'display_name': {'readonly': True}, - 'subscription_id': {'readonly': True}, - 'last_month_charges': {'readonly': True}, - 'month_to_date_charges': {'readonly': True}, - 'billing_profile_id': {'readonly': True}, - 'billing_profile_display_name': {'readonly': True}, - 'customer_id': {'readonly': True}, - 'customer_display_name': {'readonly': True}, - 'invoice_section_id': {'readonly': True}, - 'invoice_section_display_name': {'readonly': True}, - 'reseller': {'readonly': True}, - 'sku_description': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'subscription_id': {'key': 'properties.subscriptionId', 'type': 'str'}, - 'subscription_billing_status': {'key': 'properties.subscriptionBillingStatus', 'type': 'str'}, - 'last_month_charges': {'key': 'properties.lastMonthCharges', 'type': 'Amount'}, - 'month_to_date_charges': {'key': 'properties.monthToDateCharges', 'type': 'Amount'}, - 'billing_profile_id': {'key': 'properties.billingProfileId', 'type': 'str'}, - 'billing_profile_display_name': {'key': 'properties.billingProfileDisplayName', 'type': 'str'}, - 'cost_center': {'key': 'properties.costCenter', 'type': 'str'}, - 'customer_id': {'key': 'properties.customerId', 'type': 'str'}, - 'customer_display_name': {'key': 'properties.customerDisplayName', 'type': 'str'}, - 'invoice_section_id': {'key': 'properties.invoiceSectionId', 'type': 'str'}, - 'invoice_section_display_name': {'key': 'properties.invoiceSectionDisplayName', 'type': 'str'}, - 'reseller': {'key': 'properties.reseller', 'type': 'Reseller'}, - 'sku_id': {'key': 'properties.skuId', 'type': 'str'}, - 'sku_description': {'key': 'properties.skuDescription', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(BillingSubscription, self).__init__(**kwargs) - self.display_name = None - self.subscription_id = None - self.subscription_billing_status = kwargs.get('subscription_billing_status', None) - self.last_month_charges = None - self.month_to_date_charges = None - self.billing_profile_id = None - self.billing_profile_display_name = None - self.cost_center = kwargs.get('cost_center', None) - self.customer_id = None - self.customer_display_name = None - self.invoice_section_id = None - self.invoice_section_display_name = None - self.reseller = None - self.sku_id = kwargs.get('sku_id', None) - self.sku_description = None - - -class BillingSubscriptionsListResult(msrest.serialization.Model): - """The list of billing subscriptions. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of billing subscriptions. - :vartype value: list[~azure.mgmt.billing.models.BillingSubscription] - :ivar total_count: Total number of records. - :vartype total_count: int - :ivar next_link: The link (url) to the next page of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'total_count': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[BillingSubscription]'}, - 'total_count': {'key': 'totalCount', 'type': 'int'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(BillingSubscriptionsListResult, self).__init__(**kwargs) - self.value = None - self.total_count = None - self.next_link = None - - -class Customer(Resource): - """A partner's customer. - - 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 billing_profile_id: The ID of the billing profile for the invoice section. - :vartype billing_profile_id: str - :ivar billing_profile_display_name: The name of the billing profile for the invoice section. - :vartype billing_profile_display_name: str - :param display_name: The name of the customer. - :type display_name: str - :param enabled_azure_plans: Azure plans enabled for the customer. - :type enabled_azure_plans: list[~azure.mgmt.billing.models.AzurePlan] - :param resellers: The list of resellers for which an Azure plan is enabled for the customer. - :type resellers: list[~azure.mgmt.billing.models.Reseller] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'billing_profile_id': {'readonly': True}, - 'billing_profile_display_name': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'billing_profile_id': {'key': 'properties.billingProfileId', 'type': 'str'}, - 'billing_profile_display_name': {'key': 'properties.billingProfileDisplayName', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'enabled_azure_plans': {'key': 'properties.enabledAzurePlans', 'type': '[AzurePlan]'}, - 'resellers': {'key': 'properties.resellers', 'type': '[Reseller]'}, - } - - def __init__( - self, - **kwargs - ): - super(Customer, self).__init__(**kwargs) - self.billing_profile_id = None - self.billing_profile_display_name = None - self.display_name = kwargs.get('display_name', None) - self.enabled_azure_plans = kwargs.get('enabled_azure_plans', None) - self.resellers = kwargs.get('resellers', None) - - -class CustomerListResult(msrest.serialization.Model): - """The list of customers. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of customers. - :vartype value: list[~azure.mgmt.billing.models.Customer] - :ivar total_count: Total number of records. - :vartype total_count: int - :ivar next_link: The link (url) to the next page of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'total_count': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Customer]'}, - 'total_count': {'key': 'totalCount', 'type': 'int'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CustomerListResult, self).__init__(**kwargs) - self.value = None - self.total_count = None - self.next_link = None - - -class CustomerPolicy(Resource): - """The customer's Policy. - - 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 - :param view_charges: The policy that controls whether the users in customer's organization can - view charges at pay-as-you-go prices. Possible values include: "Allowed", "NotAllowed". - :type view_charges: str or ~azure.mgmt.billing.models.ViewCharges - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'view_charges': {'key': 'properties.viewCharges', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CustomerPolicy, self).__init__(**kwargs) - self.view_charges = kwargs.get('view_charges', None) - - -class Department(Resource): - """A department. - - 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 - :param department_name: The name of the department. - :type department_name: str - :param cost_center: The cost center associated with the department. - :type cost_center: str - :param status: The status of the department. - :type status: str - :param enrollment_accounts: Associated enrollment accounts. By default this is not populated, - unless it's specified in $expand. - :type enrollment_accounts: list[~azure.mgmt.billing.models.EnrollmentAccount] - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'department_name': {'key': 'properties.departmentName', 'type': 'str'}, - 'cost_center': {'key': 'properties.costCenter', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'enrollment_accounts': {'key': 'properties.enrollmentAccounts', 'type': '[EnrollmentAccount]'}, - } - - def __init__( - self, - **kwargs - ): - super(Department, self).__init__(**kwargs) - self.department_name = kwargs.get('department_name', None) - self.cost_center = kwargs.get('cost_center', None) - self.status = kwargs.get('status', None) - self.enrollment_accounts = kwargs.get('enrollment_accounts', None) - - -class Document(msrest.serialization.Model): - """The properties of a document. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar kind: The type of the document. Possible values include: "Invoice", "VoidNote", - "TaxReceipt", "CreditNote". - :vartype kind: str or ~azure.mgmt.billing.models.DocumentType - :ivar url: Document URL. - :vartype url: str - :ivar source: The source of the document. ENF for Brazil and DRS for rest of the world. - Possible values include: "DRS", "ENF". - :vartype source: str or ~azure.mgmt.billing.models.DocumentSource - """ - - _validation = { - 'kind': {'readonly': True}, - 'url': {'readonly': True}, - 'source': {'readonly': True}, - } - - _attribute_map = { - 'kind': {'key': 'kind', 'type': 'str'}, - 'url': {'key': 'url', 'type': 'str'}, - 'source': {'key': 'source', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Document, self).__init__(**kwargs) - self.kind = None - self.url = None - self.source = None - - -class DownloadUrl(msrest.serialization.Model): - """A secure URL that can be used to download a an entity until the URL expires. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar expiry_time: The time in UTC when the download URL will expire. - :vartype expiry_time: ~datetime.datetime - :ivar url: The URL to the PDF file. - :vartype url: str - """ - - _validation = { - 'expiry_time': {'readonly': True}, - 'url': {'readonly': True}, - } - - _attribute_map = { - 'expiry_time': {'key': 'expiryTime', 'type': 'iso-8601'}, - 'url': {'key': 'url', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(DownloadUrl, self).__init__(**kwargs) - self.expiry_time = None - self.url = None - - -class Enrollment(msrest.serialization.Model): - """The properties of an enrollment. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param start_date: The start date of the enrollment. - :type start_date: ~datetime.datetime - :param end_date: The end date of the enrollment. - :type end_date: ~datetime.datetime - :ivar currency: The billing currency for the enrollment. - :vartype currency: str - :ivar channel: The channel type of the enrollment. - :vartype channel: str - :ivar policies: The policies for Enterprise Agreement enrollments. - :vartype policies: ~azure.mgmt.billing.models.EnrollmentPolicies - :ivar language: The language for the enrollment. - :vartype language: str - :ivar country_code: The country code of the enrollment. - :vartype country_code: str - :ivar status: The current status of the enrollment. - :vartype status: str - :ivar billing_cycle: The billing cycle for the enrollment. - :vartype billing_cycle: str - """ - - _validation = { - 'currency': {'readonly': True}, - 'channel': {'readonly': True}, - 'policies': {'readonly': True}, - 'language': {'readonly': True}, - 'country_code': {'readonly': True}, - 'status': {'readonly': True}, - 'billing_cycle': {'readonly': True}, - } - - _attribute_map = { - 'start_date': {'key': 'startDate', 'type': 'iso-8601'}, - 'end_date': {'key': 'endDate', 'type': 'iso-8601'}, - 'currency': {'key': 'currency', 'type': 'str'}, - 'channel': {'key': 'channel', 'type': 'str'}, - 'policies': {'key': 'policies', 'type': 'EnrollmentPolicies'}, - 'language': {'key': 'language', 'type': 'str'}, - 'country_code': {'key': 'countryCode', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'billing_cycle': {'key': 'billingCycle', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Enrollment, self).__init__(**kwargs) - self.start_date = kwargs.get('start_date', None) - self.end_date = kwargs.get('end_date', None) - self.currency = None - self.channel = None - self.policies = None - self.language = None - self.country_code = None - self.status = None - self.billing_cycle = None - - -class EnrollmentAccount(Resource): - """An enrollment account. - - 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 - :param account_name: The name of the enrollment account. - :type account_name: str - :param cost_center: The cost center associated with the enrollment account. - :type cost_center: str - :param account_owner: The owner of the enrollment account. - :type account_owner: str - :param account_owner_email: The enrollment account owner email address. - :type account_owner_email: str - :param status: The status of the enrollment account. - :type status: str - :param start_date: The start date of the enrollment account. - :type start_date: ~datetime.datetime - :param end_date: The end date of the enrollment account. - :type end_date: ~datetime.datetime - :param department: Associated department. By default this is not populated, unless it's - specified in $expand. - :type department: ~azure.mgmt.billing.models.Department - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'account_name': {'key': 'properties.accountName', 'type': 'str'}, - 'cost_center': {'key': 'properties.costCenter', 'type': 'str'}, - 'account_owner': {'key': 'properties.accountOwner', 'type': 'str'}, - 'account_owner_email': {'key': 'properties.accountOwnerEmail', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'start_date': {'key': 'properties.startDate', 'type': 'iso-8601'}, - 'end_date': {'key': 'properties.endDate', 'type': 'iso-8601'}, - 'department': {'key': 'properties.department', 'type': 'Department'}, - } - - def __init__( - self, - **kwargs - ): - super(EnrollmentAccount, self).__init__(**kwargs) - self.account_name = kwargs.get('account_name', None) - self.cost_center = kwargs.get('cost_center', None) - self.account_owner = kwargs.get('account_owner', None) - self.account_owner_email = kwargs.get('account_owner_email', None) - self.status = kwargs.get('status', None) - self.start_date = kwargs.get('start_date', None) - self.end_date = kwargs.get('end_date', None) - self.department = kwargs.get('department', None) - - -class EnrollmentAccountContext(msrest.serialization.Model): - """The enrollment account context. - - :param cost_center: The cost center associated with the enrollment account. - :type cost_center: str - :param start_date: The start date of the enrollment account. - :type start_date: ~datetime.datetime - :param end_date: The end date of the enrollment account. - :type end_date: ~datetime.datetime - :param enrollment_account_name: The ID of the enrollment account. - :type enrollment_account_name: str - """ - - _attribute_map = { - 'cost_center': {'key': 'costCenter', 'type': 'str'}, - 'start_date': {'key': 'startDate', 'type': 'iso-8601'}, - 'end_date': {'key': 'endDate', 'type': 'iso-8601'}, - 'enrollment_account_name': {'key': 'enrollmentAccountName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EnrollmentAccountContext, self).__init__(**kwargs) - self.cost_center = kwargs.get('cost_center', None) - self.start_date = kwargs.get('start_date', None) - self.end_date = kwargs.get('end_date', None) - self.enrollment_account_name = kwargs.get('enrollment_account_name', None) - - -class EnrollmentAccountListResult(msrest.serialization.Model): - """Result of listing enrollment accounts. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of enrollment accounts. - :vartype value: list[~azure.mgmt.billing.models.EnrollmentAccountSummary] - :ivar next_link: The link (url) to the next page of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[EnrollmentAccountSummary]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EnrollmentAccountListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class EnrollmentAccountSummary(Resource): - """An enrollment account 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 principal_name: The account owner's principal name. - :vartype principal_name: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'principal_name': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'principal_name': {'key': 'properties.principalName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EnrollmentAccountSummary, self).__init__(**kwargs) - self.principal_name = None - - -class EnrollmentPolicies(msrest.serialization.Model): - """The policies for Enterprise Agreement enrollments. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar account_owner_view_charges: The policy that controls whether Account Owners can view - charges. - :vartype account_owner_view_charges: bool - :ivar department_admin_view_charges: The policy that controls whether Department Administrators - can view charges. - :vartype department_admin_view_charges: bool - :ivar marketplace_enabled: The policy that controls whether Azure marketplace purchases are - allowed in the enrollment. - :vartype marketplace_enabled: bool - :ivar reserved_instances_enabled: The policy that controls whether Azure reservation purchases - are allowed in the enrollment. - :vartype reserved_instances_enabled: bool - """ - - _validation = { - 'account_owner_view_charges': {'readonly': True}, - 'department_admin_view_charges': {'readonly': True}, - 'marketplace_enabled': {'readonly': True}, - 'reserved_instances_enabled': {'readonly': True}, - } - - _attribute_map = { - 'account_owner_view_charges': {'key': 'accountOwnerViewCharges', 'type': 'bool'}, - 'department_admin_view_charges': {'key': 'departmentAdminViewCharges', 'type': 'bool'}, - 'marketplace_enabled': {'key': 'marketplaceEnabled', 'type': 'bool'}, - 'reserved_instances_enabled': {'key': 'reservedInstancesEnabled', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(EnrollmentPolicies, self).__init__(**kwargs) - self.account_owner_view_charges = None - self.department_admin_view_charges = None - self.marketplace_enabled = None - self.reserved_instances_enabled = None - - -class ErrorDetails(msrest.serialization.Model): - """The details of the error. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: Error code. - :vartype code: str - :ivar message: Error message indicating why the operation failed. - :vartype message: str - :ivar target: The target of the particular error. - :vartype target: str - :ivar details: The sub details of the error. - :vartype details: list[~azure.mgmt.billing.models.ErrorSubDetailsItem] - """ - - _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorSubDetailsItem]'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorDetails, self).__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - - -class ErrorResponse(msrest.serialization.Model): - """Error response indicates that the service is not able to process the incoming request. The reason is provided in the error message. - - :param error: The details of the error. - :type error: ~azure.mgmt.billing.models.ErrorDetails - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetails'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class ErrorSubDetailsItem(msrest.serialization.Model): - """ErrorSubDetailsItem. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: Error code. - :vartype code: str - :ivar message: Error message indicating why the operation failed. - :vartype message: str - :ivar target: The target of the particular error. - :vartype target: str - """ - - _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorSubDetailsItem, self).__init__(**kwargs) - self.code = None - self.message = None - self.target = None - - -class IndirectRelationshipInfo(msrest.serialization.Model): - """The billing profile details of the partner of the customer for an indirect motion. - - :param billing_account_name: The billing account name of the partner or the customer for an - indirect motion. - :type billing_account_name: str - :param billing_profile_name: The billing profile name of the partner or the customer for an - indirect motion. - :type billing_profile_name: str - :param display_name: The display name of the partner or customer for an indirect motion. - :type display_name: str - """ - - _attribute_map = { - 'billing_account_name': {'key': 'billingAccountName', 'type': 'str'}, - 'billing_profile_name': {'key': 'billingProfileName', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IndirectRelationshipInfo, self).__init__(**kwargs) - self.billing_account_name = kwargs.get('billing_account_name', None) - self.billing_profile_name = kwargs.get('billing_profile_name', None) - self.display_name = kwargs.get('display_name', None) - - -class Instruction(Resource): - """An instruction. - - 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 - :param amount: The amount budgeted for this billing instruction. - :type amount: float - :param start_date: The date this billing instruction goes into effect. - :type start_date: ~datetime.datetime - :param end_date: The date this billing instruction is no longer in effect. - :type end_date: ~datetime.datetime - :param creation_date: The date this billing instruction was created. - :type creation_date: ~datetime.datetime - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'amount': {'key': 'properties.amount', 'type': 'float'}, - 'start_date': {'key': 'properties.startDate', 'type': 'iso-8601'}, - 'end_date': {'key': 'properties.endDate', 'type': 'iso-8601'}, - 'creation_date': {'key': 'properties.creationDate', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(Instruction, self).__init__(**kwargs) - self.amount = kwargs.get('amount', None) - self.start_date = kwargs.get('start_date', None) - self.end_date = kwargs.get('end_date', None) - self.creation_date = kwargs.get('creation_date', None) - - -class InstructionListResult(msrest.serialization.Model): - """The list of billing instructions used during invoice generation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of billing instructions used during invoice generation. - :vartype value: list[~azure.mgmt.billing.models.Instruction] - :ivar next_link: The link (url) to the next page of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Instruction]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(InstructionListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class Invoice(Resource): - """An invoice. - - 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 due_date: The due date for the invoice. - :vartype due_date: ~datetime.datetime - :ivar invoice_date: The date when the invoice was generated. - :vartype invoice_date: ~datetime.datetime - :ivar status: The current status of the invoice. Possible values include: "Due", "OverDue", - "Paid", "Void". - :vartype status: str or ~azure.mgmt.billing.models.InvoiceStatus - :ivar amount_due: The amount due as of now. - :vartype amount_due: ~azure.mgmt.billing.models.Amount - :ivar azure_prepayment_applied: The amount of Azure prepayment applied to the charges. This - field is applicable to billing accounts with agreement type Microsoft Customer Agreement. - :vartype azure_prepayment_applied: ~azure.mgmt.billing.models.Amount - :ivar billed_amount: The total charges for the invoice billing period. - :vartype billed_amount: ~azure.mgmt.billing.models.Amount - :ivar credit_amount: The total refund for returns and cancellations during the invoice billing - period. This field is applicable to billing accounts with agreement type Microsoft Customer - Agreement. - :vartype credit_amount: ~azure.mgmt.billing.models.Amount - :ivar free_azure_credit_applied: The amount of free Azure credits applied to the charges. This - field is applicable to billing accounts with agreement type Microsoft Customer Agreement. - :vartype free_azure_credit_applied: ~azure.mgmt.billing.models.Amount - :ivar sub_total: The pre-tax amount due. This field is applicable to billing accounts with - agreement type Microsoft Customer Agreement. - :vartype sub_total: ~azure.mgmt.billing.models.Amount - :ivar tax_amount: The amount of tax charged for the billing period. This field is applicable to - billing accounts with agreement type Microsoft Customer Agreement. - :vartype tax_amount: ~azure.mgmt.billing.models.Amount - :ivar total_amount: The amount due when the invoice was generated. This field is applicable to - billing accounts with agreement type Microsoft Customer Agreement. - :vartype total_amount: ~azure.mgmt.billing.models.Amount - :ivar invoice_period_start_date: The start date of the billing period for which the invoice is - generated. - :vartype invoice_period_start_date: ~datetime.datetime - :ivar invoice_period_end_date: The end date of the billing period for which the invoice is - generated. - :vartype invoice_period_end_date: ~datetime.datetime - :ivar invoice_type: Invoice type. Possible values include: "AzureService", "AzureMarketplace", - "AzureSupport". - :vartype invoice_type: str or ~azure.mgmt.billing.models.InvoiceType - :ivar is_monthly_invoice: Specifies if the invoice is generated as part of monthly invoicing - cycle or not. This field is applicable to billing accounts with agreement type Microsoft - Customer Agreement. - :vartype is_monthly_invoice: bool - :ivar billing_profile_id: The ID of the billing profile for which the invoice is generated. - :vartype billing_profile_id: str - :ivar billing_profile_display_name: The name of the billing profile for which the invoice is - generated. - :vartype billing_profile_display_name: str - :ivar purchase_order_number: An optional purchase order number for the invoice. - :vartype purchase_order_number: str - :ivar documents: List of documents available to download such as invoice and tax receipt. - :vartype documents: list[~azure.mgmt.billing.models.Document] - :ivar payments: List of payments. - :vartype payments: list[~azure.mgmt.billing.models.PaymentProperties] - :ivar rebill_details: Rebill details for an invoice. - :vartype rebill_details: dict[str, ~azure.mgmt.billing.models.RebillDetails] - :ivar document_type: The type of the document. Possible values include: "Invoice", - "CreditNote". - :vartype document_type: str or ~azure.mgmt.billing.models.InvoiceDocumentType - :ivar billed_document_id: The Id of the active invoice which is originally billed after this - invoice was voided. This field is applicable to the void invoices only. - :vartype billed_document_id: str - :ivar credit_for_document_id: The Id of the invoice which got voided and this credit note was - issued as a result. This field is applicable to the credit notes only. - :vartype credit_for_document_id: str - :ivar subscription_id: The ID of the subscription for which the invoice is generated. - :vartype subscription_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'due_date': {'readonly': True}, - 'invoice_date': {'readonly': True}, - 'status': {'readonly': True}, - 'amount_due': {'readonly': True}, - 'azure_prepayment_applied': {'readonly': True}, - 'billed_amount': {'readonly': True}, - 'credit_amount': {'readonly': True}, - 'free_azure_credit_applied': {'readonly': True}, - 'sub_total': {'readonly': True}, - 'tax_amount': {'readonly': True}, - 'total_amount': {'readonly': True}, - 'invoice_period_start_date': {'readonly': True}, - 'invoice_period_end_date': {'readonly': True}, - 'invoice_type': {'readonly': True}, - 'is_monthly_invoice': {'readonly': True}, - 'billing_profile_id': {'readonly': True}, - 'billing_profile_display_name': {'readonly': True}, - 'purchase_order_number': {'readonly': True}, - 'documents': {'readonly': True}, - 'payments': {'readonly': True}, - 'rebill_details': {'readonly': True}, - 'document_type': {'readonly': True}, - 'billed_document_id': {'readonly': True}, - 'credit_for_document_id': {'readonly': True}, - 'subscription_id': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'due_date': {'key': 'properties.dueDate', 'type': 'iso-8601'}, - 'invoice_date': {'key': 'properties.invoiceDate', 'type': 'iso-8601'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'amount_due': {'key': 'properties.amountDue', 'type': 'Amount'}, - 'azure_prepayment_applied': {'key': 'properties.azurePrepaymentApplied', 'type': 'Amount'}, - 'billed_amount': {'key': 'properties.billedAmount', 'type': 'Amount'}, - 'credit_amount': {'key': 'properties.creditAmount', 'type': 'Amount'}, - 'free_azure_credit_applied': {'key': 'properties.freeAzureCreditApplied', 'type': 'Amount'}, - 'sub_total': {'key': 'properties.subTotal', 'type': 'Amount'}, - 'tax_amount': {'key': 'properties.taxAmount', 'type': 'Amount'}, - 'total_amount': {'key': 'properties.totalAmount', 'type': 'Amount'}, - 'invoice_period_start_date': {'key': 'properties.invoicePeriodStartDate', 'type': 'iso-8601'}, - 'invoice_period_end_date': {'key': 'properties.invoicePeriodEndDate', 'type': 'iso-8601'}, - 'invoice_type': {'key': 'properties.invoiceType', 'type': 'str'}, - 'is_monthly_invoice': {'key': 'properties.isMonthlyInvoice', 'type': 'bool'}, - 'billing_profile_id': {'key': 'properties.billingProfileId', 'type': 'str'}, - 'billing_profile_display_name': {'key': 'properties.billingProfileDisplayName', 'type': 'str'}, - 'purchase_order_number': {'key': 'properties.purchaseOrderNumber', 'type': 'str'}, - 'documents': {'key': 'properties.documents', 'type': '[Document]'}, - 'payments': {'key': 'properties.payments', 'type': '[PaymentProperties]'}, - 'rebill_details': {'key': 'properties.rebillDetails', 'type': '{RebillDetails}'}, - 'document_type': {'key': 'properties.documentType', 'type': 'str'}, - 'billed_document_id': {'key': 'properties.billedDocumentId', 'type': 'str'}, - 'credit_for_document_id': {'key': 'properties.creditForDocumentId', 'type': 'str'}, - 'subscription_id': {'key': 'properties.subscriptionId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Invoice, self).__init__(**kwargs) - self.due_date = None - self.invoice_date = None - self.status = None - self.amount_due = None - self.azure_prepayment_applied = None - self.billed_amount = None - self.credit_amount = None - self.free_azure_credit_applied = None - self.sub_total = None - self.tax_amount = None - self.total_amount = None - self.invoice_period_start_date = None - self.invoice_period_end_date = None - self.invoice_type = None - self.is_monthly_invoice = None - self.billing_profile_id = None - self.billing_profile_display_name = None - self.purchase_order_number = None - self.documents = None - self.payments = None - self.rebill_details = None - self.document_type = None - self.billed_document_id = None - self.credit_for_document_id = None - self.subscription_id = None - - -class InvoiceListResult(msrest.serialization.Model): - """The list of invoices. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of invoices. - :vartype value: list[~azure.mgmt.billing.models.Invoice] - :ivar next_link: The link (url) to the next page of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Invoice]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(InvoiceListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class InvoiceSection(Resource): - """An invoice section. - - 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 - :param display_name: The name of the invoice section. - :type display_name: str - :param labels: Dictionary of metadata associated with the invoice section. - :type labels: dict[str, str] - :ivar state: Identifies the state of an invoice section. Possible values include: "Active", - "Restricted". - :vartype state: str or ~azure.mgmt.billing.models.InvoiceSectionState - :ivar system_id: The system generated unique identifier for an invoice section. - :vartype system_id: str - :ivar target_cloud: Identifies the cloud environments that are associated with an invoice - section. This is a system managed optional field and gets updated as the invoice section gets - associated with accounts in various clouds. Possible values include: "USGov", "USNat", "USSec". - :vartype target_cloud: str or ~azure.mgmt.billing.models.TargetCloud - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'state': {'readonly': True}, - 'system_id': {'readonly': True}, - 'target_cloud': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'labels': {'key': 'properties.labels', 'type': '{str}'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'system_id': {'key': 'properties.systemId', 'type': 'str'}, - 'target_cloud': {'key': 'properties.targetCloud', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(InvoiceSection, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) - self.labels = kwargs.get('labels', None) - self.state = None - self.system_id = None - self.target_cloud = None - - -class InvoiceSectionCreationRequest(msrest.serialization.Model): - """The properties of the invoice section. - - :param display_name: The name of the invoice section. - :type display_name: str - """ - - _attribute_map = { - 'display_name': {'key': 'displayName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(InvoiceSectionCreationRequest, self).__init__(**kwargs) - self.display_name = kwargs.get('display_name', None) - - -class InvoiceSectionListResult(msrest.serialization.Model): - """The list of invoice sections. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of invoice sections. - :vartype value: list[~azure.mgmt.billing.models.InvoiceSection] - :ivar total_count: Total number of records. - :vartype total_count: int - :ivar next_link: The link (url) to the next page of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'total_count': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[InvoiceSection]'}, - 'total_count': {'key': 'totalCount', 'type': 'int'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(InvoiceSectionListResult, self).__init__(**kwargs) - self.value = None - self.total_count = None - self.next_link = None - - -class InvoiceSectionListWithCreateSubPermissionResult(msrest.serialization.Model): - """The list of invoice section properties with create subscription permission. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: The list of invoice section properties with create subscription permission. - :type value: list[~azure.mgmt.billing.models.InvoiceSectionWithCreateSubPermission] - :ivar next_link: The link (url) to the next page of results. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[InvoiceSectionWithCreateSubPermission]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(InvoiceSectionListWithCreateSubPermissionResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class InvoiceSectionsOnExpand(msrest.serialization.Model): - """The invoice sections associated to the billing profile. By default this is not populated, unless it's specified in $expand. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar has_more_results: Indicates whether there are more invoice sections than the ones listed - in this collection. The collection lists a maximum of 50 invoice sections. To get all invoice - sections, use the list invoice sections API. - :vartype has_more_results: bool - :param value: The invoice sections associated to the billing profile. - :type value: list[~azure.mgmt.billing.models.InvoiceSection] - """ - - _validation = { - 'has_more_results': {'readonly': True}, - } - - _attribute_map = { - 'has_more_results': {'key': 'hasMoreResults', 'type': 'bool'}, - 'value': {'key': 'value', 'type': '[InvoiceSection]'}, - } - - def __init__( - self, - **kwargs - ): - super(InvoiceSectionsOnExpand, self).__init__(**kwargs) - self.has_more_results = None - self.value = kwargs.get('value', None) - - -class InvoiceSectionWithCreateSubPermission(msrest.serialization.Model): - """Invoice section properties with create subscription permission. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar invoice_section_id: The ID of the invoice section. - :vartype invoice_section_id: str - :ivar invoice_section_display_name: The name of the invoice section. - :vartype invoice_section_display_name: str - :ivar invoice_section_system_id: The system generated unique identifier for an invoice section. - :vartype invoice_section_system_id: str - :ivar billing_profile_id: The ID of the billing profile for the invoice section. - :vartype billing_profile_id: str - :ivar billing_profile_display_name: The name of the billing profile for the invoice section. - :vartype billing_profile_display_name: str - :ivar billing_profile_status: The status of the billing profile. Possible values include: - "Active", "Disabled", "Warned". - :vartype billing_profile_status: str or ~azure.mgmt.billing.models.BillingProfileStatus - :ivar billing_profile_status_reason_code: Reason for the specified billing profile status. - Possible values include: "PastDue", "SpendingLimitReached", "SpendingLimitExpired". - :vartype billing_profile_status_reason_code: str or - ~azure.mgmt.billing.models.StatusReasonCodeForBillingProfile - :ivar billing_profile_spending_limit: The billing profile spending limit. Possible values - include: "Off", "On". - :vartype billing_profile_spending_limit: str or - ~azure.mgmt.billing.models.SpendingLimitForBillingProfile - :ivar billing_profile_system_id: The system generated unique identifier for a billing profile. - :vartype billing_profile_system_id: str - :param enabled_azure_plans: Enabled azure plans for the associated billing profile. - :type enabled_azure_plans: list[~azure.mgmt.billing.models.AzurePlan] - """ - - _validation = { - 'invoice_section_id': {'readonly': True}, - 'invoice_section_display_name': {'readonly': True}, - 'invoice_section_system_id': {'readonly': True}, - 'billing_profile_id': {'readonly': True}, - 'billing_profile_display_name': {'readonly': True}, - 'billing_profile_status': {'readonly': True}, - 'billing_profile_status_reason_code': {'readonly': True}, - 'billing_profile_spending_limit': {'readonly': True}, - 'billing_profile_system_id': {'readonly': True}, - } - - _attribute_map = { - 'invoice_section_id': {'key': 'invoiceSectionId', 'type': 'str'}, - 'invoice_section_display_name': {'key': 'invoiceSectionDisplayName', 'type': 'str'}, - 'invoice_section_system_id': {'key': 'invoiceSectionSystemId', 'type': 'str'}, - 'billing_profile_id': {'key': 'billingProfileId', 'type': 'str'}, - 'billing_profile_display_name': {'key': 'billingProfileDisplayName', 'type': 'str'}, - 'billing_profile_status': {'key': 'billingProfileStatus', 'type': 'str'}, - 'billing_profile_status_reason_code': {'key': 'billingProfileStatusReasonCode', 'type': 'str'}, - 'billing_profile_spending_limit': {'key': 'billingProfileSpendingLimit', 'type': 'str'}, - 'billing_profile_system_id': {'key': 'billingProfileSystemId', 'type': 'str'}, - 'enabled_azure_plans': {'key': 'enabledAzurePlans', 'type': '[AzurePlan]'}, - } - - def __init__( - self, - **kwargs - ): - super(InvoiceSectionWithCreateSubPermission, self).__init__(**kwargs) - self.invoice_section_id = None - self.invoice_section_display_name = None - self.invoice_section_system_id = None - self.billing_profile_id = None - self.billing_profile_display_name = None - self.billing_profile_status = None - self.billing_profile_status_reason_code = None - self.billing_profile_spending_limit = None - self.billing_profile_system_id = None - self.enabled_azure_plans = kwargs.get('enabled_azure_plans', None) - - -class Operation(msrest.serialization.Model): - """A Billing REST API operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Operation name: {provider}/{resource}/{operation}. - :vartype name: str - :ivar is_data_action: Identifies if the operation is a data operation. - :vartype is_data_action: bool - :param display: The object that represents the operation. - :type display: ~azure.mgmt.billing.models.OperationDisplay - """ - - _validation = { - 'name': {'readonly': True}, - 'is_data_action': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = None - self.is_data_action = None - self.display = kwargs.get('display', None) - - -class OperationDisplay(msrest.serialization.Model): - """The object that represents the operation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provider: Service provider: Microsoft.Billing. - :vartype provider: str - :ivar resource: Resource on which the operation is performed such as invoice and billing - subscription. - :vartype resource: str - :ivar operation: Operation type such as read, write and delete. - :vartype operation: str - :ivar description: Description of operation. - :vartype description: str - """ - - _validation = { - 'provider': {'readonly': True}, - 'resource': {'readonly': True}, - 'operation': {'readonly': True}, - 'description': {'readonly': True}, - } - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - self.description = None - - -class OperationListResult(msrest.serialization.Model): - """The list of billing operations and a URL link to get the next set of results. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of billing operations supported by the Microsoft.Billing resource - provider. - :vartype value: list[~azure.mgmt.billing.models.Operation] - :ivar next_link: URL to get the next set of operation list results if there are any. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class Participants(msrest.serialization.Model): - """The details about a participant. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar status: The acceptance status of the participant. - :vartype status: str - :ivar status_date: The date when the status got changed. - :vartype status_date: ~datetime.datetime - :ivar email: The email address of the participant. - :vartype email: str - """ - - _validation = { - 'status': {'readonly': True}, - 'status_date': {'readonly': True}, - 'email': {'readonly': True}, - } - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'status_date': {'key': 'statusDate', 'type': 'iso-8601'}, - 'email': {'key': 'email', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Participants, self).__init__(**kwargs) - self.status = None - self.status_date = None - self.email = None - - -class PaymentProperties(msrest.serialization.Model): - """The properties of a payment. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar payment_type: The type of payment. - :vartype payment_type: str - :ivar amount: The paid amount. - :vartype amount: ~azure.mgmt.billing.models.Amount - :ivar date: The date when the payment was made. - :vartype date: ~datetime.datetime - :param payment_method_family: The family of payment method. Possible values include: "Credits", - "CheckWire", "CreditCard", "None". - :type payment_method_family: str or ~azure.mgmt.billing.models.PaymentMethodFamily - :ivar payment_method_type: The type of payment method. - :vartype payment_method_type: str - """ - - _validation = { - 'payment_type': {'readonly': True}, - 'amount': {'readonly': True}, - 'date': {'readonly': True}, - 'payment_method_type': {'readonly': True}, - } - - _attribute_map = { - 'payment_type': {'key': 'paymentType', 'type': 'str'}, - 'amount': {'key': 'amount', 'type': 'Amount'}, - 'date': {'key': 'date', 'type': 'iso-8601'}, - 'payment_method_family': {'key': 'paymentMethodFamily', 'type': 'str'}, - 'payment_method_type': {'key': 'paymentMethodType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PaymentProperties, self).__init__(**kwargs) - self.payment_type = None - self.amount = None - self.date = None - self.payment_method_family = kwargs.get('payment_method_family', None) - self.payment_method_type = None - - -class Policy(Resource): - """A policy. - - 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 - :param marketplace_purchases: The policy that controls whether Azure marketplace purchases are - allowed for a billing profile. Possible values include: "AllAllowed", "OnlyFreeAllowed", - "NotAllowed". - :type marketplace_purchases: str or ~azure.mgmt.billing.models.MarketplacePurchasesPolicy - :param reservation_purchases: The policy that controls whether Azure reservation purchases are - allowed for a billing profile. Possible values include: "Allowed", "NotAllowed". - :type reservation_purchases: str or ~azure.mgmt.billing.models.ReservationPurchasesPolicy - :param view_charges: The policy that controls whether users with Azure RBAC access to a - subscription can view its charges. Possible values include: "Allowed", "NotAllowed". - :type view_charges: str or ~azure.mgmt.billing.models.ViewChargesPolicy - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'marketplace_purchases': {'key': 'properties.marketplacePurchases', 'type': 'str'}, - 'reservation_purchases': {'key': 'properties.reservationPurchases', 'type': 'str'}, - 'view_charges': {'key': 'properties.viewCharges', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Policy, self).__init__(**kwargs) - self.marketplace_purchases = kwargs.get('marketplace_purchases', None) - self.reservation_purchases = kwargs.get('reservation_purchases', None) - self.view_charges = kwargs.get('view_charges', None) - - -class Product(Resource): - """A product. - - 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 - :param auto_renew: Indicates whether auto renewal is turned on or off for a product. Possible - values include: "Off", "On". - :type auto_renew: str or ~azure.mgmt.billing.models.AutoRenew - :ivar display_name: The display name of the product. - :vartype display_name: str - :ivar purchase_date: The date when the product was purchased. - :vartype purchase_date: ~datetime.datetime - :ivar product_type_id: The ID of the type of product. - :vartype product_type_id: str - :ivar product_type: The description of the type of product. - :vartype product_type: str - :param status: The current status of the product. Possible values include: "Active", - "Inactive", "PastDue", "Expiring", "Expired", "Disabled", "Cancelled", "AutoRenew". - :type status: str or ~azure.mgmt.billing.models.ProductStatusType - :ivar end_date: The date when the product will be renewed or canceled. - :vartype end_date: ~datetime.datetime - :param billing_frequency: The frequency at which the product will be billed. Possible values - include: "OneTime", "Monthly", "UsageBased". - :type billing_frequency: str or ~azure.mgmt.billing.models.BillingFrequency - :ivar last_charge: The last month charges. - :vartype last_charge: ~azure.mgmt.billing.models.Amount - :ivar last_charge_date: The date of the last charge. - :vartype last_charge_date: ~datetime.datetime - :ivar quantity: The quantity purchased for the product. - :vartype quantity: float - :ivar sku_id: The sku ID of the product. - :vartype sku_id: str - :ivar sku_description: The sku description of the product. - :vartype sku_description: str - :ivar tenant_id: The id of the tenant in which the product is used. - :vartype tenant_id: str - :ivar availability_id: The availability of the product. - :vartype availability_id: str - :ivar invoice_section_id: The ID of the invoice section to which the product is billed. - :vartype invoice_section_id: str - :ivar invoice_section_display_name: The name of the invoice section to which the product is - billed. - :vartype invoice_section_display_name: str - :ivar billing_profile_id: The ID of the billing profile to which the product is billed. - :vartype billing_profile_id: str - :ivar billing_profile_display_name: The name of the billing profile to which the product is - billed. - :vartype billing_profile_display_name: str - :ivar customer_id: The ID of the customer for whom the product was purchased. The field is - applicable only for Microsoft Partner Agreement billing account. - :vartype customer_id: str - :ivar customer_display_name: The name of the customer for whom the product was purchased. The - field is applicable only for Microsoft Partner Agreement billing account. - :vartype customer_display_name: str - :ivar reseller: Reseller for this product. - :vartype reseller: ~azure.mgmt.billing.models.Reseller - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'display_name': {'readonly': True}, - 'purchase_date': {'readonly': True}, - 'product_type_id': {'readonly': True}, - 'product_type': {'readonly': True}, - 'end_date': {'readonly': True}, - 'last_charge': {'readonly': True}, - 'last_charge_date': {'readonly': True}, - 'quantity': {'readonly': True}, - 'sku_id': {'readonly': True}, - 'sku_description': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'availability_id': {'readonly': True}, - 'invoice_section_id': {'readonly': True}, - 'invoice_section_display_name': {'readonly': True}, - 'billing_profile_id': {'readonly': True}, - 'billing_profile_display_name': {'readonly': True}, - 'customer_id': {'readonly': True}, - 'customer_display_name': {'readonly': True}, - 'reseller': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'auto_renew': {'key': 'properties.autoRenew', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'purchase_date': {'key': 'properties.purchaseDate', 'type': 'iso-8601'}, - 'product_type_id': {'key': 'properties.productTypeId', 'type': 'str'}, - 'product_type': {'key': 'properties.productType', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'end_date': {'key': 'properties.endDate', 'type': 'iso-8601'}, - 'billing_frequency': {'key': 'properties.billingFrequency', 'type': 'str'}, - 'last_charge': {'key': 'properties.lastCharge', 'type': 'Amount'}, - 'last_charge_date': {'key': 'properties.lastChargeDate', 'type': 'iso-8601'}, - 'quantity': {'key': 'properties.quantity', 'type': 'float'}, - 'sku_id': {'key': 'properties.skuId', 'type': 'str'}, - 'sku_description': {'key': 'properties.skuDescription', 'type': 'str'}, - 'tenant_id': {'key': 'properties.tenantId', 'type': 'str'}, - 'availability_id': {'key': 'properties.availabilityId', 'type': 'str'}, - 'invoice_section_id': {'key': 'properties.invoiceSectionId', 'type': 'str'}, - 'invoice_section_display_name': {'key': 'properties.invoiceSectionDisplayName', 'type': 'str'}, - 'billing_profile_id': {'key': 'properties.billingProfileId', 'type': 'str'}, - 'billing_profile_display_name': {'key': 'properties.billingProfileDisplayName', 'type': 'str'}, - 'customer_id': {'key': 'properties.customerId', 'type': 'str'}, - 'customer_display_name': {'key': 'properties.customerDisplayName', 'type': 'str'}, - 'reseller': {'key': 'properties.reseller', 'type': 'Reseller'}, - } - - def __init__( - self, - **kwargs - ): - super(Product, self).__init__(**kwargs) - self.auto_renew = kwargs.get('auto_renew', None) - self.display_name = None - self.purchase_date = None - self.product_type_id = None - self.product_type = None - self.status = kwargs.get('status', None) - self.end_date = None - self.billing_frequency = kwargs.get('billing_frequency', None) - self.last_charge = None - self.last_charge_date = None - self.quantity = None - self.sku_id = None - self.sku_description = None - self.tenant_id = None - self.availability_id = None - self.invoice_section_id = None - self.invoice_section_display_name = None - self.billing_profile_id = None - self.billing_profile_display_name = None - self.customer_id = None - self.customer_display_name = None - self.reseller = None - - -class ProductsListResult(msrest.serialization.Model): - """The list of products. It contains a list of available product summaries in reverse chronological order by purchase date. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of products. - :vartype value: list[~azure.mgmt.billing.models.Product] - :ivar next_link: The link (url) to the next page of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Product]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ProductsListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class RebillDetails(msrest.serialization.Model): - """The rebill details of an invoice. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar credit_note_document_id: The ID of credit note. - :vartype credit_note_document_id: str - :ivar invoice_document_id: The ID of invoice. - :vartype invoice_document_id: str - :ivar rebill_details: Rebill details for an invoice. - :vartype rebill_details: dict[str, ~azure.mgmt.billing.models.RebillDetails] - """ - - _validation = { - 'credit_note_document_id': {'readonly': True}, - 'invoice_document_id': {'readonly': True}, - 'rebill_details': {'readonly': True}, - } - - _attribute_map = { - 'credit_note_document_id': {'key': 'creditNoteDocumentId', 'type': 'str'}, - 'invoice_document_id': {'key': 'invoiceDocumentId', 'type': 'str'}, - 'rebill_details': {'key': 'rebillDetails', 'type': '{RebillDetails}'}, - } - - def __init__( - self, - **kwargs - ): - super(RebillDetails, self).__init__(**kwargs) - self.credit_note_document_id = None - self.invoice_document_id = None - self.rebill_details = None - - -class Reseller(msrest.serialization.Model): - """Details of the reseller. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar reseller_id: The MPN ID of the reseller. - :vartype reseller_id: str - :ivar description: The name of the reseller. - :vartype description: str - """ - - _validation = { - 'reseller_id': {'readonly': True}, - 'description': {'readonly': True}, - } - - _attribute_map = { - 'reseller_id': {'key': 'resellerId', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Reseller, self).__init__(**kwargs) - self.reseller_id = None - self.description = None - - -class Reservation(msrest.serialization.Model): - """The definition of the reservation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The id of the reservation. - :vartype id: str - :ivar name: The name of the reservation. - :vartype name: str - :ivar type: The type of the reservation. - :vartype type: str - :ivar location: The location of the reservation. - :vartype location: str - :param sku: The sku information associated to this reservation. - :type sku: ~azure.mgmt.billing.models.ReservationSkuProperty - :param applied_scopes: The array of applied scopes of a reservation. Will be null if the - reservation is in Shared scope. - :type applied_scopes: list[str] - :ivar applied_scope_type: The applied scope type of the reservation. - :vartype applied_scope_type: str - :ivar reserved_resource_type: The reserved source type of the reservation, e.g. virtual - machine. - :vartype reserved_resource_type: str - :ivar quantity: The number of the reservation. - :vartype quantity: float - :ivar provisioning_state: The provisioning state of the reservation, e.g. Succeeded. - :vartype provisioning_state: str - :ivar expiry_date: The expiry date of the reservation. - :vartype expiry_date: str - :ivar provisioning_sub_state: The provisioning state of the reservation, e.g. Succeeded. - :vartype provisioning_sub_state: str - :ivar display_name: The display name of the reservation. - :vartype display_name: str - :ivar display_provisioning_state: The provisioning state of the reservation for display, e.g. - Succeeded. - :vartype display_provisioning_state: str - :ivar user_friendly_renew_state: The renew state of the reservation for display, e.g. On. - :vartype user_friendly_renew_state: str - :ivar user_friendly_applied_scope_type: The applied scope type of the reservation for display, - e.g. Shared. - :vartype user_friendly_applied_scope_type: str - :ivar effective_date_time: The effective date time of the reservation. - :vartype effective_date_time: str - :ivar sku_description: The sku description of the reservation. - :vartype sku_description: str - :ivar term: The term of the reservation, e.g. P1Y. - :vartype term: str - :ivar renew: The renew state of the reservation. - :vartype renew: bool - :ivar renew_source: The renew source of the reservation. - :vartype renew_source: str - :ivar utilization: Reservation utilization. - :vartype utilization: ~azure.mgmt.billing.models.ReservationPropertyUtilization - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'readonly': True}, - 'applied_scope_type': {'readonly': True}, - 'reserved_resource_type': {'readonly': True}, - 'quantity': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'expiry_date': {'readonly': True}, - 'provisioning_sub_state': {'readonly': True}, - 'display_name': {'readonly': True}, - 'display_provisioning_state': {'readonly': True}, - 'user_friendly_renew_state': {'readonly': True}, - 'user_friendly_applied_scope_type': {'readonly': True}, - 'effective_date_time': {'readonly': True}, - 'sku_description': {'readonly': True}, - 'term': {'readonly': True}, - 'renew': {'readonly': True}, - 'renew_source': {'readonly': True}, - 'utilization': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'ReservationSkuProperty'}, - 'applied_scopes': {'key': 'properties.appliedScopes', 'type': '[str]'}, - 'applied_scope_type': {'key': 'properties.appliedScopeType', 'type': 'str'}, - 'reserved_resource_type': {'key': 'properties.reservedResourceType', 'type': 'str'}, - 'quantity': {'key': 'properties.quantity', 'type': 'float'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'expiry_date': {'key': 'properties.expiryDate', 'type': 'str'}, - 'provisioning_sub_state': {'key': 'properties.provisioningSubState', 'type': 'str'}, - 'display_name': {'key': 'properties.displayName', 'type': 'str'}, - 'display_provisioning_state': {'key': 'properties.displayProvisioningState', 'type': 'str'}, - 'user_friendly_renew_state': {'key': 'properties.userFriendlyRenewState', 'type': 'str'}, - 'user_friendly_applied_scope_type': {'key': 'properties.userFriendlyAppliedScopeType', 'type': 'str'}, - 'effective_date_time': {'key': 'properties.effectiveDateTime', 'type': 'str'}, - 'sku_description': {'key': 'properties.skuDescription', 'type': 'str'}, - 'term': {'key': 'properties.term', 'type': 'str'}, - 'renew': {'key': 'properties.renew', 'type': 'bool'}, - 'renew_source': {'key': 'properties.renewSource', 'type': 'str'}, - 'utilization': {'key': 'properties.utilization', 'type': 'ReservationPropertyUtilization'}, - } - - def __init__( - self, - **kwargs - ): - super(Reservation, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = None - self.sku = kwargs.get('sku', None) - self.applied_scopes = kwargs.get('applied_scopes', None) - self.applied_scope_type = None - self.reserved_resource_type = None - self.quantity = None - self.provisioning_state = None - self.expiry_date = None - self.provisioning_sub_state = None - self.display_name = None - self.display_provisioning_state = None - self.user_friendly_renew_state = None - self.user_friendly_applied_scope_type = None - self.effective_date_time = None - self.sku_description = None - self.term = None - self.renew = None - self.renew_source = None - self.utilization = None - - -class ReservationPropertyUtilization(msrest.serialization.Model): - """Reservation utilization. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar trend: The number of days trend for a reservation. - :vartype trend: str - :param aggregates: The array of aggregates of a reservation's utilization. - :type aggregates: list[~azure.mgmt.billing.models.ReservationUtilizationAggregates] - """ - - _validation = { - 'trend': {'readonly': True}, - } - - _attribute_map = { - 'trend': {'key': 'trend', 'type': 'str'}, - 'aggregates': {'key': 'aggregates', 'type': '[ReservationUtilizationAggregates]'}, - } - - def __init__( - self, - **kwargs - ): - super(ReservationPropertyUtilization, self).__init__(**kwargs) - self.trend = None - self.aggregates = kwargs.get('aggregates', None) - - -class ReservationSkuProperty(msrest.serialization.Model): - """The property of reservation sku object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The name of the reservation sku. - :vartype name: str - """ - - _validation = { - 'name': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ReservationSkuProperty, self).__init__(**kwargs) - self.name = None - - -class ReservationsListResult(msrest.serialization.Model): - """The list of reservations and summary of roll out count of reservations in each state. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of reservations. - :vartype value: list[~azure.mgmt.billing.models.Reservation] - :ivar next_link: The link (url) to the next page of results. - :vartype next_link: str - :param summary: The roll out count summary of the reservations. - :type summary: ~azure.mgmt.billing.models.ReservationSummary - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Reservation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'summary': {'key': 'summary', 'type': 'ReservationSummary'}, - } - - def __init__( - self, - **kwargs - ): - super(ReservationsListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - self.summary = kwargs.get('summary', None) - - -class ReservationSummary(msrest.serialization.Model): - """The roll up count summary of reservations in each state. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar succeeded_count: The number of reservation in Succeeded state. - :vartype succeeded_count: float - :ivar failed_count: The number of reservation in Failed state. - :vartype failed_count: float - :ivar expiring_count: The number of reservation in Expiring state. - :vartype expiring_count: float - :ivar expired_count: The number of reservation in Expired state. - :vartype expired_count: float - :ivar pending_count: The number of reservation in Pending state. - :vartype pending_count: float - :ivar cancelled_count: The number of reservation in Cancelled state. - :vartype cancelled_count: float - """ - - _validation = { - 'succeeded_count': {'readonly': True}, - 'failed_count': {'readonly': True}, - 'expiring_count': {'readonly': True}, - 'expired_count': {'readonly': True}, - 'pending_count': {'readonly': True}, - 'cancelled_count': {'readonly': True}, - } - - _attribute_map = { - 'succeeded_count': {'key': 'succeededCount', 'type': 'float'}, - 'failed_count': {'key': 'failedCount', 'type': 'float'}, - 'expiring_count': {'key': 'expiringCount', 'type': 'float'}, - 'expired_count': {'key': 'expiredCount', 'type': 'float'}, - 'pending_count': {'key': 'pendingCount', 'type': 'float'}, - 'cancelled_count': {'key': 'cancelledCount', 'type': 'float'}, - } - - def __init__( - self, - **kwargs - ): - super(ReservationSummary, self).__init__(**kwargs) - self.succeeded_count = None - self.failed_count = None - self.expiring_count = None - self.expired_count = None - self.pending_count = None - self.cancelled_count = None - - -class ReservationUtilizationAggregates(msrest.serialization.Model): - """The aggregate values of reservation utilization. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar grain: The grain of the aggregate. - :vartype grain: float - :ivar grain_unit: The grain unit of the aggregate. - :vartype grain_unit: str - :ivar value: The aggregate value. - :vartype value: float - :ivar value_unit: The aggregate value unit. - :vartype value_unit: str - """ - - _validation = { - 'grain': {'readonly': True}, - 'grain_unit': {'readonly': True}, - 'value': {'readonly': True}, - 'value_unit': {'readonly': True}, - } - - _attribute_map = { - 'grain': {'key': 'grain', 'type': 'float'}, - 'grain_unit': {'key': 'grainUnit', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'float'}, - 'value_unit': {'key': 'valueUnit', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ReservationUtilizationAggregates, self).__init__(**kwargs) - self.grain = None - self.grain_unit = None - self.value = None - self.value_unit = None - - -class Transaction(Resource): - """A transaction. - - 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 - :param kind: The kind of transaction. Options are all or reservation. Possible values include: - "all", "reservation". - :type kind: str or ~azure.mgmt.billing.models.TransactionTypeKind - :ivar date: The date of transaction. - :vartype date: ~datetime.datetime - :ivar invoice: Invoice on which the transaction was billed or 'pending' if the transaction is - not billed. - :vartype invoice: str - :ivar invoice_id: The ID of the invoice on which the transaction was billed. This field is only - applicable for transactions which are billed. - :vartype invoice_id: str - :ivar order_id: The order ID of the reservation. The field is only applicable for transaction - of kind reservation. - :vartype order_id: str - :ivar order_name: The name of the reservation order. The field is only applicable for - transactions of kind reservation. - :vartype order_name: str - :ivar product_family: The family of the product for which the transaction took place. - :vartype product_family: str - :ivar product_type_id: The ID of the product type for which the transaction took place. - :vartype product_type_id: str - :ivar product_type: The type of the product for which the transaction took place. - :vartype product_type: str - :ivar product_description: The description of the product for which the transaction took place. - :vartype product_description: str - :param transaction_type: The type of transaction. Possible values include: "Purchase", "Usage - Charge". - :type transaction_type: str or ~azure.mgmt.billing.models.ReservationType - :ivar transaction_amount: The charge associated with the transaction. - :vartype transaction_amount: ~azure.mgmt.billing.models.Amount - :ivar quantity: The quantity purchased in the transaction. - :vartype quantity: int - :ivar invoice_section_id: The ID of the invoice section which will be billed for the - transaction. - :vartype invoice_section_id: str - :ivar invoice_section_display_name: The name of the invoice section which will be billed for - the transaction. - :vartype invoice_section_display_name: str - :ivar billing_profile_id: The ID of the billing profile which will be billed for the - transaction. - :vartype billing_profile_id: str - :ivar billing_profile_display_name: The name of the billing profile which will be billed for - the transaction. - :vartype billing_profile_display_name: str - :ivar customer_id: The ID of the customer for which the transaction took place. The field is - applicable only for Microsoft Partner Agreement billing account. - :vartype customer_id: str - :ivar customer_display_name: The name of the customer for which the transaction took place. The - field is applicable only for Microsoft Partner Agreement billing account. - :vartype customer_display_name: str - :ivar subscription_id: The ID of the subscription that was used for the transaction. The field - is only applicable for transaction of kind reservation. - :vartype subscription_id: str - :ivar subscription_name: The name of the subscription that was used for the transaction. The - field is only applicable for transaction of kind reservation. - :vartype subscription_name: str - :ivar azure_plan: The type of azure plan of the subscription that was used for the transaction. - :vartype azure_plan: str - :ivar azure_credit_applied: The amount of any Azure credits automatically applied to this - transaction. - :vartype azure_credit_applied: ~azure.mgmt.billing.models.Amount - :ivar billing_currency: The ISO 4217 code for the currency in which this transaction is billed. - :vartype billing_currency: str - :ivar discount: The percentage discount, if any, applied to this transaction. - :vartype discount: float - :ivar effective_price: The price of the product after applying any discounts. - :vartype effective_price: ~azure.mgmt.billing.models.Amount - :ivar exchange_rate: The exchange rate used to convert charged amount to billing currency, if - applicable. - :vartype exchange_rate: float - :ivar market_price: The retail price of the product. - :vartype market_price: ~azure.mgmt.billing.models.Amount - :ivar pricing_currency: The ISO 4217 code for the currency in which the product is priced. - :vartype pricing_currency: str - :ivar service_period_start_date: The date of the purchase of the product, or the start date of - the month in which usage started. - :vartype service_period_start_date: ~datetime.datetime - :ivar service_period_end_date: The end date of the product term, or the end date of the month - in which usage ended. - :vartype service_period_end_date: ~datetime.datetime - :ivar sub_total: The pre-tax charged amount for the transaction. - :vartype sub_total: ~azure.mgmt.billing.models.Amount - :ivar tax: The tax amount applied to the transaction. - :vartype tax: ~azure.mgmt.billing.models.Amount - :ivar unit_of_measure: The unit of measure used to bill for the product. For example, compute - services are billed per hour. - :vartype unit_of_measure: str - :ivar units: The number of units used for a given product. - :vartype units: float - :ivar unit_type: The description for the unit of measure for a given product. - :vartype unit_type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'date': {'readonly': True}, - 'invoice': {'readonly': True}, - 'invoice_id': {'readonly': True}, - 'order_id': {'readonly': True}, - 'order_name': {'readonly': True}, - 'product_family': {'readonly': True}, - 'product_type_id': {'readonly': True}, - 'product_type': {'readonly': True}, - 'product_description': {'readonly': True}, - 'transaction_amount': {'readonly': True}, - 'quantity': {'readonly': True}, - 'invoice_section_id': {'readonly': True}, - 'invoice_section_display_name': {'readonly': True}, - 'billing_profile_id': {'readonly': True}, - 'billing_profile_display_name': {'readonly': True}, - 'customer_id': {'readonly': True}, - 'customer_display_name': {'readonly': True}, - 'subscription_id': {'readonly': True}, - 'subscription_name': {'readonly': True}, - 'azure_plan': {'readonly': True}, - 'azure_credit_applied': {'readonly': True}, - 'billing_currency': {'readonly': True}, - 'discount': {'readonly': True}, - 'effective_price': {'readonly': True}, - 'exchange_rate': {'readonly': True}, - 'market_price': {'readonly': True}, - 'pricing_currency': {'readonly': True}, - 'service_period_start_date': {'readonly': True}, - 'service_period_end_date': {'readonly': True}, - 'sub_total': {'readonly': True}, - 'tax': {'readonly': True}, - 'unit_of_measure': {'readonly': True}, - 'units': {'readonly': True}, - 'unit_type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'kind': {'key': 'properties.kind', 'type': 'str'}, - 'date': {'key': 'properties.date', 'type': 'iso-8601'}, - 'invoice': {'key': 'properties.invoice', 'type': 'str'}, - 'invoice_id': {'key': 'properties.invoiceId', 'type': 'str'}, - 'order_id': {'key': 'properties.orderId', 'type': 'str'}, - 'order_name': {'key': 'properties.orderName', 'type': 'str'}, - 'product_family': {'key': 'properties.productFamily', 'type': 'str'}, - 'product_type_id': {'key': 'properties.productTypeId', 'type': 'str'}, - 'product_type': {'key': 'properties.productType', 'type': 'str'}, - 'product_description': {'key': 'properties.productDescription', 'type': 'str'}, - 'transaction_type': {'key': 'properties.transactionType', 'type': 'str'}, - 'transaction_amount': {'key': 'properties.transactionAmount', 'type': 'Amount'}, - 'quantity': {'key': 'properties.quantity', 'type': 'int'}, - 'invoice_section_id': {'key': 'properties.invoiceSectionId', 'type': 'str'}, - 'invoice_section_display_name': {'key': 'properties.invoiceSectionDisplayName', 'type': 'str'}, - 'billing_profile_id': {'key': 'properties.billingProfileId', 'type': 'str'}, - 'billing_profile_display_name': {'key': 'properties.billingProfileDisplayName', 'type': 'str'}, - 'customer_id': {'key': 'properties.customerId', 'type': 'str'}, - 'customer_display_name': {'key': 'properties.customerDisplayName', 'type': 'str'}, - 'subscription_id': {'key': 'properties.subscriptionId', 'type': 'str'}, - 'subscription_name': {'key': 'properties.subscriptionName', 'type': 'str'}, - 'azure_plan': {'key': 'properties.azurePlan', 'type': 'str'}, - 'azure_credit_applied': {'key': 'properties.azureCreditApplied', 'type': 'Amount'}, - 'billing_currency': {'key': 'properties.billingCurrency', 'type': 'str'}, - 'discount': {'key': 'properties.discount', 'type': 'float'}, - 'effective_price': {'key': 'properties.effectivePrice', 'type': 'Amount'}, - 'exchange_rate': {'key': 'properties.exchangeRate', 'type': 'float'}, - 'market_price': {'key': 'properties.marketPrice', 'type': 'Amount'}, - 'pricing_currency': {'key': 'properties.pricingCurrency', 'type': 'str'}, - 'service_period_start_date': {'key': 'properties.servicePeriodStartDate', 'type': 'iso-8601'}, - 'service_period_end_date': {'key': 'properties.servicePeriodEndDate', 'type': 'iso-8601'}, - 'sub_total': {'key': 'properties.subTotal', 'type': 'Amount'}, - 'tax': {'key': 'properties.tax', 'type': 'Amount'}, - 'unit_of_measure': {'key': 'properties.unitOfMeasure', 'type': 'str'}, - 'units': {'key': 'properties.units', 'type': 'float'}, - 'unit_type': {'key': 'properties.unitType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Transaction, self).__init__(**kwargs) - self.kind = kwargs.get('kind', None) - self.date = None - self.invoice = None - self.invoice_id = None - self.order_id = None - self.order_name = None - self.product_family = None - self.product_type_id = None - self.product_type = None - self.product_description = None - self.transaction_type = kwargs.get('transaction_type', None) - self.transaction_amount = None - self.quantity = None - self.invoice_section_id = None - self.invoice_section_display_name = None - self.billing_profile_id = None - self.billing_profile_display_name = None - self.customer_id = None - self.customer_display_name = None - self.subscription_id = None - self.subscription_name = None - self.azure_plan = None - self.azure_credit_applied = None - self.billing_currency = None - self.discount = None - self.effective_price = None - self.exchange_rate = None - self.market_price = None - self.pricing_currency = None - self.service_period_start_date = None - self.service_period_end_date = None - self.sub_total = None - self.tax = None - self.unit_of_measure = None - self.units = None - self.unit_type = None - - -class TransactionListResult(msrest.serialization.Model): - """The list of transactions. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar value: The list of transactions. - :vartype value: list[~azure.mgmt.billing.models.Transaction] - :ivar next_link: The link (url) to the next page of results. - :vartype next_link: str - """ - - _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Transaction]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TransactionListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class TransferBillingSubscriptionRequestProperties(msrest.serialization.Model): - """Request parameters to transfer billing subscription. - - All required parameters must be populated in order to send to Azure. - - :param destination_invoice_section_id: Required. The destination invoice section id. - :type destination_invoice_section_id: str - """ - - _validation = { - 'destination_invoice_section_id': {'required': True}, - } - - _attribute_map = { - 'destination_invoice_section_id': {'key': 'destinationInvoiceSectionId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TransferBillingSubscriptionRequestProperties, self).__init__(**kwargs) - self.destination_invoice_section_id = kwargs['destination_invoice_section_id'] - - -class TransferProductRequestProperties(msrest.serialization.Model): - """The properties of the product to initiate a transfer. - - :param destination_invoice_section_id: The destination invoice section id. - :type destination_invoice_section_id: str - """ - - _attribute_map = { - 'destination_invoice_section_id': {'key': 'destinationInvoiceSectionId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TransferProductRequestProperties, self).__init__(**kwargs) - self.destination_invoice_section_id = kwargs.get('destination_invoice_section_id', None) - - -class ValidateAddressResponse(msrest.serialization.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: The list of suggested addresses. - :type suggested_addresses: list[~azure.mgmt.billing.models.AddressDetails] - :param validation_message: Validation error message. - :type validation_message: str - """ - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'suggested_addresses': {'key': 'suggestedAddresses', 'type': '[AddressDetails]'}, - '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) - - -class ValidateProductTransferEligibilityError(msrest.serialization.Model): - """Error details of the product transfer eligibility validation. - - :param code: Error code for the product transfer validation. Possible values include: - "InvalidSource", "ProductNotActive", "InsufficientPermissionOnSource", - "InsufficientPermissionOnDestination", "DestinationBillingProfilePastDue", - "ProductTypeNotSupported", "CrossBillingAccountNotAllowed", "NotAvailableForDestinationMarket", - "OneTimePurchaseProductTransferNotAllowed". - :type code: str or ~azure.mgmt.billing.models.ProductTransferValidationErrorCode - :param message: The error message. - :type message: str - :param details: Detailed error message explaining the error. - :type details: str - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ValidateProductTransferEligibilityError, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - self.details = kwargs.get('details', None) - - -class ValidateProductTransferEligibilityResult(msrest.serialization.Model): - """Result of the product transfer eligibility validation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar is_move_eligible: Specifies whether the transfer is eligible or not. - :vartype is_move_eligible: bool - :param error_details: Validation error details. - :type error_details: ~azure.mgmt.billing.models.ValidateProductTransferEligibilityError - """ - - _validation = { - 'is_move_eligible': {'readonly': True}, - } - - _attribute_map = { - 'is_move_eligible': {'key': 'isMoveEligible', 'type': 'bool'}, - 'error_details': {'key': 'errorDetails', 'type': 'ValidateProductTransferEligibilityError'}, - } - - def __init__( - self, - **kwargs - ): - super(ValidateProductTransferEligibilityResult, self).__init__(**kwargs) - self.is_move_eligible = None - self.error_details = kwargs.get('error_details', None) - - -class ValidateSubscriptionTransferEligibilityError(msrest.serialization.Model): - """Error details of the transfer eligibility validation. - - :param code: Error code for the product transfer validation. Possible values include: - "BillingAccountInactive", "CrossBillingAccountNotAllowed", "DestinationBillingProfileInactive", - "DestinationBillingProfileNotFound", "DestinationBillingProfilePastDue", - "DestinationInvoiceSectionInactive", "DestinationInvoiceSectionNotFound", - "InsufficientPermissionOnDestination", "InsufficientPermissionOnSource", "InvalidDestination", - "InvalidSource", "MarketplaceNotEnabledOnDestination", "NotAvailableForDestinationMarket", - "ProductInactive", "ProductNotFound", "ProductTypeNotSupported", "SourceBillingProfilePastDue", - "SourceInvoiceSectionInactive", "SubscriptionNotActive", "SubscriptionTypeNotSupported". - :type code: str or ~azure.mgmt.billing.models.SubscriptionTransferValidationErrorCode - :param message: The error message. - :type message: str - :param details: Detailed error message explaining the error. - :type details: str - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ValidateSubscriptionTransferEligibilityError, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - self.details = kwargs.get('details', None) - - -class ValidateSubscriptionTransferEligibilityResult(msrest.serialization.Model): - """Result of the transfer eligibility validation. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar is_move_eligible: Specifies whether the subscription is eligible to be transferred. - :vartype is_move_eligible: bool - :param error_details: Validation error details. - :type error_details: ~azure.mgmt.billing.models.ValidateSubscriptionTransferEligibilityError - """ - - _validation = { - 'is_move_eligible': {'readonly': True}, - } - - _attribute_map = { - 'is_move_eligible': {'key': 'isMoveEligible', 'type': 'bool'}, - 'error_details': {'key': 'errorDetails', 'type': 'ValidateSubscriptionTransferEligibilityError'}, - } - - def __init__( - self, - **kwargs - ): - super(ValidateSubscriptionTransferEligibilityResult, self).__init__(**kwargs) - self.is_move_eligible = None - self.error_details = kwargs.get('error_details', None) diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/models/_models_py3.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/models/_models_py3.py index 945556626fdb..69eba4441403 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/models/_models_py3.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/models/_models_py3.py @@ -20,34 +20,34 @@ class AddressDetails(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param first_name: First name. - :type first_name: str - :param middle_name: Middle name. - :type middle_name: str - :param last_name: Last name. - :type last_name: str - :param company_name: Company name. - :type company_name: str - :param address_line1: Required. Address line 1. - :type address_line1: str - :param address_line2: Address line 2. - :type address_line2: str - :param address_line3: Address line 3. - :type address_line3: str - :param city: Address city. - :type city: str - :param district: Address district. - :type district: str - :param region: Address region. - :type region: str - :param country: Required. Country code uses ISO2, 2-digit format. - :type country: str - :param postal_code: Postal code. - :type postal_code: str - :param email: Email address. - :type email: str - :param phone_number: Phone number. - :type phone_number: str + :ivar first_name: First name. + :vartype first_name: str + :ivar middle_name: Middle name. + :vartype middle_name: str + :ivar last_name: Last name. + :vartype last_name: str + :ivar company_name: Company name. + :vartype company_name: str + :ivar address_line1: Required. Address line 1. + :vartype address_line1: str + :ivar address_line2: Address line 2. + :vartype address_line2: str + :ivar address_line3: Address line 3. + :vartype address_line3: str + :ivar city: Address city. + :vartype city: str + :ivar district: Address district. + :vartype district: str + :ivar region: Address region. + :vartype region: str + :ivar country: Required. Country code uses ISO2, 2-digit format. + :vartype country: str + :ivar postal_code: Postal code. + :vartype postal_code: str + :ivar email: Email address. + :vartype email: str + :ivar phone_number: Phone number. + :vartype phone_number: str """ _validation = { @@ -91,6 +91,36 @@ def __init__( phone_number: Optional[str] = None, **kwargs ): + """ + :keyword first_name: First name. + :paramtype first_name: str + :keyword middle_name: Middle name. + :paramtype middle_name: str + :keyword last_name: Last name. + :paramtype last_name: str + :keyword company_name: Company name. + :paramtype company_name: str + :keyword address_line1: Required. Address line 1. + :paramtype address_line1: str + :keyword address_line2: Address line 2. + :paramtype address_line2: str + :keyword address_line3: Address line 3. + :paramtype address_line3: str + :keyword city: Address city. + :paramtype city: str + :keyword district: Address district. + :paramtype district: str + :keyword region: Address region. + :paramtype region: str + :keyword country: Required. Country code uses ISO2, 2-digit format. + :paramtype country: str + :keyword postal_code: Postal code. + :paramtype postal_code: str + :keyword email: Email address. + :paramtype email: str + :keyword phone_number: Phone number. + :paramtype phone_number: str + """ super(AddressDetails, self).__init__(**kwargs) self.first_name = first_name self.middle_name = middle_name @@ -137,6 +167,8 @@ def __init__( self, **kwargs ): + """ + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -162,12 +194,15 @@ class Agreement(Resource): :ivar acceptance_mode: The mode of acceptance for an agreement. Possible values include: "ClickToAccept", "ESignEmbedded", "ESignOffline". :vartype acceptance_mode: str or ~azure.mgmt.billing.models.AcceptanceMode + :ivar billing_profiles_info: The list of billing profiles associated with agreement and present + only for specific agreements. + :vartype billing_profiles_info: list[~azure.mgmt.billing.models.BillingProfileInfo] :ivar effective_date: The date from which the agreement is effective. :vartype effective_date: ~datetime.datetime :ivar expiration_date: The date when the agreement expires. :vartype expiration_date: ~datetime.datetime - :param participants: The list of participants that participates in acceptance of an agreement. - :type participants: list[~azure.mgmt.billing.models.Participants] + :ivar participants: The list of participants that participates in acceptance of an agreement. + :vartype participants: list[~azure.mgmt.billing.models.Participants] :ivar status: The current status of the agreement. :vartype status: str """ @@ -179,6 +214,7 @@ class Agreement(Resource): 'agreement_link': {'readonly': True}, 'category': {'readonly': True}, 'acceptance_mode': {'readonly': True}, + 'billing_profiles_info': {'readonly': True}, 'effective_date': {'readonly': True}, 'expiration_date': {'readonly': True}, 'status': {'readonly': True}, @@ -191,6 +227,7 @@ class Agreement(Resource): 'agreement_link': {'key': 'properties.agreementLink', 'type': 'str'}, 'category': {'key': 'properties.category', 'type': 'str'}, 'acceptance_mode': {'key': 'properties.acceptanceMode', 'type': 'str'}, + 'billing_profiles_info': {'key': 'properties.billingProfilesInfo', 'type': '[BillingProfileInfo]'}, 'effective_date': {'key': 'properties.effectiveDate', 'type': 'iso-8601'}, 'expiration_date': {'key': 'properties.expirationDate', 'type': 'iso-8601'}, 'participants': {'key': 'properties.participants', 'type': '[Participants]'}, @@ -203,10 +240,16 @@ def __init__( participants: Optional[List["Participants"]] = None, **kwargs ): + """ + :keyword participants: The list of participants that participates in acceptance of an + agreement. + :paramtype participants: list[~azure.mgmt.billing.models.Participants] + """ super(Agreement, self).__init__(**kwargs) self.agreement_link = None self.category = None self.acceptance_mode = None + self.billing_profiles_info = None self.effective_date = None self.expiration_date = None self.participants = participants @@ -238,6 +281,8 @@ def __init__( self, **kwargs ): + """ + """ super(AgreementListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -250,8 +295,8 @@ class Amount(msrest.serialization.Model): :ivar currency: The currency for the amount value. :vartype currency: str - :param value: Amount value. - :type value: float + :ivar value: Amount value. + :vartype value: float """ _validation = { @@ -269,6 +314,10 @@ def __init__( value: Optional[float] = None, **kwargs ): + """ + :keyword value: Amount value. + :paramtype value: float + """ super(Amount, self).__init__(**kwargs) self.currency = None self.value = value @@ -307,6 +356,8 @@ def __init__( self, **kwargs ): + """ + """ super(AvailableBalance, self).__init__(**kwargs) self.amount = None @@ -316,8 +367,8 @@ class AzurePlan(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param sku_id: The sku id. - :type sku_id: str + :ivar sku_id: The sku id. + :vartype sku_id: str :ivar sku_description: The sku description. :vartype sku_description: str """ @@ -337,6 +388,10 @@ def __init__( sku_id: Optional[str] = None, **kwargs ): + """ + :keyword sku_id: The sku id. + :paramtype sku_id: str + """ super(AzurePlan, self).__init__(**kwargs) self.sku_id = sku_id self.sku_description = None @@ -353,11 +408,11 @@ class BillingAccount(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param display_name: The billing account name. - :type display_name: str - :param sold_to: The address of the individual or organization that is responsible for the + :ivar display_name: The billing account name. + :vartype display_name: str + :ivar sold_to: The address of the individual or organization that is responsible for the billing account. - :type sold_to: ~azure.mgmt.billing.models.AddressDetails + :vartype sold_to: ~azure.mgmt.billing.models.AddressDetails :ivar agreement_type: The type of agreement. Possible values include: "MicrosoftCustomerAgreement", "EnterpriseAgreement", "MicrosoftOnlineServicesProgram", "MicrosoftPartnerAgreement". @@ -368,20 +423,20 @@ class BillingAccount(Resource): :ivar account_status: The current status of the billing account. Possible values include: "Active", "Deleted", "Disabled", "Expired", "Transferred", "Extended", "Terminated". :vartype account_status: str or ~azure.mgmt.billing.models.AccountStatus - :param billing_profiles: The billing profiles associated with the billing account. By default + :ivar billing_profiles: The billing profiles associated with the billing account. By default this is not populated, unless it's specified in $expand. - :type billing_profiles: ~azure.mgmt.billing.models.BillingProfilesOnExpand + :vartype billing_profiles: ~azure.mgmt.billing.models.BillingProfilesOnExpand :ivar enrollment_details: The details about the associated legacy enrollment. By default this is not populated, unless it's specified in $expand. :vartype enrollment_details: ~azure.mgmt.billing.models.Enrollment - :param departments: The departments associated to the enrollment. - :type departments: list[~azure.mgmt.billing.models.Department] - :param enrollment_accounts: The accounts associated to the enrollment. - :type enrollment_accounts: list[~azure.mgmt.billing.models.EnrollmentAccount] + :ivar departments: The departments associated to the enrollment. + :vartype departments: list[~azure.mgmt.billing.models.Department] + :ivar enrollment_accounts: The accounts associated to the enrollment. + :vartype enrollment_accounts: list[~azure.mgmt.billing.models.EnrollmentAccount] :ivar has_read_access: Indicates whether user has read access to the billing account. :vartype has_read_access: bool - :param notification_email_address: Notification email address, only for legacy accounts. - :type notification_email_address: str + :ivar notification_email_address: Notification email address, only for legacy accounts. + :vartype notification_email_address: str """ _validation = { @@ -423,6 +478,22 @@ def __init__( notification_email_address: Optional[str] = None, **kwargs ): + """ + :keyword display_name: The billing account name. + :paramtype display_name: str + :keyword sold_to: The address of the individual or organization that is responsible for the + billing account. + :paramtype sold_to: ~azure.mgmt.billing.models.AddressDetails + :keyword billing_profiles: The billing profiles associated with the billing account. By default + this is not populated, unless it's specified in $expand. + :paramtype billing_profiles: ~azure.mgmt.billing.models.BillingProfilesOnExpand + :keyword departments: The departments associated to the enrollment. + :paramtype departments: list[~azure.mgmt.billing.models.Department] + :keyword enrollment_accounts: The accounts associated to the enrollment. + :paramtype enrollment_accounts: list[~azure.mgmt.billing.models.EnrollmentAccount] + :keyword notification_email_address: Notification email address, only for legacy accounts. + :paramtype notification_email_address: str + """ super(BillingAccount, self).__init__(**kwargs) self.display_name = display_name self.sold_to = sold_to @@ -462,6 +533,8 @@ def __init__( self, **kwargs ): + """ + """ super(BillingAccountListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -472,11 +545,11 @@ class BillingAccountUpdateRequest(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param display_name: The billing account name. - :type display_name: str - :param sold_to: The address of the individual or organization that is responsible for the + :ivar display_name: The billing account name. + :vartype display_name: str + :ivar sold_to: The address of the individual or organization that is responsible for the billing account. - :type sold_to: ~azure.mgmt.billing.models.AddressDetails + :vartype sold_to: ~azure.mgmt.billing.models.AddressDetails :ivar agreement_type: The type of agreement. Possible values include: "MicrosoftCustomerAgreement", "EnterpriseAgreement", "MicrosoftOnlineServicesProgram", "MicrosoftPartnerAgreement". @@ -487,20 +560,20 @@ class BillingAccountUpdateRequest(msrest.serialization.Model): :ivar account_status: The current status of the billing account. Possible values include: "Active", "Deleted", "Disabled", "Expired", "Transferred", "Extended", "Terminated". :vartype account_status: str or ~azure.mgmt.billing.models.AccountStatus - :param billing_profiles: The billing profiles associated with the billing account. By default + :ivar billing_profiles: The billing profiles associated with the billing account. By default this is not populated, unless it's specified in $expand. - :type billing_profiles: ~azure.mgmt.billing.models.BillingProfilesOnExpand + :vartype billing_profiles: ~azure.mgmt.billing.models.BillingProfilesOnExpand :ivar enrollment_details: The details about the associated legacy enrollment. By default this is not populated, unless it's specified in $expand. :vartype enrollment_details: ~azure.mgmt.billing.models.Enrollment - :param departments: The departments associated to the enrollment. - :type departments: list[~azure.mgmt.billing.models.Department] - :param enrollment_accounts: The accounts associated to the enrollment. - :type enrollment_accounts: list[~azure.mgmt.billing.models.EnrollmentAccount] + :ivar departments: The departments associated to the enrollment. + :vartype departments: list[~azure.mgmt.billing.models.Department] + :ivar enrollment_accounts: The accounts associated to the enrollment. + :vartype enrollment_accounts: list[~azure.mgmt.billing.models.EnrollmentAccount] :ivar has_read_access: Indicates whether user has read access to the billing account. :vartype has_read_access: bool - :param notification_email_address: Notification email address, only for legacy accounts. - :type notification_email_address: str + :ivar notification_email_address: Notification email address, only for legacy accounts. + :vartype notification_email_address: str """ _validation = { @@ -536,6 +609,22 @@ def __init__( notification_email_address: Optional[str] = None, **kwargs ): + """ + :keyword display_name: The billing account name. + :paramtype display_name: str + :keyword sold_to: The address of the individual or organization that is responsible for the + billing account. + :paramtype sold_to: ~azure.mgmt.billing.models.AddressDetails + :keyword billing_profiles: The billing profiles associated with the billing account. By default + this is not populated, unless it's specified in $expand. + :paramtype billing_profiles: ~azure.mgmt.billing.models.BillingProfilesOnExpand + :keyword departments: The departments associated to the enrollment. + :paramtype departments: list[~azure.mgmt.billing.models.Department] + :keyword enrollment_accounts: The accounts associated to the enrollment. + :paramtype enrollment_accounts: list[~azure.mgmt.billing.models.EnrollmentAccount] + :keyword notification_email_address: Notification email address, only for legacy accounts. + :paramtype notification_email_address: str + """ super(BillingAccountUpdateRequest, self).__init__(**kwargs) self.display_name = display_name self.sold_to = sold_to @@ -591,6 +680,8 @@ def __init__( self, **kwargs ): + """ + """ super(BillingPeriod, self).__init__(**kwargs) self.billing_period_start_date = None self.billing_period_end_date = None @@ -622,6 +713,8 @@ def __init__( self, **kwargs ): + """ + """ super(BillingPeriodsListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -652,6 +745,8 @@ def __init__( self, **kwargs ): + """ + """ super(BillingPermissionsListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -682,6 +777,8 @@ def __init__( self, **kwargs ): + """ + """ super(BillingPermissionsProperties, self).__init__(**kwargs) self.actions = None self.not_actions = None @@ -698,32 +795,32 @@ class BillingProfile(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param display_name: The name of the billing profile. - :type display_name: str - :param po_number: The purchase order name that will appear on the invoices generated for the + :ivar display_name: The name of the billing profile. + :vartype display_name: str + :ivar po_number: The purchase order name that will appear on the invoices generated for the billing profile. - :type po_number: str + :vartype po_number: str :ivar billing_relationship_type: Identifies which services and purchases are paid by a billing profile. Possible values include: "Direct", "IndirectCustomer", "IndirectPartner", "CSPPartner". :vartype billing_relationship_type: str or ~azure.mgmt.billing.models.BillingRelationshipType - :param bill_to: Billing address. - :type bill_to: ~azure.mgmt.billing.models.AddressDetails + :ivar bill_to: Billing address. + :vartype bill_to: ~azure.mgmt.billing.models.AddressDetails :ivar indirect_relationship_info: Identifies the billing profile that is linked to another billing profile in indirect purchase motion. :vartype indirect_relationship_info: ~azure.mgmt.billing.models.IndirectRelationshipInfo - :param invoice_email_opt_in: Flag controlling whether the invoices for the billing profile are + :ivar invoice_email_opt_in: Flag controlling whether the invoices for the billing profile are sent through email. - :type invoice_email_opt_in: bool + :vartype invoice_email_opt_in: bool :ivar invoice_day: The day of the month when the invoice for the billing profile is generated. :vartype invoice_day: int :ivar currency: The currency in which the charges for the billing profile are billed. :vartype currency: str - :param enabled_azure_plans: Information about the enabled azure plans. - :type enabled_azure_plans: list[~azure.mgmt.billing.models.AzurePlan] - :param invoice_sections: The invoice sections associated to the billing profile. By default - this is not populated, unless it's specified in $expand. - :type invoice_sections: ~azure.mgmt.billing.models.InvoiceSectionsOnExpand + :ivar enabled_azure_plans: Information about the enabled azure plans. + :vartype enabled_azure_plans: list[~azure.mgmt.billing.models.AzurePlan] + :ivar invoice_sections: The invoice sections associated to the billing profile. By default this + is not populated, unless it's specified in $expand. + :vartype invoice_sections: ~azure.mgmt.billing.models.InvoiceSectionsOnExpand :ivar has_read_access: Indicates whether user has read access to the billing profile. :vartype has_read_access: bool :ivar system_id: The system generated unique identifier for a billing profile. @@ -740,8 +837,8 @@ class BillingProfile(Resource): profile. This is a system managed optional field and gets updated as the billing profile gets associated with accounts in various clouds. :vartype target_clouds: list[str or ~azure.mgmt.billing.models.TargetCloud] - :param tags: A set of tags. Tags of billing profiles. - :type tags: dict[str, str] + :ivar tags: A set of tags. Tags of billing profiles. + :vartype tags: dict[str, str] """ _validation = { @@ -795,6 +892,25 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword display_name: The name of the billing profile. + :paramtype display_name: str + :keyword po_number: The purchase order name that will appear on the invoices generated for the + billing profile. + :paramtype po_number: str + :keyword bill_to: Billing address. + :paramtype bill_to: ~azure.mgmt.billing.models.AddressDetails + :keyword invoice_email_opt_in: Flag controlling whether the invoices for the billing profile + are sent through email. + :paramtype invoice_email_opt_in: bool + :keyword enabled_azure_plans: Information about the enabled azure plans. + :paramtype enabled_azure_plans: list[~azure.mgmt.billing.models.AzurePlan] + :keyword invoice_sections: The invoice sections associated to the billing profile. By default + this is not populated, unless it's specified in $expand. + :paramtype invoice_sections: ~azure.mgmt.billing.models.InvoiceSectionsOnExpand + :keyword tags: A set of tags. Tags of billing profiles. + :paramtype tags: dict[str, str] + """ super(BillingProfile, self).__init__(**kwargs) self.display_name = display_name self.po_number = po_number @@ -818,19 +934,19 @@ def __init__( class BillingProfileCreationRequest(msrest.serialization.Model): """The request parameters for creating a new billing profile. - :param display_name: The name of the billing profile. - :type display_name: str - :param po_number: The purchase order name that will appear on the invoices generated for the + :ivar display_name: The name of the billing profile. + :vartype display_name: str + :ivar po_number: The purchase order name that will appear on the invoices generated for the billing profile. - :type po_number: str - :param bill_to: The address of the individual or organization that is responsible for the + :vartype po_number: str + :ivar bill_to: The address of the individual or organization that is responsible for the billing profile. - :type bill_to: ~azure.mgmt.billing.models.AddressDetails - :param invoice_email_opt_in: Flag controlling whether the invoices for the billing profile are + :vartype bill_to: ~azure.mgmt.billing.models.AddressDetails + :ivar invoice_email_opt_in: Flag controlling whether the invoices for the billing profile are sent through email. - :type invoice_email_opt_in: bool - :param enabled_azure_plans: Enabled azure plans for the billing profile. - :type enabled_azure_plans: list[~azure.mgmt.billing.models.AzurePlan] + :vartype invoice_email_opt_in: bool + :ivar enabled_azure_plans: Enabled azure plans for the billing profile. + :vartype enabled_azure_plans: list[~azure.mgmt.billing.models.AzurePlan] """ _attribute_map = { @@ -851,6 +967,21 @@ def __init__( enabled_azure_plans: Optional[List["AzurePlan"]] = None, **kwargs ): + """ + :keyword display_name: The name of the billing profile. + :paramtype display_name: str + :keyword po_number: The purchase order name that will appear on the invoices generated for the + billing profile. + :paramtype po_number: str + :keyword bill_to: The address of the individual or organization that is responsible for the + billing profile. + :paramtype bill_to: ~azure.mgmt.billing.models.AddressDetails + :keyword invoice_email_opt_in: Flag controlling whether the invoices for the billing profile + are sent through email. + :paramtype invoice_email_opt_in: bool + :keyword enabled_azure_plans: Enabled azure plans for the billing profile. + :paramtype enabled_azure_plans: list[~azure.mgmt.billing.models.AzurePlan] + """ super(BillingProfileCreationRequest, self).__init__(**kwargs) self.display_name = display_name self.po_number = po_number @@ -859,6 +990,47 @@ def __init__( self.enabled_azure_plans = enabled_azure_plans +class BillingProfileInfo(msrest.serialization.Model): + """Details about billing profile associated with agreement and available only for specific agreements. + + :ivar billing_profile_id: The unique identifier for the billing profile. + :vartype billing_profile_id: str + :ivar billing_profile_display_name: The name of the billing profile. + :vartype billing_profile_display_name: str + :ivar indirect_relationship_organization_name: Billing account name. This property is available + for a specific type of agreement. + :vartype indirect_relationship_organization_name: str + """ + + _attribute_map = { + 'billing_profile_id': {'key': 'billingProfileId', 'type': 'str'}, + 'billing_profile_display_name': {'key': 'billingProfileDisplayName', 'type': 'str'}, + 'indirect_relationship_organization_name': {'key': 'indirectRelationshipOrganizationName', 'type': 'str'}, + } + + def __init__( + self, + *, + billing_profile_id: Optional[str] = None, + billing_profile_display_name: Optional[str] = None, + indirect_relationship_organization_name: Optional[str] = None, + **kwargs + ): + """ + :keyword billing_profile_id: The unique identifier for the billing profile. + :paramtype billing_profile_id: str + :keyword billing_profile_display_name: The name of the billing profile. + :paramtype billing_profile_display_name: str + :keyword indirect_relationship_organization_name: Billing account name. This property is + available for a specific type of agreement. + :paramtype indirect_relationship_organization_name: str + """ + super(BillingProfileInfo, self).__init__(**kwargs) + self.billing_profile_id = billing_profile_id + self.billing_profile_display_name = billing_profile_display_name + self.indirect_relationship_organization_name = indirect_relationship_organization_name + + class BillingProfileListResult(msrest.serialization.Model): """The list of billing profiles. @@ -884,6 +1056,8 @@ def __init__( self, **kwargs ): + """ + """ super(BillingProfileListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -898,8 +1072,8 @@ class BillingProfilesOnExpand(msrest.serialization.Model): in this collection. The collection lists a maximum of 50 billing profiles. To get all billing profiles, use the list billing profiles API. :vartype has_more_results: bool - :param value: The billing profiles associated with the billing account. - :type value: list[~azure.mgmt.billing.models.BillingProfile] + :ivar value: The billing profiles associated with the billing account. + :vartype value: list[~azure.mgmt.billing.models.BillingProfile] """ _validation = { @@ -917,6 +1091,10 @@ def __init__( value: Optional[List["BillingProfile"]] = None, **kwargs ): + """ + :keyword value: The billing profiles associated with the billing account. + :paramtype value: list[~azure.mgmt.billing.models.BillingProfile] + """ super(BillingProfilesOnExpand, self).__init__(**kwargs) self.has_more_results = None self.value = value @@ -959,8 +1137,8 @@ class BillingProperty(Resource): include: "Off", "On". :vartype billing_profile_spending_limit: str or ~azure.mgmt.billing.models.BillingProfileSpendingLimit - :param cost_center: The cost center applied to the subscription. - :type cost_center: str + :ivar cost_center: The cost center applied to the subscription. + :vartype cost_center: str :ivar invoice_section_id: The ID of the invoice section to which the subscription is billed. :vartype invoice_section_id: str :ivar invoice_section_display_name: The name of the invoice section to which the subscription @@ -1029,6 +1207,10 @@ def __init__( cost_center: Optional[str] = None, **kwargs ): + """ + :keyword cost_center: The cost center applied to the subscription. + :paramtype cost_center: str + """ super(BillingProperty, self).__init__(**kwargs) self.account_admin_notification_email_address = None self.billing_tenant_id = None @@ -1070,18 +1252,18 @@ class BillingRoleAssignment(Resource): :ivar created_by_user_email_address: The email address of the user who created the role assignment. :vartype created_by_user_email_address: str - :param principal_id: The principal id of the user to whom the role was assigned. - :type principal_id: str - :param principal_tenant_id: The principal tenant id of the user to whom the role was assigned. - :type principal_tenant_id: str - :param role_definition_id: The ID of the role definition. - :type role_definition_id: str + :ivar principal_id: The principal id of the user to whom the role was assigned. + :vartype principal_id: str + :ivar principal_tenant_id: The principal tenant id of the user to whom the role was assigned. + :vartype principal_tenant_id: str + :ivar role_definition_id: The ID of the role definition. + :vartype role_definition_id: str :ivar scope: The scope at which the role was assigned. :vartype scope: str - :param user_authentication_type: The authentication type. - :type user_authentication_type: str - :param user_email_address: The email address of the user. - :type user_email_address: str + :ivar user_authentication_type: The authentication type. + :vartype user_authentication_type: str + :ivar user_email_address: The email address of the user. + :vartype user_email_address: str """ _validation = { @@ -1121,6 +1303,19 @@ def __init__( user_email_address: Optional[str] = None, **kwargs ): + """ + :keyword principal_id: The principal id of the user to whom the role was assigned. + :paramtype principal_id: str + :keyword principal_tenant_id: The principal tenant id of the user to whom the role was + assigned. + :paramtype principal_tenant_id: str + :keyword role_definition_id: The ID of the role definition. + :paramtype role_definition_id: str + :keyword user_authentication_type: The authentication type. + :paramtype user_authentication_type: str + :keyword user_email_address: The email address of the user. + :paramtype user_email_address: str + """ super(BillingRoleAssignment, self).__init__(**kwargs) self.created_on = None self.created_by_principal_tenant_id = None @@ -1159,6 +1354,8 @@ def __init__( self, **kwargs ): + """ + """ super(BillingRoleAssignmentListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -1177,8 +1374,8 @@ class BillingRoleDefinition(Resource): :vartype type: str :ivar description: The role description. :vartype description: str - :param permissions: The billingPermissions the role has. - :type permissions: list[~azure.mgmt.billing.models.BillingPermissionsProperties] + :ivar permissions: The billingPermissions the role has. + :vartype permissions: list[~azure.mgmt.billing.models.BillingPermissionsProperties] :ivar role_name: The name of the role. :vartype role_name: str """ @@ -1206,6 +1403,10 @@ def __init__( permissions: Optional[List["BillingPermissionsProperties"]] = None, **kwargs ): + """ + :keyword permissions: The billingPermissions the role has. + :paramtype permissions: list[~azure.mgmt.billing.models.BillingPermissionsProperties] + """ super(BillingRoleDefinition, self).__init__(**kwargs) self.description = None self.permissions = permissions @@ -1237,6 +1438,8 @@ def __init__( self, **kwargs ): + """ + """ super(BillingRoleDefinitionListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -1257,9 +1460,9 @@ class BillingSubscription(Resource): :vartype display_name: str :ivar subscription_id: The ID of the subscription. :vartype subscription_id: str - :param subscription_billing_status: The current billing status of the subscription. Possible + :ivar subscription_billing_status: The current billing status of the subscription. Possible values include: "Active", "Inactive", "Abandoned", "Deleted", "Warning". - :type subscription_billing_status: str or + :vartype subscription_billing_status: str or ~azure.mgmt.billing.models.BillingSubscriptionStatusType :ivar last_month_charges: The last month charges. :vartype last_month_charges: ~azure.mgmt.billing.models.Amount @@ -1270,8 +1473,8 @@ class BillingSubscription(Resource): :ivar billing_profile_display_name: The name of the billing profile to which the subscription is billed. :vartype billing_profile_display_name: str - :param cost_center: The cost center applied to the subscription. - :type cost_center: str + :ivar cost_center: The cost center applied to the subscription. + :vartype cost_center: str :ivar customer_id: The ID of the customer for whom the subscription was created. The field is applicable only for Microsoft Partner Agreement billing account. :vartype customer_id: str @@ -1285,10 +1488,13 @@ class BillingSubscription(Resource): :vartype invoice_section_display_name: str :ivar reseller: Reseller for this subscription. :vartype reseller: ~azure.mgmt.billing.models.Reseller - :param sku_id: The sku ID of the Azure plan for the subscription. - :type sku_id: str + :ivar sku_id: The sku ID of the Azure plan for the subscription. + :vartype sku_id: str :ivar sku_description: The sku description of the Azure plan for the subscription. :vartype sku_description: str + :ivar suspension_reasons: The suspension reason for a subscription. Applies only to + subscriptions in Microsoft Online Services Program billing accounts. + :vartype suspension_reasons: list[str] """ _validation = { @@ -1307,6 +1513,7 @@ class BillingSubscription(Resource): 'invoice_section_display_name': {'readonly': True}, 'reseller': {'readonly': True}, 'sku_description': {'readonly': True}, + 'suspension_reasons': {'readonly': True}, } _attribute_map = { @@ -1328,6 +1535,7 @@ class BillingSubscription(Resource): 'reseller': {'key': 'properties.reseller', 'type': 'Reseller'}, 'sku_id': {'key': 'properties.skuId', 'type': 'str'}, 'sku_description': {'key': 'properties.skuDescription', 'type': 'str'}, + 'suspension_reasons': {'key': 'properties.suspensionReasons', 'type': '[str]'}, } def __init__( @@ -1338,6 +1546,16 @@ def __init__( sku_id: Optional[str] = None, **kwargs ): + """ + :keyword subscription_billing_status: The current billing status of the subscription. Possible + values include: "Active", "Inactive", "Abandoned", "Deleted", "Warning". + :paramtype subscription_billing_status: str or + ~azure.mgmt.billing.models.BillingSubscriptionStatusType + :keyword cost_center: The cost center applied to the subscription. + :paramtype cost_center: str + :keyword sku_id: The sku ID of the Azure plan for the subscription. + :paramtype sku_id: str + """ super(BillingSubscription, self).__init__(**kwargs) self.display_name = None self.subscription_id = None @@ -1354,6 +1572,7 @@ def __init__( self.reseller = None self.sku_id = sku_id self.sku_description = None + self.suspension_reasons = None class BillingSubscriptionsListResult(msrest.serialization.Model): @@ -1385,6 +1604,8 @@ def __init__( self, **kwargs ): + """ + """ super(BillingSubscriptionsListResult, self).__init__(**kwargs) self.value = None self.total_count = None @@ -1406,12 +1627,12 @@ class Customer(Resource): :vartype billing_profile_id: str :ivar billing_profile_display_name: The name of the billing profile for the invoice section. :vartype billing_profile_display_name: str - :param display_name: The name of the customer. - :type display_name: str - :param enabled_azure_plans: Azure plans enabled for the customer. - :type enabled_azure_plans: list[~azure.mgmt.billing.models.AzurePlan] - :param resellers: The list of resellers for which an Azure plan is enabled for the customer. - :type resellers: list[~azure.mgmt.billing.models.Reseller] + :ivar display_name: The name of the customer. + :vartype display_name: str + :ivar enabled_azure_plans: Azure plans enabled for the customer. + :vartype enabled_azure_plans: list[~azure.mgmt.billing.models.AzurePlan] + :ivar resellers: The list of resellers for which an Azure plan is enabled for the customer. + :vartype resellers: list[~azure.mgmt.billing.models.Reseller] """ _validation = { @@ -1441,6 +1662,14 @@ def __init__( resellers: Optional[List["Reseller"]] = None, **kwargs ): + """ + :keyword display_name: The name of the customer. + :paramtype display_name: str + :keyword enabled_azure_plans: Azure plans enabled for the customer. + :paramtype enabled_azure_plans: list[~azure.mgmt.billing.models.AzurePlan] + :keyword resellers: The list of resellers for which an Azure plan is enabled for the customer. + :paramtype resellers: list[~azure.mgmt.billing.models.Reseller] + """ super(Customer, self).__init__(**kwargs) self.billing_profile_id = None self.billing_profile_display_name = None @@ -1478,6 +1707,8 @@ def __init__( self, **kwargs ): + """ + """ super(CustomerListResult, self).__init__(**kwargs) self.value = None self.total_count = None @@ -1495,9 +1726,9 @@ class CustomerPolicy(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param view_charges: The policy that controls whether the users in customer's organization can + :ivar view_charges: The policy that controls whether the users in customer's organization can view charges at pay-as-you-go prices. Possible values include: "Allowed", "NotAllowed". - :type view_charges: str or ~azure.mgmt.billing.models.ViewCharges + :vartype view_charges: str or ~azure.mgmt.billing.models.ViewCharges """ _validation = { @@ -1519,6 +1750,11 @@ def __init__( view_charges: Optional[Union[str, "ViewCharges"]] = None, **kwargs ): + """ + :keyword view_charges: The policy that controls whether the users in customer's organization + can view charges at pay-as-you-go prices. Possible values include: "Allowed", "NotAllowed". + :paramtype view_charges: str or ~azure.mgmt.billing.models.ViewCharges + """ super(CustomerPolicy, self).__init__(**kwargs) self.view_charges = view_charges @@ -1534,15 +1770,15 @@ class Department(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param department_name: The name of the department. - :type department_name: str - :param cost_center: The cost center associated with the department. - :type cost_center: str - :param status: The status of the department. - :type status: str - :param enrollment_accounts: Associated enrollment accounts. By default this is not populated, + :ivar department_name: The name of the department. + :vartype department_name: str + :ivar cost_center: The cost center associated with the department. + :vartype cost_center: str + :ivar status: The status of the department. + :vartype status: str + :ivar enrollment_accounts: Associated enrollment accounts. By default this is not populated, unless it's specified in $expand. - :type enrollment_accounts: list[~azure.mgmt.billing.models.EnrollmentAccount] + :vartype enrollment_accounts: list[~azure.mgmt.billing.models.EnrollmentAccount] """ _validation = { @@ -1570,6 +1806,17 @@ def __init__( enrollment_accounts: Optional[List["EnrollmentAccount"]] = None, **kwargs ): + """ + :keyword department_name: The name of the department. + :paramtype department_name: str + :keyword cost_center: The cost center associated with the department. + :paramtype cost_center: str + :keyword status: The status of the department. + :paramtype status: str + :keyword enrollment_accounts: Associated enrollment accounts. By default this is not populated, + unless it's specified in $expand. + :paramtype enrollment_accounts: list[~azure.mgmt.billing.models.EnrollmentAccount] + """ super(Department, self).__init__(**kwargs) self.department_name = department_name self.cost_center = cost_center @@ -1608,6 +1855,8 @@ def __init__( self, **kwargs ): + """ + """ super(Document, self).__init__(**kwargs) self.kind = None self.url = None @@ -1639,6 +1888,8 @@ def __init__( self, **kwargs ): + """ + """ super(DownloadUrl, self).__init__(**kwargs) self.expiry_time = None self.url = None @@ -1649,10 +1900,10 @@ class Enrollment(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param start_date: The start date of the enrollment. - :type start_date: ~datetime.datetime - :param end_date: The end date of the enrollment. - :type end_date: ~datetime.datetime + :ivar start_date: The start date of the enrollment. + :vartype start_date: ~datetime.datetime + :ivar end_date: The end date of the enrollment. + :vartype end_date: ~datetime.datetime :ivar currency: The billing currency for the enrollment. :vartype currency: str :ivar channel: The channel type of the enrollment. @@ -1698,6 +1949,12 @@ def __init__( end_date: Optional[datetime.datetime] = None, **kwargs ): + """ + :keyword start_date: The start date of the enrollment. + :paramtype start_date: ~datetime.datetime + :keyword end_date: The end date of the enrollment. + :paramtype end_date: ~datetime.datetime + """ super(Enrollment, self).__init__(**kwargs) self.start_date = start_date self.end_date = end_date @@ -1721,23 +1978,23 @@ class EnrollmentAccount(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param account_name: The name of the enrollment account. - :type account_name: str - :param cost_center: The cost center associated with the enrollment account. - :type cost_center: str - :param account_owner: The owner of the enrollment account. - :type account_owner: str - :param account_owner_email: The enrollment account owner email address. - :type account_owner_email: str - :param status: The status of the enrollment account. - :type status: str - :param start_date: The start date of the enrollment account. - :type start_date: ~datetime.datetime - :param end_date: The end date of the enrollment account. - :type end_date: ~datetime.datetime - :param department: Associated department. By default this is not populated, unless it's + :ivar account_name: The name of the enrollment account. + :vartype account_name: str + :ivar cost_center: The cost center associated with the enrollment account. + :vartype cost_center: str + :ivar account_owner: The owner of the enrollment account. + :vartype account_owner: str + :ivar account_owner_email: The enrollment account owner email address. + :vartype account_owner_email: str + :ivar status: The status of the enrollment account. + :vartype status: str + :ivar start_date: The start date of the enrollment account. + :vartype start_date: ~datetime.datetime + :ivar end_date: The end date of the enrollment account. + :vartype end_date: ~datetime.datetime + :ivar department: Associated department. By default this is not populated, unless it's specified in $expand. - :type department: ~azure.mgmt.billing.models.Department + :vartype department: ~azure.mgmt.billing.models.Department """ _validation = { @@ -1773,6 +2030,25 @@ def __init__( department: Optional["Department"] = None, **kwargs ): + """ + :keyword account_name: The name of the enrollment account. + :paramtype account_name: str + :keyword cost_center: The cost center associated with the enrollment account. + :paramtype cost_center: str + :keyword account_owner: The owner of the enrollment account. + :paramtype account_owner: str + :keyword account_owner_email: The enrollment account owner email address. + :paramtype account_owner_email: str + :keyword status: The status of the enrollment account. + :paramtype status: str + :keyword start_date: The start date of the enrollment account. + :paramtype start_date: ~datetime.datetime + :keyword end_date: The end date of the enrollment account. + :paramtype end_date: ~datetime.datetime + :keyword department: Associated department. By default this is not populated, unless it's + specified in $expand. + :paramtype department: ~azure.mgmt.billing.models.Department + """ super(EnrollmentAccount, self).__init__(**kwargs) self.account_name = account_name self.cost_center = cost_center @@ -1787,14 +2063,14 @@ def __init__( class EnrollmentAccountContext(msrest.serialization.Model): """The enrollment account context. - :param cost_center: The cost center associated with the enrollment account. - :type cost_center: str - :param start_date: The start date of the enrollment account. - :type start_date: ~datetime.datetime - :param end_date: The end date of the enrollment account. - :type end_date: ~datetime.datetime - :param enrollment_account_name: The ID of the enrollment account. - :type enrollment_account_name: str + :ivar cost_center: The cost center associated with the enrollment account. + :vartype cost_center: str + :ivar start_date: The start date of the enrollment account. + :vartype start_date: ~datetime.datetime + :ivar end_date: The end date of the enrollment account. + :vartype end_date: ~datetime.datetime + :ivar enrollment_account_name: The ID of the enrollment account. + :vartype enrollment_account_name: str """ _attribute_map = { @@ -1813,6 +2089,16 @@ def __init__( enrollment_account_name: Optional[str] = None, **kwargs ): + """ + :keyword cost_center: The cost center associated with the enrollment account. + :paramtype cost_center: str + :keyword start_date: The start date of the enrollment account. + :paramtype start_date: ~datetime.datetime + :keyword end_date: The end date of the enrollment account. + :paramtype end_date: ~datetime.datetime + :keyword enrollment_account_name: The ID of the enrollment account. + :paramtype enrollment_account_name: str + """ super(EnrollmentAccountContext, self).__init__(**kwargs) self.cost_center = cost_center self.start_date = start_date @@ -1845,6 +2131,8 @@ def __init__( self, **kwargs ): + """ + """ super(EnrollmentAccountListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -1883,6 +2171,8 @@ def __init__( self, **kwargs ): + """ + """ super(EnrollmentAccountSummary, self).__init__(**kwargs) self.principal_name = None @@ -1924,6 +2214,8 @@ def __init__( self, **kwargs ): + """ + """ super(EnrollmentPolicies, self).__init__(**kwargs) self.account_owner_view_charges = None self.department_admin_view_charges = None @@ -1964,6 +2256,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetails, self).__init__(**kwargs) self.code = None self.message = None @@ -1974,8 +2268,8 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Error response indicates that the service is not able to process the incoming request. The reason is provided in the error message. - :param error: The details of the error. - :type error: ~azure.mgmt.billing.models.ErrorDetails + :ivar error: The details of the error. + :vartype error: ~azure.mgmt.billing.models.ErrorDetails """ _attribute_map = { @@ -1988,6 +2282,10 @@ def __init__( error: Optional["ErrorDetails"] = None, **kwargs ): + """ + :keyword error: The details of the error. + :paramtype error: ~azure.mgmt.billing.models.ErrorDetails + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error @@ -2021,6 +2319,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorSubDetailsItem, self).__init__(**kwargs) self.code = None self.message = None @@ -2030,14 +2330,14 @@ def __init__( class IndirectRelationshipInfo(msrest.serialization.Model): """The billing profile details of the partner of the customer for an indirect motion. - :param billing_account_name: The billing account name of the partner or the customer for an + :ivar billing_account_name: The billing account name of the partner or the customer for an indirect motion. - :type billing_account_name: str - :param billing_profile_name: The billing profile name of the partner or the customer for an + :vartype billing_account_name: str + :ivar billing_profile_name: The billing profile name of the partner or the customer for an indirect motion. - :type billing_profile_name: str - :param display_name: The display name of the partner or customer for an indirect motion. - :type display_name: str + :vartype billing_profile_name: str + :ivar display_name: The display name of the partner or customer for an indirect motion. + :vartype display_name: str """ _attribute_map = { @@ -2054,6 +2354,16 @@ def __init__( display_name: Optional[str] = None, **kwargs ): + """ + :keyword billing_account_name: The billing account name of the partner or the customer for an + indirect motion. + :paramtype billing_account_name: str + :keyword billing_profile_name: The billing profile name of the partner or the customer for an + indirect motion. + :paramtype billing_profile_name: str + :keyword display_name: The display name of the partner or customer for an indirect motion. + :paramtype display_name: str + """ super(IndirectRelationshipInfo, self).__init__(**kwargs) self.billing_account_name = billing_account_name self.billing_profile_name = billing_profile_name @@ -2071,14 +2381,14 @@ class Instruction(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param amount: The amount budgeted for this billing instruction. - :type amount: float - :param start_date: The date this billing instruction goes into effect. - :type start_date: ~datetime.datetime - :param end_date: The date this billing instruction is no longer in effect. - :type end_date: ~datetime.datetime - :param creation_date: The date this billing instruction was created. - :type creation_date: ~datetime.datetime + :ivar amount: The amount budgeted for this billing instruction. + :vartype amount: float + :ivar start_date: The date this billing instruction goes into effect. + :vartype start_date: ~datetime.datetime + :ivar end_date: The date this billing instruction is no longer in effect. + :vartype end_date: ~datetime.datetime + :ivar creation_date: The date this billing instruction was created. + :vartype creation_date: ~datetime.datetime """ _validation = { @@ -2106,6 +2416,16 @@ def __init__( creation_date: Optional[datetime.datetime] = None, **kwargs ): + """ + :keyword amount: The amount budgeted for this billing instruction. + :paramtype amount: float + :keyword start_date: The date this billing instruction goes into effect. + :paramtype start_date: ~datetime.datetime + :keyword end_date: The date this billing instruction is no longer in effect. + :paramtype end_date: ~datetime.datetime + :keyword creation_date: The date this billing instruction was created. + :paramtype creation_date: ~datetime.datetime + """ super(Instruction, self).__init__(**kwargs) self.amount = amount self.start_date = start_date @@ -2138,6 +2458,8 @@ def __init__( self, **kwargs ): + """ + """ super(InstructionListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -2289,6 +2611,8 @@ def __init__( self, **kwargs ): + """ + """ super(Invoice, self).__init__(**kwargs) self.due_date = None self.invoice_date = None @@ -2326,25 +2650,32 @@ class InvoiceListResult(msrest.serialization.Model): :vartype value: list[~azure.mgmt.billing.models.Invoice] :ivar next_link: The link (url) to the next page of results. :vartype next_link: str + :ivar total_count: Total number of records. + :vartype total_count: int """ _validation = { 'value': {'readonly': True}, 'next_link': {'readonly': True}, + 'total_count': {'readonly': True}, } _attribute_map = { 'value': {'key': 'value', 'type': '[Invoice]'}, 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'total_count': {'key': 'totalCount', 'type': 'int'}, } def __init__( self, **kwargs ): + """ + """ super(InvoiceListResult, self).__init__(**kwargs) self.value = None self.next_link = None + self.total_count = None class InvoiceSection(Resource): @@ -2358,15 +2689,19 @@ class InvoiceSection(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param display_name: The name of the invoice section. - :type display_name: str - :param labels: Dictionary of metadata associated with the invoice section. - :type labels: dict[str, str] + :ivar display_name: The name of the invoice section. + :vartype display_name: str + :ivar labels: Dictionary of metadata associated with the invoice section. + :vartype labels: dict[str, str] :ivar state: Identifies the state of an invoice section. Possible values include: "Active", "Restricted". :vartype state: str or ~azure.mgmt.billing.models.InvoiceSectionState :ivar system_id: The system generated unique identifier for an invoice section. :vartype system_id: str + :ivar tags: A set of tags. Dictionary of metadata associated with the invoice section. Maximum + key/value length supported of 256 characters. Keys/value should not empty value nor null. Keys + can not contain < > % & ? /. + :vartype tags: dict[str, str] :ivar target_cloud: Identifies the cloud environments that are associated with an invoice section. This is a system managed optional field and gets updated as the invoice section gets associated with accounts in various clouds. Possible values include: "USGov", "USNat", "USSec". @@ -2390,6 +2725,7 @@ class InvoiceSection(Resource): 'labels': {'key': 'properties.labels', 'type': '{str}'}, 'state': {'key': 'properties.state', 'type': 'str'}, 'system_id': {'key': 'properties.systemId', 'type': 'str'}, + 'tags': {'key': 'properties.tags', 'type': '{str}'}, 'target_cloud': {'key': 'properties.targetCloud', 'type': 'str'}, } @@ -2398,21 +2734,33 @@ def __init__( *, display_name: Optional[str] = None, labels: Optional[Dict[str, str]] = None, + tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword display_name: The name of the invoice section. + :paramtype display_name: str + :keyword labels: Dictionary of metadata associated with the invoice section. + :paramtype labels: dict[str, str] + :keyword tags: A set of tags. Dictionary of metadata associated with the invoice section. + Maximum key/value length supported of 256 characters. Keys/value should not empty value nor + null. Keys can not contain < > % & ? /. + :paramtype tags: dict[str, str] + """ super(InvoiceSection, self).__init__(**kwargs) self.display_name = display_name self.labels = labels self.state = None self.system_id = None + self.tags = tags self.target_cloud = None class InvoiceSectionCreationRequest(msrest.serialization.Model): """The properties of the invoice section. - :param display_name: The name of the invoice section. - :type display_name: str + :ivar display_name: The name of the invoice section. + :vartype display_name: str """ _attribute_map = { @@ -2425,6 +2773,10 @@ def __init__( display_name: Optional[str] = None, **kwargs ): + """ + :keyword display_name: The name of the invoice section. + :paramtype display_name: str + """ super(InvoiceSectionCreationRequest, self).__init__(**kwargs) self.display_name = display_name @@ -2458,6 +2810,8 @@ def __init__( self, **kwargs ): + """ + """ super(InvoiceSectionListResult, self).__init__(**kwargs) self.value = None self.total_count = None @@ -2469,8 +2823,8 @@ class InvoiceSectionListWithCreateSubPermissionResult(msrest.serialization.Model Variables are only populated by the server, and will be ignored when sending a request. - :param value: The list of invoice section properties with create subscription permission. - :type value: list[~azure.mgmt.billing.models.InvoiceSectionWithCreateSubPermission] + :ivar value: The list of invoice section properties with create subscription permission. + :vartype value: list[~azure.mgmt.billing.models.InvoiceSectionWithCreateSubPermission] :ivar next_link: The link (url) to the next page of results. :vartype next_link: str """ @@ -2490,6 +2844,10 @@ def __init__( value: Optional[List["InvoiceSectionWithCreateSubPermission"]] = None, **kwargs ): + """ + :keyword value: The list of invoice section properties with create subscription permission. + :paramtype value: list[~azure.mgmt.billing.models.InvoiceSectionWithCreateSubPermission] + """ super(InvoiceSectionListWithCreateSubPermissionResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -2504,8 +2862,8 @@ class InvoiceSectionsOnExpand(msrest.serialization.Model): in this collection. The collection lists a maximum of 50 invoice sections. To get all invoice sections, use the list invoice sections API. :vartype has_more_results: bool - :param value: The invoice sections associated to the billing profile. - :type value: list[~azure.mgmt.billing.models.InvoiceSection] + :ivar value: The invoice sections associated to the billing profile. + :vartype value: list[~azure.mgmt.billing.models.InvoiceSection] """ _validation = { @@ -2523,6 +2881,10 @@ def __init__( value: Optional[List["InvoiceSection"]] = None, **kwargs ): + """ + :keyword value: The invoice sections associated to the billing profile. + :paramtype value: list[~azure.mgmt.billing.models.InvoiceSection] + """ super(InvoiceSectionsOnExpand, self).__init__(**kwargs) self.has_more_results = None self.value = value @@ -2556,8 +2918,8 @@ class InvoiceSectionWithCreateSubPermission(msrest.serialization.Model): ~azure.mgmt.billing.models.SpendingLimitForBillingProfile :ivar billing_profile_system_id: The system generated unique identifier for a billing profile. :vartype billing_profile_system_id: str - :param enabled_azure_plans: Enabled azure plans for the associated billing profile. - :type enabled_azure_plans: list[~azure.mgmt.billing.models.AzurePlan] + :ivar enabled_azure_plans: Enabled azure plans for the associated billing profile. + :vartype enabled_azure_plans: list[~azure.mgmt.billing.models.AzurePlan] """ _validation = { @@ -2591,6 +2953,10 @@ def __init__( enabled_azure_plans: Optional[List["AzurePlan"]] = None, **kwargs ): + """ + :keyword enabled_azure_plans: Enabled azure plans for the associated billing profile. + :paramtype enabled_azure_plans: list[~azure.mgmt.billing.models.AzurePlan] + """ super(InvoiceSectionWithCreateSubPermission, self).__init__(**kwargs) self.invoice_section_id = None self.invoice_section_display_name = None @@ -2613,8 +2979,8 @@ class Operation(msrest.serialization.Model): :vartype name: str :ivar is_data_action: Identifies if the operation is a data operation. :vartype is_data_action: bool - :param display: The object that represents the operation. - :type display: ~azure.mgmt.billing.models.OperationDisplay + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.billing.models.OperationDisplay """ _validation = { @@ -2634,6 +3000,10 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.billing.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = None self.is_data_action = None @@ -2674,6 +3044,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = None self.resource = None @@ -2707,6 +3079,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -2741,6 +3115,8 @@ def __init__( self, **kwargs ): + """ + """ super(Participants, self).__init__(**kwargs) self.status = None self.status_date = None @@ -2758,9 +3134,9 @@ class PaymentProperties(msrest.serialization.Model): :vartype amount: ~azure.mgmt.billing.models.Amount :ivar date: The date when the payment was made. :vartype date: ~datetime.datetime - :param payment_method_family: The family of payment method. Possible values include: "Credits", + :ivar payment_method_family: The family of payment method. Possible values include: "Credits", "CheckWire", "CreditCard", "None". - :type payment_method_family: str or ~azure.mgmt.billing.models.PaymentMethodFamily + :vartype payment_method_family: str or ~azure.mgmt.billing.models.PaymentMethodFamily :ivar payment_method_type: The type of payment method. :vartype payment_method_type: str """ @@ -2786,6 +3162,11 @@ def __init__( payment_method_family: Optional[Union[str, "PaymentMethodFamily"]] = None, **kwargs ): + """ + :keyword payment_method_family: The family of payment method. Possible values include: + "Credits", "CheckWire", "CreditCard", "None". + :paramtype payment_method_family: str or ~azure.mgmt.billing.models.PaymentMethodFamily + """ super(PaymentProperties, self).__init__(**kwargs) self.payment_type = None self.amount = None @@ -2805,16 +3186,16 @@ class Policy(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param marketplace_purchases: The policy that controls whether Azure marketplace purchases are + :ivar marketplace_purchases: The policy that controls whether Azure marketplace purchases are allowed for a billing profile. Possible values include: "AllAllowed", "OnlyFreeAllowed", "NotAllowed". - :type marketplace_purchases: str or ~azure.mgmt.billing.models.MarketplacePurchasesPolicy - :param reservation_purchases: The policy that controls whether Azure reservation purchases are + :vartype marketplace_purchases: str or ~azure.mgmt.billing.models.MarketplacePurchasesPolicy + :ivar reservation_purchases: The policy that controls whether Azure reservation purchases are allowed for a billing profile. Possible values include: "Allowed", "NotAllowed". - :type reservation_purchases: str or ~azure.mgmt.billing.models.ReservationPurchasesPolicy - :param view_charges: The policy that controls whether users with Azure RBAC access to a + :vartype reservation_purchases: str or ~azure.mgmt.billing.models.ReservationPurchasesPolicy + :ivar view_charges: The policy that controls whether users with Azure RBAC access to a subscription can view its charges. Possible values include: "Allowed", "NotAllowed". - :type view_charges: str or ~azure.mgmt.billing.models.ViewChargesPolicy + :vartype view_charges: str or ~azure.mgmt.billing.models.ViewChargesPolicy """ _validation = { @@ -2840,6 +3221,18 @@ def __init__( view_charges: Optional[Union[str, "ViewChargesPolicy"]] = None, **kwargs ): + """ + :keyword marketplace_purchases: The policy that controls whether Azure marketplace purchases + are allowed for a billing profile. Possible values include: "AllAllowed", "OnlyFreeAllowed", + "NotAllowed". + :paramtype marketplace_purchases: str or ~azure.mgmt.billing.models.MarketplacePurchasesPolicy + :keyword reservation_purchases: The policy that controls whether Azure reservation purchases + are allowed for a billing profile. Possible values include: "Allowed", "NotAllowed". + :paramtype reservation_purchases: str or ~azure.mgmt.billing.models.ReservationPurchasesPolicy + :keyword view_charges: The policy that controls whether users with Azure RBAC access to a + subscription can view its charges. Possible values include: "Allowed", "NotAllowed". + :paramtype view_charges: str or ~azure.mgmt.billing.models.ViewChargesPolicy + """ super(Policy, self).__init__(**kwargs) self.marketplace_purchases = marketplace_purchases self.reservation_purchases = reservation_purchases @@ -2857,9 +3250,9 @@ class Product(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param auto_renew: Indicates whether auto renewal is turned on or off for a product. Possible + :ivar auto_renew: Indicates whether auto renewal is turned on or off for a product. Possible values include: "Off", "On". - :type auto_renew: str or ~azure.mgmt.billing.models.AutoRenew + :vartype auto_renew: str or ~azure.mgmt.billing.models.AutoRenew :ivar display_name: The display name of the product. :vartype display_name: str :ivar purchase_date: The date when the product was purchased. @@ -2868,14 +3261,14 @@ class Product(Resource): :vartype product_type_id: str :ivar product_type: The description of the type of product. :vartype product_type: str - :param status: The current status of the product. Possible values include: "Active", - "Inactive", "PastDue", "Expiring", "Expired", "Disabled", "Cancelled", "AutoRenew". - :type status: str or ~azure.mgmt.billing.models.ProductStatusType + :ivar status: The current status of the product. Possible values include: "Active", "Inactive", + "PastDue", "Expiring", "Expired", "Disabled", "Cancelled", "AutoRenew". + :vartype status: str or ~azure.mgmt.billing.models.ProductStatusType :ivar end_date: The date when the product will be renewed or canceled. :vartype end_date: ~datetime.datetime - :param billing_frequency: The frequency at which the product will be billed. Possible values + :ivar billing_frequency: The frequency at which the product will be billed. Possible values include: "OneTime", "Monthly", "UsageBased". - :type billing_frequency: str or ~azure.mgmt.billing.models.BillingFrequency + :vartype billing_frequency: str or ~azure.mgmt.billing.models.BillingFrequency :ivar last_charge: The last month charges. :vartype last_charge: ~azure.mgmt.billing.models.Amount :ivar last_charge_date: The date of the last charge. @@ -2971,6 +3364,17 @@ def __init__( billing_frequency: Optional[Union[str, "BillingFrequency"]] = None, **kwargs ): + """ + :keyword auto_renew: Indicates whether auto renewal is turned on or off for a product. Possible + values include: "Off", "On". + :paramtype auto_renew: str or ~azure.mgmt.billing.models.AutoRenew + :keyword status: The current status of the product. Possible values include: "Active", + "Inactive", "PastDue", "Expiring", "Expired", "Disabled", "Cancelled", "AutoRenew". + :paramtype status: str or ~azure.mgmt.billing.models.ProductStatusType + :keyword billing_frequency: The frequency at which the product will be billed. Possible values + include: "OneTime", "Monthly", "UsageBased". + :paramtype billing_frequency: str or ~azure.mgmt.billing.models.BillingFrequency + """ super(Product, self).__init__(**kwargs) self.auto_renew = auto_renew self.display_name = None @@ -3003,17 +3407,21 @@ class ProductsListResult(msrest.serialization.Model): :ivar value: The list of products. :vartype value: list[~azure.mgmt.billing.models.Product] + :ivar total_count: Total number of records. + :vartype total_count: int :ivar next_link: The link (url) to the next page of results. :vartype next_link: str """ _validation = { 'value': {'readonly': True}, + 'total_count': {'readonly': True}, 'next_link': {'readonly': True}, } _attribute_map = { 'value': {'key': 'value', 'type': '[Product]'}, + 'total_count': {'key': 'totalCount', 'type': 'int'}, 'next_link': {'key': 'nextLink', 'type': 'str'}, } @@ -3021,8 +3429,11 @@ def __init__( self, **kwargs ): + """ + """ super(ProductsListResult, self).__init__(**kwargs) self.value = None + self.total_count = None self.next_link = None @@ -3055,6 +3466,8 @@ def __init__( self, **kwargs ): + """ + """ super(RebillDetails, self).__init__(**kwargs) self.credit_note_document_id = None self.invoice_document_id = None @@ -3086,6 +3499,8 @@ def __init__( self, **kwargs ): + """ + """ super(Reseller, self).__init__(**kwargs) self.reseller_id = None self.description = None @@ -3104,11 +3519,11 @@ class Reservation(msrest.serialization.Model): :vartype type: str :ivar location: The location of the reservation. :vartype location: str - :param sku: The sku information associated to this reservation. - :type sku: ~azure.mgmt.billing.models.ReservationSkuProperty - :param applied_scopes: The array of applied scopes of a reservation. Will be null if the + :ivar sku: The sku information associated to this reservation. + :vartype sku: ~azure.mgmt.billing.models.ReservationSkuProperty + :ivar applied_scopes: The array of applied scopes of a reservation. Will be null if the reservation is in Shared scope. - :type applied_scopes: list[str] + :vartype applied_scopes: list[str] :ivar applied_scope_type: The applied scope type of the reservation. :vartype applied_scope_type: str :ivar reserved_resource_type: The reserved source type of the reservation, e.g. virtual @@ -3201,6 +3616,13 @@ def __init__( applied_scopes: Optional[List[str]] = None, **kwargs ): + """ + :keyword sku: The sku information associated to this reservation. + :paramtype sku: ~azure.mgmt.billing.models.ReservationSkuProperty + :keyword applied_scopes: The array of applied scopes of a reservation. Will be null if the + reservation is in Shared scope. + :paramtype applied_scopes: list[str] + """ super(Reservation, self).__init__(**kwargs) self.id = None self.name = None @@ -3233,8 +3655,8 @@ class ReservationPropertyUtilization(msrest.serialization.Model): :ivar trend: The number of days trend for a reservation. :vartype trend: str - :param aggregates: The array of aggregates of a reservation's utilization. - :type aggregates: list[~azure.mgmt.billing.models.ReservationUtilizationAggregates] + :ivar aggregates: The array of aggregates of a reservation's utilization. + :vartype aggregates: list[~azure.mgmt.billing.models.ReservationUtilizationAggregates] """ _validation = { @@ -3252,6 +3674,10 @@ def __init__( aggregates: Optional[List["ReservationUtilizationAggregates"]] = None, **kwargs ): + """ + :keyword aggregates: The array of aggregates of a reservation's utilization. + :paramtype aggregates: list[~azure.mgmt.billing.models.ReservationUtilizationAggregates] + """ super(ReservationPropertyUtilization, self).__init__(**kwargs) self.trend = None self.aggregates = aggregates @@ -3278,6 +3704,8 @@ def __init__( self, **kwargs ): + """ + """ super(ReservationSkuProperty, self).__init__(**kwargs) self.name = None @@ -3291,8 +3719,8 @@ class ReservationsListResult(msrest.serialization.Model): :vartype value: list[~azure.mgmt.billing.models.Reservation] :ivar next_link: The link (url) to the next page of results. :vartype next_link: str - :param summary: The roll out count summary of the reservations. - :type summary: ~azure.mgmt.billing.models.ReservationSummary + :ivar summary: The roll out count summary of the reservations. + :vartype summary: ~azure.mgmt.billing.models.ReservationSummary """ _validation = { @@ -3312,6 +3740,10 @@ def __init__( summary: Optional["ReservationSummary"] = None, **kwargs ): + """ + :keyword summary: The roll out count summary of the reservations. + :paramtype summary: ~azure.mgmt.billing.models.ReservationSummary + """ super(ReservationsListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -3359,6 +3791,8 @@ def __init__( self, **kwargs ): + """ + """ super(ReservationSummary, self).__init__(**kwargs) self.succeeded_count = None self.failed_count = None @@ -3401,6 +3835,8 @@ def __init__( self, **kwargs ): + """ + """ super(ReservationUtilizationAggregates, self).__init__(**kwargs) self.grain = None self.grain_unit = None @@ -3419,9 +3855,9 @@ class Transaction(Resource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param kind: The kind of transaction. Options are all or reservation. Possible values include: + :ivar kind: The kind of transaction. Options are all or reservation. Possible values include: "all", "reservation". - :type kind: str or ~azure.mgmt.billing.models.TransactionTypeKind + :vartype kind: str or ~azure.mgmt.billing.models.TransactionTypeKind :ivar date: The date of transaction. :vartype date: ~datetime.datetime :ivar invoice: Invoice on which the transaction was billed or 'pending' if the transaction is @@ -3444,9 +3880,9 @@ class Transaction(Resource): :vartype product_type: str :ivar product_description: The description of the product for which the transaction took place. :vartype product_description: str - :param transaction_type: The type of transaction. Possible values include: "Purchase", "Usage + :ivar transaction_type: The type of transaction. Possible values include: "Purchase", "Usage Charge". - :type transaction_type: str or ~azure.mgmt.billing.models.ReservationType + :vartype transaction_type: str or ~azure.mgmt.billing.models.ReservationType :ivar transaction_amount: The charge associated with the transaction. :vartype transaction_amount: ~azure.mgmt.billing.models.Amount :ivar quantity: The quantity purchased in the transaction. @@ -3601,6 +4037,14 @@ def __init__( transaction_type: Optional[Union[str, "ReservationType"]] = None, **kwargs ): + """ + :keyword kind: The kind of transaction. Options are all or reservation. Possible values + include: "all", "reservation". + :paramtype kind: str or ~azure.mgmt.billing.models.TransactionTypeKind + :keyword transaction_type: The type of transaction. Possible values include: "Purchase", "Usage + Charge". + :paramtype transaction_type: str or ~azure.mgmt.billing.models.ReservationType + """ super(Transaction, self).__init__(**kwargs) self.kind = kind self.date = None @@ -3647,17 +4091,21 @@ class TransactionListResult(msrest.serialization.Model): :ivar value: The list of transactions. :vartype value: list[~azure.mgmt.billing.models.Transaction] + :ivar total_count: Total number of records. + :vartype total_count: int :ivar next_link: The link (url) to the next page of results. :vartype next_link: str """ _validation = { 'value': {'readonly': True}, + 'total_count': {'readonly': True}, 'next_link': {'readonly': True}, } _attribute_map = { 'value': {'key': 'value', 'type': '[Transaction]'}, + 'total_count': {'key': 'totalCount', 'type': 'int'}, 'next_link': {'key': 'nextLink', 'type': 'str'}, } @@ -3665,8 +4113,11 @@ def __init__( self, **kwargs ): + """ + """ super(TransactionListResult, self).__init__(**kwargs) self.value = None + self.total_count = None self.next_link = None @@ -3675,8 +4126,8 @@ class TransferBillingSubscriptionRequestProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param destination_invoice_section_id: Required. The destination invoice section id. - :type destination_invoice_section_id: str + :ivar destination_invoice_section_id: Required. The destination invoice section id. + :vartype destination_invoice_section_id: str """ _validation = { @@ -3693,6 +4144,10 @@ def __init__( destination_invoice_section_id: str, **kwargs ): + """ + :keyword destination_invoice_section_id: Required. The destination invoice section id. + :paramtype destination_invoice_section_id: str + """ super(TransferBillingSubscriptionRequestProperties, self).__init__(**kwargs) self.destination_invoice_section_id = destination_invoice_section_id @@ -3700,8 +4155,8 @@ def __init__( class TransferProductRequestProperties(msrest.serialization.Model): """The properties of the product to initiate a transfer. - :param destination_invoice_section_id: The destination invoice section id. - :type destination_invoice_section_id: str + :ivar destination_invoice_section_id: The destination invoice section id. + :vartype destination_invoice_section_id: str """ _attribute_map = { @@ -3714,6 +4169,10 @@ def __init__( destination_invoice_section_id: Optional[str] = None, **kwargs ): + """ + :keyword destination_invoice_section_id: The destination invoice section id. + :paramtype destination_invoice_section_id: str + """ super(TransferProductRequestProperties, self).__init__(**kwargs) self.destination_invoice_section_id = destination_invoice_section_id @@ -3721,12 +4180,12 @@ def __init__( class ValidateAddressResponse(msrest.serialization.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: The list of suggested addresses. - :type suggested_addresses: list[~azure.mgmt.billing.models.AddressDetails] - :param validation_message: Validation error message. - :type validation_message: str + :ivar status: status of the address validation. Possible values include: "Valid", "Invalid". + :vartype status: str or ~azure.mgmt.billing.models.AddressValidationStatus + :ivar suggested_addresses: The list of suggested addresses. + :vartype suggested_addresses: list[~azure.mgmt.billing.models.AddressDetails] + :ivar validation_message: Validation error message. + :vartype validation_message: str """ _attribute_map = { @@ -3743,6 +4202,14 @@ def __init__( validation_message: Optional[str] = None, **kwargs ): + """ + :keyword status: status of the address validation. Possible values include: "Valid", "Invalid". + :paramtype status: str or ~azure.mgmt.billing.models.AddressValidationStatus + :keyword suggested_addresses: The list of suggested addresses. + :paramtype suggested_addresses: list[~azure.mgmt.billing.models.AddressDetails] + :keyword validation_message: Validation error message. + :paramtype validation_message: str + """ super(ValidateAddressResponse, self).__init__(**kwargs) self.status = status self.suggested_addresses = suggested_addresses @@ -3752,16 +4219,16 @@ def __init__( class ValidateProductTransferEligibilityError(msrest.serialization.Model): """Error details of the product transfer eligibility validation. - :param code: Error code for the product transfer validation. Possible values include: + :ivar code: Error code for the product transfer validation. Possible values include: "InvalidSource", "ProductNotActive", "InsufficientPermissionOnSource", "InsufficientPermissionOnDestination", "DestinationBillingProfilePastDue", "ProductTypeNotSupported", "CrossBillingAccountNotAllowed", "NotAvailableForDestinationMarket", "OneTimePurchaseProductTransferNotAllowed". - :type code: str or ~azure.mgmt.billing.models.ProductTransferValidationErrorCode - :param message: The error message. - :type message: str - :param details: Detailed error message explaining the error. - :type details: str + :vartype code: str or ~azure.mgmt.billing.models.ProductTransferValidationErrorCode + :ivar message: The error message. + :vartype message: str + :ivar details: Detailed error message explaining the error. + :vartype details: str """ _attribute_map = { @@ -3778,6 +4245,18 @@ def __init__( details: Optional[str] = None, **kwargs ): + """ + :keyword code: Error code for the product transfer validation. Possible values include: + "InvalidSource", "ProductNotActive", "InsufficientPermissionOnSource", + "InsufficientPermissionOnDestination", "DestinationBillingProfilePastDue", + "ProductTypeNotSupported", "CrossBillingAccountNotAllowed", "NotAvailableForDestinationMarket", + "OneTimePurchaseProductTransferNotAllowed". + :paramtype code: str or ~azure.mgmt.billing.models.ProductTransferValidationErrorCode + :keyword message: The error message. + :paramtype message: str + :keyword details: Detailed error message explaining the error. + :paramtype details: str + """ super(ValidateProductTransferEligibilityError, self).__init__(**kwargs) self.code = code self.message = message @@ -3791,8 +4270,8 @@ class ValidateProductTransferEligibilityResult(msrest.serialization.Model): :ivar is_move_eligible: Specifies whether the transfer is eligible or not. :vartype is_move_eligible: bool - :param error_details: Validation error details. - :type error_details: ~azure.mgmt.billing.models.ValidateProductTransferEligibilityError + :ivar error_details: Validation error details. + :vartype error_details: ~azure.mgmt.billing.models.ValidateProductTransferEligibilityError """ _validation = { @@ -3810,6 +4289,10 @@ def __init__( error_details: Optional["ValidateProductTransferEligibilityError"] = None, **kwargs ): + """ + :keyword error_details: Validation error details. + :paramtype error_details: ~azure.mgmt.billing.models.ValidateProductTransferEligibilityError + """ super(ValidateProductTransferEligibilityResult, self).__init__(**kwargs) self.is_move_eligible = None self.error_details = error_details @@ -3818,7 +4301,7 @@ def __init__( class ValidateSubscriptionTransferEligibilityError(msrest.serialization.Model): """Error details of the transfer eligibility validation. - :param code: Error code for the product transfer validation. Possible values include: + :ivar code: Error code for the product transfer validation. Possible values include: "BillingAccountInactive", "CrossBillingAccountNotAllowed", "DestinationBillingProfileInactive", "DestinationBillingProfileNotFound", "DestinationBillingProfilePastDue", "DestinationInvoiceSectionInactive", "DestinationInvoiceSectionNotFound", @@ -3826,11 +4309,11 @@ class ValidateSubscriptionTransferEligibilityError(msrest.serialization.Model): "InvalidSource", "MarketplaceNotEnabledOnDestination", "NotAvailableForDestinationMarket", "ProductInactive", "ProductNotFound", "ProductTypeNotSupported", "SourceBillingProfilePastDue", "SourceInvoiceSectionInactive", "SubscriptionNotActive", "SubscriptionTypeNotSupported". - :type code: str or ~azure.mgmt.billing.models.SubscriptionTransferValidationErrorCode - :param message: The error message. - :type message: str - :param details: Detailed error message explaining the error. - :type details: str + :vartype code: str or ~azure.mgmt.billing.models.SubscriptionTransferValidationErrorCode + :ivar message: The error message. + :vartype message: str + :ivar details: Detailed error message explaining the error. + :vartype details: str """ _attribute_map = { @@ -3847,6 +4330,21 @@ def __init__( details: Optional[str] = None, **kwargs ): + """ + :keyword code: Error code for the product transfer validation. Possible values include: + "BillingAccountInactive", "CrossBillingAccountNotAllowed", "DestinationBillingProfileInactive", + "DestinationBillingProfileNotFound", "DestinationBillingProfilePastDue", + "DestinationInvoiceSectionInactive", "DestinationInvoiceSectionNotFound", + "InsufficientPermissionOnDestination", "InsufficientPermissionOnSource", "InvalidDestination", + "InvalidSource", "MarketplaceNotEnabledOnDestination", "NotAvailableForDestinationMarket", + "ProductInactive", "ProductNotFound", "ProductTypeNotSupported", "SourceBillingProfilePastDue", + "SourceInvoiceSectionInactive", "SubscriptionNotActive", "SubscriptionTypeNotSupported". + :paramtype code: str or ~azure.mgmt.billing.models.SubscriptionTransferValidationErrorCode + :keyword message: The error message. + :paramtype message: str + :keyword details: Detailed error message explaining the error. + :paramtype details: str + """ super(ValidateSubscriptionTransferEligibilityError, self).__init__(**kwargs) self.code = code self.message = message @@ -3860,8 +4358,8 @@ class ValidateSubscriptionTransferEligibilityResult(msrest.serialization.Model): :ivar is_move_eligible: Specifies whether the subscription is eligible to be transferred. :vartype is_move_eligible: bool - :param error_details: Validation error details. - :type error_details: ~azure.mgmt.billing.models.ValidateSubscriptionTransferEligibilityError + :ivar error_details: Validation error details. + :vartype error_details: ~azure.mgmt.billing.models.ValidateSubscriptionTransferEligibilityError """ _validation = { @@ -3879,6 +4377,11 @@ def __init__( error_details: Optional["ValidateSubscriptionTransferEligibilityError"] = None, **kwargs ): + """ + :keyword error_details: Validation error details. + :paramtype error_details: + ~azure.mgmt.billing.models.ValidateSubscriptionTransferEligibilityError + """ super(ValidateSubscriptionTransferEligibilityResult, self).__init__(**kwargs) self.is_move_eligible = None self.error_details = error_details diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_address_operations.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_address_operations.py index 57bc172decfd..0644b38a60f5 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_address_operations.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_address_operations.py @@ -5,22 +5,59 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_validate_request( + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/validateAddress') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class AddressOperations(object): """AddressOperations operations. @@ -44,12 +81,12 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def validate( self, - address, # type: "_models.AddressDetails" - **kwargs # type: Any - ): - # type: (...) -> "_models.ValidateAddressResponse" + address: "_models.AddressDetails", + **kwargs: Any + ) -> "_models.ValidateAddressResponse": """Validates an address. Use the operation to validate an address before using it as soldTo or a billTo address. @@ -65,32 +102,25 @@ def validate( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(address, 'AddressDetails') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(address, 'AddressDetails') + + request = build_validate_request( + content_type=content_type, + json=_json, + template_url=self.validate.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ValidateAddressResponse', pipeline_response) @@ -99,4 +129,6 @@ def validate( return cls(pipeline_response, deserialized, {}) return deserialized + validate.metadata = {'url': '/providers/Microsoft.Billing/validateAddress'} # type: ignore + diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_agreements_operations.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_agreements_operations.py index 50c0ee838512..aa9fd102c7de 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_agreements_operations.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_agreements_operations.py @@ -5,23 +5,97 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_billing_account_request( + billing_account_name: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/agreements') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + billing_account_name: str, + agreement_name: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/agreements/{agreementName}') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "agreementName": _SERIALIZER.url("agreement_name", agreement_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class AgreementsOperations(object): """AgreementsOperations operations. @@ -45,13 +119,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_billing_account( self, - billing_account_name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AgreementListResult"] + billing_account_name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.AgreementListResult"]: """Lists the agreements for a billing account. :param billing_account_name: The ID that uniquely identifies a billing account. @@ -68,36 +142,31 @@ def list_by_billing_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_billing_account.metadata['url'] # type: ignore - 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 = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_account_request( + billing_account_name=billing_account_name, + expand=expand, + template_url=self.list_by_billing_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_account_request( + billing_account_name=billing_account_name, + expand=expand, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AgreementListResult', pipeline_response) + deserialized = self._deserialize("AgreementListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,25 +179,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/agreements'} # type: ignore + @distributed_trace def get( self, - billing_account_name, # type: str - agreement_name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.Agreement" + billing_account_name: str, + agreement_name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> "_models.Agreement": """Gets an agreement by ID. :param billing_account_name: The ID that uniquely identifies a billing account. @@ -147,34 +217,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'agreementName': self._serialize.url("agreement_name", agreement_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + billing_account_name=billing_account_name, + agreement_name=agreement_name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Agreement', pipeline_response) @@ -183,4 +242,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/agreements/{agreementName}'} # type: ignore + diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_available_balances_operations.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_available_balances_operations.py index 6c812855a098..64ae1923f3a6 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_available_balances_operations.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_available_balances_operations.py @@ -5,22 +5,57 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + billing_account_name: str, + billing_profile_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/availableBalance/default') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingProfileName": _SERIALIZER.url("billing_profile_name", billing_profile_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class AvailableBalancesOperations(object): """AvailableBalancesOperations operations. @@ -44,13 +79,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - billing_account_name, # type: str - billing_profile_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AvailableBalance" + billing_account_name: str, + billing_profile_name: str, + **kwargs: Any + ) -> "_models.AvailableBalance": """The available credit balance for a billing profile. This is the balance that can be used for pay now to settle due or past due invoices. The operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. @@ -69,32 +104,22 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AvailableBalance', pipeline_response) @@ -103,4 +128,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/availableBalance/default'} # type: ignore + diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_billing_accounts_operations.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_billing_accounts_operations.py index f16bab94220e..eb70cd716942 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_billing_accounts_operations.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_billing_accounts_operations.py @@ -5,25 +5,163 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + billing_account_name: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_request_initial( + billing_account_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_invoice_sections_by_create_subscription_permission_request( + billing_account_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/listInvoiceSectionsWithCreateSubscriptionPermission') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class BillingAccountsOperations(object): """BillingAccountsOperations operations. @@ -47,18 +185,19 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.BillingAccountListResult"] + expand: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.BillingAccountListResult"]: """Lists the billing accounts that a user has access to. :param expand: May be used to expand the soldTo, invoice sections and billing profiles. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BillingAccountListResult or the result of cls(response) + :return: An iterator like instance of either BillingAccountListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.billing.models.BillingAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -67,32 +206,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + expand=expand, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + expand=expand, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('BillingAccountListResult', pipeline_response) + deserialized = self._deserialize("BillingAccountListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -105,24 +241,25 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts'} # type: ignore + @distributed_trace def get( self, - billing_account_name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.BillingAccount" + billing_account_name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> "_models.BillingAccount": """Gets a billing account by its ID. :param billing_account_name: The ID that uniquely identifies a billing account. @@ -139,33 +276,22 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - 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 = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + billing_account_name=billing_account_name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('BillingAccount', pipeline_response) @@ -174,51 +300,41 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}'} # type: ignore + def _update_initial( self, - billing_account_name, # type: str - parameters, # type: "_models.BillingAccountUpdateRequest" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.BillingAccount"] + billing_account_name: str, + parameters: "_models.BillingAccountUpdateRequest", + **kwargs: Any + ) -> Optional["_models.BillingAccount"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.BillingAccount"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - 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 = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'BillingAccountUpdateRequest') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request_initial( + billing_account_name=billing_account_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'BillingAccountUpdateRequest') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -228,15 +344,17 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}'} # type: ignore + + @distributed_trace def begin_update( self, - billing_account_name, # type: str - parameters, # type: "_models.BillingAccountUpdateRequest" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.BillingAccount"] + billing_account_name: str, + parameters: "_models.BillingAccountUpdateRequest", + **kwargs: Any + ) -> LROPoller["_models.BillingAccount"]: """Updates the properties of a billing account. Currently, displayName and address can be updated. The operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. @@ -248,15 +366,19 @@ def begin_update( :type parameters: ~azure.mgmt.billing.models.BillingAccountUpdateRequest :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either BillingAccount or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BillingAccount or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.billing.models.BillingAccount] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.BillingAccount"] lro_delay = kwargs.pop( 'polling_interval', @@ -267,25 +389,21 @@ def begin_update( raw_result = self._update_initial( billing_account_name=billing_account_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('BillingAccount', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -297,14 +415,15 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}'} # type: ignore + @distributed_trace def list_invoice_sections_by_create_subscription_permission( self, - billing_account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.InvoiceSectionListWithCreateSubPermissionResult"] + billing_account_name: str, + **kwargs: Any + ) -> Iterable["_models.InvoiceSectionListWithCreateSubPermissionResult"]: """Lists the invoice sections for which the user has permission to create Azure subscriptions. The operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. @@ -312,8 +431,10 @@ def list_invoice_sections_by_create_subscription_permission( :param billing_account_name: The ID that uniquely identifies a billing account. :type billing_account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either InvoiceSectionListWithCreateSubPermissionResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.billing.models.InvoiceSectionListWithCreateSubPermissionResult] + :return: An iterator like instance of either InvoiceSectionListWithCreateSubPermissionResult or + the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.billing.models.InvoiceSectionListWithCreateSubPermissionResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.InvoiceSectionListWithCreateSubPermissionResult"] @@ -321,34 +442,29 @@ def list_invoice_sections_by_create_subscription_permission( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_invoice_sections_by_create_subscription_permission.metadata['url'] # type: ignore - 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 = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.post(url, query_parameters, header_parameters) + + request = build_list_invoice_sections_by_create_subscription_permission_request( + billing_account_name=billing_account_name, + template_url=self.list_invoice_sections_by_create_subscription_permission.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_invoice_sections_by_create_subscription_permission_request( + billing_account_name=billing_account_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('InvoiceSectionListWithCreateSubPermissionResult', pipeline_response) + deserialized = self._deserialize("InvoiceSectionListWithCreateSubPermissionResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -361,12 +477,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_billing_periods_operations.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_billing_periods_operations.py index f14d0fb7b717..6c8ba1bc1bc2 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_billing_periods_operations.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_billing_periods_operations.py @@ -5,23 +5,99 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +def build_list_request( + subscription_id: str, + *, + filter: Optional[str] = None, + skiptoken: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingPeriods') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if skiptoken is not None: + query_parameters['$skiptoken'] = _SERIALIZER.query("skiptoken", skiptoken, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', maximum=100, minimum=1) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + billing_period_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "billingPeriodName": _SERIALIZER.url("billing_period_name", billing_period_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class BillingPeriodsOperations(object): """BillingPeriodsOperations operations. @@ -45,14 +121,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - filter=None, # type: Optional[str] - skiptoken=None, # type: Optional[str] - top=None, # type: Optional[int] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.BillingPeriodsListResult"] + filter: Optional[str] = None, + skiptoken: Optional[str] = None, + top: Optional[int] = None, + **kwargs: Any + ) -> Iterable["_models.BillingPeriodsListResult"]: """Lists the available billing periods for a subscription in reverse chronological order. This is only supported for Azure Web-Direct subscriptions. Other subscription types which were not purchased directly through the Azure web portal are not supported through this preview API. @@ -68,7 +144,8 @@ def list( :param top: May be used to limit the number of results to the most recent N billing periods. :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BillingPeriodsListResult or the result of cls(response) + :return: An iterator like instance of either BillingPeriodsListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.billing.models.BillingPeriodsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -77,40 +154,35 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - 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 = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if skiptoken is not None: - query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int', maximum=100, minimum=1) - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + filter=filter, + skiptoken=skiptoken, + top=top, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + filter=filter, + skiptoken=skiptoken, + top=top, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('BillingPeriodsListResult', pipeline_response) + deserialized = self._deserialize("BillingPeriodsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -123,23 +195,24 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingPeriods'} # type: ignore + @distributed_trace def get( self, - billing_period_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.BillingPeriod" + billing_period_name: str, + **kwargs: Any + ) -> "_models.BillingPeriod": """Gets a named billing period. This is only supported for Azure Web-Direct subscriptions. Other subscription types which were not purchased directly through the Azure web portal are not supported through this preview API. @@ -156,32 +229,22 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'billingPeriodName': self._serialize.url("billing_period_name", billing_period_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + billing_period_name=billing_period_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('BillingPeriod', pipeline_response) @@ -190,4 +253,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingPeriods/{billingPeriodName}'} # type: ignore + diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_billing_permissions_operations.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_billing_permissions_operations.py index aed9a76bc326..995d68555d75 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_billing_permissions_operations.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_billing_permissions_operations.py @@ -5,23 +5,157 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_customer_request( + billing_account_name: str, + customer_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/billingPermissions') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "customerName": _SERIALIZER.url("customer_name", customer_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_billing_account_request( + billing_account_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingPermissions') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_invoice_sections_request( + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingPermissions') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingProfileName": _SERIALIZER.url("billing_profile_name", billing_profile_name, 'str'), + "invoiceSectionName": _SERIALIZER.url("invoice_section_name", invoice_section_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_billing_profile_request( + billing_account_name: str, + billing_profile_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingPermissions') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingProfileName": _SERIALIZER.url("billing_profile_name", billing_profile_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class BillingPermissionsOperations(object): """BillingPermissionsOperations operations. @@ -45,13 +179,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_customer( self, - billing_account_name, # type: str - customer_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.BillingPermissionsListResult"] + billing_account_name: str, + customer_name: str, + **kwargs: Any + ) -> Iterable["_models.BillingPermissionsListResult"]: """Lists the billing permissions the caller has for a customer. :param billing_account_name: The ID that uniquely identifies a billing account. @@ -59,7 +193,8 @@ def list_by_customer( :param customer_name: The ID that uniquely identifies a customer. :type customer_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BillingPermissionsListResult or the result of cls(response) + :return: An iterator like instance of either BillingPermissionsListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.billing.models.BillingPermissionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -68,35 +203,31 @@ def list_by_customer( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_customer.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'customerName': self._serialize.url("customer_name", customer_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_customer_request( + billing_account_name=billing_account_name, + customer_name=customer_name, + template_url=self.list_by_customer.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_customer_request( + billing_account_name=billing_account_name, + customer_name=customer_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('BillingPermissionsListResult', pipeline_response) + deserialized = self._deserialize("BillingPermissionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -109,29 +240,31 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_customer.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/billingPermissions'} # type: ignore + @distributed_trace def list_by_billing_account( self, - billing_account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.BillingPermissionsListResult"] + billing_account_name: str, + **kwargs: Any + ) -> Iterable["_models.BillingPermissionsListResult"]: """Lists the billing permissions the caller has on a billing account. :param billing_account_name: The ID that uniquely identifies a billing account. :type billing_account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BillingPermissionsListResult or the result of cls(response) + :return: An iterator like instance of either BillingPermissionsListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.billing.models.BillingPermissionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -140,34 +273,29 @@ def list_by_billing_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_billing_account.metadata['url'] # type: ignore - 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 = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_account_request( + billing_account_name=billing_account_name, + template_url=self.list_by_billing_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_account_request( + billing_account_name=billing_account_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('BillingPermissionsListResult', pipeline_response) + deserialized = self._deserialize("BillingPermissionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -180,25 +308,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingPermissions'} # type: ignore + @distributed_trace def list_by_invoice_sections( self, - billing_account_name, # type: str - billing_profile_name, # type: str - invoice_section_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.BillingPermissionsListResult"] + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + **kwargs: Any + ) -> Iterable["_models.BillingPermissionsListResult"]: """Lists the billing permissions the caller has on an invoice section. :param billing_account_name: The ID that uniquely identifies a billing account. @@ -208,7 +337,8 @@ def list_by_invoice_sections( :param invoice_section_name: The ID that uniquely identifies an invoice section. :type invoice_section_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BillingPermissionsListResult or the result of cls(response) + :return: An iterator like instance of either BillingPermissionsListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.billing.models.BillingPermissionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -217,36 +347,33 @@ def list_by_invoice_sections( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_invoice_sections.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - 'invoiceSectionName': self._serialize.url("invoice_section_name", invoice_section_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_invoice_sections_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + template_url=self.list_by_invoice_sections.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_invoice_sections_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('BillingPermissionsListResult', pipeline_response) + deserialized = self._deserialize("BillingPermissionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -259,24 +386,25 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_invoice_sections.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingPermissions'} # type: ignore + @distributed_trace def list_by_billing_profile( self, - billing_account_name, # type: str - billing_profile_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.BillingPermissionsListResult"] + billing_account_name: str, + billing_profile_name: str, + **kwargs: Any + ) -> Iterable["_models.BillingPermissionsListResult"]: """Lists the billing permissions the caller has on a billing profile. :param billing_account_name: The ID that uniquely identifies a billing account. @@ -284,7 +412,8 @@ def list_by_billing_profile( :param billing_profile_name: The ID that uniquely identifies a billing profile. :type billing_profile_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BillingPermissionsListResult or the result of cls(response) + :return: An iterator like instance of either BillingPermissionsListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.billing.models.BillingPermissionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -293,35 +422,31 @@ def list_by_billing_profile( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_billing_profile.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + template_url=self.list_by_billing_profile.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('BillingPermissionsListResult', pipeline_response) + deserialized = self._deserialize("BillingPermissionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -334,12 +459,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_billing_profiles_operations.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_billing_profiles_operations.py index 355606d61b54..0e3a1437f561 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_billing_profiles_operations.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_billing_profiles_operations.py @@ -5,25 +5,142 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_billing_account_request( + billing_account_name: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + billing_account_name: str, + billing_profile_name: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingProfileName": _SERIALIZER.url("billing_profile_name", billing_profile_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + billing_account_name: str, + billing_profile_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingProfileName": _SERIALIZER.url("billing_profile_name", billing_profile_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class BillingProfilesOperations(object): """BillingProfilesOperations operations. @@ -47,13 +164,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_billing_account( self, - billing_account_name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.BillingProfileListResult"] + billing_account_name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.BillingProfileListResult"]: """Lists the billing profiles that a user has access to. The operation is supported for billing accounts with agreement type Microsoft Customer Agreement or Microsoft Partner Agreement. @@ -62,7 +179,8 @@ def list_by_billing_account( :param expand: May be used to expand the invoice sections. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BillingProfileListResult or the result of cls(response) + :return: An iterator like instance of either BillingProfileListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.billing.models.BillingProfileListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -71,36 +189,31 @@ def list_by_billing_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_billing_account.metadata['url'] # type: ignore - 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 = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_account_request( + billing_account_name=billing_account_name, + expand=expand, + template_url=self.list_by_billing_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_account_request( + billing_account_name=billing_account_name, + expand=expand, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('BillingProfileListResult', pipeline_response) + deserialized = self._deserialize("BillingProfileListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -113,25 +226,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles'} # type: ignore + @distributed_trace def get( self, - billing_account_name, # type: str - billing_profile_name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.BillingProfile" + billing_account_name: str, + billing_profile_name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> "_models.BillingProfile": """Gets a billing profile by its ID. The operation is supported for billing accounts with agreement type Microsoft Customer Agreement or Microsoft Partner Agreement. @@ -151,34 +265,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('BillingProfile', pipeline_response) @@ -187,77 +290,70 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}'} # type: ignore + def _create_or_update_initial( self, - billing_account_name, # type: str - billing_profile_name, # type: str - parameters, # type: "_models.BillingProfile" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.BillingProfile"] + billing_account_name: str, + billing_profile_name: str, + parameters: "_models.BillingProfile", + **kwargs: Any + ) -> Optional["_models.BillingProfile"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.BillingProfile"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'BillingProfile') + + request = build_create_or_update_request_initial( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'BillingProfile') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('BillingProfile', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _create_or_update_initial.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - billing_account_name, # type: str - billing_profile_name, # type: str - parameters, # type: "_models.BillingProfile" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.BillingProfile"] + billing_account_name: str, + billing_profile_name: str, + parameters: "_models.BillingProfile", + **kwargs: Any + ) -> LROPoller["_models.BillingProfile"]: """Creates or updates a billing profile. The operation is supported for billing accounts with agreement type Microsoft Customer Agreement or Microsoft Partner Agreement. @@ -269,15 +365,19 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.billing.models.BillingProfile :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either BillingProfile or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BillingProfile or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.billing.models.BillingProfile] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.BillingProfile"] lro_delay = kwargs.pop( 'polling_interval', @@ -289,26 +389,21 @@ def begin_create_or_update( billing_account_name=billing_account_name, billing_profile_name=billing_profile_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('BillingProfile', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -320,4 +415,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}'} # type: ignore diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_billing_property_operations.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_billing_property_operations.py index 27b207d37848..6a91713acb23 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_billing_property_operations.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_billing_property_operations.py @@ -5,22 +5,96 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingProperty/default') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_request( + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingProperty/default') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class BillingPropertyOperations(object): """BillingPropertyOperations operations. @@ -44,11 +118,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - **kwargs # type: Any - ): - # type: (...) -> "_models.BillingProperty" + **kwargs: Any + ) -> "_models.BillingProperty": """Get the billing properties for a subscription. This operation is not supported for billing accounts with agreement type Enterprise Agreement. @@ -62,31 +136,21 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - 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 = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('BillingProperty', pipeline_response) @@ -95,14 +159,16 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingProperty/default'} # type: ignore + + @distributed_trace def update( self, - parameters, # type: "_models.BillingProperty" - **kwargs # type: Any - ): - # type: (...) -> "_models.BillingProperty" + parameters: "_models.BillingProperty", + **kwargs: Any + ) -> "_models.BillingProperty": """Updates the billing property of a subscription. Currently, cost center can be updated. The operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. @@ -120,36 +186,26 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - 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 = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'BillingProperty') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'BillingProperty') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('BillingProperty', pipeline_response) @@ -158,4 +214,6 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Billing/billingProperty/default'} # type: ignore + diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_billing_role_assignments_operations.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_billing_role_assignments_operations.py index 3ab2113a6808..588055713802 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_billing_role_assignments_operations.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_billing_role_assignments_operations.py @@ -5,23 +5,334 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_by_billing_account_request( + billing_account_name: str, + billing_role_assignment_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleAssignments/{billingRoleAssignmentName}') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingRoleAssignmentName": _SERIALIZER.url("billing_role_assignment_name", billing_role_assignment_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_by_billing_account_request( + billing_account_name: str, + billing_role_assignment_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleAssignments/{billingRoleAssignmentName}') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingRoleAssignmentName": _SERIALIZER.url("billing_role_assignment_name", billing_role_assignment_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_by_invoice_section_request( + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + billing_role_assignment_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRoleAssignments/{billingRoleAssignmentName}') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingProfileName": _SERIALIZER.url("billing_profile_name", billing_profile_name, 'str'), + "invoiceSectionName": _SERIALIZER.url("invoice_section_name", invoice_section_name, 'str'), + "billingRoleAssignmentName": _SERIALIZER.url("billing_role_assignment_name", billing_role_assignment_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_by_invoice_section_request( + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + billing_role_assignment_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRoleAssignments/{billingRoleAssignmentName}') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingProfileName": _SERIALIZER.url("billing_profile_name", billing_profile_name, 'str'), + "invoiceSectionName": _SERIALIZER.url("invoice_section_name", invoice_section_name, 'str'), + "billingRoleAssignmentName": _SERIALIZER.url("billing_role_assignment_name", billing_role_assignment_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_by_billing_profile_request( + billing_account_name: str, + billing_profile_name: str, + billing_role_assignment_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRoleAssignments/{billingRoleAssignmentName}') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingProfileName": _SERIALIZER.url("billing_profile_name", billing_profile_name, 'str'), + "billingRoleAssignmentName": _SERIALIZER.url("billing_role_assignment_name", billing_role_assignment_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_by_billing_profile_request( + billing_account_name: str, + billing_profile_name: str, + billing_role_assignment_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRoleAssignments/{billingRoleAssignmentName}') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingProfileName": _SERIALIZER.url("billing_profile_name", billing_profile_name, 'str'), + "billingRoleAssignmentName": _SERIALIZER.url("billing_role_assignment_name", billing_role_assignment_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_billing_account_request( + billing_account_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleAssignments') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_invoice_section_request( + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRoleAssignments') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingProfileName": _SERIALIZER.url("billing_profile_name", billing_profile_name, 'str'), + "invoiceSectionName": _SERIALIZER.url("invoice_section_name", invoice_section_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_billing_profile_request( + billing_account_name: str, + billing_profile_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRoleAssignments') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingProfileName": _SERIALIZER.url("billing_profile_name", billing_profile_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class BillingRoleAssignmentsOperations(object): """BillingRoleAssignmentsOperations operations. @@ -45,13 +356,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get_by_billing_account( self, - billing_account_name, # type: str - billing_role_assignment_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.BillingRoleAssignment" + billing_account_name: str, + billing_role_assignment_name: str, + **kwargs: Any + ) -> "_models.BillingRoleAssignment": """Gets a role assignment for the caller on a billing account. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. @@ -70,32 +381,22 @@ def get_by_billing_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.get_by_billing_account.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingRoleAssignmentName': self._serialize.url("billing_role_assignment_name", billing_role_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_billing_account_request( + billing_account_name=billing_account_name, + billing_role_assignment_name=billing_role_assignment_name, + template_url=self.get_by_billing_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('BillingRoleAssignment', pipeline_response) @@ -104,15 +405,17 @@ def get_by_billing_account( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleAssignments/{billingRoleAssignmentName}'} # type: ignore + + @distributed_trace def delete_by_billing_account( self, - billing_account_name, # type: str - billing_role_assignment_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.BillingRoleAssignment" + billing_account_name: str, + billing_role_assignment_name: str, + **kwargs: Any + ) -> "_models.BillingRoleAssignment": """Deletes a role assignment for the caller on a billing account. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. @@ -131,32 +434,22 @@ def delete_by_billing_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.delete_by_billing_account.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingRoleAssignmentName': self._serialize.url("billing_role_assignment_name", billing_role_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_billing_account_request( + billing_account_name=billing_account_name, + billing_role_assignment_name=billing_role_assignment_name, + template_url=self.delete_by_billing_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('BillingRoleAssignment', pipeline_response) @@ -165,17 +458,19 @@ def delete_by_billing_account( return cls(pipeline_response, deserialized, {}) return deserialized + delete_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleAssignments/{billingRoleAssignmentName}'} # type: ignore + + @distributed_trace def get_by_invoice_section( self, - billing_account_name, # type: str - billing_profile_name, # type: str - invoice_section_name, # type: str - billing_role_assignment_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.BillingRoleAssignment" + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + billing_role_assignment_name: str, + **kwargs: Any + ) -> "_models.BillingRoleAssignment": """Gets a role assignment for the caller on an invoice section. The operation is supported for billing accounts with agreement type Microsoft Customer Agreement. @@ -197,34 +492,24 @@ def get_by_invoice_section( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.get_by_invoice_section.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - 'invoiceSectionName': self._serialize.url("invoice_section_name", invoice_section_name, 'str'), - 'billingRoleAssignmentName': self._serialize.url("billing_role_assignment_name", billing_role_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_invoice_section_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + billing_role_assignment_name=billing_role_assignment_name, + template_url=self.get_by_invoice_section.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('BillingRoleAssignment', pipeline_response) @@ -233,17 +518,19 @@ def get_by_invoice_section( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_invoice_section.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRoleAssignments/{billingRoleAssignmentName}'} # type: ignore + + @distributed_trace def delete_by_invoice_section( self, - billing_account_name, # type: str - billing_profile_name, # type: str - invoice_section_name, # type: str - billing_role_assignment_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.BillingRoleAssignment" + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + billing_role_assignment_name: str, + **kwargs: Any + ) -> "_models.BillingRoleAssignment": """Deletes a role assignment for the caller on an invoice section. The operation is supported for billing accounts with agreement type Microsoft Customer Agreement. @@ -265,34 +552,24 @@ def delete_by_invoice_section( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.delete_by_invoice_section.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - 'invoiceSectionName': self._serialize.url("invoice_section_name", invoice_section_name, 'str'), - 'billingRoleAssignmentName': self._serialize.url("billing_role_assignment_name", billing_role_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_invoice_section_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + billing_role_assignment_name=billing_role_assignment_name, + template_url=self.delete_by_invoice_section.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('BillingRoleAssignment', pipeline_response) @@ -301,16 +578,18 @@ def delete_by_invoice_section( return cls(pipeline_response, deserialized, {}) return deserialized + delete_by_invoice_section.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRoleAssignments/{billingRoleAssignmentName}'} # type: ignore + + @distributed_trace def get_by_billing_profile( self, - billing_account_name, # type: str - billing_profile_name, # type: str - billing_role_assignment_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.BillingRoleAssignment" + billing_account_name: str, + billing_profile_name: str, + billing_role_assignment_name: str, + **kwargs: Any + ) -> "_models.BillingRoleAssignment": """Gets a role assignment for the caller on a billing profile. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. @@ -331,33 +610,23 @@ def get_by_billing_profile( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.get_by_billing_profile.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - 'billingRoleAssignmentName': self._serialize.url("billing_role_assignment_name", billing_role_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + billing_role_assignment_name=billing_role_assignment_name, + template_url=self.get_by_billing_profile.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('BillingRoleAssignment', pipeline_response) @@ -366,16 +635,18 @@ def get_by_billing_profile( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRoleAssignments/{billingRoleAssignmentName}'} # type: ignore + + @distributed_trace def delete_by_billing_profile( self, - billing_account_name, # type: str - billing_profile_name, # type: str - billing_role_assignment_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.BillingRoleAssignment" + billing_account_name: str, + billing_profile_name: str, + billing_role_assignment_name: str, + **kwargs: Any + ) -> "_models.BillingRoleAssignment": """Deletes a role assignment for the caller on a billing profile. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. @@ -396,33 +667,23 @@ def delete_by_billing_profile( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.delete_by_billing_profile.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - 'billingRoleAssignmentName': self._serialize.url("billing_role_assignment_name", billing_role_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + billing_role_assignment_name=billing_role_assignment_name, + template_url=self.delete_by_billing_profile.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('BillingRoleAssignment', pipeline_response) @@ -431,14 +692,16 @@ def delete_by_billing_profile( return cls(pipeline_response, deserialized, {}) return deserialized + delete_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRoleAssignments/{billingRoleAssignmentName}'} # type: ignore + + @distributed_trace def list_by_billing_account( self, - billing_account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.BillingRoleAssignmentListResult"] + billing_account_name: str, + **kwargs: Any + ) -> Iterable["_models.BillingRoleAssignmentListResult"]: """Lists the role assignments for the caller on a billing account. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. @@ -446,8 +709,10 @@ def list_by_billing_account( :param billing_account_name: The ID that uniquely identifies a billing account. :type billing_account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BillingRoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.billing.models.BillingRoleAssignmentListResult] + :return: An iterator like instance of either BillingRoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.billing.models.BillingRoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.BillingRoleAssignmentListResult"] @@ -455,34 +720,29 @@ def list_by_billing_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_billing_account.metadata['url'] # type: ignore - 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 = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_account_request( + billing_account_name=billing_account_name, + template_url=self.list_by_billing_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_account_request( + billing_account_name=billing_account_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('BillingRoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("BillingRoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -495,25 +755,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleAssignments'} # type: ignore + @distributed_trace def list_by_invoice_section( self, - billing_account_name, # type: str - billing_profile_name, # type: str - invoice_section_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.BillingRoleAssignmentListResult"] + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + **kwargs: Any + ) -> Iterable["_models.BillingRoleAssignmentListResult"]: """Lists the role assignments for the caller on an invoice section. The operation is supported for billing accounts with agreement type Microsoft Customer Agreement. @@ -524,8 +785,10 @@ def list_by_invoice_section( :param invoice_section_name: The ID that uniquely identifies an invoice section. :type invoice_section_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BillingRoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.billing.models.BillingRoleAssignmentListResult] + :return: An iterator like instance of either BillingRoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.billing.models.BillingRoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.BillingRoleAssignmentListResult"] @@ -533,36 +796,33 @@ def list_by_invoice_section( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_invoice_section.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - 'invoiceSectionName': self._serialize.url("invoice_section_name", invoice_section_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_invoice_section_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + template_url=self.list_by_invoice_section.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_invoice_section_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('BillingRoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("BillingRoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -575,24 +835,25 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_invoice_section.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRoleAssignments'} # type: ignore + @distributed_trace def list_by_billing_profile( self, - billing_account_name, # type: str - billing_profile_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.BillingRoleAssignmentListResult"] + billing_account_name: str, + billing_profile_name: str, + **kwargs: Any + ) -> Iterable["_models.BillingRoleAssignmentListResult"]: """Lists the role assignments for the caller on a billing profile. The operation is supported for billing accounts with agreement type Microsoft Customer Agreement. @@ -601,8 +862,10 @@ def list_by_billing_profile( :param billing_profile_name: The ID that uniquely identifies a billing profile. :type billing_profile_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BillingRoleAssignmentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.billing.models.BillingRoleAssignmentListResult] + :return: An iterator like instance of either BillingRoleAssignmentListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.billing.models.BillingRoleAssignmentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.BillingRoleAssignmentListResult"] @@ -610,35 +873,31 @@ def list_by_billing_profile( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_billing_profile.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + template_url=self.list_by_billing_profile.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('BillingRoleAssignmentListResult', pipeline_response) + deserialized = self._deserialize("BillingRoleAssignmentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -651,12 +910,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_billing_role_definitions_operations.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_billing_role_definitions_operations.py index 1c6ebe650d73..0a1b4b31f951 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_billing_role_definitions_operations.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_billing_role_definitions_operations.py @@ -5,23 +5,229 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_by_billing_account_request( + billing_account_name: str, + billing_role_definition_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleDefinitions/{billingRoleDefinitionName}') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingRoleDefinitionName": _SERIALIZER.url("billing_role_definition_name", billing_role_definition_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_by_invoice_section_request( + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + billing_role_definition_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRoleDefinitions/{billingRoleDefinitionName}') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingProfileName": _SERIALIZER.url("billing_profile_name", billing_profile_name, 'str'), + "invoiceSectionName": _SERIALIZER.url("invoice_section_name", invoice_section_name, 'str'), + "billingRoleDefinitionName": _SERIALIZER.url("billing_role_definition_name", billing_role_definition_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_by_billing_profile_request( + billing_account_name: str, + billing_profile_name: str, + billing_role_definition_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRoleDefinitions/{billingRoleDefinitionName}') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingProfileName": _SERIALIZER.url("billing_profile_name", billing_profile_name, 'str'), + "billingRoleDefinitionName": _SERIALIZER.url("billing_role_definition_name", billing_role_definition_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_billing_account_request( + billing_account_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleDefinitions') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_invoice_section_request( + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRoleDefinitions') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingProfileName": _SERIALIZER.url("billing_profile_name", billing_profile_name, 'str'), + "invoiceSectionName": _SERIALIZER.url("invoice_section_name", invoice_section_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_billing_profile_request( + billing_account_name: str, + billing_profile_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRoleDefinitions') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingProfileName": _SERIALIZER.url("billing_profile_name", billing_profile_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class BillingRoleDefinitionsOperations(object): """BillingRoleDefinitionsOperations operations. @@ -45,13 +251,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get_by_billing_account( self, - billing_account_name, # type: str - billing_role_definition_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.BillingRoleDefinition" + billing_account_name: str, + billing_role_definition_name: str, + **kwargs: Any + ) -> "_models.BillingRoleDefinition": """Gets the definition for a role on a billing account. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. @@ -69,32 +275,22 @@ def get_by_billing_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.get_by_billing_account.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingRoleDefinitionName': self._serialize.url("billing_role_definition_name", billing_role_definition_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_billing_account_request( + billing_account_name=billing_account_name, + billing_role_definition_name=billing_role_definition_name, + template_url=self.get_by_billing_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('BillingRoleDefinition', pipeline_response) @@ -103,17 +299,19 @@ def get_by_billing_account( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleDefinitions/{billingRoleDefinitionName}'} # type: ignore + + @distributed_trace def get_by_invoice_section( self, - billing_account_name, # type: str - billing_profile_name, # type: str - invoice_section_name, # type: str - billing_role_definition_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.BillingRoleDefinition" + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + billing_role_definition_name: str, + **kwargs: Any + ) -> "_models.BillingRoleDefinition": """Gets the definition for a role on an invoice section. The operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. @@ -135,34 +333,24 @@ def get_by_invoice_section( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.get_by_invoice_section.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - 'invoiceSectionName': self._serialize.url("invoice_section_name", invoice_section_name, 'str'), - 'billingRoleDefinitionName': self._serialize.url("billing_role_definition_name", billing_role_definition_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_invoice_section_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + billing_role_definition_name=billing_role_definition_name, + template_url=self.get_by_invoice_section.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('BillingRoleDefinition', pipeline_response) @@ -171,16 +359,18 @@ def get_by_invoice_section( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_invoice_section.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRoleDefinitions/{billingRoleDefinitionName}'} # type: ignore + + @distributed_trace def get_by_billing_profile( self, - billing_account_name, # type: str - billing_profile_name, # type: str - billing_role_definition_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.BillingRoleDefinition" + billing_account_name: str, + billing_profile_name: str, + billing_role_definition_name: str, + **kwargs: Any + ) -> "_models.BillingRoleDefinition": """Gets the definition for a role on a billing profile. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. @@ -200,33 +390,23 @@ def get_by_billing_profile( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.get_by_billing_profile.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - 'billingRoleDefinitionName': self._serialize.url("billing_role_definition_name", billing_role_definition_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + billing_role_definition_name=billing_role_definition_name, + template_url=self.get_by_billing_profile.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('BillingRoleDefinition', pipeline_response) @@ -235,22 +415,26 @@ def get_by_billing_profile( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingRoleDefinitions/{billingRoleDefinitionName}'} # type: ignore + + @distributed_trace def list_by_billing_account( self, - billing_account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.BillingRoleDefinitionListResult"] + billing_account_name: str, + **kwargs: Any + ) -> Iterable["_models.BillingRoleDefinitionListResult"]: """Lists the role definitions for a billing account. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. :param billing_account_name: The ID that uniquely identifies a billing account. :type billing_account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BillingRoleDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.billing.models.BillingRoleDefinitionListResult] + :return: An iterator like instance of either BillingRoleDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.billing.models.BillingRoleDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.BillingRoleDefinitionListResult"] @@ -258,34 +442,29 @@ def list_by_billing_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_billing_account.metadata['url'] # type: ignore - 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 = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_account_request( + billing_account_name=billing_account_name, + template_url=self.list_by_billing_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_account_request( + billing_account_name=billing_account_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('BillingRoleDefinitionListResult', pipeline_response) + deserialized = self._deserialize("BillingRoleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -298,25 +477,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingRoleDefinitions'} # type: ignore + @distributed_trace def list_by_invoice_section( self, - billing_account_name, # type: str - billing_profile_name, # type: str - invoice_section_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.BillingRoleDefinitionListResult"] + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + **kwargs: Any + ) -> Iterable["_models.BillingRoleDefinitionListResult"]: """Lists the role definitions for an invoice section. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. @@ -327,8 +507,10 @@ def list_by_invoice_section( :param invoice_section_name: The ID that uniquely identifies an invoice section. :type invoice_section_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BillingRoleDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.billing.models.BillingRoleDefinitionListResult] + :return: An iterator like instance of either BillingRoleDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.billing.models.BillingRoleDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.BillingRoleDefinitionListResult"] @@ -336,36 +518,33 @@ def list_by_invoice_section( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_invoice_section.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - 'invoiceSectionName': self._serialize.url("invoice_section_name", invoice_section_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_invoice_section_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + template_url=self.list_by_invoice_section.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_invoice_section_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('BillingRoleDefinitionListResult', pipeline_response) + deserialized = self._deserialize("BillingRoleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -378,24 +557,25 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_invoice_section.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingRoleDefinitions'} # type: ignore + @distributed_trace def list_by_billing_profile( self, - billing_account_name, # type: str - billing_profile_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.BillingRoleDefinitionListResult"] + billing_account_name: str, + billing_profile_name: str, + **kwargs: Any + ) -> Iterable["_models.BillingRoleDefinitionListResult"]: """Lists the role definitions for a billing profile. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. @@ -404,8 +584,10 @@ def list_by_billing_profile( :param billing_profile_name: The ID that uniquely identifies a billing profile. :type billing_profile_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BillingRoleDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.billing.models.BillingRoleDefinitionListResult] + :return: An iterator like instance of either BillingRoleDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.billing.models.BillingRoleDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.BillingRoleDefinitionListResult"] @@ -413,35 +595,31 @@ def list_by_billing_profile( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_billing_profile.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + template_url=self.list_by_billing_profile.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('BillingRoleDefinitionListResult', pipeline_response) + deserialized = self._deserialize("BillingRoleDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -454,12 +632,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_billing_subscriptions_operations.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_billing_subscriptions_operations.py index 1e437388e858..93c0ff933f6d 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_billing_subscriptions_operations.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_billing_subscriptions_operations.py @@ -5,25 +5,319 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_customer_request( + billing_account_name: str, + customer_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/billingSubscriptions') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "customerName": _SERIALIZER.url("customer_name", customer_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_billing_account_request( + billing_account_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_billing_profile_request( + billing_account_name: str, + billing_profile_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingSubscriptions') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingProfileName": _SERIALIZER.url("billing_profile_name", billing_profile_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_invoice_section_request( + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingSubscriptions') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingProfileName": _SERIALIZER.url("billing_profile_name", billing_profile_name, 'str'), + "invoiceSectionName": _SERIALIZER.url("invoice_section_name", invoice_section_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + billing_account_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{subscriptionId}') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_request( + billing_account_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{subscriptionId}') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_move_request_initial( + billing_account_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{subscriptionId}/move') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_validate_move_request( + billing_account_name: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{subscriptionId}/validateMoveEligibility') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class BillingSubscriptionsOperations(object): """BillingSubscriptionsOperations operations. @@ -47,13 +341,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_customer( self, - billing_account_name, # type: str - customer_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.BillingSubscriptionsListResult"] + billing_account_name: str, + customer_name: str, + **kwargs: Any + ) -> Iterable["_models.BillingSubscriptionsListResult"]: """Lists the subscriptions for a customer. The operation is supported only for billing accounts with agreement type Microsoft Partner Agreement. @@ -62,7 +356,8 @@ def list_by_customer( :param customer_name: The ID that uniquely identifies a customer. :type customer_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BillingSubscriptionsListResult or the result of cls(response) + :return: An iterator like instance of either BillingSubscriptionsListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.billing.models.BillingSubscriptionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -71,35 +366,31 @@ def list_by_customer( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_customer.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'customerName': self._serialize.url("customer_name", customer_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_customer_request( + billing_account_name=billing_account_name, + customer_name=customer_name, + template_url=self.list_by_customer.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_customer_request( + billing_account_name=billing_account_name, + customer_name=customer_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('BillingSubscriptionsListResult', pipeline_response) + deserialized = self._deserialize("BillingSubscriptionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -112,30 +403,32 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_customer.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/billingSubscriptions'} # type: ignore + @distributed_trace def list_by_billing_account( self, - billing_account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.BillingSubscriptionsListResult"] + billing_account_name: str, + **kwargs: Any + ) -> Iterable["_models.BillingSubscriptionsListResult"]: """Lists the subscriptions for a billing account. The operation is supported for billing accounts with agreement type Microsoft Customer Agreement or Microsoft Partner Agreement. :param billing_account_name: The ID that uniquely identifies a billing account. :type billing_account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BillingSubscriptionsListResult or the result of cls(response) + :return: An iterator like instance of either BillingSubscriptionsListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.billing.models.BillingSubscriptionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -144,34 +437,29 @@ def list_by_billing_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_billing_account.metadata['url'] # type: ignore - 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 = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_account_request( + billing_account_name=billing_account_name, + template_url=self.list_by_billing_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_account_request( + billing_account_name=billing_account_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('BillingSubscriptionsListResult', pipeline_response) + deserialized = self._deserialize("BillingSubscriptionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -184,24 +472,25 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions'} # type: ignore + @distributed_trace def list_by_billing_profile( self, - billing_account_name, # type: str - billing_profile_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.BillingSubscriptionsListResult"] + billing_account_name: str, + billing_profile_name: str, + **kwargs: Any + ) -> Iterable["_models.BillingSubscriptionsListResult"]: """Lists the subscriptions that are billed to a billing profile. The operation is supported for billing accounts with agreement type Microsoft Customer Agreement or Microsoft Partner Agreement. @@ -211,7 +500,8 @@ def list_by_billing_profile( :param billing_profile_name: The ID that uniquely identifies a billing profile. :type billing_profile_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BillingSubscriptionsListResult or the result of cls(response) + :return: An iterator like instance of either BillingSubscriptionsListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.billing.models.BillingSubscriptionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -220,35 +510,31 @@ def list_by_billing_profile( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_billing_profile.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + template_url=self.list_by_billing_profile.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('BillingSubscriptionsListResult', pipeline_response) + deserialized = self._deserialize("BillingSubscriptionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -261,25 +547,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/billingSubscriptions'} # type: ignore + @distributed_trace def list_by_invoice_section( self, - billing_account_name, # type: str - billing_profile_name, # type: str - invoice_section_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.BillingSubscriptionsListResult"] + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + **kwargs: Any + ) -> Iterable["_models.BillingSubscriptionsListResult"]: """Lists the subscriptions that are billed to an invoice section. The operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. @@ -290,7 +577,8 @@ def list_by_invoice_section( :param invoice_section_name: The ID that uniquely identifies an invoice section. :type invoice_section_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either BillingSubscriptionsListResult or the result of cls(response) + :return: An iterator like instance of either BillingSubscriptionsListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.billing.models.BillingSubscriptionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -299,36 +587,33 @@ def list_by_invoice_section( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_invoice_section.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - 'invoiceSectionName': self._serialize.url("invoice_section_name", invoice_section_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_invoice_section_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + template_url=self.list_by_invoice_section.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_invoice_section_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('BillingSubscriptionsListResult', pipeline_response) + deserialized = self._deserialize("BillingSubscriptionsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -341,23 +626,24 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_invoice_section.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/billingSubscriptions'} # type: ignore + @distributed_trace def get( self, - billing_account_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.BillingSubscription" + billing_account_name: str, + **kwargs: Any + ) -> "_models.BillingSubscription": """Gets a subscription by its ID. The operation is supported for billing accounts with agreement type Microsoft Customer Agreement and Microsoft Partner Agreement. @@ -373,32 +659,22 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - '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 = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + billing_account_name=billing_account_name, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('BillingSubscription', pipeline_response) @@ -407,15 +683,17 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{subscriptionId}'} # type: ignore + + @distributed_trace def update( self, - billing_account_name, # type: str - parameters, # type: "_models.BillingSubscription" - **kwargs # type: Any - ): - # type: (...) -> "_models.BillingSubscription" + billing_account_name: str, + parameters: "_models.BillingSubscription", + **kwargs: Any + ) -> "_models.BillingSubscription": """Updates the properties of a billing subscription. Currently, cost center can be updated. The operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. @@ -435,37 +713,27 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - '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 = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'BillingSubscription') + + request = build_update_request( + billing_account_name=billing_account_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'BillingSubscription') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('BillingSubscription', pipeline_response) @@ -474,75 +742,68 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{subscriptionId}'} # type: ignore + def _move_initial( self, - billing_account_name, # type: str - parameters, # type: "_models.TransferBillingSubscriptionRequestProperties" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.BillingSubscription"] + billing_account_name: str, + parameters: "_models.TransferBillingSubscriptionRequestProperties", + **kwargs: Any + ) -> Optional["_models.BillingSubscription"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.BillingSubscription"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._move_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - '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 = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'TransferBillingSubscriptionRequestProperties') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_move_request_initial( + billing_account_name=billing_account_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._move_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TransferBillingSubscriptionRequestProperties') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('BillingSubscription', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _move_initial.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{subscriptionId}/move'} # type: ignore + + @distributed_trace def begin_move( self, - billing_account_name, # type: str - parameters, # type: "_models.TransferBillingSubscriptionRequestProperties" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.BillingSubscription"] + billing_account_name: str, + parameters: "_models.TransferBillingSubscriptionRequestProperties", + **kwargs: Any + ) -> LROPoller["_models.BillingSubscription"]: """Moves a subscription's charges to a new invoice section. The new invoice section must belong to the same billing profile as the existing invoice section. This operation is supported for billing accounts with agreement type Microsoft Customer Agreement. @@ -553,15 +814,19 @@ def begin_move( :type parameters: ~azure.mgmt.billing.models.TransferBillingSubscriptionRequestProperties :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either BillingSubscription or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either BillingSubscription or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.billing.models.BillingSubscription] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.BillingSubscription"] lro_delay = kwargs.pop( 'polling_interval', @@ -572,26 +837,21 @@ def begin_move( raw_result = self._move_initial( billing_account_name=billing_account_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('BillingSubscription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -603,15 +863,16 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_move.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{subscriptionId}/move'} # type: ignore + @distributed_trace def validate_move( self, - billing_account_name, # type: str - parameters, # type: "_models.TransferBillingSubscriptionRequestProperties" - **kwargs # type: Any - ): - # type: (...) -> "_models.ValidateSubscriptionTransferEligibilityResult" + billing_account_name: str, + parameters: "_models.TransferBillingSubscriptionRequestProperties", + **kwargs: Any + ) -> "_models.ValidateSubscriptionTransferEligibilityResult": """Validates if a subscription's charges can be moved to a new invoice section. This operation is supported for billing accounts with agreement type Microsoft Customer Agreement. @@ -630,37 +891,27 @@ def validate_move( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate_move.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - '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 = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'TransferBillingSubscriptionRequestProperties') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_move_request( + billing_account_name=billing_account_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.validate_move.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TransferBillingSubscriptionRequestProperties') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ValidateSubscriptionTransferEligibilityResult', pipeline_response) @@ -669,4 +920,6 @@ def validate_move( return cls(pipeline_response, deserialized, {}) return deserialized + validate_move.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingSubscriptions/{subscriptionId}/validateMoveEligibility'} # type: ignore + diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_customers_operations.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_customers_operations.py index 5e112bddbaec..cf5fabafcfdd 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_customers_operations.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_customers_operations.py @@ -5,23 +5,140 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_billing_profile_request( + billing_account_name: str, + billing_profile_name: str, + *, + search: Optional[str] = None, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingProfileName": _SERIALIZER.url("billing_profile_name", billing_profile_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if search is not None: + query_parameters['$search'] = _SERIALIZER.query("search", search, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_billing_account_request( + billing_account_name: str, + *, + search: Optional[str] = None, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if search is not None: + query_parameters['$search'] = _SERIALIZER.query("search", search, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + billing_account_name: str, + customer_name: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "customerName": _SERIALIZER.url("customer_name", customer_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class CustomersOperations(object): """CustomersOperations operations. @@ -45,15 +162,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_billing_profile( self, - billing_account_name, # type: str - billing_profile_name, # type: str - search=None, # type: Optional[str] - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.CustomerListResult"] + billing_account_name: str, + billing_profile_name: str, + search: Optional[str] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.CustomerListResult"]: """Lists the customers that are billed to a billing profile. The operation is supported only for billing accounts with agreement type Microsoft Partner Agreement. @@ -76,39 +193,35 @@ def list_by_billing_profile( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_billing_profile.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if search is not None: - query_parameters['$search'] = self._serialize.query("search", search, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + search=search, + filter=filter, + template_url=self.list_by_billing_profile.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + search=search, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('CustomerListResult', pipeline_response) + deserialized = self._deserialize("CustomerListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -121,25 +234,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/customers'} # type: ignore + @distributed_trace def list_by_billing_account( self, - billing_account_name, # type: str - search=None, # type: Optional[str] - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.CustomerListResult"] + billing_account_name: str, + search: Optional[str] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.CustomerListResult"]: """Lists the customers that are billed to a billing account. The operation is supported only for billing accounts with agreement type Microsoft Partner Agreement. @@ -160,38 +274,33 @@ def list_by_billing_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_billing_account.metadata['url'] # type: ignore - 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 = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if search is not None: - query_parameters['$search'] = self._serialize.query("search", search, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_account_request( + billing_account_name=billing_account_name, + search=search, + filter=filter, + template_url=self.list_by_billing_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_account_request( + billing_account_name=billing_account_name, + search=search, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('CustomerListResult', pipeline_response) + deserialized = self._deserialize("CustomerListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -204,25 +313,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers'} # type: ignore + @distributed_trace def get( self, - billing_account_name, # type: str - customer_name, # type: str - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.Customer" + billing_account_name: str, + customer_name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> "_models.Customer": """Gets a customer by its ID. The operation is supported only for billing accounts with agreement type Microsoft Partner Agreement. @@ -242,34 +352,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'customerName': self._serialize.url("customer_name", customer_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + billing_account_name=billing_account_name, + customer_name=customer_name, + expand=expand, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Customer', pipeline_response) @@ -278,4 +377,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}'} # type: ignore + diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_enrollment_accounts_operations.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_enrollment_accounts_operations.py index 36a5e9836b06..9b402c44f127 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_enrollment_accounts_operations.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_enrollment_accounts_operations.py @@ -5,23 +5,81 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = "2018-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/enrollmentAccounts') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/enrollmentAccounts/{name}') + path_format_arguments = { + "name": _SERIALIZER.url("name", name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class EnrollmentAccountsOperations(object): """EnrollmentAccountsOperations operations. @@ -45,15 +103,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.EnrollmentAccountListResult"] + **kwargs: Any + ) -> Iterable["_models.EnrollmentAccountListResult"]: """Lists the enrollment accounts the caller has access to. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EnrollmentAccountListResult or the result of cls(response) + :return: An iterator like instance of either EnrollmentAccountListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.billing.models.EnrollmentAccountListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -62,30 +121,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('EnrollmentAccountListResult', pipeline_response) + deserialized = self._deserialize("EnrollmentAccountListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,23 +154,24 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/providers/Microsoft.Billing/enrollmentAccounts'} # type: ignore + @distributed_trace def get( self, - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.EnrollmentAccountSummary" + name: str, + **kwargs: Any + ) -> "_models.EnrollmentAccountSummary": """Gets a enrollment account by name. :param name: Enrollment Account name. @@ -129,31 +186,21 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01-preview" - accept = "application/json" - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + name=name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EnrollmentAccountSummary', pipeline_response) @@ -162,4 +209,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/Microsoft.Billing/enrollmentAccounts/{name}'} # type: ignore + diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_instructions_operations.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_instructions_operations.py index 3b7a277eb67a..aa720a69b769 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_instructions_operations.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_instructions_operations.py @@ -5,23 +5,138 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_billing_profile_request( + billing_account_name: str, + billing_profile_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/instructions') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingProfileName": _SERIALIZER.url("billing_profile_name", billing_profile_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + billing_account_name: str, + billing_profile_name: str, + instruction_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/instructions/{instructionName}') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingProfileName": _SERIALIZER.url("billing_profile_name", billing_profile_name, 'str'), + "instructionName": _SERIALIZER.url("instruction_name", instruction_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_put_request( + billing_account_name: str, + billing_profile_name: str, + instruction_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/instructions/{instructionName}') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingProfileName": _SERIALIZER.url("billing_profile_name", billing_profile_name, 'str'), + "instructionName": _SERIALIZER.url("instruction_name", instruction_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class InstructionsOperations(object): """InstructionsOperations operations. @@ -45,13 +160,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_billing_profile( self, - billing_account_name, # type: str - billing_profile_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.InstructionListResult"] + billing_account_name: str, + billing_profile_name: str, + **kwargs: Any + ) -> Iterable["_models.InstructionListResult"]: """Lists the instructions by billing profile id. :param billing_account_name: The ID that uniquely identifies a billing account. @@ -59,7 +174,8 @@ def list_by_billing_profile( :param billing_profile_name: The ID that uniquely identifies a billing profile. :type billing_profile_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either InstructionListResult or the result of cls(response) + :return: An iterator like instance of either InstructionListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.billing.models.InstructionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -68,35 +184,31 @@ def list_by_billing_profile( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_billing_profile.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + template_url=self.list_by_billing_profile.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('InstructionListResult', pipeline_response) + deserialized = self._deserialize("InstructionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -109,25 +221,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/instructions'} # type: ignore + @distributed_trace def get( self, - billing_account_name, # type: str - billing_profile_name, # type: str - instruction_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Instruction" + billing_account_name: str, + billing_profile_name: str, + instruction_name: str, + **kwargs: Any + ) -> "_models.Instruction": """Get the instruction by name. These are custom billing instructions and are only applicable for certain customers. @@ -147,33 +260,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - 'instructionName': self._serialize.url("instruction_name", instruction_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + instruction_name=instruction_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Instruction', pipeline_response) @@ -182,17 +285,19 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/instructions/{instructionName}'} # type: ignore + + @distributed_trace def put( self, - billing_account_name, # type: str - billing_profile_name, # type: str - instruction_name, # type: str - parameters, # type: "_models.Instruction" - **kwargs # type: Any - ): - # type: (...) -> "_models.Instruction" + billing_account_name: str, + billing_profile_name: str, + instruction_name: str, + parameters: "_models.Instruction", + **kwargs: Any + ) -> "_models.Instruction": """Creates or updates an instruction. These are custom billing instructions and are only applicable for certain customers. @@ -214,38 +319,28 @@ def put( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.put.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - 'instructionName': self._serialize.url("instruction_name", instruction_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Instruction') + + request = build_put_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + instruction_name=instruction_name, + content_type=content_type, + json=_json, + template_url=self.put.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Instruction') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Instruction', pipeline_response) @@ -254,4 +349,6 @@ def put( return cls(pipeline_response, deserialized, {}) return deserialized + put.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/instructions/{instructionName}'} # type: ignore + diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_invoice_sections_operations.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_invoice_sections_operations.py index 5a5af73619bd..dc5f7b010ef6 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_invoice_sections_operations.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_invoice_sections_operations.py @@ -5,25 +5,140 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_billing_profile_request( + billing_account_name: str, + billing_profile_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingProfileName": _SERIALIZER.url("billing_profile_name", billing_profile_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingProfileName": _SERIALIZER.url("billing_profile_name", billing_profile_name, 'str'), + "invoiceSectionName": _SERIALIZER.url("invoice_section_name", invoice_section_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingProfileName": _SERIALIZER.url("billing_profile_name", billing_profile_name, 'str'), + "invoiceSectionName": _SERIALIZER.url("invoice_section_name", invoice_section_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class InvoiceSectionsOperations(object): """InvoiceSectionsOperations operations. @@ -47,13 +162,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_billing_profile( self, - billing_account_name, # type: str - billing_profile_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.InvoiceSectionListResult"] + billing_account_name: str, + billing_profile_name: str, + **kwargs: Any + ) -> Iterable["_models.InvoiceSectionListResult"]: """Lists the invoice sections that a user has access to. The operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. @@ -62,7 +177,8 @@ def list_by_billing_profile( :param billing_profile_name: The ID that uniquely identifies a billing profile. :type billing_profile_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either InvoiceSectionListResult or the result of cls(response) + :return: An iterator like instance of either InvoiceSectionListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.billing.models.InvoiceSectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -71,35 +187,31 @@ def list_by_billing_profile( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_billing_profile.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + template_url=self.list_by_billing_profile.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('InvoiceSectionListResult', pipeline_response) + deserialized = self._deserialize("InvoiceSectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -112,25 +224,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections'} # type: ignore + @distributed_trace def get( self, - billing_account_name, # type: str - billing_profile_name, # type: str - invoice_section_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.InvoiceSection" + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + **kwargs: Any + ) -> "_models.InvoiceSection": """Gets an invoice section by its ID. The operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. @@ -150,33 +263,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - 'invoiceSectionName': self._serialize.url("invoice_section_name", invoice_section_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('InvoiceSection', pipeline_response) @@ -185,80 +288,73 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}'} # type: ignore + def _create_or_update_initial( self, - billing_account_name, # type: str - billing_profile_name, # type: str - invoice_section_name, # type: str - parameters, # type: "_models.InvoiceSection" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.InvoiceSection"] + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + parameters: "_models.InvoiceSection", + **kwargs: Any + ) -> Optional["_models.InvoiceSection"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.InvoiceSection"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - 'invoiceSectionName': self._serialize.url("invoice_section_name", invoice_section_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'InvoiceSection') + + request = build_create_or_update_request_initial( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'InvoiceSection') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('InvoiceSection', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _create_or_update_initial.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - billing_account_name, # type: str - billing_profile_name, # type: str - invoice_section_name, # type: str - parameters, # type: "_models.InvoiceSection" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.InvoiceSection"] + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + parameters: "_models.InvoiceSection", + **kwargs: Any + ) -> LROPoller["_models.InvoiceSection"]: """Creates or updates an invoice section. The operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. @@ -272,15 +368,19 @@ def begin_create_or_update( :type parameters: ~azure.mgmt.billing.models.InvoiceSection :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either InvoiceSection or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either InvoiceSection or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.billing.models.InvoiceSection] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.InvoiceSection"] lro_delay = kwargs.pop( 'polling_interval', @@ -293,27 +393,21 @@ def begin_create_or_update( billing_profile_name=billing_profile_name, invoice_section_name=invoice_section_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('InvoiceSection', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - 'invoiceSectionName': self._serialize.url("invoice_section_name", invoice_section_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -325,4 +419,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}'} # type: ignore diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_invoices_operations.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_invoices_operations.py index 4949075cee12..98b7e4bac41e 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_invoices_operations.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_invoices_operations.py @@ -5,25 +5,387 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_billing_account_request( + billing_account_name: str, + *, + period_start_date: str, + period_end_date: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + query_parameters['periodStartDate'] = _SERIALIZER.query("period_start_date", period_start_date, 'str') + query_parameters['periodEndDate'] = _SERIALIZER.query("period_end_date", period_end_date, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_billing_profile_request( + billing_account_name: str, + billing_profile_name: str, + *, + period_start_date: str, + period_end_date: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoices') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingProfileName": _SERIALIZER.url("billing_profile_name", billing_profile_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + query_parameters['periodStartDate'] = _SERIALIZER.query("period_start_date", period_start_date, 'str') + query_parameters['periodEndDate'] = _SERIALIZER.query("period_end_date", period_end_date, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + billing_account_name: str, + invoice_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/{invoiceName}') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "invoiceName": _SERIALIZER.url("invoice_name", invoice_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_by_id_request( + invoice_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/default/invoices/{invoiceName}') + path_format_arguments = { + "invoiceName": _SERIALIZER.url("invoice_name", invoice_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_download_invoice_request_initial( + billing_account_name: str, + invoice_name: str, + *, + download_token: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/{invoiceName}/download') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "invoiceName": _SERIALIZER.url("invoice_name", invoice_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + query_parameters['downloadToken'] = _SERIALIZER.query("download_token", download_token, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_download_multiple_billing_profile_invoices_request_initial( + billing_account_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/downloadDocuments') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_by_billing_subscription_request( + subscription_id: str, + *, + period_start_date: str, + period_end_date: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/{subscriptionId}/invoices') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['periodStartDate'] = _SERIALIZER.query("period_start_date", period_start_date, 'str') + query_parameters['periodEndDate'] = _SERIALIZER.query("period_end_date", period_end_date, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_by_subscription_and_invoice_id_request( + subscription_id: str, + invoice_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/{subscriptionId}/invoices/{invoiceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "invoiceName": _SERIALIZER.url("invoice_name", invoice_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_download_billing_subscription_invoice_request_initial( + subscription_id: str, + invoice_name: str, + *, + download_token: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/{subscriptionId}/invoices/{invoiceName}/download') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "invoiceName": _SERIALIZER.url("invoice_name", invoice_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + query_parameters['downloadToken'] = _SERIALIZER.query("download_token", download_token, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_download_multiple_billing_subscription_invoices_request_initial( + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/{subscriptionId}/downloadDocuments') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class InvoicesOperations(object): """InvoicesOperations operations. @@ -47,14 +409,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_billing_account( self, - billing_account_name, # type: str - period_start_date, # type: str - period_end_date, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.InvoiceListResult"] + billing_account_name: str, + period_start_date: str, + period_end_date: str, + **kwargs: Any + ) -> Iterable["_models.InvoiceListResult"]: """Lists the invoices for a billing account for a given start date and end date. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. @@ -77,36 +439,33 @@ def list_by_billing_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_billing_account.metadata['url'] # type: ignore - 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 = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - query_parameters['periodStartDate'] = self._serialize.query("period_start_date", period_start_date, 'str') - query_parameters['periodEndDate'] = self._serialize.query("period_end_date", period_end_date, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_account_request( + billing_account_name=billing_account_name, + period_start_date=period_start_date, + period_end_date=period_end_date, + template_url=self.list_by_billing_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_account_request( + billing_account_name=billing_account_name, + period_start_date=period_start_date, + period_end_date=period_end_date, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('InvoiceListResult', pipeline_response) + deserialized = self._deserialize("InvoiceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -119,26 +478,27 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices'} # type: ignore + @distributed_trace def list_by_billing_profile( self, - billing_account_name, # type: str - billing_profile_name, # type: str - period_start_date, # type: str - period_end_date, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.InvoiceListResult"] + billing_account_name: str, + billing_profile_name: str, + period_start_date: str, + period_end_date: str, + **kwargs: Any + ) -> Iterable["_models.InvoiceListResult"]: """Lists the invoices for a billing profile for a given start date and end date. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. @@ -163,37 +523,35 @@ def list_by_billing_profile( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_billing_profile.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - query_parameters['periodStartDate'] = self._serialize.query("period_start_date", period_start_date, 'str') - query_parameters['periodEndDate'] = self._serialize.query("period_end_date", period_end_date, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + period_start_date=period_start_date, + period_end_date=period_end_date, + template_url=self.list_by_billing_profile.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + period_start_date=period_start_date, + period_end_date=period_end_date, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('InvoiceListResult', pipeline_response) + deserialized = self._deserialize("InvoiceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -206,24 +564,25 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoices'} # type: ignore + @distributed_trace def get( self, - billing_account_name, # type: str - invoice_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Invoice" + billing_account_name: str, + invoice_name: str, + **kwargs: Any + ) -> "_models.Invoice": """Gets an invoice by billing account name and ID. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. @@ -241,32 +600,22 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'invoiceName': self._serialize.url("invoice_name", invoice_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + billing_account_name=billing_account_name, + invoice_name=invoice_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Invoice', pipeline_response) @@ -275,14 +624,16 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/{invoiceName}'} # type: ignore + + @distributed_trace def get_by_id( self, - invoice_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Invoice" + invoice_name: str, + **kwargs: Any + ) -> "_models.Invoice": """Gets an invoice by ID. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. @@ -298,31 +649,21 @@ def get_by_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.get_by_id.metadata['url'] # type: ignore - path_format_arguments = { - 'invoiceName': self._serialize.url("invoice_name", invoice_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_id_request( + invoice_name=invoice_name, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Invoice', pipeline_response) @@ -331,73 +672,66 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/default/invoices/{invoiceName}'} # type: ignore + def _download_invoice_initial( self, - billing_account_name, # type: str - invoice_name, # type: str - download_token, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.DownloadUrl"] + billing_account_name: str, + invoice_name: str, + download_token: str, + **kwargs: Any + ) -> Optional["_models.DownloadUrl"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DownloadUrl"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self._download_invoice_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'invoiceName': self._serialize.url("invoice_name", invoice_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - query_parameters['downloadToken'] = self._serialize.query("download_token", download_token, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_download_invoice_request_initial( + billing_account_name=billing_account_name, + invoice_name=invoice_name, + download_token=download_token, + template_url=self._download_invoice_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('DownloadUrl', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _download_invoice_initial.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/{invoiceName}/download'} # type: ignore + + @distributed_trace def begin_download_invoice( self, - billing_account_name, # type: str - invoice_name, # type: str - download_token, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.DownloadUrl"] + billing_account_name: str, + invoice_name: str, + download_token: str, + **kwargs: Any + ) -> LROPoller["_models.DownloadUrl"]: """Gets a URL to download an invoice. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. @@ -409,15 +743,18 @@ def begin_download_invoice( :type download_token: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either DownloadUrl or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DownloadUrl or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.billing.models.DownloadUrl] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DownloadUrl"] lro_delay = kwargs.pop( 'polling_interval', @@ -432,23 +769,17 @@ def begin_download_invoice( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DownloadUrl', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'invoiceName': self._serialize.url("invoice_name", invoice_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -460,74 +791,66 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_download_invoice.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/{invoiceName}/download'} # type: ignore def _download_multiple_billing_profile_invoices_initial( self, - billing_account_name, # type: str - download_urls, # type: List[str] - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.DownloadUrl"] + billing_account_name: str, + download_urls: List[str], + **kwargs: Any + ) -> Optional["_models.DownloadUrl"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DownloadUrl"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._download_multiple_billing_profile_invoices_initial.metadata['url'] # type: ignore - 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 = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(download_urls, '[str]') + + request = build_download_multiple_billing_profile_invoices_request_initial( + billing_account_name=billing_account_name, + content_type=content_type, + json=_json, + template_url=self._download_multiple_billing_profile_invoices_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(download_urls, '[str]') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('DownloadUrl', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _download_multiple_billing_profile_invoices_initial.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/downloadDocuments'} # type: ignore + + @distributed_trace def begin_download_multiple_billing_profile_invoices( self, - billing_account_name, # type: str - download_urls, # type: List[str] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.DownloadUrl"] + billing_account_name: str, + download_urls: List[str], + **kwargs: Any + ) -> LROPoller["_models.DownloadUrl"]: """Gets a URL to download multiple invoice documents (invoice pdf, tax receipts, credit notes) as a zip file. The operation is supported for billing accounts with agreement type Microsoft Partner Agreement or Microsoft Customer Agreement. @@ -538,15 +861,19 @@ def begin_download_multiple_billing_profile_invoices( :type download_urls: list[str] :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either DownloadUrl or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DownloadUrl or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.billing.models.DownloadUrl] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DownloadUrl"] lro_delay = kwargs.pop( 'polling_interval', @@ -557,25 +884,21 @@ def begin_download_multiple_billing_profile_invoices( raw_result = self._download_multiple_billing_profile_invoices_initial( billing_account_name=billing_account_name, download_urls=download_urls, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DownloadUrl', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -587,15 +910,16 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_download_multiple_billing_profile_invoices.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/downloadDocuments'} # type: ignore + @distributed_trace def list_by_billing_subscription( self, - period_start_date, # type: str - period_end_date, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.InvoiceListResult"] + period_start_date: str, + period_end_date: str, + **kwargs: Any + ) -> Iterable["_models.InvoiceListResult"]: """Lists the invoices for a subscription. :param period_start_date: Invoice period start date. @@ -612,36 +936,33 @@ def list_by_billing_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_billing_subscription.metadata['url'] # type: ignore - 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 = {} # type: Dict[str, Any] - query_parameters['periodStartDate'] = self._serialize.query("period_start_date", period_start_date, 'str') - query_parameters['periodEndDate'] = self._serialize.query("period_end_date", period_end_date, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_subscription_request( + subscription_id=self._config.subscription_id, + period_start_date=period_start_date, + period_end_date=period_end_date, + template_url=self.list_by_billing_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_subscription_request( + subscription_id=self._config.subscription_id, + period_start_date=period_start_date, + period_end_date=period_end_date, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('InvoiceListResult', pipeline_response) + deserialized = self._deserialize("InvoiceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -654,23 +975,24 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_billing_subscription.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/{subscriptionId}/invoices'} # type: ignore + @distributed_trace def get_by_subscription_and_invoice_id( self, - invoice_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Invoice" + invoice_name: str, + **kwargs: Any + ) -> "_models.Invoice": """Gets an invoice by subscription ID and invoice ID. :param invoice_name: The ID that uniquely identifies an invoice. @@ -685,32 +1007,22 @@ def get_by_subscription_and_invoice_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.get_by_subscription_and_invoice_id.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'invoiceName': self._serialize.url("invoice_name", invoice_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_subscription_and_invoice_id_request( + subscription_id=self._config.subscription_id, + invoice_name=invoice_name, + template_url=self.get_by_subscription_and_invoice_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Invoice', pipeline_response) @@ -719,71 +1031,64 @@ def get_by_subscription_and_invoice_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_subscription_and_invoice_id.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/{subscriptionId}/invoices/{invoiceName}'} # type: ignore + def _download_billing_subscription_invoice_initial( self, - invoice_name, # type: str - download_token, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.DownloadUrl"] + invoice_name: str, + download_token: str, + **kwargs: Any + ) -> Optional["_models.DownloadUrl"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DownloadUrl"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self._download_billing_subscription_invoice_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'invoiceName': self._serialize.url("invoice_name", invoice_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - query_parameters['downloadToken'] = self._serialize.query("download_token", download_token, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_download_billing_subscription_invoice_request_initial( + subscription_id=self._config.subscription_id, + invoice_name=invoice_name, + download_token=download_token, + template_url=self._download_billing_subscription_invoice_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('DownloadUrl', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _download_billing_subscription_invoice_initial.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/{subscriptionId}/invoices/{invoiceName}/download'} # type: ignore + + @distributed_trace def begin_download_billing_subscription_invoice( self, - invoice_name, # type: str - download_token, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.DownloadUrl"] + invoice_name: str, + download_token: str, + **kwargs: Any + ) -> LROPoller["_models.DownloadUrl"]: """Gets a URL to download an invoice. :param invoice_name: The ID that uniquely identifies an invoice. @@ -792,15 +1097,18 @@ def begin_download_billing_subscription_invoice( :type download_token: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either DownloadUrl or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DownloadUrl or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.billing.models.DownloadUrl] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DownloadUrl"] lro_delay = kwargs.pop( 'polling_interval', @@ -814,23 +1122,17 @@ def begin_download_billing_subscription_invoice( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DownloadUrl', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'invoiceName': self._serialize.url("invoice_name", invoice_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -842,72 +1144,64 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_download_billing_subscription_invoice.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/{subscriptionId}/invoices/{invoiceName}/download'} # type: ignore def _download_multiple_billing_subscription_invoices_initial( self, - download_urls, # type: List[str] - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.DownloadUrl"] + download_urls: List[str], + **kwargs: Any + ) -> Optional["_models.DownloadUrl"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.DownloadUrl"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._download_multiple_billing_subscription_invoices_initial.metadata['url'] # type: ignore - 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 = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(download_urls, '[str]') + + request = build_download_multiple_billing_subscription_invoices_request_initial( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._download_multiple_billing_subscription_invoices_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(download_urls, '[str]') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('DownloadUrl', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('str', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + _download_multiple_billing_subscription_invoices_initial.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/{subscriptionId}/downloadDocuments'} # type: ignore + + @distributed_trace def begin_download_multiple_billing_subscription_invoices( self, - download_urls, # type: List[str] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.DownloadUrl"] + download_urls: List[str], + **kwargs: Any + ) -> LROPoller["_models.DownloadUrl"]: """Gets a URL to download multiple invoice documents (invoice pdf, tax receipts, credit notes) as a zip file. @@ -915,15 +1209,19 @@ def begin_download_multiple_billing_subscription_invoices( :type download_urls: list[str] :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: Pass in True if you'd like the ARMPolling polling method, - False for no polling, or your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either DownloadUrl or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either DownloadUrl or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.billing.models.DownloadUrl] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.DownloadUrl"] lro_delay = kwargs.pop( 'polling_interval', @@ -933,25 +1231,21 @@ def begin_download_multiple_billing_subscription_invoices( if cont_token is None: raw_result = self._download_multiple_billing_subscription_invoices_initial( download_urls=download_urls, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('DownloadUrl', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -963,4 +1257,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_download_multiple_billing_subscription_invoices.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/default/billingSubscriptions/{subscriptionId}/downloadDocuments'} # type: ignore diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_operations.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_operations.py index 643a38021450..b0a568715ea8 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_operations.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_operations.py @@ -5,23 +5,50 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/operations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -45,11 +72,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationListResult"] + **kwargs: Any + ) -> Iterable["_models.OperationListResult"]: """Lists the available billing REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -62,30 +89,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,12 +122,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_policies_operations.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_policies_operations.py index d347885b4814..2ffc3a973e45 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_policies_operations.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_policies_operations.py @@ -5,22 +5,175 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_by_billing_profile_request( + billing_account_name: str, + billing_profile_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/policies/default') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingProfileName": _SERIALIZER.url("billing_profile_name", billing_profile_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_request( + billing_account_name: str, + billing_profile_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/policies/default') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingProfileName": _SERIALIZER.url("billing_profile_name", billing_profile_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_by_customer_request( + billing_account_name: str, + customer_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/policies/default') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "customerName": _SERIALIZER.url("customer_name", customer_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_customer_request( + billing_account_name: str, + customer_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/policies/default') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "customerName": _SERIALIZER.url("customer_name", customer_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class PoliciesOperations(object): """PoliciesOperations operations. @@ -44,13 +197,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get_by_billing_profile( self, - billing_account_name, # type: str - billing_profile_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Policy" + billing_account_name: str, + billing_profile_name: str, + **kwargs: Any + ) -> "_models.Policy": """Lists the policies for a billing profile. This operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. @@ -68,32 +221,22 @@ def get_by_billing_profile( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.get_by_billing_profile.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + template_url=self.get_by_billing_profile.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Policy', pipeline_response) @@ -102,16 +245,18 @@ def get_by_billing_profile( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/policies/default'} # type: ignore + + @distributed_trace def update( self, - billing_account_name, # type: str - billing_profile_name, # type: str - parameters, # type: "_models.Policy" - **kwargs # type: Any - ): - # type: (...) -> "_models.Policy" + billing_account_name: str, + billing_profile_name: str, + parameters: "_models.Policy", + **kwargs: Any + ) -> "_models.Policy": """Updates the policies for a billing profile. This operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. @@ -131,37 +276,27 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(parameters, 'Policy') + + request = build_update_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Policy') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Policy', pipeline_response) @@ -170,15 +305,17 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/policies/default'} # type: ignore + + @distributed_trace def get_by_customer( self, - billing_account_name, # type: str - customer_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CustomerPolicy" + billing_account_name: str, + customer_name: str, + **kwargs: Any + ) -> "_models.CustomerPolicy": """Lists the policies for a customer. This operation is supported only for billing accounts with agreement type Microsoft Partner Agreement. @@ -196,32 +333,22 @@ def get_by_customer( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.get_by_customer.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'customerName': self._serialize.url("customer_name", customer_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_customer_request( + billing_account_name=billing_account_name, + customer_name=customer_name, + template_url=self.get_by_customer.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CustomerPolicy', pipeline_response) @@ -230,16 +357,18 @@ def get_by_customer( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_customer.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/policies/default'} # type: ignore + + @distributed_trace def update_customer( self, - billing_account_name, # type: str - customer_name, # type: str - parameters, # type: "_models.CustomerPolicy" - **kwargs # type: Any - ): - # type: (...) -> "_models.CustomerPolicy" + billing_account_name: str, + customer_name: str, + parameters: "_models.CustomerPolicy", + **kwargs: Any + ) -> "_models.CustomerPolicy": """Updates the policies for a customer. This operation is supported only for billing accounts with agreement type Microsoft Partner Agreement. @@ -259,37 +388,27 @@ def update_customer( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_customer.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'customerName': self._serialize.url("customer_name", customer_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'CustomerPolicy') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_customer_request( + billing_account_name=billing_account_name, + customer_name=customer_name, + content_type=content_type, + json=_json, + template_url=self.update_customer.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'CustomerPolicy') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CustomerPolicy', pipeline_response) @@ -298,4 +417,6 @@ def update_customer( return cls(pipeline_response, deserialized, {}) return deserialized + update_customer.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/policies/default'} # type: ignore + diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_products_operations.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_products_operations.py index 6b08ee6d89a3..7abe9059dd37 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_products_operations.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_products_operations.py @@ -5,23 +5,329 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_customer_request( + billing_account_name: str, + customer_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/products') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "customerName": _SERIALIZER.url("customer_name", customer_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_billing_account_request( + billing_account_name: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/products') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_billing_profile_request( + billing_account_name: str, + billing_profile_name: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/products') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingProfileName": _SERIALIZER.url("billing_profile_name", billing_profile_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_invoice_section_request( + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + *, + filter: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/products') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingProfileName": _SERIALIZER.url("billing_profile_name", billing_profile_name, 'str'), + "invoiceSectionName": _SERIALIZER.url("invoice_section_name", invoice_section_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + billing_account_name: str, + product_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/products/{productName}') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "productName": _SERIALIZER.url("product_name", product_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_request( + billing_account_name: str, + product_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/products/{productName}') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "productName": _SERIALIZER.url("product_name", product_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_move_request( + billing_account_name: str, + product_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/products/{productName}/move') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "productName": _SERIALIZER.url("product_name", product_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_validate_move_request( + billing_account_name: str, + product_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/products/{productName}/validateMoveEligibility') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "productName": _SERIALIZER.url("product_name", product_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class ProductsOperations(object): """ProductsOperations operations. @@ -45,13 +351,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_customer( self, - billing_account_name, # type: str - customer_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ProductsListResult"] + billing_account_name: str, + customer_name: str, + **kwargs: Any + ) -> Iterable["_models.ProductsListResult"]: """Lists the products for a customer. These don't include products billed based on usage.The operation is supported only for billing accounts with agreement type Microsoft Partner Agreement. @@ -70,35 +376,31 @@ def list_by_customer( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_customer.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'customerName': self._serialize.url("customer_name", customer_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_customer_request( + billing_account_name=billing_account_name, + customer_name=customer_name, + template_url=self.list_by_customer.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_customer_request( + billing_account_name=billing_account_name, + customer_name=customer_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ProductsListResult', pipeline_response) + deserialized = self._deserialize("ProductsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -111,24 +413,25 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_customer.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/customers/{customerName}/products'} # type: ignore + @distributed_trace def list_by_billing_account( self, - billing_account_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ProductsListResult"] + billing_account_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.ProductsListResult"]: """Lists the products for a billing account. These don't include products billed based on usage. The operation is supported for billing accounts with agreement type Microsoft Customer Agreement or Microsoft Partner Agreement. @@ -149,36 +452,31 @@ def list_by_billing_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_billing_account.metadata['url'] # type: ignore - 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 = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_account_request( + billing_account_name=billing_account_name, + filter=filter, + template_url=self.list_by_billing_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_account_request( + billing_account_name=billing_account_name, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ProductsListResult', pipeline_response) + deserialized = self._deserialize("ProductsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -191,25 +489,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/products'} # type: ignore + @distributed_trace def list_by_billing_profile( self, - billing_account_name, # type: str - billing_profile_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ProductsListResult"] + billing_account_name: str, + billing_profile_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.ProductsListResult"]: """Lists the products for a billing profile. These don't include products billed based on usage. The operation is supported for billing accounts with agreement type Microsoft Customer Agreement or Microsoft Partner Agreement. @@ -232,37 +531,33 @@ def list_by_billing_profile( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_billing_profile.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + filter=filter, + template_url=self.list_by_billing_profile.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ProductsListResult', pipeline_response) + deserialized = self._deserialize("ProductsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -275,26 +570,27 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_billing_profile.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/products'} # type: ignore + @distributed_trace def list_by_invoice_section( self, - billing_account_name, # type: str - billing_profile_name, # type: str - invoice_section_name, # type: str - filter=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ProductsListResult"] + billing_account_name: str, + billing_profile_name: str, + invoice_section_name: str, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.ProductsListResult"]: """Lists the products for an invoice section. These don't include products billed based on usage. The operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. @@ -319,38 +615,35 @@ def list_by_invoice_section( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_invoice_section.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - 'invoiceSectionName': self._serialize.url("invoice_section_name", invoice_section_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_invoice_section_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + filter=filter, + template_url=self.list_by_invoice_section.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_invoice_section_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + invoice_section_name=invoice_section_name, + filter=filter, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ProductsListResult', pipeline_response) + deserialized = self._deserialize("ProductsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -363,24 +656,25 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_invoice_section.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/invoiceSections/{invoiceSectionName}/products'} # type: ignore + @distributed_trace def get( self, - billing_account_name, # type: str - product_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Product" + billing_account_name: str, + product_name: str, + **kwargs: Any + ) -> "_models.Product": """Gets a product by ID. The operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. @@ -398,32 +692,22 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'productName': self._serialize.url("product_name", product_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + billing_account_name=billing_account_name, + product_name=product_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Product', pipeline_response) @@ -432,16 +716,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/products/{productName}'} # type: ignore + + @distributed_trace def update( self, - billing_account_name, # type: str - product_name, # type: str - parameters, # type: "_models.Product" - **kwargs # type: Any - ): - # type: (...) -> "_models.Product" + billing_account_name: str, + product_name: str, + parameters: "_models.Product", + **kwargs: Any + ) -> "_models.Product": """Updates the properties of a Product. Currently, auto renew can be updated. The operation is supported only for billing accounts with agreement type Microsoft Customer Agreement. @@ -461,37 +747,27 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'productName': self._serialize.url("product_name", product_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Product') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request( + billing_account_name=billing_account_name, + product_name=product_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Product') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Product', pipeline_response) @@ -500,16 +776,18 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/products/{productName}'} # type: ignore + + @distributed_trace def move( self, - billing_account_name, # type: str - product_name, # type: str - parameters, # type: "_models.TransferProductRequestProperties" - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.Product"] + billing_account_name: str, + product_name: str, + parameters: "_models.TransferProductRequestProperties", + **kwargs: Any + ) -> Optional["_models.Product"]: """Moves a product's charges to a new invoice section. The new invoice section must belong to the same billing profile as the existing invoice section. This operation is supported only for products that are purchased with a recurring charge and for billing accounts with agreement @@ -531,62 +809,55 @@ def move( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.move.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'productName': self._serialize.url("product_name", product_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'TransferProductRequestProperties') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_move_request( + billing_account_name=billing_account_name, + product_name=product_name, + content_type=content_type, + json=_json, + template_url=self.move.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TransferProductRequestProperties') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - response_headers = {} deserialized = None + response_headers = {} if response.status_code == 200: deserialized = self._deserialize('Product', pipeline_response) if response.status_code == 202: response_headers['Location']=self._deserialize('str', response.headers.get('Location')) response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) + if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + move.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/products/{productName}/move'} # type: ignore + + @distributed_trace def validate_move( self, - billing_account_name, # type: str - product_name, # type: str - parameters, # type: "_models.TransferProductRequestProperties" - **kwargs # type: Any - ): - # type: (...) -> "_models.ValidateProductTransferEligibilityResult" + billing_account_name: str, + product_name: str, + parameters: "_models.TransferProductRequestProperties", + **kwargs: Any + ) -> "_models.ValidateProductTransferEligibilityResult": """Validates if a product's charges can be moved to a new invoice section. This operation is supported only for products that are purchased with a recurring charge and for billing accounts with agreement type Microsoft Customer Agreement. @@ -608,37 +879,27 @@ def validate_move( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.validate_move.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'productName': self._serialize.url("product_name", product_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'TransferProductRequestProperties') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_validate_move_request( + billing_account_name=billing_account_name, + product_name=product_name, + content_type=content_type, + json=_json, + template_url=self.validate_move.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'TransferProductRequestProperties') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ValidateProductTransferEligibilityResult', pipeline_response) @@ -647,4 +908,6 @@ def validate_move( return cls(pipeline_response, deserialized, {}) return deserialized + validate_move.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/products/{productName}/validateMoveEligibility'} # type: ignore + diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_reservations_operations.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_reservations_operations.py index 3bb4d1c96b1e..338f8d71babd 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_reservations_operations.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_reservations_operations.py @@ -5,23 +5,115 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +def build_list_by_billing_account_request( + billing_account_name: str, + *, + filter: Optional[str] = None, + orderby: Optional[str] = None, + refresh_summary: Optional[str] = None, + selected_state: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/reservations') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if orderby is not None: + query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + if refresh_summary is not None: + query_parameters['refreshSummary'] = _SERIALIZER.query("refresh_summary", refresh_summary, 'str') + if selected_state is not None: + query_parameters['selectedState'] = _SERIALIZER.query("selected_state", selected_state, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_billing_profile_request( + billing_account_name: str, + billing_profile_name: str, + *, + filter: Optional[str] = None, + orderby: Optional[str] = None, + refresh_summary: Optional[str] = None, + selected_state: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/billingProfiles/{billingProfileName}/reservations') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "billingProfileName": _SERIALIZER.url("billing_profile_name", billing_profile_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if orderby is not None: + query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + if refresh_summary is not None: + query_parameters['refreshSummary'] = _SERIALIZER.query("refresh_summary", refresh_summary, 'str') + if selected_state is not None: + query_parameters['selectedState'] = _SERIALIZER.query("selected_state", selected_state, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ReservationsOperations(object): """ReservationsOperations operations. @@ -45,16 +137,16 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_billing_account( self, - billing_account_name, # type: str - filter=None, # type: Optional[str] - orderby=None, # type: Optional[str] - refresh_summary=None, # type: Optional[str] - selected_state=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ReservationsListResult"] + billing_account_name: str, + filter: Optional[str] = None, + orderby: Optional[str] = None, + refresh_summary: Optional[str] = None, + selected_state: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.ReservationsListResult"]: """Lists the reservations for a billing account and the roll up counts of reservations group by provisioning states. @@ -71,7 +163,8 @@ def list_by_billing_account( :param selected_state: The selected provisioning state. :type selected_state: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReservationsListResult or the result of cls(response) + :return: An iterator like instance of either ReservationsListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.billing.models.ReservationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -80,42 +173,37 @@ def list_by_billing_account( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_billing_account.metadata['url'] # type: ignore - 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 = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - if refresh_summary is not None: - query_parameters['refreshSummary'] = self._serialize.query("refresh_summary", refresh_summary, 'str') - if selected_state is not None: - query_parameters['selectedState'] = self._serialize.query("selected_state", selected_state, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_account_request( + billing_account_name=billing_account_name, + filter=filter, + orderby=orderby, + refresh_summary=refresh_summary, + selected_state=selected_state, + template_url=self.list_by_billing_account.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_account_request( + billing_account_name=billing_account_name, + filter=filter, + orderby=orderby, + refresh_summary=refresh_summary, + selected_state=selected_state, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ReservationsListResult', pipeline_response) + deserialized = self._deserialize("ReservationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -128,28 +216,29 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_billing_account.metadata = {'url': '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/reservations'} # type: ignore + @distributed_trace def list_by_billing_profile( self, - billing_account_name, # type: str - billing_profile_name, # type: str - filter=None, # type: Optional[str] - orderby=None, # type: Optional[str] - refresh_summary=None, # type: Optional[str] - selected_state=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ReservationsListResult"] + billing_account_name: str, + billing_profile_name: str, + filter: Optional[str] = None, + orderby: Optional[str] = None, + refresh_summary: Optional[str] = None, + selected_state: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.ReservationsListResult"]: """Lists the reservations for a billing profile and the roll up counts of reservations group by provisioning state. @@ -168,7 +257,8 @@ def list_by_billing_profile( :param selected_state: The selected provisioning state. :type selected_state: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ReservationsListResult or the result of cls(response) + :return: An iterator like instance of either ReservationsListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.billing.models.ReservationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -177,43 +267,39 @@ def list_by_billing_profile( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_billing_profile.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'billingProfileName': self._serialize.url("billing_profile_name", billing_profile_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - if refresh_summary is not None: - query_parameters['refreshSummary'] = self._serialize.query("refresh_summary", refresh_summary, 'str') - if selected_state is not None: - query_parameters['selectedState'] = self._serialize.query("selected_state", selected_state, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + filter=filter, + orderby=orderby, + refresh_summary=refresh_summary, + selected_state=selected_state, + template_url=self.list_by_billing_profile.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_billing_profile_request( + billing_account_name=billing_account_name, + billing_profile_name=billing_profile_name, + filter=filter, + orderby=orderby, + refresh_summary=refresh_summary, + selected_state=selected_state, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ReservationsListResult', pipeline_response) + deserialized = self._deserialize("ReservationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -226,12 +312,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_transactions_operations.py b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_transactions_operations.py index 4eb99fe2bdb8..d58e7dafcafa 100644 --- a/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_transactions_operations.py +++ b/sdk/billing/azure-mgmt-billing/azure/mgmt/billing/operations/_transactions_operations.py @@ -5,23 +5,58 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_invoice_request( + billing_account_name: str, + invoice_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Billing/billingAccounts/{billingAccountName}/invoices/{invoiceName}/transactions') + path_format_arguments = { + "billingAccountName": _SERIALIZER.url("billing_account_name", billing_account_name, 'str'), + "invoiceName": _SERIALIZER.url("invoice_name", invoice_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class TransactionsOperations(object): """TransactionsOperations operations. @@ -45,13 +80,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_invoice( self, - billing_account_name, # type: str - invoice_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.TransactionListResult"] + billing_account_name: str, + invoice_name: str, + **kwargs: Any + ) -> Iterable["_models.TransactionListResult"]: """Lists the transactions for an invoice. Transactions include purchases, refunds and Azure usage charges. @@ -60,7 +95,8 @@ def list_by_invoice( :param invoice_name: The ID that uniquely identifies an invoice. :type invoice_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either TransactionListResult or the result of cls(response) + :return: An iterator like instance of either TransactionListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.billing.models.TransactionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -69,35 +105,31 @@ def list_by_invoice( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_invoice.metadata['url'] # type: ignore - path_format_arguments = { - 'billingAccountName': self._serialize.url("billing_account_name", billing_account_name, 'str'), - 'invoiceName': self._serialize.url("invoice_name", invoice_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_invoice_request( + billing_account_name=billing_account_name, + invoice_name=invoice_name, + template_url=self.list_by_invoice.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_invoice_request( + billing_account_name=billing_account_name, + invoice_name=invoice_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('TransactionListResult', pipeline_response) + deserialized = self._deserialize("TransactionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,12 +142,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data )