From fb171919ba83bbf5c156ff06e396881b91d6896f Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Thu, 11 Aug 2022 02:16:42 +0000 Subject: [PATCH] CodeGen from PR 20130 in Azure/azure-rest-api-specs Merge fd3740520302f8432b55a6b6727082bdafc31607 into 80065490402157d0df0dd37ab347c651b22eb576 --- .../azure-mgmt-reservations/_meta.json | 6 +- .../azure/mgmt/reservations/__init__.py | 13 +- .../reservations/_azure_reservation_api.py | 28 +- .../azure/mgmt/reservations/_metadata.json | 126 ----- .../azure/mgmt/reservations/_vendor.py | 18 + .../azure/mgmt/reservations/_version.py | 2 +- .../azure/mgmt/reservations/aio/__init__.py | 13 +- .../aio/_azure_reservation_api.py | 28 +- .../azure/mgmt/reservations/aio/_vendor.py | 27 + .../reservations/aio/operations/__init__.py | 5 + .../_azure_reservation_api_operations.py | 38 +- .../_calculate_exchange_operations.py | 81 +-- .../aio/operations/_exchange_operations.py | 81 +-- .../aio/operations/_operation_operations.py | 49 +- .../reservations/aio/operations/_patch.py | 19 + .../aio/operations/_quota_operations.py | 180 ++++--- .../_quota_request_status_operations.py | 72 +-- .../aio/operations/_reservation_operations.py | 302 +++++++---- .../_reservation_order_operations.py | 159 +++--- .../mgmt/reservations/models/__init__.py | 6 +- .../models/_azure_reservation_api_enums.py | 39 +- .../mgmt/reservations/models/_models_py3.py | 475 +++++++++-------- .../azure/mgmt/reservations/models/_patch.py | 19 + .../mgmt/reservations/operations/__init__.py | 5 + .../_azure_reservation_api_operations.py | 83 +-- .../_calculate_exchange_operations.py | 108 ++-- .../operations/_exchange_operations.py | 108 ++-- .../operations/_operation_operations.py | 69 +-- .../mgmt/reservations/operations/_patch.py | 19 + .../operations/_quota_operations.py | 264 +++++----- .../_quota_request_status_operations.py | 115 +++-- .../operations/_reservation_operations.py | 480 +++++++++++------- .../_reservation_order_operations.py | 268 +++++----- 33 files changed, 1883 insertions(+), 1422 deletions(-) delete mode 100644 sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/_metadata.json create mode 100644 sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/_vendor.py create mode 100644 sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/operations/_patch.py create mode 100644 sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/models/_patch.py create mode 100644 sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/operations/_patch.py diff --git a/sdk/reservations/azure-mgmt-reservations/_meta.json b/sdk/reservations/azure-mgmt-reservations/_meta.json index e5cf08c785d4..d3c0c52b9175 100644 --- a/sdk/reservations/azure-mgmt-reservations/_meta.json +++ b/sdk/reservations/azure-mgmt-reservations/_meta.json @@ -1,11 +1,11 @@ { "autorest": "3.7.2", "use": [ - "@autorest/python@5.13.0", + "@autorest/python@5.16.0", "@autorest/modelerfour@4.19.3" ], - "commit": "b1bbbab2f04c23e279c717f955d9a86bc4757946", + "commit": "0c24cf7941c25c9fe4f0fcecd49720ac7b08191a", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/reservations/resource-manager/readme.md --multiapi --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.13.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "autorest_command": "autorest specification/reservations/resource-manager/readme.md --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.16.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", "readme": "specification/reservations/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/__init__.py b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/__init__.py index b532c1a982f0..8aaa7bf8b377 100644 --- a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/__init__.py +++ b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/__init__.py @@ -10,9 +10,14 @@ from ._version import VERSION __version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['AzureReservationAPI'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._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() +_patch_sdk() diff --git a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/_azure_reservation_api.py b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/_azure_reservation_api.py index d4e93e14837c..3f251d69c453 100644 --- a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/_azure_reservation_api.py +++ b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/_azure_reservation_api.py @@ -60,13 +60,27 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.reservation = ReservationOperations(self._client, self._config, self._serialize, self._deserialize) - self.reservation_order = ReservationOrderOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation = OperationOperations(self._client, self._config, self._serialize, self._deserialize) - self.calculate_exchange = CalculateExchangeOperations(self._client, self._config, self._serialize, self._deserialize) - self.exchange = ExchangeOperations(self._client, self._config, self._serialize, self._deserialize) - self.quota = QuotaOperations(self._client, self._config, self._serialize, self._deserialize) - self.quota_request_status = QuotaRequestStatusOperations(self._client, self._config, self._serialize, self._deserialize) + self.reservation = ReservationOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.reservation_order = ReservationOrderOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operation = OperationOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.calculate_exchange = CalculateExchangeOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.exchange = ExchangeOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.quota = QuotaOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.quota_request_status = QuotaRequestStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/_metadata.json b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/_metadata.json deleted file mode 100644 index 5b4db5eff99c..000000000000 --- a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/_metadata.json +++ /dev/null @@ -1,126 +0,0 @@ -{ - "chosen_version": "", - "total_api_version_list": ["2020-10-25", "2022-03-01"], - "client": { - "name": "AzureReservationAPI", - "filename": "_azure_reservation_api", - "description": "This API describe Azure Reservation.", - "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\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AzureReservationAPIConfiguration\"], \"._operations_mixin\": [\"AzureReservationAPIOperationsMixin\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"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\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AzureReservationAPIConfiguration\"], \"._operations_mixin\": [\"AzureReservationAPIOperationsMixin\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - } - }, - "constant": { - }, - "call": "credential", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version=None, # type: Optional[str]", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "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": { - "reservation": "ReservationOperations", - "reservation_order": "ReservationOrderOperations", - "operation": "OperationOperations", - "calculate_exchange": "CalculateExchangeOperations", - "exchange": "ExchangeOperations", - "quota": "QuotaOperations", - "quota_request_status": "QuotaRequestStatusOperations" - }, - "operation_mixins": { - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"List\", \"Optional\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"List\", \"Optional\"]}}}", - "operations": { - "get_catalog" : { - "sync": { - "signature": "def get_catalog(\n self,\n subscription_id, # type: str\n reserved_resource_type=None, # type: Optional[str]\n location=None, # type: Optional[str]\n publisher_id=None, # type: Optional[str]\n offer_id=None, # type: Optional[str]\n plan_id=None, # type: Optional[str]\n **kwargs # type: Any\n):\n # type: (...) -\u003e List[\"_models.Catalog\"]\n", - "doc": "\"\"\"Get the regions and skus that are available for RI purchase for the specified Azure\nsubscription.\n\nGet the regions and skus that are available for RI purchase for the specified Azure\nsubscription.\n\n:param subscription_id: Id of the subscription.\n:type subscription_id: str\n:param reserved_resource_type: The type of the resource for which the skus should be provided.\n Default value is None.\n:type reserved_resource_type: str\n:param location: Filters the skus based on the location specified in this parameter. This can\n be an azure region or global. Default value is None.\n:type location: str\n:param publisher_id: Publisher id used to get the third party products. Default value is None.\n:type publisher_id: str\n:param offer_id: Offer id used to get the third party products. Default value is None.\n:type offer_id: str\n:param plan_id: Plan id used to get the third party products. Default value is None.\n:type plan_id: str\n:keyword api_version: Api Version. Default value is \"2022-03-01\". Note that overriding this\n default value may result in unsupported behavior.\n:paramtype api_version: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: list of Catalog, or the result of cls(response)\n:rtype: list[~azure.mgmt.reservations.models.Catalog]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "async": { - "coroutine": true, - "signature": "async def get_catalog(\n self,\n subscription_id: str,\n reserved_resource_type: Optional[str] = None,\n location: Optional[str] = None,\n publisher_id: Optional[str] = None,\n offer_id: Optional[str] = None,\n plan_id: Optional[str] = None,\n **kwargs: Any\n) -\u003e List[\"_models.Catalog\"]:\n", - "doc": "\"\"\"Get the regions and skus that are available for RI purchase for the specified Azure\nsubscription.\n\nGet the regions and skus that are available for RI purchase for the specified Azure\nsubscription.\n\n:param subscription_id: Id of the subscription.\n:type subscription_id: str\n:param reserved_resource_type: The type of the resource for which the skus should be provided.\n Default value is None.\n:type reserved_resource_type: str\n:param location: Filters the skus based on the location specified in this parameter. This can\n be an azure region or global. Default value is None.\n:type location: str\n:param publisher_id: Publisher id used to get the third party products. Default value is None.\n:type publisher_id: str\n:param offer_id: Offer id used to get the third party products. Default value is None.\n:type offer_id: str\n:param plan_id: Plan id used to get the third party products. Default value is None.\n:type plan_id: str\n:keyword api_version: Api Version. Default value is \"2022-03-01\". Note that overriding this\n default value may result in unsupported behavior.\n:paramtype api_version: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: list of Catalog, or the result of cls(response)\n:rtype: list[~azure.mgmt.reservations.models.Catalog]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "call": "subscription_id, reserved_resource_type, location, publisher_id, offer_id, plan_id" - }, - "get_applied_reservation_list" : { - "sync": { - "signature": "def get_applied_reservation_list(\n self,\n subscription_id, # type: str\n **kwargs # type: Any\n):\n # type: (...) -\u003e \"_models.AppliedReservations\"\n", - "doc": "\"\"\"Get list of applicable ``Reservation``\\ s.\n\nGet applicable ``Reservation``\\ s that are applied to this subscription or a resource group\nunder this subscription.\n\n:param subscription_id: Id of the subscription.\n:type subscription_id: str\n:keyword api_version: Api Version. Default value is \"2022-03-01\". Note that overriding this\n default value may result in unsupported behavior.\n:paramtype api_version: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: AppliedReservations, or the result of cls(response)\n:rtype: ~azure.mgmt.reservations.models.AppliedReservations\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "async": { - "coroutine": true, - "signature": "async def get_applied_reservation_list(\n self,\n subscription_id: str,\n **kwargs: Any\n) -\u003e \"_models.AppliedReservations\":\n", - "doc": "\"\"\"Get list of applicable ``Reservation``\\ s.\n\nGet applicable ``Reservation``\\ s that are applied to this subscription or a resource group\nunder this subscription.\n\n:param subscription_id: Id of the subscription.\n:type subscription_id: str\n:keyword api_version: Api Version. Default value is \"2022-03-01\". Note that overriding this\n default value may result in unsupported behavior.\n:paramtype api_version: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: AppliedReservations, or the result of cls(response)\n:rtype: ~azure.mgmt.reservations.models.AppliedReservations\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" - }, - "call": "subscription_id" - } - } - } -} \ No newline at end of file diff --git a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/_vendor.py b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/_vendor.py index 138f663c53a4..d0e8f76327f8 100644 --- a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/_vendor.py +++ b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/_vendor.py @@ -5,8 +5,19 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from abc import ABC +from typing import TYPE_CHECKING + from azure.core.pipeline.transport import HttpRequest +from ._configuration import AzureReservationAPIConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from msrest import Deserializer, Serializer + + from azure.core import PipelineClient + 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) @@ -25,3 +36,10 @@ def _format_url_section(template, **kwargs): c for c in formatted_components if "{}".format(key.args[0]) not in c ] template = "/".join(components) + +class MixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + _client: "PipelineClient" + _config: AzureReservationAPIConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/_version.py b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/_version.py index 48944bf3938a..e5754a47ce68 100644 --- a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/_version.py +++ b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/__init__.py b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/__init__.py index 099f702e574c..d72dd60d8dbd 100644 --- a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/__init__.py +++ b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/__init__.py @@ -7,9 +7,14 @@ # -------------------------------------------------------------------------- from ._azure_reservation_api import AzureReservationAPI + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['AzureReservationAPI'] +__all__.extend([p for p in _patch_all if p not in __all__]) -# `._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() +_patch_sdk() diff --git a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/_azure_reservation_api.py b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/_azure_reservation_api.py index 155f7bea7dc3..d526b9a8010d 100644 --- a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/_azure_reservation_api.py +++ b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/_azure_reservation_api.py @@ -61,13 +61,27 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.reservation = ReservationOperations(self._client, self._config, self._serialize, self._deserialize) - self.reservation_order = ReservationOrderOperations(self._client, self._config, self._serialize, self._deserialize) - self.operation = OperationOperations(self._client, self._config, self._serialize, self._deserialize) - self.calculate_exchange = CalculateExchangeOperations(self._client, self._config, self._serialize, self._deserialize) - self.exchange = ExchangeOperations(self._client, self._config, self._serialize, self._deserialize) - self.quota = QuotaOperations(self._client, self._config, self._serialize, self._deserialize) - self.quota_request_status = QuotaRequestStatusOperations(self._client, self._config, self._serialize, self._deserialize) + self.reservation = ReservationOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.reservation_order = ReservationOrderOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.operation = OperationOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.calculate_exchange = CalculateExchangeOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.exchange = ExchangeOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.quota = QuotaOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.quota_request_status = QuotaRequestStatusOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request( diff --git a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/_vendor.py b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/_vendor.py new file mode 100644 index 000000000000..e9bcbce006bc --- /dev/null +++ b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/_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 abc import ABC +from typing import TYPE_CHECKING + +from azure.core.pipeline.transport import HttpRequest + +from ._configuration import AzureReservationAPIConfiguration + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from msrest import Deserializer, Serializer + + from azure.core import AsyncPipelineClient + + +class MixinABC(ABC): + """DO NOT use this class. It is for internal typing use only.""" + _client: "AsyncPipelineClient" + _config: AzureReservationAPIConfiguration + _serialize: "Serializer" + _deserialize: "Deserializer" diff --git a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/operations/__init__.py b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/operations/__init__.py index 5cf631a610fd..eea7bcb5c4c0 100644 --- a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/operations/__init__.py +++ b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/operations/__init__.py @@ -15,6 +15,9 @@ from ._quota_operations import QuotaOperations from ._quota_request_status_operations import QuotaRequestStatusOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'ReservationOperations', 'AzureReservationAPIOperationsMixin', @@ -25,3 +28,5 @@ 'QuotaOperations', 'QuotaRequestStatusOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/operations/_azure_reservation_api_operations.py b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/operations/_azure_reservation_api_operations.py index bf01dc6ab1d9..dcc07bc2d213 100644 --- a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/operations/_azure_reservation_api_operations.py +++ b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/operations/_azure_reservation_api_operations.py @@ -13,15 +13,17 @@ 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._azure_reservation_api_operations import build_get_applied_reservation_list_request, build_get_catalog_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class AzureReservationAPIOperationsMixin: +class AzureReservationAPIOperationsMixin(MixinABC): @distributed_trace_async async def get_catalog( @@ -33,7 +35,7 @@ async def get_catalog( offer_id: Optional[str] = None, plan_id: Optional[str] = None, **kwargs: Any - ) -> List["_models.Catalog"]: + ) -> List[_models.Catalog]: """Get the regions and skus that are available for RI purchase for the specified Azure subscription. @@ -62,13 +64,16 @@ async def get_catalog( :rtype: list[~azure.mgmt.reservations.models.Catalog] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.Catalog"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.Catalog]] request = build_get_catalog_request( @@ -80,11 +85,13 @@ async def get_catalog( offer_id=offer_id, plan_id=plan_id, template_url=self.get_catalog.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -111,7 +118,7 @@ async def get_applied_reservation_list( self, subscription_id: str, **kwargs: Any - ) -> "_models.AppliedReservations": + ) -> _models.AppliedReservations: """Get list of applicable ``Reservation``\ s. Get applicable ``Reservation``\ s that are applied to this subscription or a resource group @@ -127,24 +134,29 @@ async def get_applied_reservation_list( :rtype: ~azure.mgmt.reservations.models.AppliedReservations :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppliedReservations"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AppliedReservations] request = build_get_applied_reservation_list_request( subscription_id=subscription_id, api_version=api_version, template_url=self.get_applied_reservation_list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/operations/_calculate_exchange_operations.py b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/operations/_calculate_exchange_operations.py index 5e59baffcd56..ea986b8e90e0 100644 --- a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/operations/_calculate_exchange_operations.py +++ b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/operations/_calculate_exchange_operations.py @@ -6,7 +6,7 @@ # 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 Any, Callable, Dict, Optional, TypeVar, Union +from typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,50 +14,53 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict 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._calculate_exchange_operations import build_post_request_initial +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class CalculateExchangeOperations: - """CalculateExchangeOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.reservations.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.reservations.aio.AzureReservationAPI`'s + :attr:`calculate_exchange` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _post_initial( self, - body: "_models.CalculateExchangeRequest", + body: _models.CalculateExchangeRequest, **kwargs: Any - ) -> Optional["_models.CalculateExchangeOperationResultResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.CalculateExchangeOperationResultResponse"]] + ) -> Optional[_models.CalculateExchangeOperationResultResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.CalculateExchangeOperationResultResponse]] _json = self._serialize.body(body, 'CalculateExchangeRequest') @@ -66,11 +69,13 @@ async def _post_initial( content_type=content_type, json=_json, template_url=self._post_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -103,9 +108,9 @@ async def _post_initial( @distributed_trace_async async def begin_post( self, - body: "_models.CalculateExchangeRequest", + body: _models.CalculateExchangeRequest, **kwargs: Any - ) -> AsyncLROPoller["_models.CalculateExchangeOperationResultResponse"]: + ) -> AsyncLROPoller[_models.CalculateExchangeOperationResultResponse]: """Calculates the refund amounts and price of the new purchases. Calculates price for exchanging ``Reservations`` if there are no policy errors. @@ -129,35 +134,45 @@ async def begin_post( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.reservations.models.CalculateExchangeOperationResultResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CalculateExchangeOperationResultResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CalculateExchangeOperationResultResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._post_initial( + raw_result = await self._post_initial( # type: ignore body=body, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('CalculateExchangeOperationResultResponse', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - 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() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( diff --git a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/operations/_exchange_operations.py b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/operations/_exchange_operations.py index b6bfcc7c1161..d83d1643eb6f 100644 --- a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/operations/_exchange_operations.py +++ b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/operations/_exchange_operations.py @@ -6,7 +6,7 @@ # 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 Any, Callable, Dict, Optional, TypeVar, Union +from typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse @@ -14,50 +14,53 @@ from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict 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._exchange_operations import build_post_request_initial +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ExchangeOperations: - """ExchangeOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.reservations.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.reservations.aio.AzureReservationAPI`'s + :attr:`exchange` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _post_initial( self, - body: "_models.ExchangeRequest", + body: _models.ExchangeRequest, **kwargs: Any - ) -> Optional["_models.ExchangeOperationResultResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ExchangeOperationResultResponse"]] + ) -> Optional[_models.ExchangeOperationResultResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ExchangeOperationResultResponse]] _json = self._serialize.body(body, 'ExchangeRequest') @@ -66,11 +69,13 @@ async def _post_initial( content_type=content_type, json=_json, template_url=self._post_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -103,9 +108,9 @@ async def _post_initial( @distributed_trace_async async def begin_post( self, - body: "_models.ExchangeRequest", + body: _models.ExchangeRequest, **kwargs: Any - ) -> AsyncLROPoller["_models.ExchangeOperationResultResponse"]: + ) -> AsyncLROPoller[_models.ExchangeOperationResultResponse]: """Exchange Reservation(s). Returns one or more ``Reservations`` in exchange for one or more ``Reservation`` purchases. @@ -129,35 +134,45 @@ async def begin_post( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.reservations.models.ExchangeOperationResultResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ExchangeOperationResultResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExchangeOperationResultResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._post_initial( + raw_result = await self._post_initial( # type: ignore body=body, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('ExchangeOperationResultResponse', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - 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() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( diff --git a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/operations/_operation_operations.py b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/operations/_operation_operations.py index 47074b6254f0..82c3e2ffce63 100644 --- a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/operations/_operation_operations.py +++ b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/operations/_operation_operations.py @@ -14,41 +14,41 @@ from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._operation_operations import build_list_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class OperationOperations: - """OperationOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.reservations.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.reservations.aio.AzureReservationAPI`'s + :attr:`operation` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.OperationList"]: + ) -> AsyncIterable[_models.OperationList]: """Get operations. List all the operations. @@ -61,31 +61,38 @@ def list( :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.reservations.models.OperationList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/operations/_patch.py b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/operations/_quota_operations.py b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/operations/_quota_operations.py index 8218f8c9de86..1e46b78353f4 100644 --- a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/operations/_quota_operations.py +++ b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/operations/_quota_operations.py @@ -6,7 +6,7 @@ # 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 Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,36 +16,36 @@ 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.core.utils import case_insensitive_dict 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._quota_operations import build_create_or_update_request_initial, build_get_request, build_list_request, build_update_request_initial +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class QuotaOperations: - """QuotaOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.reservations.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.reservations.aio.AzureReservationAPI`'s + :attr:`quota` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( @@ -55,7 +55,7 @@ async def get( location: str, resource_name: str, **kwargs: Any - ) -> "_models.CurrentQuotaLimitBase": + ) -> _models.CurrentQuotaLimitBase: """Get the current quota (service limit) and usage of a resource. You can use the response from the GET operation to submit quota update request. @@ -76,13 +76,16 @@ async def get( :rtype: ~azure.mgmt.reservations.models.CurrentQuotaLimitBase :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CurrentQuotaLimitBase"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-25") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-25")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CurrentQuotaLimitBase] request = build_get_request( @@ -92,11 +95,13 @@ async def get( resource_name=resource_name, api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -127,17 +132,20 @@ async def _create_or_update_initial( provider_id: str, location: str, resource_name: str, - create_quota_request: "_models.CurrentQuotaLimitBase", + create_quota_request: _models.CurrentQuotaLimitBase, **kwargs: Any - ) -> Union["_models.CurrentQuotaLimitBase", "_models.QuotaRequestSubmitResponse201"]: - cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.CurrentQuotaLimitBase", "_models.QuotaRequestSubmitResponse201"]] + ) -> Union[_models.CurrentQuotaLimitBase, _models.QuotaRequestSubmitResponse201]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-25") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-25")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Union[_models.CurrentQuotaLimitBase, _models.QuotaRequestSubmitResponse201]] _json = self._serialize.body(create_quota_request, 'CurrentQuotaLimitBase') @@ -150,11 +158,13 @@ async def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -186,21 +196,16 @@ async def begin_create_or_update( provider_id: str, location: str, resource_name: str, - create_quota_request: "_models.CurrentQuotaLimitBase", + create_quota_request: _models.CurrentQuotaLimitBase, **kwargs: Any - ) -> AsyncLROPoller[Union["_models.CurrentQuotaLimitBase", "_models.QuotaRequestSubmitResponse201"]]: + ) -> AsyncLROPoller[Union[_models.CurrentQuotaLimitBase, _models.QuotaRequestSubmitResponse201]]: """Create or update the quota (service limits) of a resource to the requested value. Steps: - #. - Make the Get request to get the quota information for specific resource. - - #. - To increase the quota, update the limit field in the response from Get request to new value. - - #. - Submit the JSON to the quota request API to update the quota. + #. Make the Get request to get the quota information for specific resource. + #. To increase the quota, update the limit field in the response from Get request to new value. + #. Submit the JSON to the quota request API to update the quota. The Create quota request may be constructed as follows. The PUT operation can be used to update the quota. @@ -233,17 +238,20 @@ async def begin_create_or_update( ~azure.mgmt.reservations.models.QuotaRequestSubmitResponse201] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-10-25") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-25")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Union[_models.CurrentQuotaLimitBase, _models.QuotaRequestSubmitResponse201]] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.CurrentQuotaLimitBase", "_models.QuotaRequestSubmitResponse201"]] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore subscription_id=subscription_id, provider_id=provider_id, location=location, @@ -252,20 +260,27 @@ async def begin_create_or_update( api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('CurrentQuotaLimitBase', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'original-uri'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'original-uri'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -284,17 +299,20 @@ async def _update_initial( provider_id: str, location: str, resource_name: str, - create_quota_request: "_models.CurrentQuotaLimitBase", + create_quota_request: _models.CurrentQuotaLimitBase, **kwargs: Any - ) -> Union["_models.CurrentQuotaLimitBase", "_models.QuotaRequestSubmitResponse201"]: - cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.CurrentQuotaLimitBase", "_models.QuotaRequestSubmitResponse201"]] + ) -> Union[_models.CurrentQuotaLimitBase, _models.QuotaRequestSubmitResponse201]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-25") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-25")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Union[_models.CurrentQuotaLimitBase, _models.QuotaRequestSubmitResponse201]] _json = self._serialize.body(create_quota_request, 'CurrentQuotaLimitBase') @@ -307,11 +325,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -343,15 +363,12 @@ async def begin_update( provider_id: str, location: str, resource_name: str, - create_quota_request: "_models.CurrentQuotaLimitBase", + create_quota_request: _models.CurrentQuotaLimitBase, **kwargs: Any - ) -> AsyncLROPoller[Union["_models.CurrentQuotaLimitBase", "_models.QuotaRequestSubmitResponse201"]]: + ) -> AsyncLROPoller[Union[_models.CurrentQuotaLimitBase, _models.QuotaRequestSubmitResponse201]]: """Update the quota (service limits) of this resource to the requested value. - • To get the quota information for specific resource, send a GET request. - • To increase the quota, update the limit field from the GET response to a new value. - • To update the quota value, submit the JSON response to the quota request API to update the quota. • To update the quota. use the PATCH operation. @@ -385,17 +402,20 @@ async def begin_update( ~azure.mgmt.reservations.models.QuotaRequestSubmitResponse201] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-10-25") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-25")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Union[_models.CurrentQuotaLimitBase, _models.QuotaRequestSubmitResponse201]] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.CurrentQuotaLimitBase", "_models.QuotaRequestSubmitResponse201"]] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore subscription_id=subscription_id, provider_id=provider_id, location=location, @@ -404,20 +424,27 @@ async def begin_update( api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('CurrentQuotaLimitBase', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'original-uri'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'original-uri'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -437,7 +464,7 @@ def list( provider_id: str, location: str, **kwargs: Any - ) -> AsyncIterable["_models.QuotaLimits"]: + ) -> AsyncIterable[_models.QuotaLimits]: """Gets a list of current quotas (service limits) and usage for all resources. The response from the list quota operation can be leveraged to request quota updates. @@ -455,13 +482,16 @@ def list( :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.reservations.models.QuotaLimits] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-10-25") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-25")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.QuotaLimits] - cls = kwargs.pop('cls', None) # type: ClsType["_models.QuotaLimits"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -471,9 +501,11 @@ def prepare_request(next_link=None): location=location, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -483,9 +515,11 @@ def prepare_request(next_link=None): location=location, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/operations/_quota_request_status_operations.py b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/operations/_quota_request_status_operations.py index e8b05cc8d928..40483b94ff86 100644 --- a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/operations/_quota_request_status_operations.py +++ b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/operations/_quota_request_status_operations.py @@ -15,35 +15,35 @@ 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._quota_request_status_operations import build_get_request, build_list_request +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class QuotaRequestStatusOperations: - """QuotaRequestStatusOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.reservations.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.reservations.aio.AzureReservationAPI`'s + :attr:`quota_request_status` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def get( @@ -53,7 +53,7 @@ async def get( location: str, id: str, **kwargs: Any - ) -> "_models.QuotaRequestDetails": + ) -> _models.QuotaRequestDetails: """For the specified Azure region (location), get the details and status of the quota request by the quota request ID for the resources of the resource provider. The PUT request for the quota (service limit) returns a response with the requestId parameter. @@ -74,13 +74,16 @@ async def get( :rtype: ~azure.mgmt.reservations.models.QuotaRequestDetails :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QuotaRequestDetails"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-25") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-25")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.QuotaRequestDetails] request = build_get_request( @@ -90,11 +93,13 @@ async def get( id=id, api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -126,7 +131,7 @@ def list( top: Optional[int] = None, skiptoken: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.QuotaRequestDetailsList"]: + ) -> AsyncIterable[_models.QuotaRequestDetailsList]: """For the specified Azure region (location), subscription, and resource provider, get the history of the quota requests for the past year. To select specific quota requests, use the oData filter. @@ -142,10 +147,8 @@ def list( * - Field - Supported operators - * - - - - |requestSubmitTime | ge, le, eq, gt, lt. Default value is None. + * - requestSubmitTime + - ge, le, eq, gt, lt. Default value is None. :type filter: str :param top: Number of records to return. Default value is None. :type top: int @@ -164,13 +167,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.reservations.models.QuotaRequestDetailsList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-10-25") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-25")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.QuotaRequestDetailsList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.QuotaRequestDetailsList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -183,9 +189,11 @@ def prepare_request(next_link=None): top=top, skiptoken=skiptoken, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -198,9 +206,11 @@ def prepare_request(next_link=None): top=top, skiptoken=skiptoken, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/operations/_reservation_operations.py b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/operations/_reservation_operations.py index c4030fe08e9e..3e393a3c36f5 100644 --- a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/operations/_reservation_operations.py +++ b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/operations/_reservation_operations.py @@ -6,7 +6,7 @@ # 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 Any, AsyncIterable, Callable, Dict, List, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, List, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,52 +16,55 @@ 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.core.utils import case_insensitive_dict 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._reservation_operations import build_available_scopes_request_initial, build_get_request, build_list_all_request, build_list_request, build_list_revisions_request, build_merge_request_initial, build_split_request_initial, build_update_request_initial +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ReservationOperations: - """ReservationOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.reservations.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.reservations.aio.AzureReservationAPI`'s + :attr:`reservation` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + async def _available_scopes_initial( self, reservation_order_id: str, reservation_id: str, - body: "_models.AvailableScopeRequest", + body: _models.AvailableScopeRequest, **kwargs: Any - ) -> "_models.AvailableScopeProperties": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailableScopeProperties"] + ) -> _models.AvailableScopeProperties: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailableScopeProperties] _json = self._serialize.body(body, 'AvailableScopeRequest') @@ -72,11 +75,13 @@ async def _available_scopes_initial( content_type=content_type, json=_json, template_url=self._available_scopes_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -102,9 +107,9 @@ async def begin_available_scopes( self, reservation_order_id: str, reservation_id: str, - body: "_models.AvailableScopeRequest", + body: _models.AvailableScopeRequest, **kwargs: Any - ) -> AsyncLROPoller["_models.AvailableScopeProperties"]: + ) -> AsyncLROPoller[_models.AvailableScopeProperties]: """Get Available Scopes for ``Reservation``. Get Available Scopes for ``Reservation``. @@ -132,37 +137,47 @@ async def begin_available_scopes( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.reservations.models.AvailableScopeProperties] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailableScopeProperties] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailableScopeProperties"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._available_scopes_initial( + raw_result = await self._available_scopes_initial( # type: ignore reservation_order_id=reservation_order_id, reservation_id=reservation_id, body=body, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('AvailableScopeProperties', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -178,17 +193,20 @@ def get_long_running_output(pipeline_response): async def _split_initial( self, reservation_order_id: str, - body: "_models.SplitRequest", + body: _models.SplitRequest, **kwargs: Any - ) -> Optional[List["_models.ReservationResponse"]]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional[List["_models.ReservationResponse"]]] + ) -> Optional[List[_models.ReservationResponse]]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[List[_models.ReservationResponse]]] _json = self._serialize.body(body, 'SplitRequest') @@ -198,11 +216,13 @@ async def _split_initial( content_type=content_type, json=_json, template_url=self._split_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -229,9 +249,9 @@ async def _split_initial( async def begin_split( self, reservation_order_id: str, - body: "_models.SplitRequest", + body: _models.SplitRequest, **kwargs: Any - ) -> AsyncLROPoller[List["_models.ReservationResponse"]]: + ) -> AsyncLROPoller[List[_models.ReservationResponse]]: """Split the ``Reservation``. Split a ``Reservation`` into two ``Reservation``\ s with specified quantity distribution. @@ -257,36 +277,46 @@ async def begin_split( ~azure.core.polling.AsyncLROPoller[list[~azure.mgmt.reservations.models.ReservationResponse]] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.ReservationResponse]] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.ReservationResponse"]] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._split_initial( + raw_result = await self._split_initial( # type: ignore reservation_order_id=reservation_order_id, body=body, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('[ReservationResponse]', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -302,17 +332,20 @@ def get_long_running_output(pipeline_response): async def _merge_initial( self, reservation_order_id: str, - body: "_models.MergeRequest", + body: _models.MergeRequest, **kwargs: Any - ) -> Optional[List["_models.ReservationResponse"]]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional[List["_models.ReservationResponse"]]] + ) -> Optional[List[_models.ReservationResponse]]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[List[_models.ReservationResponse]]] _json = self._serialize.body(body, 'MergeRequest') @@ -322,11 +355,13 @@ async def _merge_initial( content_type=content_type, json=_json, template_url=self._merge_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -353,9 +388,9 @@ async def _merge_initial( async def begin_merge( self, reservation_order_id: str, - body: "_models.MergeRequest", + body: _models.MergeRequest, **kwargs: Any - ) -> AsyncLROPoller[List["_models.ReservationResponse"]]: + ) -> AsyncLROPoller[List[_models.ReservationResponse]]: """Merges two ``Reservation``\ s. Merge the specified ``Reservation``\ s into a new ``Reservation``. The two ``Reservation``\ s @@ -382,36 +417,46 @@ async def begin_merge( ~azure.core.polling.AsyncLROPoller[list[~azure.mgmt.reservations.models.ReservationResponse]] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.ReservationResponse]] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.ReservationResponse"]] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._merge_initial( + raw_result = await self._merge_initial( # type: ignore reservation_order_id=reservation_order_id, body=body, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('[ReservationResponse]', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -429,7 +474,7 @@ def list( self, reservation_order_id: str, **kwargs: Any - ) -> AsyncIterable["_models.ReservationList"]: + ) -> AsyncIterable[_models.ReservationList]: """Get ``Reservation``\ s in a given reservation Order. List ``Reservation``\ s within a single ``ReservationOrder``. @@ -445,13 +490,16 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.reservations.models.ReservationList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ReservationList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -459,9 +507,11 @@ def prepare_request(next_link=None): reservation_order_id=reservation_order_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -469,9 +519,11 @@ def prepare_request(next_link=None): reservation_order_id=reservation_order_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -512,7 +564,7 @@ async def get( reservation_order_id: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.ReservationResponse": + ) -> _models.ReservationResponse: """Get ``Reservation`` details. Get specific ``Reservation`` details. @@ -531,13 +583,16 @@ async def get( :rtype: ~azure.mgmt.reservations.models.ReservationResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ReservationResponse] request = build_get_request( @@ -546,11 +601,13 @@ async def get( api_version=api_version, expand=expand, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -576,17 +633,20 @@ async def _update_initial( self, reservation_order_id: str, reservation_id: str, - parameters: "_models.Patch", + parameters: _models.Patch, **kwargs: Any - ) -> Optional["_models.ReservationResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ReservationResponse"]] + ) -> Optional[_models.ReservationResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ReservationResponse]] _json = self._serialize.body(parameters, 'Patch') @@ -597,11 +657,13 @@ async def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -629,9 +691,9 @@ async def begin_update( self, reservation_order_id: str, reservation_id: str, - parameters: "_models.Patch", + parameters: _models.Patch, **kwargs: Any - ) -> AsyncLROPoller["_models.ReservationResponse"]: + ) -> AsyncLROPoller[_models.ReservationResponse]: """Updates a ``Reservation``. Updates the applied scopes of the ``Reservation``. @@ -658,37 +720,47 @@ async def begin_update( :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.reservations.models.ReservationResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ReservationResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore reservation_order_id=reservation_order_id, reservation_id=reservation_id, parameters=parameters, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('ReservationResponse', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -707,7 +779,7 @@ def list_revisions( reservation_id: str, reservation_order_id: str, **kwargs: Any - ) -> AsyncIterable["_models.ReservationList"]: + ) -> AsyncIterable[_models.ReservationList]: """Get ``Reservation`` revisions. List of all the revisions for the ``Reservation``. @@ -725,13 +797,16 @@ def list_revisions( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.reservations.models.ReservationList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ReservationList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -740,9 +815,11 @@ def prepare_request(next_link=None): reservation_order_id=reservation_order_id, api_version=api_version, template_url=self.list_revisions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -751,9 +828,11 @@ def prepare_request(next_link=None): reservation_order_id=reservation_order_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -797,7 +876,7 @@ def list_all( selected_state: Optional[str] = None, take: Optional[float] = None, **kwargs: Any - ) -> AsyncIterable["_models.ReservationsListResult"]: + ) -> AsyncIterable[_models.ReservationsListResult]: """List the reservations and the roll up counts of reservations group by provisioning states that the user has access to in the current tenant. @@ -830,13 +909,16 @@ def list_all( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.reservations.models.ReservationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ReservationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -849,9 +931,11 @@ def prepare_request(next_link=None): selected_state=selected_state, take=take, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -864,9 +948,11 @@ def prepare_request(next_link=None): selected_state=selected_state, take=take, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/operations/_reservation_order_operations.py b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/operations/_reservation_order_operations.py index 4bdadf0812f9..a30344e978d9 100644 --- a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/operations/_reservation_order_operations.py +++ b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/aio/operations/_reservation_order_operations.py @@ -6,7 +6,7 @@ # 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 Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error @@ -16,43 +16,43 @@ 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.core.utils import case_insensitive_dict 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._reservation_order_operations import build_calculate_request, build_change_directory_request, build_get_request, build_list_request, build_purchase_request_initial +from .._vendor import MixinABC T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class ReservationOrderOperations: - """ReservationOrderOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.reservations.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.reservations.aio.AzureReservationAPI`'s + :attr:`reservation_order` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async async def calculate( self, - body: "_models.PurchaseRequest", + body: _models.PurchaseRequest, **kwargs: Any - ) -> "_models.CalculatePriceResponse": + ) -> _models.CalculatePriceResponse: """Calculate price for a ``ReservationOrder``. Calculate price for placing a ``ReservationOrder``. @@ -67,14 +67,17 @@ async def calculate( :rtype: ~azure.mgmt.reservations.models.CalculatePriceResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CalculatePriceResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CalculatePriceResponse] _json = self._serialize.body(body, 'PurchaseRequest') @@ -83,11 +86,13 @@ async def calculate( content_type=content_type, json=_json, template_url=self.calculate.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -113,7 +118,7 @@ async def calculate( def list( self, **kwargs: Any - ) -> AsyncIterable["_models.ReservationOrderList"]: + ) -> AsyncIterable[_models.ReservationOrderList]: """Get all ``ReservationOrder``\ s. List of all the ``ReservationOrder``\ s that the user has access to in the current tenant. @@ -128,31 +133,38 @@ def list( ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.reservations.models.ReservationOrderList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ReservationOrderList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationOrderList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -189,17 +201,20 @@ async def get_next(next_link=None): async def _purchase_initial( self, reservation_order_id: str, - body: "_models.PurchaseRequest", + body: _models.PurchaseRequest, **kwargs: Any - ) -> "_models.ReservationOrderResponse": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationOrderResponse"] + ) -> _models.ReservationOrderResponse: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ReservationOrderResponse] _json = self._serialize.body(body, 'PurchaseRequest') @@ -209,11 +224,13 @@ async def _purchase_initial( content_type=content_type, json=_json, template_url=self._purchase_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -242,9 +259,9 @@ async def _purchase_initial( async def begin_purchase( self, reservation_order_id: str, - body: "_models.PurchaseRequest", + body: _models.PurchaseRequest, **kwargs: Any - ) -> AsyncLROPoller["_models.ReservationOrderResponse"]: + ) -> AsyncLROPoller[_models.ReservationOrderResponse]: """Purchase ``ReservationOrder``. Purchase ``ReservationOrder`` and create resource under the specified URI. @@ -270,36 +287,46 @@ async def begin_purchase( ~azure.core.polling.AsyncLROPoller[~azure.mgmt.reservations.models.ReservationOrderResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ReservationOrderResponse] polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationOrderResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._purchase_initial( + raw_result = await self._purchase_initial( # type: ignore reservation_order_id=reservation_order_id, body=body, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('ReservationOrderResponse', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( @@ -318,7 +345,7 @@ async def get( reservation_order_id: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.ReservationOrderResponse": + ) -> _models.ReservationOrderResponse: """Get a specific ``ReservationOrder``. Get the details of the ``ReservationOrder``. @@ -335,13 +362,16 @@ async def get( :rtype: ~azure.mgmt.reservations.models.ReservationOrderResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationOrderResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ReservationOrderResponse] request = build_get_request( @@ -349,11 +379,13 @@ async def get( api_version=api_version, expand=expand, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -379,9 +411,9 @@ async def get( async def change_directory( self, reservation_order_id: str, - body: "_models.ChangeDirectoryRequest", + body: _models.ChangeDirectoryRequest, **kwargs: Any - ) -> "_models.ChangeDirectoryResponse": + ) -> _models.ChangeDirectoryResponse: """Change directory of ``ReservationOrder``. Change directory (tenant) of ``ReservationOrder`` and all ``Reservation`` under it to specified @@ -399,14 +431,17 @@ async def change_directory( :rtype: ~azure.mgmt.reservations.models.ChangeDirectoryResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ChangeDirectoryResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ChangeDirectoryResponse] _json = self._serialize.body(body, 'ChangeDirectoryRequest') @@ -416,11 +451,13 @@ async def change_directory( content_type=content_type, json=_json, template_url=self.change_directory.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/models/__init__.py b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/models/__init__.py index 2dc65ef71c67..99230d8bcd3f 100644 --- a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/models/__init__.py +++ b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/models/__init__.py @@ -115,7 +115,9 @@ UserFriendlyAppliedScopeType, UserFriendlyRenewState, ) - +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'AppliedReservationList', 'AppliedReservations', @@ -223,3 +225,5 @@ 'UserFriendlyAppliedScopeType', 'UserFriendlyRenewState', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/models/_azure_reservation_api_enums.py b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/models/_azure_reservation_api_enums.py index f65bf9b4e89f..8174c7bbcfb6 100644 --- a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/models/_azure_reservation_api_enums.py +++ b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/models/_azure_reservation_api_enums.py @@ -7,18 +7,17 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AppliedScopeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class AppliedScopeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of the Applied Scope. """ SINGLE = "Single" SHARED = "Shared" -class CalculateExchangeOperationResultStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CalculateExchangeOperationResultStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Status of the operation. """ @@ -27,7 +26,7 @@ class CalculateExchangeOperationResultStatus(with_metaclass(CaseInsensitiveEnumM CANCELLED = "Cancelled" PENDING = "Pending" -class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity that created the resource. """ @@ -36,7 +35,7 @@ class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class DisplayProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class DisplayProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Represent the current display state of the Reservation. """ @@ -48,7 +47,7 @@ class DisplayProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum CANCELLED = "Cancelled" FAILED = "Failed" -class ErrorResponseCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ErrorResponseCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): NOT_SPECIFIED = "NotSpecified" INTERNAL_SERVER_ERROR = "InternalServerError" @@ -107,7 +106,7 @@ class ErrorResponseCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): CALCULATE_PRICE_FAILED = "CalculatePriceFailed" APPLIED_SCOPES_SAME_AS_EXISTING = "AppliedScopesSameAsExisting" -class ExchangeOperationResultStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ExchangeOperationResultStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Status of the operation. """ @@ -117,7 +116,7 @@ class ExchangeOperationResultStatus(with_metaclass(CaseInsensitiveEnumMeta, str, PENDING_REFUNDS = "PendingRefunds" PENDING_PURCHASES = "PendingPurchases" -class InstanceFlexibility(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class InstanceFlexibility(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Turning this on will apply the reservation discount to other VMs in the same VM size group. Only specify for VirtualMachines reserved resource type. """ @@ -125,7 +124,7 @@ class InstanceFlexibility(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ON = "On" OFF = "Off" -class Location(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class Location(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Location in which the Resources needs to be reserved. It cannot be changed after the resource has been created. """ @@ -155,7 +154,7 @@ class Location(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): WESTCENTRALUS = "westcentralus" UKWEST = "ukwest" -class OperationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class OperationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Status of the individual operation. """ @@ -164,7 +163,7 @@ class OperationStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): CANCELLED = "Cancelled" PENDING = "Pending" -class PaymentStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class PaymentStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Describes whether the payment is completed, failed, cancelled or scheduled in the future. """ @@ -173,7 +172,7 @@ class PaymentStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SCHEDULED = "Scheduled" CANCELLED = "Cancelled" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Represent the current state of the Reservation. """ @@ -191,7 +190,7 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SPLIT = "Split" MERGED = "Merged" -class QuotaRequestState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class QuotaRequestState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The quota request status. """ @@ -201,14 +200,14 @@ class QuotaRequestState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FAILED = "Failed" IN_PROGRESS = "InProgress" -class ReservationBillingPlan(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ReservationBillingPlan(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Represent the billing plans. """ UPFRONT = "Upfront" MONTHLY = "Monthly" -class ReservationStatusCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ReservationStatusCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): NONE = "None" PENDING = "Pending" @@ -221,7 +220,7 @@ class ReservationStatusCode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): EXPIRED = "Expired" SUCCEEDED = "Succeeded" -class ReservationTerm(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ReservationTerm(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Represent the term of Reservation. """ @@ -229,7 +228,7 @@ class ReservationTerm(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): P3_Y = "P3Y" P5_Y = "P5Y" -class ReservedResourceType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ReservedResourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of the resource that is being reserved. """ @@ -260,7 +259,7 @@ class ReservedResourceType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SQL_EDGE = "SqlEdge" VIRTUAL_MACHINE_SOFTWARE = "VirtualMachineSoftware" -class ResourceType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class ResourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The resource types. """ @@ -270,7 +269,7 @@ class ResourceType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SHARED = "shared" SERVICE_SPECIFIC = "serviceSpecific" -class UserFriendlyAppliedScopeType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UserFriendlyAppliedScopeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The applied scope type """ @@ -280,7 +279,7 @@ class UserFriendlyAppliedScopeType(with_metaclass(CaseInsensitiveEnumMeta, str, RESOURCE_GROUP = "ResourceGroup" MANAGEMENT_GROUP = "ManagementGroup" -class UserFriendlyRenewState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): +class UserFriendlyRenewState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The renew state of the reservation """ diff --git a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/models/_models_py3.py b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/models/_models_py3.py index a8d9b0340f1d..7cfbdae9812f 100644 --- a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/models/_models_py3.py +++ b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/models/_models_py3.py @@ -7,12 +7,14 @@ # -------------------------------------------------------------------------- import datetime -from typing import Any, Dict, List, Optional, Union +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._azure_reservation_api_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class AppliedReservationList(msrest.serialization.Model): @@ -78,7 +80,7 @@ class AppliedReservations(msrest.serialization.Model): def __init__( self, *, - reservation_order_ids: Optional["AppliedReservationList"] = None, + reservation_order_ids: Optional["_models.AppliedReservationList"] = None, **kwargs ): """ @@ -106,7 +108,7 @@ class AvailableScopeProperties(msrest.serialization.Model): def __init__( self, *, - properties: Optional["SubscriptionScopeProperties"] = None, + properties: Optional["_models.SubscriptionScopeProperties"] = None, **kwargs ): """ @@ -131,7 +133,7 @@ class AvailableScopeRequest(msrest.serialization.Model): def __init__( self, *, - properties: Optional["AvailableScopeRequestProperties"] = None, + properties: Optional["_models.AvailableScopeRequestProperties"] = None, **kwargs ): """ @@ -187,9 +189,9 @@ class BillingInformation(msrest.serialization.Model): def __init__( self, *, - billing_currency_total_paid_amount: Optional["Price"] = None, - billing_currency_prorated_amount: Optional["Price"] = None, - billing_currency_remaining_commitment_amount: Optional["Price"] = None, + billing_currency_total_paid_amount: Optional["_models.Price"] = None, + billing_currency_prorated_amount: Optional["_models.Price"] = None, + billing_currency_remaining_commitment_amount: Optional["_models.Price"] = None, **kwargs ): """ @@ -214,8 +216,8 @@ class CalculateExchangeOperationResultResponse(msrest.serialization.Model): :ivar name: It must match the last segment of the id field, and will typically be a GUID / system generated value. :vartype name: str - :ivar status: Status of the operation. Possible values include: "Succeeded", "Failed", - "Cancelled", "Pending". + :ivar status: Status of the operation. Known values are: "Succeeded", "Failed", "Cancelled", + "Pending". :vartype status: str or ~azure.mgmt.reservations.models.CalculateExchangeOperationResultStatus :ivar properties: CalculateExchange response properties. :vartype properties: ~azure.mgmt.reservations.models.CalculateExchangeResponseProperties @@ -236,9 +238,9 @@ def __init__( *, id: Optional[str] = None, name: Optional[str] = None, - status: Optional[Union[str, "CalculateExchangeOperationResultStatus"]] = None, - properties: Optional["CalculateExchangeResponseProperties"] = None, - error: Optional["OperationResultError"] = None, + status: Optional[Union[str, "_models.CalculateExchangeOperationResultStatus"]] = None, + properties: Optional["_models.CalculateExchangeResponseProperties"] = None, + error: Optional["_models.OperationResultError"] = None, **kwargs ): """ @@ -247,8 +249,8 @@ def __init__( :keyword name: It must match the last segment of the id field, and will typically be a GUID / system generated value. :paramtype name: str - :keyword status: Status of the operation. Possible values include: "Succeeded", "Failed", - "Cancelled", "Pending". + :keyword status: Status of the operation. Known values are: "Succeeded", "Failed", "Cancelled", + "Pending". :paramtype status: str or ~azure.mgmt.reservations.models.CalculateExchangeOperationResultStatus :keyword properties: CalculateExchange response properties. @@ -278,7 +280,7 @@ class CalculateExchangeRequest(msrest.serialization.Model): def __init__( self, *, - properties: Optional["CalculateExchangeRequestProperties"] = None, + properties: Optional["_models.CalculateExchangeRequestProperties"] = None, **kwargs ): """ @@ -306,8 +308,8 @@ class CalculateExchangeRequestProperties(msrest.serialization.Model): def __init__( self, *, - reservations_to_purchase: Optional[List["PurchaseRequest"]] = None, - reservations_to_exchange: Optional[List["ReservationToReturn"]] = None, + reservations_to_purchase: Optional[List["_models.PurchaseRequest"]] = None, + reservations_to_exchange: Optional[List["_models.ReservationToReturn"]] = None, **kwargs ): """ @@ -357,12 +359,12 @@ def __init__( self, *, session_id: Optional[str] = None, - net_payable: Optional["Price"] = None, - refunds_total: Optional["Price"] = None, - purchases_total: Optional["Price"] = None, - reservations_to_purchase: Optional[List["ReservationToPurchaseCalculateExchange"]] = None, - reservations_to_exchange: Optional[List["ReservationToExchange"]] = None, - policy_result: Optional["ExchangePolicyErrors"] = None, + net_payable: Optional["_models.Price"] = None, + refunds_total: Optional["_models.Price"] = None, + purchases_total: Optional["_models.Price"] = None, + reservations_to_purchase: Optional[List["_models.ReservationToPurchaseCalculateExchange"]] = None, + reservations_to_exchange: Optional[List["_models.ReservationToExchange"]] = None, + policy_result: Optional["_models.ExchangePolicyErrors"] = None, **kwargs ): """ @@ -407,7 +409,7 @@ class CalculatePriceResponse(msrest.serialization.Model): def __init__( self, *, - properties: Optional["CalculatePriceResponseProperties"] = None, + properties: Optional["_models.CalculatePriceResponseProperties"] = None, **kwargs ): """ @@ -468,7 +470,7 @@ class CalculatePriceResponseProperties(msrest.serialization.Model): def __init__( self, *, - billing_currency_total: Optional["CalculatePriceResponsePropertiesBillingCurrencyTotal"] = None, + billing_currency_total: Optional["_models.CalculatePriceResponsePropertiesBillingCurrencyTotal"] = None, net_total: Optional[float] = None, tax_total: Optional[float] = None, grand_total: Optional[float] = None, @@ -477,8 +479,8 @@ def __init__( reservation_order_id: Optional[str] = None, sku_title: Optional[str] = None, sku_description: Optional[str] = None, - pricing_currency_total: Optional["CalculatePriceResponsePropertiesPricingCurrencyTotal"] = None, - payment_schedule: Optional[List["PaymentDetail"]] = None, + pricing_currency_total: Optional["_models.CalculatePriceResponsePropertiesPricingCurrencyTotal"] = None, + payment_schedule: Optional[List["_models.PaymentDetail"]] = None, **kwargs ): """ @@ -653,7 +655,7 @@ class Catalog(msrest.serialization.Model): def __init__( self, *, - billing_plans: Optional[Dict[str, List[Union[str, "ReservationBillingPlan"]]]] = None, + billing_plans: Optional[Dict[str, List[Union[str, "_models.ReservationBillingPlan"]]]] = None, **kwargs ): """ @@ -689,7 +691,7 @@ class CatalogMsrp(msrest.serialization.Model): def __init__( self, *, - p1_y: Optional["Price"] = None, + p1_y: Optional["_models.Price"] = None, **kwargs ): """ @@ -742,8 +744,8 @@ class ChangeDirectoryResponse(msrest.serialization.Model): def __init__( self, *, - reservation_order: Optional["ChangeDirectoryResult"] = None, - reservations: Optional[List["ChangeDirectoryResult"]] = None, + reservation_order: Optional["_models.ChangeDirectoryResult"] = None, + reservations: Optional[List["_models.ChangeDirectoryResult"]] = None, **kwargs ): """ @@ -819,7 +821,7 @@ class CreateGenericQuotaRequestParameters(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["CurrentQuotaLimitBase"]] = None, + value: Optional[List["_models.CurrentQuotaLimitBase"]] = None, **kwargs ): """ @@ -835,7 +837,7 @@ class CurrentQuotaLimit(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: The details of the quota request status. Possible values include: + :ivar provisioning_state: The details of the quota request status. Known values are: "Accepted", "Invalid", "Succeeded", "Failed", "InProgress". :vartype provisioning_state: str or ~azure.mgmt.reservations.models.QuotaRequestState :ivar message: A user friendly message. @@ -870,7 +872,7 @@ class CurrentQuotaLimit(msrest.serialization.Model): def __init__( self, *, - properties: Optional["QuotaProperties"] = None, + properties: Optional["_models.QuotaProperties"] = None, **kwargs ): """ @@ -917,7 +919,7 @@ class CurrentQuotaLimitBase(msrest.serialization.Model): def __init__( self, *, - properties: Optional["QuotaProperties"] = None, + properties: Optional["_models.QuotaProperties"] = None, **kwargs ): """ @@ -945,7 +947,7 @@ class Error(msrest.serialization.Model): def __init__( self, *, - error: Optional["ExtendedErrorInfo"] = None, + error: Optional["_models.ExtendedErrorInfo"] = None, **kwargs ): """ @@ -1007,7 +1009,7 @@ class ErrorResponse(msrest.serialization.Model): def __init__( self, *, - error: Optional["ErrorDetails"] = None, + error: Optional["_models.ErrorDetails"] = None, **kwargs ): """ @@ -1032,7 +1034,7 @@ class ExceptionResponse(msrest.serialization.Model): def __init__( self, *, - error: Optional["ServiceError"] = None, + error: Optional["_models.ServiceError"] = None, **kwargs ): """ @@ -1051,8 +1053,8 @@ class ExchangeOperationResultResponse(msrest.serialization.Model): :ivar name: It must match the last segment of the id field, and will typically be a GUID / system generated value. :vartype name: str - :ivar status: Status of the operation. Possible values include: "Succeeded", "Failed", - "Cancelled", "PendingRefunds", "PendingPurchases". + :ivar status: Status of the operation. Known values are: "Succeeded", "Failed", "Cancelled", + "PendingRefunds", "PendingPurchases". :vartype status: str or ~azure.mgmt.reservations.models.ExchangeOperationResultStatus :ivar properties: Exchange response properties. :vartype properties: ~azure.mgmt.reservations.models.ExchangeResponseProperties @@ -1073,9 +1075,9 @@ def __init__( *, id: Optional[str] = None, name: Optional[str] = None, - status: Optional[Union[str, "ExchangeOperationResultStatus"]] = None, - properties: Optional["ExchangeResponseProperties"] = None, - error: Optional["OperationResultError"] = None, + status: Optional[Union[str, "_models.ExchangeOperationResultStatus"]] = None, + properties: Optional["_models.ExchangeResponseProperties"] = None, + error: Optional["_models.OperationResultError"] = None, **kwargs ): """ @@ -1084,8 +1086,8 @@ def __init__( :keyword name: It must match the last segment of the id field, and will typically be a GUID / system generated value. :paramtype name: str - :keyword status: Status of the operation. Possible values include: "Succeeded", "Failed", - "Cancelled", "PendingRefunds", "PendingPurchases". + :keyword status: Status of the operation. Known values are: "Succeeded", "Failed", "Cancelled", + "PendingRefunds", "PendingPurchases". :paramtype status: str or ~azure.mgmt.reservations.models.ExchangeOperationResultStatus :keyword properties: Exchange response properties. :paramtype properties: ~azure.mgmt.reservations.models.ExchangeResponseProperties @@ -1146,7 +1148,7 @@ class ExchangePolicyErrors(msrest.serialization.Model): def __init__( self, *, - policy_errors: Optional[List["ExchangePolicyError"]] = None, + policy_errors: Optional[List["_models.ExchangePolicyError"]] = None, **kwargs ): """ @@ -1171,7 +1173,7 @@ class ExchangeRequest(msrest.serialization.Model): def __init__( self, *, - properties: Optional["ExchangeRequestProperties"] = None, + properties: Optional["_models.ExchangeRequestProperties"] = None, **kwargs ): """ @@ -1242,12 +1244,12 @@ def __init__( self, *, session_id: Optional[str] = None, - net_payable: Optional["Price"] = None, - refunds_total: Optional["Price"] = None, - purchases_total: Optional["Price"] = None, - reservations_to_purchase: Optional[List["ReservationToPurchaseExchange"]] = None, - reservations_to_exchange: Optional[List["ReservationToReturnForExchange"]] = None, - policy_result: Optional["ExchangePolicyErrors"] = None, + net_payable: Optional["_models.Price"] = None, + refunds_total: Optional["_models.Price"] = None, + purchases_total: Optional["_models.Price"] = None, + reservations_to_purchase: Optional[List["_models.ReservationToPurchaseExchange"]] = None, + reservations_to_exchange: Optional[List["_models.ReservationToReturnForExchange"]] = None, + policy_result: Optional["_models.ExchangePolicyErrors"] = None, **kwargs ): """ @@ -1281,7 +1283,7 @@ def __init__( class ExtendedErrorInfo(msrest.serialization.Model): """ExtendedErrorInfo. - :ivar code: Possible values include: "NotSpecified", "InternalServerError", "ServerTimeout", + :ivar code: Known values are: "NotSpecified", "InternalServerError", "ServerTimeout", "AuthorizationFailed", "BadRequest", "ClientCertificateThumbprintNotSet", "InvalidRequestContent", "OperationFailed", "HttpMethodNotSupported", "InvalidRequestUri", "MissingTenantId", "InvalidTenantId", "InvalidReservationOrderId", "InvalidReservationId", @@ -1313,12 +1315,12 @@ class ExtendedErrorInfo(msrest.serialization.Model): def __init__( self, *, - code: Optional[Union[str, "ErrorResponseCode"]] = None, + code: Optional[Union[str, "_models.ErrorResponseCode"]] = None, message: Optional[str] = None, **kwargs ): """ - :keyword code: Possible values include: "NotSpecified", "InternalServerError", "ServerTimeout", + :keyword code: Known values are: "NotSpecified", "InternalServerError", "ServerTimeout", "AuthorizationFailed", "BadRequest", "ClientCertificateThumbprintNotSet", "InvalidRequestContent", "OperationFailed", "HttpMethodNotSupported", "InvalidRequestUri", "MissingTenantId", "InvalidTenantId", "InvalidReservationOrderId", "InvalidReservationId", @@ -1349,7 +1351,7 @@ def __init__( class ExtendedStatusInfo(msrest.serialization.Model): """ExtendedStatusInfo. - :ivar status_code: Possible values include: "None", "Pending", "Processing", "Active", + :ivar status_code: Known values are: "None", "Pending", "Processing", "Active", "PurchaseError", "PaymentInstrumentError", "Split", "Merged", "Expired", "Succeeded". :vartype status_code: str or ~azure.mgmt.reservations.models.ReservationStatusCode :ivar message: The message giving detailed information about the status code. @@ -1364,12 +1366,12 @@ class ExtendedStatusInfo(msrest.serialization.Model): def __init__( self, *, - status_code: Optional[Union[str, "ReservationStatusCode"]] = None, + status_code: Optional[Union[str, "_models.ReservationStatusCode"]] = None, message: Optional[str] = None, **kwargs ): """ - :keyword status_code: Possible values include: "None", "Pending", "Processing", "Active", + :keyword status_code: Known values are: "None", "Pending", "Processing", "Active", "PurchaseError", "PaymentInstrumentError", "Split", "Merged", "Expired", "Succeeded". :paramtype status_code: str or ~azure.mgmt.reservations.models.ReservationStatusCode :keyword message: The message giving detailed information about the status code. @@ -1470,7 +1472,7 @@ class OperationList(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["OperationResponse"]] = None, + value: Optional[List["_models.OperationResponse"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -1513,7 +1515,7 @@ def __init__( *, name: Optional[str] = None, is_data_action: Optional[bool] = None, - display: Optional["OperationDisplay"] = None, + display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, properties: Optional[Any] = None, **kwargs @@ -1579,15 +1581,14 @@ def __init__( class Patch(msrest.serialization.Model): """Patch. - :ivar applied_scope_type: Type of the Applied Scope. Possible values include: "Single", - "Shared". + :ivar applied_scope_type: Type of the Applied Scope. Known values are: "Single", "Shared". :vartype applied_scope_type: str or ~azure.mgmt.reservations.models.AppliedScopeType :ivar applied_scopes: List of the subscriptions that the benefit will be applied. Do not specify if AppliedScopeType is Shared. :vartype applied_scopes: list[str] :ivar instance_flexibility: Turning this on will apply the reservation discount to other VMs in - the same VM size group. Only specify for VirtualMachines reserved resource type. Possible - values include: "On", "Off". + the same VM size group. Only specify for VirtualMachines reserved resource type. Known values + are: "On", "Off". :vartype instance_flexibility: str or ~azure.mgmt.reservations.models.InstanceFlexibility :ivar name: Name of the Reservation. :vartype name: str @@ -1610,24 +1611,23 @@ class Patch(msrest.serialization.Model): def __init__( self, *, - applied_scope_type: Optional[Union[str, "AppliedScopeType"]] = None, + applied_scope_type: Optional[Union[str, "_models.AppliedScopeType"]] = None, applied_scopes: Optional[List[str]] = None, - instance_flexibility: Optional[Union[str, "InstanceFlexibility"]] = None, + instance_flexibility: Optional[Union[str, "_models.InstanceFlexibility"]] = None, name: Optional[str] = None, renew: Optional[bool] = False, - renew_properties: Optional["PatchPropertiesRenewProperties"] = None, + renew_properties: Optional["_models.PatchPropertiesRenewProperties"] = None, **kwargs ): """ - :keyword applied_scope_type: Type of the Applied Scope. Possible values include: "Single", - "Shared". + :keyword applied_scope_type: Type of the Applied Scope. Known values are: "Single", "Shared". :paramtype applied_scope_type: str or ~azure.mgmt.reservations.models.AppliedScopeType :keyword applied_scopes: List of the subscriptions that the benefit will be applied. Do not specify if AppliedScopeType is Shared. :paramtype applied_scopes: list[str] :keyword instance_flexibility: Turning this on will apply the reservation discount to other VMs - in the same VM size group. Only specify for VirtualMachines reserved resource type. Possible - values include: "On", "Off". + in the same VM size group. Only specify for VirtualMachines reserved resource type. Known + values are: "On", "Off". :paramtype instance_flexibility: str or ~azure.mgmt.reservations.models.InstanceFlexibility :keyword name: Name of the Reservation. :paramtype name: str @@ -1660,7 +1660,7 @@ class PatchPropertiesRenewProperties(msrest.serialization.Model): def __init__( self, *, - purchase_properties: Optional["PurchaseRequest"] = None, + purchase_properties: Optional["_models.PurchaseRequest"] = None, **kwargs ): """ @@ -1686,7 +1686,7 @@ class PaymentDetail(msrest.serialization.Model): :ivar billing_account: Shows the Account that is charged for this payment. :vartype billing_account: str :ivar status: Describes whether the payment is completed, failed, cancelled or scheduled in the - future. Possible values include: "Succeeded", "Failed", "Scheduled", "Cancelled". + future. Known values are: "Succeeded", "Failed", "Scheduled", "Cancelled". :vartype status: str or ~azure.mgmt.reservations.models.PaymentStatus :ivar extended_status_info: :vartype extended_status_info: ~azure.mgmt.reservations.models.ExtendedStatusInfo @@ -1707,11 +1707,11 @@ def __init__( *, due_date: Optional[datetime.date] = None, payment_date: Optional[datetime.date] = None, - pricing_currency_total: Optional["Price"] = None, - billing_currency_total: Optional["Price"] = None, + pricing_currency_total: Optional["_models.Price"] = None, + billing_currency_total: Optional["_models.Price"] = None, billing_account: Optional[str] = None, - status: Optional[Union[str, "PaymentStatus"]] = None, - extended_status_info: Optional["ExtendedStatusInfo"] = None, + status: Optional[Union[str, "_models.PaymentStatus"]] = None, + extended_status_info: Optional["_models.ExtendedStatusInfo"] = None, **kwargs ): """ @@ -1727,7 +1727,7 @@ def __init__( :keyword billing_account: Shows the Account that is charged for this payment. :paramtype billing_account: str :keyword status: Describes whether the payment is completed, failed, cancelled or scheduled in - the future. Possible values include: "Succeeded", "Failed", "Scheduled", "Cancelled". + the future. Known values are: "Succeeded", "Failed", "Scheduled", "Cancelled". :paramtype status: str or ~azure.mgmt.reservations.models.PaymentStatus :keyword extended_status_info: :paramtype extended_status_info: ~azure.mgmt.reservations.models.ExtendedStatusInfo @@ -1783,25 +1783,24 @@ class PurchaseRequest(msrest.serialization.Model): :vartype sku: ~azure.mgmt.reservations.models.SkuName :ivar location: The Azure Region where the reserved resource lives. :vartype location: str - :ivar reserved_resource_type: The type of the resource that is being reserved. Possible values - include: "VirtualMachines", "SqlDatabases", "SuseLinux", "CosmosDb", "RedHat", - "SqlDataWarehouse", "VMwareCloudSimple", "RedHatOsa", "Databricks", "AppService", - "ManagedDisk", "BlockBlob", "RedisCache", "AzureDataExplorer", "MySql", "MariaDb", - "PostgreSql", "DedicatedHost", "SapHana", "SqlAzureHybridBenefit", "AVS", "DataFactory", - "NetAppStorage", "AzureFiles", "SqlEdge", "VirtualMachineSoftware". + :ivar reserved_resource_type: The type of the resource that is being reserved. Known values + are: "VirtualMachines", "SqlDatabases", "SuseLinux", "CosmosDb", "RedHat", "SqlDataWarehouse", + "VMwareCloudSimple", "RedHatOsa", "Databricks", "AppService", "ManagedDisk", "BlockBlob", + "RedisCache", "AzureDataExplorer", "MySql", "MariaDb", "PostgreSql", "DedicatedHost", + "SapHana", "SqlAzureHybridBenefit", "AVS", "DataFactory", "NetAppStorage", "AzureFiles", + "SqlEdge", "VirtualMachineSoftware". :vartype reserved_resource_type: str or ~azure.mgmt.reservations.models.ReservedResourceType :ivar billing_scope_id: Subscription that will be charged for purchasing Reservation. :vartype billing_scope_id: str - :ivar term: Represent the term of Reservation. Possible values include: "P1Y", "P3Y", "P5Y". + :ivar term: Represent the term of Reservation. Known values are: "P1Y", "P3Y", "P5Y". :vartype term: str or ~azure.mgmt.reservations.models.ReservationTerm - :ivar billing_plan: Represent the billing plans. Possible values include: "Upfront", "Monthly". + :ivar billing_plan: Represent the billing plans. Known values are: "Upfront", "Monthly". :vartype billing_plan: str or ~azure.mgmt.reservations.models.ReservationBillingPlan :ivar quantity: Quantity of the SKUs that are part of the Reservation. :vartype quantity: int :ivar display_name: Friendly name of the Reservation. :vartype display_name: str - :ivar applied_scope_type: Type of the Applied Scope. Possible values include: "Single", - "Shared". + :ivar applied_scope_type: Type of the Applied Scope. Known values are: "Single", "Shared". :vartype applied_scope_type: str or ~azure.mgmt.reservations.models.AppliedScopeType :ivar applied_scopes: List of the subscriptions that the benefit will be applied. Do not specify if AppliedScopeType is Shared. @@ -1833,18 +1832,18 @@ class PurchaseRequest(msrest.serialization.Model): def __init__( self, *, - sku: Optional["SkuName"] = None, + sku: Optional["_models.SkuName"] = None, location: Optional[str] = None, - reserved_resource_type: Optional[Union[str, "ReservedResourceType"]] = None, + reserved_resource_type: Optional[Union[str, "_models.ReservedResourceType"]] = None, billing_scope_id: Optional[str] = None, - term: Optional[Union[str, "ReservationTerm"]] = None, - billing_plan: Optional[Union[str, "ReservationBillingPlan"]] = None, + term: Optional[Union[str, "_models.ReservationTerm"]] = None, + billing_plan: Optional[Union[str, "_models.ReservationBillingPlan"]] = None, quantity: Optional[int] = None, display_name: Optional[str] = None, - applied_scope_type: Optional[Union[str, "AppliedScopeType"]] = None, + applied_scope_type: Optional[Union[str, "_models.AppliedScopeType"]] = None, applied_scopes: Optional[List[str]] = None, renew: Optional[bool] = False, - reserved_resource_properties: Optional["PurchaseRequestPropertiesReservedResourceProperties"] = None, + reserved_resource_properties: Optional["_models.PurchaseRequestPropertiesReservedResourceProperties"] = None, **kwargs ): """ @@ -1852,26 +1851,24 @@ def __init__( :paramtype sku: ~azure.mgmt.reservations.models.SkuName :keyword location: The Azure Region where the reserved resource lives. :paramtype location: str - :keyword reserved_resource_type: The type of the resource that is being reserved. Possible - values include: "VirtualMachines", "SqlDatabases", "SuseLinux", "CosmosDb", "RedHat", - "SqlDataWarehouse", "VMwareCloudSimple", "RedHatOsa", "Databricks", "AppService", - "ManagedDisk", "BlockBlob", "RedisCache", "AzureDataExplorer", "MySql", "MariaDb", - "PostgreSql", "DedicatedHost", "SapHana", "SqlAzureHybridBenefit", "AVS", "DataFactory", - "NetAppStorage", "AzureFiles", "SqlEdge", "VirtualMachineSoftware". + :keyword reserved_resource_type: The type of the resource that is being reserved. Known values + are: "VirtualMachines", "SqlDatabases", "SuseLinux", "CosmosDb", "RedHat", "SqlDataWarehouse", + "VMwareCloudSimple", "RedHatOsa", "Databricks", "AppService", "ManagedDisk", "BlockBlob", + "RedisCache", "AzureDataExplorer", "MySql", "MariaDb", "PostgreSql", "DedicatedHost", + "SapHana", "SqlAzureHybridBenefit", "AVS", "DataFactory", "NetAppStorage", "AzureFiles", + "SqlEdge", "VirtualMachineSoftware". :paramtype reserved_resource_type: str or ~azure.mgmt.reservations.models.ReservedResourceType :keyword billing_scope_id: Subscription that will be charged for purchasing Reservation. :paramtype billing_scope_id: str - :keyword term: Represent the term of Reservation. Possible values include: "P1Y", "P3Y", "P5Y". + :keyword term: Represent the term of Reservation. Known values are: "P1Y", "P3Y", "P5Y". :paramtype term: str or ~azure.mgmt.reservations.models.ReservationTerm - :keyword billing_plan: Represent the billing plans. Possible values include: "Upfront", - "Monthly". + :keyword billing_plan: Represent the billing plans. Known values are: "Upfront", "Monthly". :paramtype billing_plan: str or ~azure.mgmt.reservations.models.ReservationBillingPlan :keyword quantity: Quantity of the SKUs that are part of the Reservation. :paramtype quantity: int :keyword display_name: Friendly name of the Reservation. :paramtype display_name: str - :keyword applied_scope_type: Type of the Applied Scope. Possible values include: "Single", - "Shared". + :keyword applied_scope_type: Type of the Applied Scope. Known values are: "Single", "Shared". :paramtype applied_scope_type: str or ~azure.mgmt.reservations.models.AppliedScopeType :keyword applied_scopes: List of the subscriptions that the benefit will be applied. Do not specify if AppliedScopeType is Shared. @@ -1903,8 +1900,8 @@ class PurchaseRequestPropertiesReservedResourceProperties(msrest.serialization.M """Properties specific to each reserved resource type. Not required if not applicable. :ivar instance_flexibility: Turning this on will apply the reservation discount to other VMs in - the same VM size group. Only specify for VirtualMachines reserved resource type. Possible - values include: "On", "Off". + the same VM size group. Only specify for VirtualMachines reserved resource type. Known values + are: "On", "Off". :vartype instance_flexibility: str or ~azure.mgmt.reservations.models.InstanceFlexibility """ @@ -1915,13 +1912,13 @@ class PurchaseRequestPropertiesReservedResourceProperties(msrest.serialization.M def __init__( self, *, - instance_flexibility: Optional[Union[str, "InstanceFlexibility"]] = None, + instance_flexibility: Optional[Union[str, "_models.InstanceFlexibility"]] = None, **kwargs ): """ :keyword instance_flexibility: Turning this on will apply the reservation discount to other VMs - in the same VM size group. Only specify for VirtualMachines reserved resource type. Possible - values include: "On", "Off". + in the same VM size group. Only specify for VirtualMachines reserved resource type. Known + values are: "On", "Off". :paramtype instance_flexibility: str or ~azure.mgmt.reservations.models.InstanceFlexibility """ super(PurchaseRequestPropertiesReservedResourceProperties, self).__init__(**kwargs) @@ -1946,7 +1943,7 @@ class QuotaLimits(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["CurrentQuotaLimitBase"]] = None, + value: Optional[List["_models.CurrentQuotaLimitBase"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -1980,7 +1977,7 @@ class QuotaLimitsResponse(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["CurrentQuotaLimit"]] = None, + value: Optional[List["_models.CurrentQuotaLimit"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -2011,8 +2008,8 @@ class QuotaProperties(msrest.serialization.Model): :ivar name: Name of the resource provide by the resource provider. Use this property for quotaRequests resource operations. :vartype name: ~azure.mgmt.reservations.models.ResourceName - :ivar resource_type: The name of the resource type. Possible values include: "standard", - "dedicated", "lowPriority", "shared", "serviceSpecific". + :ivar resource_type: The name of the resource type. Known values are: "standard", "dedicated", + "lowPriority", "shared", "serviceSpecific". :vartype resource_type: str or ~azure.mgmt.reservations.models.ResourceType :ivar quota_period: The time period over which the quota usage values are summarized. For example, P1D (per one day), PT1M (per one minute), and PT1S (per one second). This parameter is @@ -2042,8 +2039,8 @@ def __init__( *, limit: Optional[int] = None, unit: Optional[str] = None, - name: Optional["ResourceName"] = None, - resource_type: Optional[Union[str, "ResourceType"]] = None, + name: Optional["_models.ResourceName"] = None, + resource_type: Optional[Union[str, "_models.ResourceType"]] = None, properties: Optional[Any] = None, **kwargs ): @@ -2056,7 +2053,7 @@ def __init__( :keyword name: Name of the resource provide by the resource provider. Use this property for quotaRequests resource operations. :paramtype name: ~azure.mgmt.reservations.models.ResourceName - :keyword resource_type: The name of the resource type. Possible values include: "standard", + :keyword resource_type: The name of the resource type. Known values are: "standard", "dedicated", "lowPriority", "shared", "serviceSpecific". :paramtype resource_type: str or ~azure.mgmt.reservations.models.ResourceType :keyword properties: Additional properties for the specified resource provider. @@ -2083,8 +2080,8 @@ class QuotaRequestDetails(msrest.serialization.Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar provisioning_state: The quota request status. Possible values include: "Accepted", - "Invalid", "Succeeded", "Failed", "InProgress". + :ivar provisioning_state: The quota request status. Known values are: "Accepted", "Invalid", + "Succeeded", "Failed", "InProgress". :vartype provisioning_state: str or ~azure.mgmt.reservations.models.QuotaRequestState :ivar message: User friendly status message. :vartype message: str @@ -2116,13 +2113,13 @@ class QuotaRequestDetails(msrest.serialization.Model): def __init__( self, *, - provisioning_state: Optional[Union[str, "QuotaRequestState"]] = None, - value: Optional[List["SubRequest"]] = None, + provisioning_state: Optional[Union[str, "_models.QuotaRequestState"]] = None, + value: Optional[List["_models.SubRequest"]] = None, **kwargs ): """ - :keyword provisioning_state: The quota request status. Possible values include: "Accepted", - "Invalid", "Succeeded", "Failed", "InProgress". + :keyword provisioning_state: The quota request status. Known values are: "Accepted", "Invalid", + "Succeeded", "Failed", "InProgress". :paramtype provisioning_state: str or ~azure.mgmt.reservations.models.QuotaRequestState :keyword value: The quotaRequests. :paramtype value: list[~azure.mgmt.reservations.models.SubRequest] @@ -2155,7 +2152,7 @@ class QuotaRequestDetailsList(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["QuotaRequestDetails"]] = None, + value: Optional[List["_models.QuotaRequestDetails"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -2182,8 +2179,8 @@ class QuotaRequestOneResourceSubmitResponse(msrest.serialization.Model): :vartype name: str :ivar type: Type of resource. "Microsoft.Capacity/ServiceLimits". :vartype type: str - :ivar provisioning_state: The quota request status. Possible values include: "Accepted", - "Invalid", "Succeeded", "Failed", "InProgress". + :ivar provisioning_state: The quota request status. Known values are: "Accepted", "Invalid", + "Succeeded", "Failed", "InProgress". :vartype provisioning_state: str or ~azure.mgmt.reservations.models.QuotaRequestState :ivar message: User friendly status message. :vartype message: str @@ -2228,7 +2225,7 @@ class QuotaRequestOneResourceSubmitResponse(msrest.serialization.Model): def __init__( self, *, - properties: Optional["QuotaProperties"] = None, + properties: Optional["_models.QuotaProperties"] = None, **kwargs ): """ @@ -2253,8 +2250,8 @@ class QuotaRequestProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: The quota request status. Possible values include: "Accepted", - "Invalid", "Succeeded", "Failed", "InProgress". + :ivar provisioning_state: The quota request status. Known values are: "Accepted", "Invalid", + "Succeeded", "Failed", "InProgress". :vartype provisioning_state: str or ~azure.mgmt.reservations.models.QuotaRequestState :ivar message: User friendly status message. :vartype message: str @@ -2280,13 +2277,13 @@ class QuotaRequestProperties(msrest.serialization.Model): def __init__( self, *, - provisioning_state: Optional[Union[str, "QuotaRequestState"]] = None, - value: Optional[List["SubRequest"]] = None, + provisioning_state: Optional[Union[str, "_models.QuotaRequestState"]] = None, + value: Optional[List["_models.SubRequest"]] = None, **kwargs ): """ - :keyword provisioning_state: The quota request status. Possible values include: "Accepted", - "Invalid", "Succeeded", "Failed", "InProgress". + :keyword provisioning_state: The quota request status. Known values are: "Accepted", "Invalid", + "Succeeded", "Failed", "InProgress". :paramtype provisioning_state: str or ~azure.mgmt.reservations.models.QuotaRequestState :keyword value: The quotaRequests. :paramtype value: list[~azure.mgmt.reservations.models.SubRequest] @@ -2329,7 +2326,7 @@ class QuotaRequestSubmitResponse(msrest.serialization.Model): def __init__( self, *, - properties: Optional["QuotaRequestProperties"] = None, + properties: Optional["_models.QuotaRequestProperties"] = None, **kwargs ): """ @@ -2354,7 +2351,7 @@ class QuotaRequestSubmitResponse201(msrest.serialization.Model): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar provisioning_state: The details of the quota request status. Possible values include: + :ivar provisioning_state: The details of the quota request status. Known values are: "Accepted", "Invalid", "Succeeded", "Failed", "InProgress". :vartype provisioning_state: str or ~azure.mgmt.reservations.models.QuotaRequestState :ivar message: A user friendly message. @@ -2415,9 +2412,9 @@ class RenewPropertiesResponse(msrest.serialization.Model): def __init__( self, *, - purchase_properties: Optional["PurchaseRequest"] = None, - pricing_currency_total: Optional["RenewPropertiesResponsePricingCurrencyTotal"] = None, - billing_currency_total: Optional["RenewPropertiesResponseBillingCurrencyTotal"] = None, + purchase_properties: Optional["_models.PurchaseRequest"] = None, + pricing_currency_total: Optional["_models.RenewPropertiesResponsePricingCurrencyTotal"] = None, + billing_currency_total: Optional["_models.RenewPropertiesResponseBillingCurrencyTotal"] = None, **kwargs ): """ @@ -2523,7 +2520,7 @@ class ReservationList(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["ReservationResponse"]] = None, + value: Optional[List["_models.ReservationResponse"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -2602,10 +2599,10 @@ class ReservationOrderBillingPlanInformation(msrest.serialization.Model): def __init__( self, *, - pricing_currency_total: Optional["Price"] = None, + pricing_currency_total: Optional["_models.Price"] = None, start_date: Optional[datetime.date] = None, next_payment_due_date: Optional[datetime.date] = None, - transactions: Optional[List["PaymentDetail"]] = None, + transactions: Optional[List["_models.PaymentDetail"]] = None, **kwargs ): """ @@ -2643,7 +2640,7 @@ class ReservationOrderList(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["ReservationOrderResponse"]] = None, + value: Optional[List["_models.ReservationOrderResponse"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -2686,14 +2683,13 @@ class ReservationOrderResponse(msrest.serialization.Model): :vartype benefit_start_time: ~datetime.datetime :ivar original_quantity: Total Quantity of the SKUs purchased in the Reservation. :vartype original_quantity: int - :ivar term: Represent the term of Reservation. Possible values include: "P1Y", "P3Y", "P5Y". + :ivar term: Represent the term of Reservation. Known values are: "P1Y", "P3Y", "P5Y". :vartype term: str or ~azure.mgmt.reservations.models.ReservationTerm - :ivar provisioning_state: Current state of the reservation. Possible values include: - "Creating", "PendingResourceHold", "ConfirmedResourceHold", "PendingBilling", - "ConfirmedBilling", "Created", "Succeeded", "Cancelled", "Expired", "BillingFailed", "Failed", - "Split", "Merged". + :ivar provisioning_state: Current state of the reservation. Known values are: "Creating", + "PendingResourceHold", "ConfirmedResourceHold", "PendingBilling", "ConfirmedBilling", + "Created", "Succeeded", "Cancelled", "Expired", "BillingFailed", "Failed", "Split", "Merged". :vartype provisioning_state: str or ~azure.mgmt.reservations.models.ProvisioningState - :ivar billing_plan: Represent the billing plans. Possible values include: "Upfront", "Monthly". + :ivar billing_plan: Represent the billing plans. Known values are: "Upfront", "Monthly". :vartype billing_plan: str or ~azure.mgmt.reservations.models.ReservationBillingPlan :ivar plan_information: Information describing the type of billing plan for this reservation. :vartype plan_information: @@ -2738,11 +2734,11 @@ def __init__( expiry_date: Optional[datetime.date] = None, benefit_start_time: Optional[datetime.datetime] = None, original_quantity: Optional[int] = None, - term: Optional[Union[str, "ReservationTerm"]] = None, - provisioning_state: Optional[Union[str, "ProvisioningState"]] = None, - billing_plan: Optional[Union[str, "ReservationBillingPlan"]] = None, - plan_information: Optional["ReservationOrderBillingPlanInformation"] = None, - reservations: Optional[List["ReservationResponse"]] = None, + term: Optional[Union[str, "_models.ReservationTerm"]] = None, + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None, + billing_plan: Optional[Union[str, "_models.ReservationBillingPlan"]] = None, + plan_information: Optional["_models.ReservationOrderBillingPlanInformation"] = None, + reservations: Optional[List["_models.ReservationResponse"]] = None, **kwargs ): """ @@ -2761,15 +2757,13 @@ def __init__( :paramtype benefit_start_time: ~datetime.datetime :keyword original_quantity: Total Quantity of the SKUs purchased in the Reservation. :paramtype original_quantity: int - :keyword term: Represent the term of Reservation. Possible values include: "P1Y", "P3Y", "P5Y". + :keyword term: Represent the term of Reservation. Known values are: "P1Y", "P3Y", "P5Y". :paramtype term: str or ~azure.mgmt.reservations.models.ReservationTerm - :keyword provisioning_state: Current state of the reservation. Possible values include: - "Creating", "PendingResourceHold", "ConfirmedResourceHold", "PendingBilling", - "ConfirmedBilling", "Created", "Succeeded", "Cancelled", "Expired", "BillingFailed", "Failed", - "Split", "Merged". + :keyword provisioning_state: Current state of the reservation. Known values are: "Creating", + "PendingResourceHold", "ConfirmedResourceHold", "PendingBilling", "ConfirmedBilling", + "Created", "Succeeded", "Cancelled", "Expired", "BillingFailed", "Failed", "Split", "Merged". :paramtype provisioning_state: str or ~azure.mgmt.reservations.models.ProvisioningState - :keyword billing_plan: Represent the billing plans. Possible values include: "Upfront", - "Monthly". + :keyword billing_plan: Represent the billing plans. Known values are: "Upfront", "Monthly". :paramtype billing_plan: str or ~azure.mgmt.reservations.models.ReservationBillingPlan :keyword plan_information: Information describing the type of billing plan for this reservation. @@ -2847,8 +2841,8 @@ def __init__( *, location: Optional[str] = None, etag: Optional[int] = None, - sku: Optional["SkuName"] = None, - properties: Optional["ReservationsProperties"] = None, + sku: Optional["_models.SkuName"] = None, + properties: Optional["_models.ReservationsProperties"] = None, kind: Optional[str] = None, **kwargs ): @@ -2904,7 +2898,7 @@ class ReservationsListResult(msrest.serialization.Model): def __init__( self, *, - summary: Optional["ReservationSummary"] = None, + summary: Optional["_models.ReservationSummary"] = None, **kwargs ): """ @@ -2962,22 +2956,22 @@ class ReservationsProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar reserved_resource_type: The type of the resource that is being reserved. Possible values - include: "VirtualMachines", "SqlDatabases", "SuseLinux", "CosmosDb", "RedHat", - "SqlDataWarehouse", "VMwareCloudSimple", "RedHatOsa", "Databricks", "AppService", - "ManagedDisk", "BlockBlob", "RedisCache", "AzureDataExplorer", "MySql", "MariaDb", - "PostgreSql", "DedicatedHost", "SapHana", "SqlAzureHybridBenefit", "AVS", "DataFactory", - "NetAppStorage", "AzureFiles", "SqlEdge", "VirtualMachineSoftware". + :ivar reserved_resource_type: The type of the resource that is being reserved. Known values + are: "VirtualMachines", "SqlDatabases", "SuseLinux", "CosmosDb", "RedHat", "SqlDataWarehouse", + "VMwareCloudSimple", "RedHatOsa", "Databricks", "AppService", "ManagedDisk", "BlockBlob", + "RedisCache", "AzureDataExplorer", "MySql", "MariaDb", "PostgreSql", "DedicatedHost", + "SapHana", "SqlAzureHybridBenefit", "AVS", "DataFactory", "NetAppStorage", "AzureFiles", + "SqlEdge", "VirtualMachineSoftware". :vartype reserved_resource_type: str or ~azure.mgmt.reservations.models.ReservedResourceType :ivar instance_flexibility: Allows reservation discount to be applied across skus within the - same Autofit group. Not all skus support instance size flexibility. Possible values include: - "On", "Off". + same Autofit group. Not all skus support instance size flexibility. Known values are: "On", + "Off". :vartype instance_flexibility: str or ~azure.mgmt.reservations.models.InstanceFlexibility :ivar display_name: Friendly name for user to easily identify the reservation. :vartype display_name: str :ivar applied_scopes: The list of applied scopes. :vartype applied_scopes: list[str] - :ivar applied_scope_type: The applied scope type. Possible values include: "Single", "Shared". + :ivar applied_scope_type: The applied scope type. Known values are: "Single", "Shared". :vartype applied_scope_type: str or ~azure.mgmt.reservations.models.AppliedScopeType :ivar archived: Indicates if the reservation is archived. :vartype archived: bool @@ -2985,10 +2979,9 @@ class ReservationsProperties(msrest.serialization.Model): :vartype capabilities: str :ivar quantity: Quantity of the SKUs that are part of the Reservation. :vartype quantity: int - :ivar provisioning_state: Current state of the reservation. Possible values include: - "Creating", "PendingResourceHold", "ConfirmedResourceHold", "PendingBilling", - "ConfirmedBilling", "Created", "Succeeded", "Cancelled", "Expired", "BillingFailed", "Failed", - "Split", "Merged". + :ivar provisioning_state: Current state of the reservation. Known values are: "Creating", + "PendingResourceHold", "ConfirmedResourceHold", "PendingBilling", "ConfirmedBilling", + "Created", "Succeeded", "Cancelled", "Expired", "BillingFailed", "Failed", "Split", "Merged". :vartype provisioning_state: str or ~azure.mgmt.reservations.models.ProvisioningState :ivar effective_date_time: DateTime of the Reservation starting when this version is effective from. @@ -3003,7 +2996,7 @@ class ReservationsProperties(msrest.serialization.Model): :vartype sku_description: str :ivar extended_status_info: The message giving detailed information about the status code. :vartype extended_status_info: ~azure.mgmt.reservations.models.ExtendedStatusInfo - :ivar billing_plan: The billing plan options available for this SKU. Possible values include: + :ivar billing_plan: The billing plan options available for this SKU. Known values are: "Upfront", "Monthly". :vartype billing_plan: str or ~azure.mgmt.reservations.models.ReservationBillingPlan :ivar display_provisioning_state: The provisioning state of the reservation for display, e.g. @@ -3032,7 +3025,7 @@ class ReservationsProperties(msrest.serialization.Model): :vartype renew_destination: str :ivar renew_properties: :vartype renew_properties: ~azure.mgmt.reservations.models.RenewPropertiesResponse - :ivar term: Represent the term of Reservation. Possible values include: "P1Y", "P3Y", "P5Y". + :ivar term: Represent the term of Reservation. Known values are: "P1Y", "P3Y", "P5Y". :vartype term: str or ~azure.mgmt.reservations.models.ReservationTerm :ivar user_friendly_applied_scope_type: The applied scope type of the reservation for display, e.g. Shared. @@ -3088,50 +3081,49 @@ class ReservationsProperties(msrest.serialization.Model): def __init__( self, *, - reserved_resource_type: Optional[Union[str, "ReservedResourceType"]] = None, - instance_flexibility: Optional[Union[str, "InstanceFlexibility"]] = None, + reserved_resource_type: Optional[Union[str, "_models.ReservedResourceType"]] = None, + instance_flexibility: Optional[Union[str, "_models.InstanceFlexibility"]] = None, display_name: Optional[str] = None, applied_scopes: Optional[List[str]] = None, - applied_scope_type: Optional[Union[str, "AppliedScopeType"]] = None, + applied_scope_type: Optional[Union[str, "_models.AppliedScopeType"]] = None, archived: Optional[bool] = None, capabilities: Optional[str] = None, quantity: Optional[int] = None, - provisioning_state: Optional[Union[str, "ProvisioningState"]] = None, + provisioning_state: Optional[Union[str, "_models.ProvisioningState"]] = None, effective_date_time: Optional[datetime.datetime] = None, benefit_start_time: Optional[datetime.datetime] = None, expiry_date: Optional[datetime.date] = None, sku_description: Optional[str] = None, - extended_status_info: Optional["ExtendedStatusInfo"] = None, - billing_plan: Optional[Union[str, "ReservationBillingPlan"]] = None, + extended_status_info: Optional["_models.ExtendedStatusInfo"] = None, + billing_plan: Optional[Union[str, "_models.ReservationBillingPlan"]] = None, purchase_date: Optional[datetime.date] = None, - split_properties: Optional["ReservationSplitProperties"] = None, - merge_properties: Optional["ReservationMergeProperties"] = None, + split_properties: Optional["_models.ReservationSplitProperties"] = None, + merge_properties: Optional["_models.ReservationMergeProperties"] = None, billing_scope_id: Optional[str] = None, renew: Optional[bool] = False, renew_source: Optional[str] = None, renew_destination: Optional[str] = None, - renew_properties: Optional["RenewPropertiesResponse"] = None, - term: Optional[Union[str, "ReservationTerm"]] = None, + renew_properties: Optional["_models.RenewPropertiesResponse"] = None, + term: Optional[Union[str, "_models.ReservationTerm"]] = None, **kwargs ): """ - :keyword reserved_resource_type: The type of the resource that is being reserved. Possible - values include: "VirtualMachines", "SqlDatabases", "SuseLinux", "CosmosDb", "RedHat", - "SqlDataWarehouse", "VMwareCloudSimple", "RedHatOsa", "Databricks", "AppService", - "ManagedDisk", "BlockBlob", "RedisCache", "AzureDataExplorer", "MySql", "MariaDb", - "PostgreSql", "DedicatedHost", "SapHana", "SqlAzureHybridBenefit", "AVS", "DataFactory", - "NetAppStorage", "AzureFiles", "SqlEdge", "VirtualMachineSoftware". + :keyword reserved_resource_type: The type of the resource that is being reserved. Known values + are: "VirtualMachines", "SqlDatabases", "SuseLinux", "CosmosDb", "RedHat", "SqlDataWarehouse", + "VMwareCloudSimple", "RedHatOsa", "Databricks", "AppService", "ManagedDisk", "BlockBlob", + "RedisCache", "AzureDataExplorer", "MySql", "MariaDb", "PostgreSql", "DedicatedHost", + "SapHana", "SqlAzureHybridBenefit", "AVS", "DataFactory", "NetAppStorage", "AzureFiles", + "SqlEdge", "VirtualMachineSoftware". :paramtype reserved_resource_type: str or ~azure.mgmt.reservations.models.ReservedResourceType :keyword instance_flexibility: Allows reservation discount to be applied across skus within the - same Autofit group. Not all skus support instance size flexibility. Possible values include: - "On", "Off". + same Autofit group. Not all skus support instance size flexibility. Known values are: "On", + "Off". :paramtype instance_flexibility: str or ~azure.mgmt.reservations.models.InstanceFlexibility :keyword display_name: Friendly name for user to easily identify the reservation. :paramtype display_name: str :keyword applied_scopes: The list of applied scopes. :paramtype applied_scopes: list[str] - :keyword applied_scope_type: The applied scope type. Possible values include: "Single", - "Shared". + :keyword applied_scope_type: The applied scope type. Known values are: "Single", "Shared". :paramtype applied_scope_type: str or ~azure.mgmt.reservations.models.AppliedScopeType :keyword archived: Indicates if the reservation is archived. :paramtype archived: bool @@ -3139,10 +3131,9 @@ def __init__( :paramtype capabilities: str :keyword quantity: Quantity of the SKUs that are part of the Reservation. :paramtype quantity: int - :keyword provisioning_state: Current state of the reservation. Possible values include: - "Creating", "PendingResourceHold", "ConfirmedResourceHold", "PendingBilling", - "ConfirmedBilling", "Created", "Succeeded", "Cancelled", "Expired", "BillingFailed", "Failed", - "Split", "Merged". + :keyword provisioning_state: Current state of the reservation. Known values are: "Creating", + "PendingResourceHold", "ConfirmedResourceHold", "PendingBilling", "ConfirmedBilling", + "Created", "Succeeded", "Cancelled", "Expired", "BillingFailed", "Failed", "Split", "Merged". :paramtype provisioning_state: str or ~azure.mgmt.reservations.models.ProvisioningState :keyword effective_date_time: DateTime of the Reservation starting when this version is effective from. @@ -3155,8 +3146,8 @@ def __init__( :paramtype sku_description: str :keyword extended_status_info: The message giving detailed information about the status code. :paramtype extended_status_info: ~azure.mgmt.reservations.models.ExtendedStatusInfo - :keyword billing_plan: The billing plan options available for this SKU. Possible values - include: "Upfront", "Monthly". + :keyword billing_plan: The billing plan options available for this SKU. Known values are: + "Upfront", "Monthly". :paramtype billing_plan: str or ~azure.mgmt.reservations.models.ReservationBillingPlan :keyword purchase_date: This is the date when the Reservation was purchased. :paramtype purchase_date: ~datetime.date @@ -3179,7 +3170,7 @@ def __init__( :paramtype renew_destination: str :keyword renew_properties: :paramtype renew_properties: ~azure.mgmt.reservations.models.RenewPropertiesResponse - :keyword term: Represent the term of Reservation. Possible values include: "P1Y", "P3Y", "P5Y". + :keyword term: Represent the term of Reservation. Known values are: "P1Y", "P3Y", "P5Y". :paramtype term: str or ~azure.mgmt.reservations.models.ReservationTerm """ super(ReservationsProperties, self).__init__(**kwargs) @@ -3238,7 +3229,7 @@ class ReservationsPropertiesUtilization(msrest.serialization.Model): def __init__( self, *, - aggregates: Optional[List["ReservationUtilizationAggregates"]] = None, + aggregates: Optional[List["_models.ReservationUtilizationAggregates"]] = None, **kwargs ): """ @@ -3332,8 +3323,8 @@ def __init__( *, reservation_id: Optional[str] = None, quantity: Optional[int] = None, - billing_refund_amount: Optional["Price"] = None, - billing_information: Optional["BillingInformation"] = None, + billing_refund_amount: Optional["_models.Price"] = None, + billing_information: Optional["_models.BillingInformation"] = None, **kwargs ): """ @@ -3370,8 +3361,8 @@ class ReservationToPurchaseCalculateExchange(msrest.serialization.Model): def __init__( self, *, - properties: Optional["PurchaseRequest"] = None, - billing_currency_total: Optional["Price"] = None, + properties: Optional["_models.PurchaseRequest"] = None, + billing_currency_total: Optional["_models.Price"] = None, **kwargs ): """ @@ -3397,8 +3388,8 @@ class ReservationToPurchaseExchange(msrest.serialization.Model): :vartype properties: ~azure.mgmt.reservations.models.PurchaseRequest :ivar billing_currency_total: :vartype billing_currency_total: ~azure.mgmt.reservations.models.Price - :ivar status: Status of the individual operation. Possible values include: "Succeeded", - "Failed", "Cancelled", "Pending". + :ivar status: Status of the individual operation. Known values are: "Succeeded", "Failed", + "Cancelled", "Pending". :vartype status: str or ~azure.mgmt.reservations.models.OperationStatus """ @@ -3415,9 +3406,9 @@ def __init__( *, reservation_order_id: Optional[str] = None, reservation_id: Optional[str] = None, - properties: Optional["PurchaseRequest"] = None, - billing_currency_total: Optional["Price"] = None, - status: Optional[Union[str, "OperationStatus"]] = None, + properties: Optional["_models.PurchaseRequest"] = None, + billing_currency_total: Optional["_models.Price"] = None, + status: Optional[Union[str, "_models.OperationStatus"]] = None, **kwargs ): """ @@ -3430,8 +3421,8 @@ def __init__( :paramtype properties: ~azure.mgmt.reservations.models.PurchaseRequest :keyword billing_currency_total: :paramtype billing_currency_total: ~azure.mgmt.reservations.models.Price - :keyword status: Status of the individual operation. Possible values include: "Succeeded", - "Failed", "Cancelled", "Pending". + :keyword status: Status of the individual operation. Known values are: "Succeeded", "Failed", + "Cancelled", "Pending". :paramtype status: str or ~azure.mgmt.reservations.models.OperationStatus """ super(ReservationToPurchaseExchange, self).__init__(**kwargs) @@ -3485,8 +3476,8 @@ class ReservationToReturnForExchange(msrest.serialization.Model): :vartype billing_refund_amount: ~azure.mgmt.reservations.models.Price :ivar billing_information: billing information. :vartype billing_information: ~azure.mgmt.reservations.models.BillingInformation - :ivar status: Status of the individual operation. Possible values include: "Succeeded", - "Failed", "Cancelled", "Pending". + :ivar status: Status of the individual operation. Known values are: "Succeeded", "Failed", + "Cancelled", "Pending". :vartype status: str or ~azure.mgmt.reservations.models.OperationStatus """ @@ -3503,9 +3494,9 @@ def __init__( *, reservation_id: Optional[str] = None, quantity: Optional[int] = None, - billing_refund_amount: Optional["Price"] = None, - billing_information: Optional["BillingInformation"] = None, - status: Optional[Union[str, "OperationStatus"]] = None, + billing_refund_amount: Optional["_models.Price"] = None, + billing_information: Optional["_models.BillingInformation"] = None, + status: Optional[Union[str, "_models.OperationStatus"]] = None, **kwargs ): """ @@ -3517,8 +3508,8 @@ def __init__( :paramtype billing_refund_amount: ~azure.mgmt.reservations.models.Price :keyword billing_information: billing information. :paramtype billing_information: ~azure.mgmt.reservations.models.BillingInformation - :keyword status: Status of the individual operation. Possible values include: "Succeeded", - "Failed", "Cancelled", "Pending". + :keyword status: Status of the individual operation. Known values are: "Succeeded", "Failed", + "Cancelled", "Pending". :paramtype status: str or ~azure.mgmt.reservations.models.OperationStatus """ super(ReservationToReturnForExchange, self).__init__(**kwargs) @@ -3892,8 +3883,8 @@ class SubRequest(msrest.serialization.Model): :ivar unit: The limit units, such as **count** and **bytes**. Use the unit field provided in the response of the GET quota operation. :vartype unit: str - :ivar provisioning_state: The quota request status. Possible values include: "Accepted", - "Invalid", "Succeeded", "Failed", "InProgress". + :ivar provisioning_state: The quota request status. Known values are: "Accepted", "Invalid", + "Succeeded", "Failed", "InProgress". :vartype provisioning_state: str or ~azure.mgmt.reservations.models.QuotaRequestState :ivar message: User-friendly status message. :vartype message: str @@ -3921,9 +3912,9 @@ class SubRequest(msrest.serialization.Model): def __init__( self, *, - name: Optional["ResourceName"] = None, + name: Optional["_models.ResourceName"] = None, unit: Optional[str] = None, - provisioning_state: Optional[Union[str, "QuotaRequestState"]] = None, + provisioning_state: Optional[Union[str, "_models.QuotaRequestState"]] = None, **kwargs ): """ @@ -3932,8 +3923,8 @@ def __init__( :keyword unit: The limit units, such as **count** and **bytes**. Use the unit field provided in the response of the GET quota operation. :paramtype unit: str - :keyword provisioning_state: The quota request status. Possible values include: "Accepted", - "Invalid", "Succeeded", "Failed", "InProgress". + :keyword provisioning_state: The quota request status. Known values are: "Accepted", "Invalid", + "Succeeded", "Failed", "InProgress". :paramtype provisioning_state: str or ~azure.mgmt.reservations.models.QuotaRequestState """ super(SubRequest, self).__init__(**kwargs) @@ -3960,7 +3951,7 @@ class SubscriptionScopeProperties(msrest.serialization.Model): def __init__( self, *, - scopes: Optional[List["ScopeProperties"]] = None, + scopes: Optional[List["_models.ScopeProperties"]] = None, **kwargs ): """ @@ -3976,15 +3967,15 @@ class SystemData(msrest.serialization.Model): :ivar created_by: The identity that created the resource. :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Possible values include: + :ivar created_by_type: The type of identity that created the resource. Known values are: "User", "Application", "ManagedIdentity", "Key". :vartype created_by_type: str or ~azure.mgmt.reservations.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", "Key". :vartype last_modified_by_type: str or ~azure.mgmt.reservations.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). :vartype last_modified_at: ~datetime.datetime @@ -4003,25 +3994,25 @@ def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", "Key". :paramtype created_by_type: str or ~azure.mgmt.reservations.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.reservations.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime diff --git a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/models/_patch.py b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/operations/__init__.py b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/operations/__init__.py index 5cf631a610fd..eea7bcb5c4c0 100644 --- a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/operations/__init__.py +++ b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/operations/__init__.py @@ -15,6 +15,9 @@ from ._quota_operations import QuotaOperations from ._quota_request_status_operations import QuotaRequestStatusOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'ReservationOperations', 'AzureReservationAPIOperationsMixin', @@ -25,3 +28,5 @@ 'QuotaOperations', 'QuotaRequestStatusOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/operations/_azure_reservation_api_operations.py b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/operations/_azure_reservation_api_operations.py index f5e89d96616a..e0905561c090 100644 --- a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/operations/_azure_reservation_api_operations.py +++ b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/operations/_azure_reservation_api_operations.py @@ -15,10 +15,11 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -35,9 +36,12 @@ def build_get_catalog_request( plan_id: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/catalogs") path_format_arguments = { @@ -47,28 +51,26 @@ def build_get_catalog_request( _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') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if reserved_resource_type is not None: - _query_parameters['reservedResourceType'] = _SERIALIZER.query("reserved_resource_type", reserved_resource_type, 'str') + _params['reservedResourceType'] = _SERIALIZER.query("reserved_resource_type", reserved_resource_type, 'str') if location is not None: - _query_parameters['location'] = _SERIALIZER.query("location", location, 'str') + _params['location'] = _SERIALIZER.query("location", location, 'str') if publisher_id is not None: - _query_parameters['publisherId'] = _SERIALIZER.query("publisher_id", publisher_id, 'str') + _params['publisherId'] = _SERIALIZER.query("publisher_id", publisher_id, 'str') if offer_id is not None: - _query_parameters['offerId'] = _SERIALIZER.query("offer_id", offer_id, 'str') + _params['offerId'] = _SERIALIZER.query("offer_id", offer_id, 'str') if plan_id is not None: - _query_parameters['planId'] = _SERIALIZER.query("plan_id", plan_id, 'str') + _params['planId'] = _SERIALIZER.query("plan_id", plan_id, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -77,9 +79,12 @@ def build_get_applied_reservation_list_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/appliedReservations") path_format_arguments = { @@ -89,22 +94,20 @@ def build_get_applied_reservation_list_request( _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') + _params['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') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class AzureReservationAPIOperationsMixin(object): +class AzureReservationAPIOperationsMixin(MixinABC): @distributed_trace def get_catalog( @@ -116,7 +119,7 @@ def get_catalog( offer_id: Optional[str] = None, plan_id: Optional[str] = None, **kwargs: Any - ) -> List["_models.Catalog"]: + ) -> List[_models.Catalog]: """Get the regions and skus that are available for RI purchase for the specified Azure subscription. @@ -145,13 +148,16 @@ def get_catalog( :rtype: list[~azure.mgmt.reservations.models.Catalog] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.Catalog"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.Catalog]] request = build_get_catalog_request( @@ -163,11 +169,13 @@ def get_catalog( offer_id=offer_id, plan_id=plan_id, template_url=self.get_catalog.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -194,7 +202,7 @@ def get_applied_reservation_list( self, subscription_id: str, **kwargs: Any - ) -> "_models.AppliedReservations": + ) -> _models.AppliedReservations: """Get list of applicable ``Reservation``\ s. Get applicable ``Reservation``\ s that are applied to this subscription or a resource group @@ -210,24 +218,29 @@ def get_applied_reservation_list( :rtype: ~azure.mgmt.reservations.models.AppliedReservations :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AppliedReservations"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.AppliedReservations] request = build_get_applied_reservation_list_request( subscription_id=subscription_id, api_version=api_version, template_url=self.get_applied_reservation_list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs diff --git a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/operations/_calculate_exchange_operations.py b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/operations/_calculate_exchange_operations.py index 81a66d4fd9b5..e7d08bcc3f9b 100644 --- a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/operations/_calculate_exchange_operations.py +++ b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/operations/_calculate_exchange_operations.py @@ -6,7 +6,7 @@ # 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 Any, Callable, Dict, Optional, TypeVar, Union +from typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from .._vendor import _convert_request +from .._vendor import MixinABC, _convert_request T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -30,72 +30,74 @@ def build_post_request_initial( *, - json: JSONType = None, + json: Optional[_models.CalculateExchangeRequest] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Capacity/calculateExchange") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['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') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class CalculateExchangeOperations(object): - """CalculateExchangeOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class CalculateExchangeOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.reservations.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.reservations.AzureReservationAPI`'s + :attr:`calculate_exchange` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _post_initial( self, - body: "_models.CalculateExchangeRequest", + body: _models.CalculateExchangeRequest, **kwargs: Any - ) -> Optional["_models.CalculateExchangeOperationResultResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.CalculateExchangeOperationResultResponse"]] + ) -> Optional[_models.CalculateExchangeOperationResultResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.CalculateExchangeOperationResultResponse]] _json = self._serialize.body(body, 'CalculateExchangeRequest') @@ -104,11 +106,13 @@ def _post_initial( content_type=content_type, json=_json, template_url=self._post_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -141,9 +145,9 @@ def _post_initial( @distributed_trace def begin_post( self, - body: "_models.CalculateExchangeRequest", + body: _models.CalculateExchangeRequest, **kwargs: Any - ) -> LROPoller["_models.CalculateExchangeOperationResultResponse"]: + ) -> LROPoller[_models.CalculateExchangeOperationResultResponse]: """Calculates the refund amounts and price of the new purchases. Calculates price for exchanging ``Reservations`` if there are no policy errors. @@ -167,35 +171,45 @@ def begin_post( ~azure.core.polling.LROPoller[~azure.mgmt.reservations.models.CalculateExchangeOperationResultResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CalculateExchangeOperationResultResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CalculateExchangeOperationResultResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._post_initial( + raw_result = self._post_initial( # type: ignore body=body, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('CalculateExchangeOperationResultResponse', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - 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() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( diff --git a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/operations/_exchange_operations.py b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/operations/_exchange_operations.py index 1e8e42e1673f..c2fb5db0be3e 100644 --- a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/operations/_exchange_operations.py +++ b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/operations/_exchange_operations.py @@ -6,7 +6,7 @@ # 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 Any, Callable, Dict, Optional, TypeVar, Union +from typing import Any, Callable, Dict, Optional, TypeVar, Union, cast from msrest import Serializer @@ -16,13 +16,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from .._vendor import _convert_request +from .._vendor import MixinABC, _convert_request T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -30,72 +30,74 @@ def build_post_request_initial( *, - json: JSONType = None, + json: Optional[_models.ExchangeRequest] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Capacity/exchange") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['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') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class ExchangeOperations(object): - """ExchangeOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ExchangeOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.reservations.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.reservations.AzureReservationAPI`'s + :attr:`exchange` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _post_initial( self, - body: "_models.ExchangeRequest", + body: _models.ExchangeRequest, **kwargs: Any - ) -> Optional["_models.ExchangeOperationResultResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ExchangeOperationResultResponse"]] + ) -> Optional[_models.ExchangeOperationResultResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ExchangeOperationResultResponse]] _json = self._serialize.body(body, 'ExchangeRequest') @@ -104,11 +106,13 @@ def _post_initial( content_type=content_type, json=_json, template_url=self._post_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -141,9 +145,9 @@ def _post_initial( @distributed_trace def begin_post( self, - body: "_models.ExchangeRequest", + body: _models.ExchangeRequest, **kwargs: Any - ) -> LROPoller["_models.ExchangeOperationResultResponse"]: + ) -> LROPoller[_models.ExchangeOperationResultResponse]: """Exchange Reservation(s). Returns one or more ``Reservations`` in exchange for one or more ``Reservation`` purchases. @@ -167,35 +171,45 @@ def begin_post( ~azure.core.polling.LROPoller[~azure.mgmt.reservations.models.ExchangeOperationResultResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ExchangeOperationResultResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ExchangeOperationResultResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._post_initial( + raw_result = self._post_initial( # type: ignore body=body, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('ExchangeOperationResultResponse', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - 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() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( diff --git a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/operations/_operation_operations.py b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/operations/_operation_operations.py index f64915950b4d..53d88bcad34b 100644 --- a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/operations/_operation_operations.py +++ b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/operations/_operation_operations.py @@ -16,10 +16,11 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from .._vendor import _convert_request +from .._vendor import MixinABC, _convert_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -29,55 +30,54 @@ def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Capacity/operations") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['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') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class OperationOperations(object): - """OperationOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class OperationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.reservations.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.reservations.AzureReservationAPI`'s + :attr:`operation` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def list( self, **kwargs: Any - ) -> Iterable["_models.OperationList"]: + ) -> Iterable[_models.OperationList]: """Get operations. List all the operations. @@ -90,31 +90,38 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.reservations.models.OperationList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/operations/_patch.py b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/operations/_quota_operations.py b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/operations/_quota_operations.py index 0b36a323ae2d..1fd68be62ef0 100644 --- a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/operations/_quota_operations.py +++ b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/operations/_quota_operations.py @@ -6,7 +6,7 @@ # 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 Any, Callable, Dict, Iterable, Optional, TypeVar, Union +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -36,9 +36,12 @@ def build_get_request( resource_name: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-25") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-25")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/resourceProviders/{providerId}/locations/{location}/serviceLimits/{resourceName}") # pylint: disable=line-too-long path_format_arguments = { @@ -51,18 +54,16 @@ def build_get_request( _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') + _params['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') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -73,14 +74,17 @@ def build_create_or_update_request_initial( location: str, resource_name: str, *, - json: JSONType = None, + json: Optional[_models.CurrentQuotaLimitBase] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-25") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-25")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/resourceProviders/{providerId}/locations/{location}/serviceLimits/{resourceName}") # pylint: disable=line-too-long path_format_arguments = { @@ -93,20 +97,18 @@ def build_create_or_update_request_initial( _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') + _params['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') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -119,14 +121,17 @@ def build_update_request_initial( location: str, resource_name: str, *, - json: JSONType = None, + json: Optional[_models.CurrentQuotaLimitBase] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-25") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-25")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/resourceProviders/{providerId}/locations/{location}/serviceLimits/{resourceName}") # pylint: disable=line-too-long path_format_arguments = { @@ -139,20 +144,18 @@ def build_update_request_initial( _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') + _params['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') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -165,9 +168,12 @@ def build_list_request( location: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-25") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-25")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/resourceProviders/{providerId}/locations/{location}/serviceLimits") # pylint: disable=line-too-long path_format_arguments = { @@ -179,42 +185,38 @@ def build_list_request( _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') + _params['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') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class QuotaOperations(object): - """QuotaOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class QuotaOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.reservations.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.reservations.AzureReservationAPI`'s + :attr:`quota` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get( @@ -224,7 +226,7 @@ def get( location: str, resource_name: str, **kwargs: Any - ) -> "_models.CurrentQuotaLimitBase": + ) -> _models.CurrentQuotaLimitBase: """Get the current quota (service limit) and usage of a resource. You can use the response from the GET operation to submit quota update request. @@ -245,13 +247,16 @@ def get( :rtype: ~azure.mgmt.reservations.models.CurrentQuotaLimitBase :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CurrentQuotaLimitBase"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-25") # type: str + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-25")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.CurrentQuotaLimitBase] request = build_get_request( @@ -261,11 +266,13 @@ def get( resource_name=resource_name, api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -296,17 +303,20 @@ def _create_or_update_initial( provider_id: str, location: str, resource_name: str, - create_quota_request: "_models.CurrentQuotaLimitBase", + create_quota_request: _models.CurrentQuotaLimitBase, **kwargs: Any - ) -> Union["_models.CurrentQuotaLimitBase", "_models.QuotaRequestSubmitResponse201"]: - cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.CurrentQuotaLimitBase", "_models.QuotaRequestSubmitResponse201"]] + ) -> Union[_models.CurrentQuotaLimitBase, _models.QuotaRequestSubmitResponse201]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-25") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-25")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Union[_models.CurrentQuotaLimitBase, _models.QuotaRequestSubmitResponse201]] _json = self._serialize.body(create_quota_request, 'CurrentQuotaLimitBase') @@ -319,11 +329,13 @@ def _create_or_update_initial( content_type=content_type, json=_json, template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -355,21 +367,16 @@ def begin_create_or_update( provider_id: str, location: str, resource_name: str, - create_quota_request: "_models.CurrentQuotaLimitBase", + create_quota_request: _models.CurrentQuotaLimitBase, **kwargs: Any - ) -> LROPoller[Union["_models.CurrentQuotaLimitBase", "_models.QuotaRequestSubmitResponse201"]]: + ) -> LROPoller[Union[_models.CurrentQuotaLimitBase, _models.QuotaRequestSubmitResponse201]]: """Create or update the quota (service limits) of a resource to the requested value. Steps: - #. - Make the Get request to get the quota information for specific resource. - - #. - To increase the quota, update the limit field in the response from Get request to new value. - - #. - Submit the JSON to the quota request API to update the quota. + #. Make the Get request to get the quota information for specific resource. + #. To increase the quota, update the limit field in the response from Get request to new value. + #. Submit the JSON to the quota request API to update the quota. The Create quota request may be constructed as follows. The PUT operation can be used to update the quota. @@ -401,17 +408,20 @@ def begin_create_or_update( ~azure.mgmt.reservations.models.QuotaRequestSubmitResponse201] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-10-25") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-25")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Union[_models.CurrentQuotaLimitBase, _models.QuotaRequestSubmitResponse201]] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.CurrentQuotaLimitBase", "_models.QuotaRequestSubmitResponse201"]] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore subscription_id=subscription_id, provider_id=provider_id, location=location, @@ -420,20 +430,27 @@ def begin_create_or_update( api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('CurrentQuotaLimitBase', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'original-uri'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'original-uri'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -452,17 +469,20 @@ def _update_initial( provider_id: str, location: str, resource_name: str, - create_quota_request: "_models.CurrentQuotaLimitBase", + create_quota_request: _models.CurrentQuotaLimitBase, **kwargs: Any - ) -> Union["_models.CurrentQuotaLimitBase", "_models.QuotaRequestSubmitResponse201"]: - cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.CurrentQuotaLimitBase", "_models.QuotaRequestSubmitResponse201"]] + ) -> Union[_models.CurrentQuotaLimitBase, _models.QuotaRequestSubmitResponse201]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-25") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-25")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Union[_models.CurrentQuotaLimitBase, _models.QuotaRequestSubmitResponse201]] _json = self._serialize.body(create_quota_request, 'CurrentQuotaLimitBase') @@ -475,11 +495,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -511,15 +533,12 @@ def begin_update( provider_id: str, location: str, resource_name: str, - create_quota_request: "_models.CurrentQuotaLimitBase", + create_quota_request: _models.CurrentQuotaLimitBase, **kwargs: Any - ) -> LROPoller[Union["_models.CurrentQuotaLimitBase", "_models.QuotaRequestSubmitResponse201"]]: + ) -> LROPoller[Union[_models.CurrentQuotaLimitBase, _models.QuotaRequestSubmitResponse201]]: """Update the quota (service limits) of this resource to the requested value. - • To get the quota information for specific resource, send a GET request. - • To increase the quota, update the limit field from the GET response to a new value. - • To update the quota value, submit the JSON response to the quota request API to update the quota. • To update the quota. use the PATCH operation. @@ -552,17 +571,20 @@ def begin_update( ~azure.mgmt.reservations.models.QuotaRequestSubmitResponse201] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-10-25") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-25")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Union[_models.CurrentQuotaLimitBase, _models.QuotaRequestSubmitResponse201]] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.CurrentQuotaLimitBase", "_models.QuotaRequestSubmitResponse201"]] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore subscription_id=subscription_id, provider_id=provider_id, location=location, @@ -571,20 +593,27 @@ def begin_update( api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('CurrentQuotaLimitBase', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'original-uri'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'original-uri'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -604,7 +633,7 @@ def list( provider_id: str, location: str, **kwargs: Any - ) -> Iterable["_models.QuotaLimits"]: + ) -> Iterable[_models.QuotaLimits]: """Gets a list of current quotas (service limits) and usage for all resources. The response from the list quota operation can be leveraged to request quota updates. @@ -622,13 +651,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.reservations.models.QuotaLimits] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-10-25") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-25")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.QuotaLimits] - cls = kwargs.pop('cls', None) # type: ClsType["_models.QuotaLimits"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -638,9 +670,11 @@ def prepare_request(next_link=None): location=location, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -650,9 +684,11 @@ def prepare_request(next_link=None): location=location, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/operations/_quota_request_status_operations.py b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/operations/_quota_request_status_operations.py index d7b364144e6a..b5ce3bd41f9d 100644 --- a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/operations/_quota_request_status_operations.py +++ b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/operations/_quota_request_status_operations.py @@ -16,10 +16,11 @@ from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -33,9 +34,12 @@ def build_get_request( id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-25") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-25")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/resourceProviders/{providerId}/locations/{location}/serviceLimitsRequests/{id}") # pylint: disable=line-too-long path_format_arguments = { @@ -48,18 +52,16 @@ def build_get_request( _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') + _params['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') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -74,9 +76,12 @@ def build_list_request( skiptoken: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2020-10-25") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-25")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/resourceProviders/{providerId}/locations/{location}/serviceLimitsRequests") # pylint: disable=line-too-long path_format_arguments = { @@ -88,48 +93,44 @@ def build_list_request( _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') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if top is not None: - _query_parameters['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) + _params['$top'] = _SERIALIZER.query("top", top, 'int', minimum=1) if skiptoken is not None: - _query_parameters['$skiptoken'] = _SERIALIZER.query("skiptoken", skiptoken, 'str') + _params['$skiptoken'] = _SERIALIZER.query("skiptoken", skiptoken, 'str') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class QuotaRequestStatusOperations(object): - """QuotaRequestStatusOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class QuotaRequestStatusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.reservations.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.reservations.AzureReservationAPI`'s + :attr:`quota_request_status` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def get( @@ -139,7 +140,7 @@ def get( location: str, id: str, **kwargs: Any - ) -> "_models.QuotaRequestDetails": + ) -> _models.QuotaRequestDetails: """For the specified Azure region (location), get the details and status of the quota request by the quota request ID for the resources of the resource provider. The PUT request for the quota (service limit) returns a response with the requestId parameter. @@ -160,13 +161,16 @@ def get( :rtype: ~azure.mgmt.reservations.models.QuotaRequestDetails :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.QuotaRequestDetails"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2020-10-25") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-25")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.QuotaRequestDetails] request = build_get_request( @@ -176,11 +180,13 @@ def get( id=id, api_version=api_version, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -212,7 +218,7 @@ def list( top: Optional[int] = None, skiptoken: Optional[str] = None, **kwargs: Any - ) -> Iterable["_models.QuotaRequestDetailsList"]: + ) -> Iterable[_models.QuotaRequestDetailsList]: """For the specified Azure region (location), subscription, and resource provider, get the history of the quota requests for the past year. To select specific quota requests, use the oData filter. @@ -228,10 +234,8 @@ def list( * - Field - Supported operators - * - - - - |requestSubmitTime | ge, le, eq, gt, lt. Default value is None. + * - requestSubmitTime + - ge, le, eq, gt, lt. Default value is None. :type filter: str :param top: Number of records to return. Default value is None. :type top: int @@ -249,13 +253,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.reservations.models.QuotaRequestDetailsList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2020-10-25") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-10-25")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.QuotaRequestDetailsList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.QuotaRequestDetailsList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -268,9 +275,11 @@ def prepare_request(next_link=None): top=top, skiptoken=skiptoken, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -283,9 +292,11 @@ def prepare_request(next_link=None): top=top, skiptoken=skiptoken, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/operations/_reservation_operations.py b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/operations/_reservation_operations.py index f4f1d8346c62..2754602902c0 100644 --- a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/operations/_reservation_operations.py +++ b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/operations/_reservation_operations.py @@ -6,7 +6,7 @@ # 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 Any, Callable, Dict, Iterable, List, Optional, TypeVar, Union +from typing import Any, Callable, Dict, Iterable, List, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -33,14 +33,17 @@ def build_available_scopes_request_initial( reservation_order_id: str, reservation_id: str, *, - json: JSONType = None, + json: Optional[_models.AvailableScopeRequest] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}/availableScopes") # pylint: disable=line-too-long path_format_arguments = { @@ -51,20 +54,18 @@ def build_available_scopes_request_initial( _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') + _params['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') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -74,14 +75,17 @@ def build_available_scopes_request_initial( def build_split_request_initial( reservation_order_id: str, *, - json: JSONType = None, + json: Optional[_models.SplitRequest] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/split") path_format_arguments = { @@ -91,20 +95,18 @@ def build_split_request_initial( _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') + _params['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') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -114,14 +116,17 @@ def build_split_request_initial( def build_merge_request_initial( reservation_order_id: str, *, - json: JSONType = None, + json: Optional[_models.MergeRequest] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/merge") path_format_arguments = { @@ -131,20 +136,18 @@ def build_merge_request_initial( _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') + _params['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') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -155,9 +158,12 @@ def build_list_request( reservation_order_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations") path_format_arguments = { @@ -167,18 +173,16 @@ def build_list_request( _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') + _params['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') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -190,9 +194,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}") # pylint: disable=line-too-long path_format_arguments = { @@ -203,20 +210,18 @@ def build_get_request( _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') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if expand is not None: - _query_parameters['expand'] = _SERIALIZER.query("expand", expand, 'str') + _params['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') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -225,14 +230,17 @@ def build_update_request_initial( reservation_order_id: str, reservation_id: str, *, - json: JSONType = None, + json: Optional[_models.Patch] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}") # pylint: disable=line-too-long path_format_arguments = { @@ -243,20 +251,18 @@ def build_update_request_initial( _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') + _params['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') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PATCH", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -268,9 +274,12 @@ def build_list_revisions_request( reservation_order_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}/revisions") # pylint: disable=line-too-long path_format_arguments = { @@ -281,18 +290,16 @@ def build_list_revisions_request( _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') + _params['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') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -307,77 +314,79 @@ def build_list_all_request( take: Optional[float] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Capacity/reservations") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') if orderby is not None: - _query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + _params['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') if refresh_summary is not None: - _query_parameters['refreshSummary'] = _SERIALIZER.query("refresh_summary", refresh_summary, 'str') + _params['refreshSummary'] = _SERIALIZER.query("refresh_summary", refresh_summary, 'str') if skiptoken is not None: - _query_parameters['$skiptoken'] = _SERIALIZER.query("skiptoken", skiptoken, 'float') + _params['$skiptoken'] = _SERIALIZER.query("skiptoken", skiptoken, 'float') if selected_state is not None: - _query_parameters['selectedState'] = _SERIALIZER.query("selected_state", selected_state, 'str') + _params['selectedState'] = _SERIALIZER.query("selected_state", selected_state, 'str') if take is not None: - _query_parameters['take'] = _SERIALIZER.query("take", take, 'float') + _params['take'] = _SERIALIZER.query("take", take, 'float') # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) -class ReservationOperations(object): - """ReservationOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ReservationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.reservations.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.reservations.AzureReservationAPI`'s + :attr:`reservation` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + def _available_scopes_initial( self, reservation_order_id: str, reservation_id: str, - body: "_models.AvailableScopeRequest", + body: _models.AvailableScopeRequest, **kwargs: Any - ) -> "_models.AvailableScopeProperties": - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailableScopeProperties"] + ) -> _models.AvailableScopeProperties: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailableScopeProperties] _json = self._serialize.body(body, 'AvailableScopeRequest') @@ -388,11 +397,13 @@ def _available_scopes_initial( content_type=content_type, json=_json, template_url=self._available_scopes_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -418,9 +429,9 @@ def begin_available_scopes( self, reservation_order_id: str, reservation_id: str, - body: "_models.AvailableScopeRequest", + body: _models.AvailableScopeRequest, **kwargs: Any - ) -> LROPoller["_models.AvailableScopeProperties"]: + ) -> LROPoller[_models.AvailableScopeProperties]: """Get Available Scopes for ``Reservation``. Get Available Scopes for ``Reservation``. @@ -447,37 +458,47 @@ def begin_available_scopes( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.reservations.models.AvailableScopeProperties] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.AvailableScopeProperties] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailableScopeProperties"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._available_scopes_initial( + raw_result = self._available_scopes_initial( # type: ignore reservation_order_id=reservation_order_id, reservation_id=reservation_id, body=body, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('AvailableScopeProperties', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -493,17 +514,20 @@ def get_long_running_output(pipeline_response): def _split_initial( self, reservation_order_id: str, - body: "_models.SplitRequest", + body: _models.SplitRequest, **kwargs: Any - ) -> Optional[List["_models.ReservationResponse"]]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional[List["_models.ReservationResponse"]]] + ) -> Optional[List[_models.ReservationResponse]]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[List[_models.ReservationResponse]]] _json = self._serialize.body(body, 'SplitRequest') @@ -513,11 +537,13 @@ def _split_initial( content_type=content_type, json=_json, template_url=self._split_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -544,9 +570,9 @@ def _split_initial( def begin_split( self, reservation_order_id: str, - body: "_models.SplitRequest", + body: _models.SplitRequest, **kwargs: Any - ) -> LROPoller[List["_models.ReservationResponse"]]: + ) -> LROPoller[List[_models.ReservationResponse]]: """Split the ``Reservation``. Split a ``Reservation`` into two ``Reservation``\ s with specified quantity distribution. @@ -572,36 +598,46 @@ def begin_split( ~azure.core.polling.LROPoller[list[~azure.mgmt.reservations.models.ReservationResponse]] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.ReservationResponse]] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.ReservationResponse"]] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._split_initial( + raw_result = self._split_initial( # type: ignore reservation_order_id=reservation_order_id, body=body, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('[ReservationResponse]', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -617,17 +653,20 @@ def get_long_running_output(pipeline_response): def _merge_initial( self, reservation_order_id: str, - body: "_models.MergeRequest", + body: _models.MergeRequest, **kwargs: Any - ) -> Optional[List["_models.ReservationResponse"]]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional[List["_models.ReservationResponse"]]] + ) -> Optional[List[_models.ReservationResponse]]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[List[_models.ReservationResponse]]] _json = self._serialize.body(body, 'MergeRequest') @@ -637,11 +676,13 @@ def _merge_initial( content_type=content_type, json=_json, template_url=self._merge_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -668,9 +709,9 @@ def _merge_initial( def begin_merge( self, reservation_order_id: str, - body: "_models.MergeRequest", + body: _models.MergeRequest, **kwargs: Any - ) -> LROPoller[List["_models.ReservationResponse"]]: + ) -> LROPoller[List[_models.ReservationResponse]]: """Merges two ``Reservation``\ s. Merge the specified ``Reservation``\ s into a new ``Reservation``. The two ``Reservation``\ s @@ -697,36 +738,46 @@ def begin_merge( ~azure.core.polling.LROPoller[list[~azure.mgmt.reservations.models.ReservationResponse]] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[List[_models.ReservationResponse]] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.ReservationResponse"]] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._merge_initial( + raw_result = self._merge_initial( # type: ignore reservation_order_id=reservation_order_id, body=body, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('[ReservationResponse]', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -744,7 +795,7 @@ def list( self, reservation_order_id: str, **kwargs: Any - ) -> Iterable["_models.ReservationList"]: + ) -> Iterable[_models.ReservationList]: """Get ``Reservation``\ s in a given reservation Order. List ``Reservation``\ s within a single ``ReservationOrder``. @@ -759,13 +810,16 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.reservations.models.ReservationList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ReservationList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -773,9 +827,11 @@ def prepare_request(next_link=None): reservation_order_id=reservation_order_id, api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -783,9 +839,11 @@ def prepare_request(next_link=None): reservation_order_id=reservation_order_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -826,7 +884,7 @@ def get( reservation_order_id: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.ReservationResponse": + ) -> _models.ReservationResponse: """Get ``Reservation`` details. Get specific ``Reservation`` details. @@ -845,13 +903,16 @@ def get( :rtype: ~azure.mgmt.reservations.models.ReservationResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ReservationResponse] request = build_get_request( @@ -860,11 +921,13 @@ def get( api_version=api_version, expand=expand, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -890,17 +953,20 @@ def _update_initial( self, reservation_order_id: str, reservation_id: str, - parameters: "_models.Patch", + parameters: _models.Patch, **kwargs: Any - ) -> Optional["_models.ReservationResponse"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ReservationResponse"]] + ) -> Optional[_models.ReservationResponse]: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ReservationResponse]] _json = self._serialize.body(parameters, 'Patch') @@ -911,11 +977,13 @@ def _update_initial( content_type=content_type, json=_json, template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -943,9 +1011,9 @@ def begin_update( self, reservation_order_id: str, reservation_id: str, - parameters: "_models.Patch", + parameters: _models.Patch, **kwargs: Any - ) -> LROPoller["_models.ReservationResponse"]: + ) -> LROPoller[_models.ReservationResponse]: """Updates a ``Reservation``. Updates the applied scopes of the ``Reservation``. @@ -972,37 +1040,47 @@ def begin_update( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.reservations.models.ReservationResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ReservationResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore reservation_order_id=reservation_order_id, reservation_id=reservation_id, parameters=parameters, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('ReservationResponse', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -1021,7 +1099,7 @@ def list_revisions( reservation_id: str, reservation_order_id: str, **kwargs: Any - ) -> Iterable["_models.ReservationList"]: + ) -> Iterable[_models.ReservationList]: """Get ``Reservation`` revisions. List of all the revisions for the ``Reservation``. @@ -1038,13 +1116,16 @@ def list_revisions( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.reservations.models.ReservationList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ReservationList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1053,9 +1134,11 @@ def prepare_request(next_link=None): reservation_order_id=reservation_order_id, api_version=api_version, template_url=self.list_revisions.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1064,9 +1147,11 @@ def prepare_request(next_link=None): reservation_order_id=reservation_order_id, api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1110,7 +1195,7 @@ def list_all( selected_state: Optional[str] = None, take: Optional[float] = None, **kwargs: Any - ) -> Iterable["_models.ReservationsListResult"]: + ) -> Iterable[_models.ReservationsListResult]: """List the reservations and the roll up counts of reservations group by provisioning states that the user has access to in the current tenant. @@ -1142,13 +1227,16 @@ def list_all( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.reservations.models.ReservationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ReservationsListResult] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationsListResult"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: @@ -1161,9 +1249,11 @@ def prepare_request(next_link=None): selected_state=selected_state, take=take, template_url=self.list_all.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: @@ -1176,9 +1266,11 @@ def prepare_request(next_link=None): selected_state=selected_state, take=take, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request diff --git a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/operations/_reservation_order_operations.py b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/operations/_reservation_order_operations.py index 7fbdc80817b7..c72ca91680d3 100644 --- a/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/operations/_reservation_order_operations.py +++ b/sdk/reservations/azure-mgmt-reservations/azure/mgmt/reservations/operations/_reservation_order_operations.py @@ -6,7 +6,7 @@ # 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 Any, Callable, Dict, Iterable, Optional, TypeVar, Union +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast from msrest import Serializer @@ -17,13 +17,13 @@ from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models -from .._vendor import _convert_request, _format_url_section +from .._vendor import MixinABC, _convert_request, _format_url_section T = TypeVar('T') -JSONType = Any ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() @@ -31,32 +31,33 @@ def build_calculate_request( *, - json: JSONType = None, + json: Optional[_models.PurchaseRequest] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Capacity/calculatePrice") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['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') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -66,25 +67,26 @@ def build_calculate_request( def build_list_request( **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Capacity/reservationOrders") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params['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') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -92,14 +94,17 @@ def build_list_request( def build_purchase_request_initial( reservation_order_id: str, *, - json: JSONType = None, + json: Optional[_models.PurchaseRequest] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}") path_format_arguments = { @@ -109,20 +114,18 @@ def build_purchase_request_initial( _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') + _params['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') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="PUT", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs @@ -135,9 +138,12 @@ def build_get_request( expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}") path_format_arguments = { @@ -147,20 +153,18 @@ def build_get_request( _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') + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') if expand is not None: - _query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params['$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') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="GET", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, **kwargs ) @@ -168,14 +172,17 @@ def build_get_request( def build_change_directory_request( reservation_order_id: str, *, - json: JSONType = None, + json: Optional[_models.ChangeDirectoryRequest] = None, content: Any = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") - accept = "application/json" # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/changeDirectory") path_format_arguments = { @@ -185,53 +192,49 @@ def build_change_directory_request( _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') + _params['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') + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') return HttpRequest( method="POST", url=_url, - params=_query_parameters, - headers=_header_parameters, + params=_params, + headers=_headers, json=json, content=content, **kwargs ) -class ReservationOrderOperations(object): - """ReservationOrderOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ReservationOrderOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.reservations.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.reservations.AzureReservationAPI`'s + :attr:`reservation_order` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace def calculate( self, - body: "_models.PurchaseRequest", + body: _models.PurchaseRequest, **kwargs: Any - ) -> "_models.CalculatePriceResponse": + ) -> _models.CalculatePriceResponse: """Calculate price for a ``ReservationOrder``. Calculate price for placing a ``ReservationOrder``. @@ -246,14 +249,17 @@ def calculate( :rtype: ~azure.mgmt.reservations.models.CalculatePriceResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CalculatePriceResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.CalculatePriceResponse] _json = self._serialize.body(body, 'PurchaseRequest') @@ -262,11 +268,13 @@ def calculate( content_type=content_type, json=_json, template_url=self.calculate.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -292,7 +300,7 @@ def calculate( def list( self, **kwargs: Any - ) -> Iterable["_models.ReservationOrderList"]: + ) -> Iterable[_models.ReservationOrderList]: """Get all ``ReservationOrder``\ s. List of all the ``ReservationOrder``\ s that the user has access to in the current tenant. @@ -306,31 +314,38 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.reservations.models.ReservationOrderList] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ReservationOrderList] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationOrderList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) def prepare_request(next_link=None): if not next_link: request = build_list_request( api_version=api_version, template_url=self.list.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: request = build_list_request( api_version=api_version, template_url=next_link, + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -367,17 +382,20 @@ def get_next(next_link=None): def _purchase_initial( self, reservation_order_id: str, - body: "_models.PurchaseRequest", + body: _models.PurchaseRequest, **kwargs: Any - ) -> "_models.ReservationOrderResponse": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationOrderResponse"] + ) -> _models.ReservationOrderResponse: error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ReservationOrderResponse] _json = self._serialize.body(body, 'PurchaseRequest') @@ -387,11 +405,13 @@ def _purchase_initial( content_type=content_type, json=_json, template_url=self._purchase_initial.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -420,9 +440,9 @@ def _purchase_initial( def begin_purchase( self, reservation_order_id: str, - body: "_models.PurchaseRequest", + body: _models.PurchaseRequest, **kwargs: Any - ) -> LROPoller["_models.ReservationOrderResponse"]: + ) -> LROPoller[_models.ReservationOrderResponse]: """Purchase ``ReservationOrder``. Purchase ``ReservationOrder`` and create resource under the specified URI. @@ -447,36 +467,46 @@ def begin_purchase( :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.reservations.models.ReservationOrderResponse] :raises: ~azure.core.exceptions.HttpResponseError """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ReservationOrderResponse] polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationOrderResponse"] lro_delay = kwargs.pop( 'polling_interval', self._config.polling_interval ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._purchase_initial( + raw_result = self._purchase_initial( # type: ignore reservation_order_id=reservation_order_id, body=body, api_version=api_version, content_type=content_type, cls=lambda x,y,z: x, + headers=_headers, + params=_params, **kwargs ) kwargs.pop('error_map', None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response deserialized = self._deserialize('ReservationOrderResponse', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) - elif polling is False: polling_method = NoPolling() + if polling is True: + polling_method = cast(PollingMethod, ARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: PollingMethod + elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller.from_continuation_token( @@ -495,7 +525,7 @@ def get( reservation_order_id: str, expand: Optional[str] = None, **kwargs: Any - ) -> "_models.ReservationOrderResponse": + ) -> _models.ReservationOrderResponse: """Get a specific ``ReservationOrder``. Get the details of the ``ReservationOrder``. @@ -512,13 +542,16 @@ def get( :rtype: ~azure.mgmt.reservations.models.ReservationOrderResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReservationOrderResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ReservationOrderResponse] request = build_get_request( @@ -526,11 +559,13 @@ def get( api_version=api_version, expand=expand, template_url=self.get.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs @@ -556,9 +591,9 @@ def get( def change_directory( self, reservation_order_id: str, - body: "_models.ChangeDirectoryRequest", + body: _models.ChangeDirectoryRequest, **kwargs: Any - ) -> "_models.ChangeDirectoryResponse": + ) -> _models.ChangeDirectoryResponse: """Change directory of ``ReservationOrder``. Change directory (tenant) of ``ReservationOrder`` and all ``Reservation`` under it to specified @@ -576,14 +611,17 @@ def change_directory( :rtype: ~azure.mgmt.reservations.models.ChangeDirectoryResponse :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ChangeDirectoryResponse"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-03-01")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ChangeDirectoryResponse] _json = self._serialize.body(body, 'ChangeDirectoryRequest') @@ -593,11 +631,13 @@ def change_directory( content_type=content_type, json=_json, template_url=self.change_directory.metadata['url'], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access request, stream=False, **kwargs