From d9a17c90ab88c54b389a01a4c50ab288190676b0 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Wed, 14 Jul 2021 04:21:40 +0000 Subject: [PATCH] CodeGen from PR 15189 in Azure/azure-rest-api-specs Merge b9c39a548e9667c2722cfad8adebdd4594826f15 into 92afb2ddb4bf54d2e80ba39ba1d3572de9f5218a --- src/reservations/HISTORY.rst | 8 + src/reservations/README.md | 168 ++ .../azext_reservations/__init__.py | 50 + src/reservations/azext_reservations/action.py | 17 + .../azext_reservations/azext_metadata.json | 4 + src/reservations/azext_reservations/custom.py | 17 + .../azext_reservations/generated/__init__.py | 12 + .../generated/_client_factory.py | 45 + .../azext_reservations/generated/_help.py | 396 +++ .../azext_reservations/generated/_params.py | 262 ++ .../generated/_validators.py | 9 + .../azext_reservations/generated/action.py | 116 + .../azext_reservations/generated/commands.py | 98 + .../azext_reservations/generated/custom.py | 343 +++ .../azext_reservations/manual/__init__.py | 12 + .../azext_reservations/tests/__init__.py | 116 + .../tests/latest/__init__.py | 12 + .../tests/latest/example_steps.py | 357 +++ .../tests/latest/test_quota_scenario.py | 145 + .../vendored_sdks/__init__.py | 12 + .../vendored_sdks/quota/__init__.py | 16 + .../quota/_azure_reservation_api.py | 97 + .../vendored_sdks/quota/_configuration.py | 63 + .../vendored_sdks/quota/aio/__init__.py | 10 + .../quota/aio/_azure_reservation_api.py | 91 + .../vendored_sdks/quota/aio/_configuration.py | 59 + .../quota/aio/operations/__init__.py | 27 + .../_azure_reservation_api_operations.py | 145 + .../_calculate_exchange_operations.py | 156 + .../aio/operations/_exchange_operations.py | 156 + .../aio/operations/_operation_operations.py | 107 + .../quota/aio/operations/_quota_operations.py | 498 +++ .../_quota_request_status_operations.py | 215 ++ .../aio/operations/_reservation_operations.py | 750 +++++ .../_reservation_order_operations.py | 349 +++ .../vendored_sdks/quota/models/__init__.py | 264 ++ .../models/_azure_reservation_api_enums.py | 208 ++ .../vendored_sdks/quota/models/_models.py | 2401 +++++++++++++++ .../vendored_sdks/quota/models/_models_py3.py | 2687 +++++++++++++++++ .../quota/operations/__init__.py | 27 + .../_azure_reservation_api_operations.py | 151 + .../_calculate_exchange_operations.py | 162 + .../quota/operations/_exchange_operations.py | 162 + .../quota/operations/_operation_operations.py | 112 + .../quota/operations/_quota_operations.py | 508 ++++ .../_quota_request_status_operations.py | 221 ++ .../operations/_reservation_operations.py | 765 +++++ .../_reservation_order_operations.py | 358 +++ .../vendored_sdks/quota/py.typed | 1 + src/reservations/report.md | 463 +++ src/reservations/setup.cfg | 1 + src/reservations/setup.py | 58 + 52 files changed, 13487 insertions(+) create mode 100644 src/reservations/HISTORY.rst create mode 100644 src/reservations/README.md create mode 100644 src/reservations/azext_reservations/__init__.py create mode 100644 src/reservations/azext_reservations/action.py create mode 100644 src/reservations/azext_reservations/azext_metadata.json create mode 100644 src/reservations/azext_reservations/custom.py create mode 100644 src/reservations/azext_reservations/generated/__init__.py create mode 100644 src/reservations/azext_reservations/generated/_client_factory.py create mode 100644 src/reservations/azext_reservations/generated/_help.py create mode 100644 src/reservations/azext_reservations/generated/_params.py create mode 100644 src/reservations/azext_reservations/generated/_validators.py create mode 100644 src/reservations/azext_reservations/generated/action.py create mode 100644 src/reservations/azext_reservations/generated/commands.py create mode 100644 src/reservations/azext_reservations/generated/custom.py create mode 100644 src/reservations/azext_reservations/manual/__init__.py create mode 100644 src/reservations/azext_reservations/tests/__init__.py create mode 100644 src/reservations/azext_reservations/tests/latest/__init__.py create mode 100644 src/reservations/azext_reservations/tests/latest/example_steps.py create mode 100644 src/reservations/azext_reservations/tests/latest/test_quota_scenario.py create mode 100644 src/reservations/azext_reservations/vendored_sdks/__init__.py create mode 100644 src/reservations/azext_reservations/vendored_sdks/quota/__init__.py create mode 100644 src/reservations/azext_reservations/vendored_sdks/quota/_azure_reservation_api.py create mode 100644 src/reservations/azext_reservations/vendored_sdks/quota/_configuration.py create mode 100644 src/reservations/azext_reservations/vendored_sdks/quota/aio/__init__.py create mode 100644 src/reservations/azext_reservations/vendored_sdks/quota/aio/_azure_reservation_api.py create mode 100644 src/reservations/azext_reservations/vendored_sdks/quota/aio/_configuration.py create mode 100644 src/reservations/azext_reservations/vendored_sdks/quota/aio/operations/__init__.py create mode 100644 src/reservations/azext_reservations/vendored_sdks/quota/aio/operations/_azure_reservation_api_operations.py create mode 100644 src/reservations/azext_reservations/vendored_sdks/quota/aio/operations/_calculate_exchange_operations.py create mode 100644 src/reservations/azext_reservations/vendored_sdks/quota/aio/operations/_exchange_operations.py create mode 100644 src/reservations/azext_reservations/vendored_sdks/quota/aio/operations/_operation_operations.py create mode 100644 src/reservations/azext_reservations/vendored_sdks/quota/aio/operations/_quota_operations.py create mode 100644 src/reservations/azext_reservations/vendored_sdks/quota/aio/operations/_quota_request_status_operations.py create mode 100644 src/reservations/azext_reservations/vendored_sdks/quota/aio/operations/_reservation_operations.py create mode 100644 src/reservations/azext_reservations/vendored_sdks/quota/aio/operations/_reservation_order_operations.py create mode 100644 src/reservations/azext_reservations/vendored_sdks/quota/models/__init__.py create mode 100644 src/reservations/azext_reservations/vendored_sdks/quota/models/_azure_reservation_api_enums.py create mode 100644 src/reservations/azext_reservations/vendored_sdks/quota/models/_models.py create mode 100644 src/reservations/azext_reservations/vendored_sdks/quota/models/_models_py3.py create mode 100644 src/reservations/azext_reservations/vendored_sdks/quota/operations/__init__.py create mode 100644 src/reservations/azext_reservations/vendored_sdks/quota/operations/_azure_reservation_api_operations.py create mode 100644 src/reservations/azext_reservations/vendored_sdks/quota/operations/_calculate_exchange_operations.py create mode 100644 src/reservations/azext_reservations/vendored_sdks/quota/operations/_exchange_operations.py create mode 100644 src/reservations/azext_reservations/vendored_sdks/quota/operations/_operation_operations.py create mode 100644 src/reservations/azext_reservations/vendored_sdks/quota/operations/_quota_operations.py create mode 100644 src/reservations/azext_reservations/vendored_sdks/quota/operations/_quota_request_status_operations.py create mode 100644 src/reservations/azext_reservations/vendored_sdks/quota/operations/_reservation_operations.py create mode 100644 src/reservations/azext_reservations/vendored_sdks/quota/operations/_reservation_order_operations.py create mode 100644 src/reservations/azext_reservations/vendored_sdks/quota/py.typed create mode 100644 src/reservations/report.md create mode 100644 src/reservations/setup.cfg create mode 100644 src/reservations/setup.py diff --git a/src/reservations/HISTORY.rst b/src/reservations/HISTORY.rst new file mode 100644 index 00000000000..1c139576ba0 --- /dev/null +++ b/src/reservations/HISTORY.rst @@ -0,0 +1,8 @@ +.. :changelog: + +Release History +=============== + +0.1.0 +++++++ +* Initial release. diff --git a/src/reservations/README.md b/src/reservations/README.md new file mode 100644 index 00000000000..1439bcc2e5d --- /dev/null +++ b/src/reservations/README.md @@ -0,0 +1,168 @@ +# Azure CLI quota Extension # +This is the extension for quota + +### How to use ### +Install this extension using the below CLI command +``` +az extension add --name quota +``` + +### Included Features ### +#### quota reservation #### +##### List ##### +``` +az quota reservation list --reservation-order-id "276e7ae4-84d0-4da6-ab4b-d6b94f3557da" +``` +##### Show ##### +``` +az quota reservation show --expand "renewProperties" --reservation-id "6ef59113-3482-40da-8d79-787f823e34bc" \ + --reservation-order-id "276e7ae4-84d0-4da6-ab4b-d6b94f3557da" +``` +##### Update ##### +``` +az quota reservation update --applied-scope-type "Shared" --instance-flexibility "Off" \ + --reservation-id "6ef59113-3482-40da-8d79-787f823e34bc" \ + --reservation-order-id "276e7ae4-84d0-4da6-ab4b-d6b94f3557da" +``` +##### Available-scope ##### +``` +az quota reservation available-scope --properties scopes="/subscriptions/efc7c997-7700-4a74-b731-55aec16c15e9" \ + --reservation-id "356e7ae4-84d0-4da6-ab4b-d6b94f3557da" \ + --reservation-order-id "276e7ae4-84d0-4da6-ab4b-d6b94f3557da" +``` +##### List-revision ##### +``` +az quota reservation list-revision --reservation-id "6ef59113-3482-40da-8d79-787f823e34bc" \ + --reservation-order-id "276e7ae4-84d0-4da6-ab4b-d6b94f3557da" +``` +##### Merge ##### +``` +az quota reservation merge \ + --sources "/providers/Microsoft.Capacity/reservationOrders/c0565a8a-4491-4e77-b07b-5e6d66718e1c/reservations/cea04232-932e-47db-acb5-e29a945ecc73" "/providers/Microsoft.Capacity/reservationOrders/c0565a8a-4491-4e77-b07b-5e6d66718e1c/reservations/5bf54dc7-dacd-4f46-a16b-7b78f4a59799" \ + --reservation-order-id "276e7ae4-84d0-4da6-ab4b-d6b94f3557da" +``` +##### Split ##### +``` +az quota reservation split --quantities 1 2 \ + --reservation-id "/providers/Microsoft.Capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/bcae77cd-3119-4766-919f-b50d36c75c7a" \ + --reservation-order-id "276e7ae4-84d0-4da6-ab4b-d6b94f3557da" +``` +#### quota #### +##### Show-applied-reservation-list ##### +``` +az quota show-applied-reservation-list --subscription-id "23bc208b-083f-4901-ae85-4f98c0c3b4b6" +``` +##### Show-catalog ##### +``` +az quota show-catalog --location "eastus" --reserved-resource-type "VirtualMachines" \ + --subscription-id "23bc208b-083f-4901-ae85-4f98c0c3b4b6" +``` +#### quota reservation-order #### +##### Purchase ##### +``` +az quota reservation-order purchase --location "westus" --applied-scope-type "Shared" --billing-plan "Monthly" \ + --billing-scope-id "/subscriptions/ed3a1871-612d-abcd-a849-c2542a68be83" --display-name "TestReservationOrder" \ + --quantity 1 --renew false --instance-flexibility "On" --reserved-resource-type "VirtualMachines" --term "P1Y" \ + --name "standard_D1" --reservation-order-id "a075419f-44cc-497f-b68a-14ee811d48b9" +``` +##### Show ##### +``` +az quota reservation-order show --reservation-order-id "a075419f-44cc-497f-b68a-14ee811d48b9" +``` +##### Show ##### +``` +az quota reservation-order show --expand "schedule" --reservation-order-id "a075419f-44cc-497f-b68a-14ee811d48b9" +``` +##### Calculate ##### +``` +az quota reservation-order calculate --location "westus" --applied-scope-type "Shared" --billing-plan "Monthly" \ + --billing-scope-id "/subscriptions/ed3a1871-612d-abcd-a849-c2542a68be83" --display-name "TestReservationOrder" \ + --quantity 1 --instance-flexibility "On" --reserved-resource-type "VirtualMachines" --term "P1Y" \ + --name "standard_D1" +``` +##### List ##### +``` +az quota reservation-order list +``` +#### quota operation #### +##### List ##### +``` +az quota operation list +``` +#### quota calculate-exchange #### +##### Post ##### +``` +az quota calculate-exchange post \ + --reservations-to-exchange quantity=1 reservation-id="/providers/microsoft.capacity/reservationOrders/1f14354c-dc12-4c8d-8090-6f295a3a34aa/reservations/c8c926bd-fc5d-4e29-9d43-b68340ac23a6" \ + --reservations-to-purchase location="westus" reserved-resource-type="VirtualMachines" billing-scope-id="/subscriptions/ed3a1871-612d-abcd-a849-c2542a68be83" term="P1Y" billing-plan="Upfront" quantity=1 display-name="testDisplayName" applied-scope-type="Shared" applied-scopes=null renew=false instance-flexibility="On" name="Standard_B1ls" +``` +#### quota exchange #### +##### Post ##### +``` +az quota exchange post --session-id "66e2ac8f-439e-4345-8235-6fef07608081" +``` +#### quota #### +##### Create ##### +``` +az quota create \ + --properties "{\\"name\\":{\\"value\\":\\"standardFSv2Family\\"},\\"limit\\":200,\\"unit\\":\\"Count\\"}" \ + --location "eastus" --provider-id "Microsoft.Compute" --resource-name "standardFSv2Family" \ + --subscription-id "D7EC67B3-7657-4966-BFFC-41EFD36BAAB3" +``` +##### Create ##### +``` +az quota create \ + --properties "{\\"name\\":{\\"value\\":\\"StandardDv2Family\\"},\\"limit\\":200,\\"resourceType\\":\\"dedicated\\",\\"unit\\":\\"Count\\"}" \ + --location "eastus" --provider-id "Microsoft.MachineLearningServices" --resource-name "StandardDv2Family" \ + --subscription-id "D7EC67B3-7657-4966-BFFC-41EFD36BAAB3" +``` +##### Create ##### +``` +az quota create \ + --properties "{\\"name\\":{\\"value\\":\\"TotalLowPriorityCores\\"},\\"limit\\":200,\\"resourceType\\":\\"lowPriority\\",\\"unit\\":\\"Count\\"}" \ + --location "eastus" --provider-id "Microsoft.MachineLearningServices" --resource-name "TotalLowPriorityCores" \ + --subscription-id "D7EC67B3-7657-4966-BFFC-41EFD36BAAB3" +``` +##### List ##### +``` +az quota list --location "eastus" --provider-id "Microsoft.Compute" \ + --subscription-id "00000000-0000-0000-0000-000000000000" +``` +##### List ##### +``` +az quota list --location "eastus" --provider-id "Microsoft.MachineLearningServices" \ + --subscription-id "00000000-0000-0000-0000-000000000000" +``` +##### Show ##### +``` +az quota show --location "eastus" --provider-id "Microsoft.Compute" --resource-name "standardNDSFamily" \ + --subscription-id "00000000-0000-0000-0000-000000000000" +``` +##### Update ##### +``` +az quota update \ + --properties "{\\"name\\":{\\"value\\":\\"standardFSv2Family\\"},\\"limit\\":200,\\"unit\\":\\"Count\\"}" \ + --location "eastus" --provider-id "Microsoft.Compute" --resource-name "standardFSv2Family" \ + --subscription-id "D7EC67B3-7657-4966-BFFC-41EFD36BAAB3" +``` +#### quota quota-request-status #### +##### List ##### +``` +az quota quota-request-status list --location "eastus" --provider-id "Microsoft.Compute" \ + --subscription-id "3f75fdf7-977e-44ad-990d-99f14f0f299f" +``` +##### Show ##### +``` +az quota quota-request-status show --id "2B5C8515-37D8-4B6A-879B-CD641A2CF605" --location "eastus" \ + --provider-id "Microsoft.Compute" --subscription-id "00000000-0000-0000-0000-000000000000" +``` +##### Show ##### +``` +az quota quota-request-status show --id "2B5C8515-37D8-4B6A-879B-CD641A2CF605" --location "eastus" \ + --provider-id "Microsoft.Compute" --subscription-id "00000000-0000-0000-0000-000000000000" +``` +##### Show ##### +``` +az quota quota-request-status show --id "2B5C8515-37D8-4B6A-879B-CD641A2CF605" --location "eastus" \ + --provider-id "Microsoft.Compute" --subscription-id "00000000-0000-0000-0000-000000000000" +``` \ No newline at end of file diff --git a/src/reservations/azext_reservations/__init__.py b/src/reservations/azext_reservations/__init__.py new file mode 100644 index 00000000000..8ef631102c3 --- /dev/null +++ b/src/reservations/azext_reservations/__init__.py @@ -0,0 +1,50 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from azure.cli.core import AzCommandsLoader +from azext_reservations.generated._help import helps # pylint: disable=unused-import +try: + from azext_reservations.manual._help import helps # pylint: disable=reimported +except ImportError: + pass + + +class AzureReservationAPICommandsLoader(AzCommandsLoader): + + def __init__(self, cli_ctx=None): + from azure.cli.core.commands import CliCommandType + from azext_reservations.generated._client_factory import cf_quota_cl + quota_custom = CliCommandType( + operations_tmpl='azext_reservations.custom#{}', + client_factory=cf_quota_cl) + parent = super(AzureReservationAPICommandsLoader, self) + parent.__init__(cli_ctx=cli_ctx, custom_command_type=quota_custom) + + def load_command_table(self, args): + from azext_reservations.generated.commands import load_command_table + load_command_table(self, args) + try: + from azext_reservations.manual.commands import load_command_table as load_command_table_manual + load_command_table_manual(self, args) + except ImportError: + pass + return self.command_table + + def load_arguments(self, command): + from azext_reservations.generated._params import load_arguments + load_arguments(self, command) + try: + from azext_reservations.manual._params import load_arguments as load_arguments_manual + load_arguments_manual(self, command) + except ImportError: + pass + + +COMMAND_LOADER_CLS = AzureReservationAPICommandsLoader diff --git a/src/reservations/azext_reservations/action.py b/src/reservations/azext_reservations/action.py new file mode 100644 index 00000000000..d95d53bf711 --- /dev/null +++ b/src/reservations/azext_reservations/action.py @@ -0,0 +1,17 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=wildcard-import +# pylint: disable=unused-wildcard-import + +from .generated.action import * # noqa: F403 +try: + from .manual.action import * # noqa: F403 +except ImportError: + pass diff --git a/src/reservations/azext_reservations/azext_metadata.json b/src/reservations/azext_reservations/azext_metadata.json new file mode 100644 index 00000000000..cfc30c747c7 --- /dev/null +++ b/src/reservations/azext_reservations/azext_metadata.json @@ -0,0 +1,4 @@ +{ + "azext.isExperimental": true, + "azext.minCliCoreVersion": "2.15.0" +} \ No newline at end of file diff --git a/src/reservations/azext_reservations/custom.py b/src/reservations/azext_reservations/custom.py new file mode 100644 index 00000000000..dbe9d5f9742 --- /dev/null +++ b/src/reservations/azext_reservations/custom.py @@ -0,0 +1,17 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=wildcard-import +# pylint: disable=unused-wildcard-import + +from .generated.custom import * # noqa: F403 +try: + from .manual.custom import * # noqa: F403 +except ImportError: + pass diff --git a/src/reservations/azext_reservations/generated/__init__.py b/src/reservations/azext_reservations/generated/__init__.py new file mode 100644 index 00000000000..c9cfdc73e77 --- /dev/null +++ b/src/reservations/azext_reservations/generated/__init__.py @@ -0,0 +1,12 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/src/reservations/azext_reservations/generated/_client_factory.py b/src/reservations/azext_reservations/generated/_client_factory.py new file mode 100644 index 00000000000..e07bfd8e540 --- /dev/null +++ b/src/reservations/azext_reservations/generated/_client_factory.py @@ -0,0 +1,45 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + + +def cf_quota_cl(cli_ctx, *_): + from azure.cli.core.commands.client_factory import get_mgmt_service_client + from azext_reservations.vendored_sdks.quota import AzureReservationAPI + return get_mgmt_service_client(cli_ctx, + AzureReservationAPI, + subscription_bound=False) + + +def cf_reservation(cli_ctx, *_): + return cf_quota_cl(cli_ctx).reservation + + +def cf_reservation_order(cli_ctx, *_): + return cf_quota_cl(cli_ctx).reservation_order + + +def cf_operation(cli_ctx, *_): + return cf_quota_cl(cli_ctx).operation + + +def cf_calculate_exchange(cli_ctx, *_): + return cf_quota_cl(cli_ctx).calculate_exchange + + +def cf_exchange(cli_ctx, *_): + return cf_quota_cl(cli_ctx).exchange + + +def cf_quota(cli_ctx, *_): + return cf_quota_cl(cli_ctx).quota + + +def cf_quota_request_status(cli_ctx, *_): + return cf_quota_cl(cli_ctx).quota_request_status diff --git a/src/reservations/azext_reservations/generated/_help.py b/src/reservations/azext_reservations/generated/_help.py new file mode 100644 index 00000000000..09dcf2ed6db --- /dev/null +++ b/src/reservations/azext_reservations/generated/_help.py @@ -0,0 +1,396 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=too-many-lines + +from knack.help_files import helps + + +helps['quota reservation'] = """ + type: group + short-summary: Manage reservation with quota +""" + +helps['quota reservation list'] = """ + type: command + short-summary: "List `Reservation`s within a single `ReservationOrder`." + examples: + - name: ReservationList + text: |- + az quota reservation list --reservation-order-id "276e7ae4-84d0-4da6-ab4b-d6b94f3557da" +""" + +helps['quota reservation show'] = """ + type: command + short-summary: "Get specific `Reservation` details." + examples: + - name: GetReservation + text: |- + az quota reservation show --expand "renewProperties" --reservation-id "6ef59113-3482-40da-8d79-787f823e3\ +4bc" --reservation-order-id "276e7ae4-84d0-4da6-ab4b-d6b94f3557da" +""" + +helps['quota reservation update'] = """ + type: command + short-summary: "Updates the applied scopes of the `Reservation`." + examples: + - name: PatchReservation + text: |- + az quota reservation update --applied-scope-type "Shared" --instance-flexibility "Off" --reservation-id \ +"6ef59113-3482-40da-8d79-787f823e34bc" --reservation-order-id "276e7ae4-84d0-4da6-ab4b-d6b94f3557da" +""" + +helps['quota reservation available-scope'] = """ + type: command + short-summary: "Get Available Scopes for `Reservation`." + parameters: + - name: --properties + short-summary: "Available scope request properties" + long-summary: | + Usage: --properties scopes=XX + + examples: + - name: AvailableScopes + text: |- + az quota reservation available-scope --properties scopes="/subscriptions/efc7c997-7700-4a74-b731-55aec16\ +c15e9" --reservation-id "356e7ae4-84d0-4da6-ab4b-d6b94f3557da" --reservation-order-id "276e7ae4-84d0-4da6-ab4b-d6b94f35\ +57da" +""" + +helps['quota reservation list-revision'] = """ + type: command + short-summary: "List of all the revisions for the `Reservation`." + examples: + - name: ReservationRevisions + text: |- + az quota reservation list-revision --reservation-id "6ef59113-3482-40da-8d79-787f823e34bc" \ +--reservation-order-id "276e7ae4-84d0-4da6-ab4b-d6b94f3557da" +""" + +helps['quota reservation merge'] = """ + type: command + short-summary: "Merge the specified `Reservation`s into a new `Reservation`. The two `Reservation`s being merged \ +must have same properties." + examples: + - name: Merge + text: |- + az quota reservation merge --sources "/providers/Microsoft.Capacity/reservationOrders/c0565a8a-4491-4e77\ +-b07b-5e6d66718e1c/reservations/cea04232-932e-47db-acb5-e29a945ecc73" "/providers/Microsoft.Capacity/reservationOrders/\ +c0565a8a-4491-4e77-b07b-5e6d66718e1c/reservations/5bf54dc7-dacd-4f46-a16b-7b78f4a59799" --reservation-order-id \ +"276e7ae4-84d0-4da6-ab4b-d6b94f3557da" +""" + +helps['quota reservation split'] = """ + type: command + short-summary: "Split a `Reservation` into two `Reservation`s with specified quantity distribution." + examples: + - name: Split + text: |- + az quota reservation split --quantities 1 2 --reservation-id "/providers/Microsoft.Capacity/reservationO\ +rders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/bcae77cd-3119-4766-919f-b50d36c75c7a" --reservation-order-id \ +"276e7ae4-84d0-4da6-ab4b-d6b94f3557da" +""" + +helps['quota reservation wait'] = """ + type: command + short-summary: Place the CLI in a waiting state until a condition of the quota reservation is met. + examples: + - name: Pause executing next line of CLI script until the quota reservation is successfully updated. + text: |- + az quota reservation wait --expand "renewProperties" --reservation-id "6ef59113-3482-40da-8d79-787f823e3\ +4bc" --reservation-order-id "276e7ae4-84d0-4da6-ab4b-d6b94f3557da" --updated + - name: Pause executing next line of CLI script until the quota reservation is successfully created. + text: |- + az quota reservation wait --expand "renewProperties" --reservation-id "6ef59113-3482-40da-8d79-787f823e3\ +4bc" --reservation-order-id "276e7ae4-84d0-4da6-ab4b-d6b94f3557da" --created +""" + +helps['quota'] = """ + type: group + short-summary: Manage with quota +""" + +helps['quota show-applied-reservation-list'] = """ + type: command + short-summary: "Get applicable `Reservation`s that are applied to this subscription or a resource group under this \ +subscription." + examples: + - name: AppliedReservationList + text: |- + az quota show-applied-reservation-list --subscription-id "23bc208b-083f-4901-ae85-4f98c0c3b4b6" +""" + +helps['quota show-catalog'] = """ + type: command + short-summary: "Get the regions and skus that are available for RI purchase for the specified Azure subscription." + examples: + - name: Catalog + text: |- + az quota show-catalog --location "eastus" --reserved-resource-type "VirtualMachines" --subscription-id \ +"23bc208b-083f-4901-ae85-4f98c0c3b4b6" +""" + +helps['quota reservation-order'] = """ + type: group + short-summary: Manage reservation order with quota +""" + +helps['quota reservation-order list'] = """ + type: command + short-summary: "List of all the `ReservationOrder`s that the user has access to in the current tenant." + examples: + - name: ReservationOrderList + text: |- + az quota reservation-order list +""" + +helps['quota reservation-order show'] = """ + type: command + short-summary: "Get the details of the `ReservationOrder`." + examples: + - name: GetReservation + text: |- + az quota reservation-order show --reservation-order-id "a075419f-44cc-497f-b68a-14ee811d48b9" + - name: GetReservationWithExpandPayments + text: |- + az quota reservation-order show --expand "schedule" --reservation-order-id \ +"a075419f-44cc-497f-b68a-14ee811d48b9" +""" + +helps['quota reservation-order calculate'] = """ + type: command + short-summary: "Calculate price for placing a `ReservationOrder`." + examples: + - name: Purchase + text: |- + az quota reservation-order calculate --location "westus" --applied-scope-type "Shared" --billing-plan \ +"Monthly" --billing-scope-id "/subscriptions/ed3a1871-612d-abcd-a849-c2542a68be83" --display-name \ +"TestReservationOrder" --quantity 1 --instance-flexibility "On" --reserved-resource-type "VirtualMachines" --term \ +"P1Y" --name "standard_D1" +""" + +helps['quota reservation-order purchase'] = """ + type: command + short-summary: "Purchase `ReservationOrder` and create resource under the specified URI." + examples: + - name: Purchase + text: |- + az quota reservation-order purchase --location "westus" --applied-scope-type "Shared" --billing-plan \ +"Monthly" --billing-scope-id "/subscriptions/ed3a1871-612d-abcd-a849-c2542a68be83" --display-name \ +"TestReservationOrder" --quantity 1 --renew false --instance-flexibility "On" --reserved-resource-type \ +"VirtualMachines" --term "P1Y" --name "standard_D1" --reservation-order-id "a075419f-44cc-497f-b68a-14ee811d48b9" +""" + +helps['quota reservation-order wait'] = """ + type: command + short-summary: Place the CLI in a waiting state until a condition of the quota reservation-order is met. + examples: + - name: Pause executing next line of CLI script until the quota reservation-order is successfully created. + text: |- + az quota reservation-order wait --expand "schedule" --reservation-order-id \ +"a075419f-44cc-497f-b68a-14ee811d48b9" --created +""" + +helps['quota operation'] = """ + type: group + short-summary: Manage operation with quota +""" + +helps['quota operation list'] = """ + type: command + short-summary: "List all the operations." + examples: + - name: GetOperations + text: |- + az quota operation list +""" + +helps['quota calculate-exchange'] = """ + type: group + short-summary: Manage calculate exchange with quota +""" + +helps['quota calculate-exchange post'] = """ + type: command + short-summary: "Calculates price for exchanging `Reservations` if there are no policy errors." + parameters: + - name: --reservations-to-purchase + short-summary: "List of reservations that are being purchased in this exchange." + long-summary: | + Usage: --reservations-to-purchase location=XX reserved-resource-type=XX billing-scope-id=XX term=XX \ +billing-plan=XX quantity=XX display-name=XX applied-scope-type=XX applied-scopes=XX renew=XX instance-flexibility=XX \ +name=XX + + location: The Azure Region where the reserved resource lives. + reserved-resource-type: The type of the resource that is being reserved. + billing-scope-id: Subscription that will be charged for purchasing Reservation + term: Represent the term of Reservation. + billing-plan: Represent the billing plans. + quantity: Quantity of the SKUs that are part of the Reservation. Must be greater than zero. + display-name: Friendly name of the Reservation + applied-scope-type: Type of the Applied Scope. + applied-scopes: List of the subscriptions that the benefit will be applied. Do not specify if \ +AppliedScopeType is Shared. + renew: Setting this to true will automatically purchase a new reservation on the expiration date time. + 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. + + Multiple actions can be specified by using more than one --reservations-to-purchase argument. + - name: --reservations-to-exchange + short-summary: "List of reservations that are being returned in this exchange." + long-summary: | + Usage: --reservations-to-exchange reservation-id=XX quantity=XX + + reservation-id: Fully qualified identifier of the Reservation being returned + quantity: Quantity to be returned. Must be greater than zero. + + Multiple actions can be specified by using more than one --reservations-to-exchange argument. + examples: + - name: CalculateExchange + text: |- + az quota calculate-exchange post --reservations-to-exchange quantity=1 reservation-id="/providers/micros\ +oft.capacity/reservationOrders/1f14354c-dc12-4c8d-8090-6f295a3a34aa/reservations/c8c926bd-fc5d-4e29-9d43-b68340ac23a6" \ +--reservations-to-purchase location="westus" reserved-resource-type="VirtualMachines" billing-scope-id="/subscriptions/\ +ed3a1871-612d-abcd-a849-c2542a68be83" term="P1Y" billing-plan="Upfront" quantity=1 display-name="testDisplayName" \ +applied-scope-type="Shared" applied-scopes=null renew=false instance-flexibility="On" name="Standard_B1ls" +""" + +helps['quota exchange'] = """ + type: group + short-summary: Manage exchange with quota +""" + +helps['quota exchange post'] = """ + type: command + short-summary: "Returns one or more `Reservations` in exchange for one or more `Reservation` purchases." + examples: + - name: Exchange + text: |- + az quota exchange post --session-id "66e2ac8f-439e-4345-8235-6fef07608081" +""" + +helps['quota'] = """ + type: group + short-summary: Manage quota +""" + +helps['quota list'] = """ + type: command + short-summary: "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." + examples: + - name: Quotas_listUsagesForCompute + text: |- + az quota list --location "eastus" --provider-id "Microsoft.Compute" --subscription-id \ +"00000000-0000-0000-0000-000000000000" + - name: Quotas_listUsagesMachineLearningServices + text: |- + az quota list --location "eastus" --provider-id "Microsoft.MachineLearningServices" --subscription-id \ +"00000000-0000-0000-0000-000000000000" +""" + +helps['quota show'] = """ + type: command + short-summary: "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." + examples: + - name: Quotas_Request_ForCompute + text: |- + az quota show --location "eastus" --provider-id "Microsoft.Compute" --resource-name "standardNDSFamily" \ +--subscription-id "00000000-0000-0000-0000-000000000000" +""" + +helps['quota create'] = """ + type: command + short-summary: "Create the quota (service limits) of a resource to the requested value. Steps: 1. Make the Get \ +request to get the quota information for specific resource. 2. To increase the quota, update the limit field in the \ +response from Get request to new value. 3. 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." + examples: + - name: Quotas_Request_PutForCompute + text: |- + az quota create --properties "{\\"name\\":{\\"value\\":\\"standardFSv2Family\\"},\\"limit\\":200,\\"unit\ +\\":\\"Count\\"}" --location "eastus" --provider-id "Microsoft.Compute" --resource-name "standardFSv2Family" \ +--subscription-id "D7EC67B3-7657-4966-BFFC-41EFD36BAAB3" + - name: Quotas_Request_PutForMachineLearningServices_DedicatedResource + text: |- + az quota create --properties "{\\"name\\":{\\"value\\":\\"StandardDv2Family\\"},\\"limit\\":200,\\"resou\ +rceType\\":\\"dedicated\\",\\"unit\\":\\"Count\\"}" --location "eastus" --provider-id "Microsoft.MachineLearningService\ +s" --resource-name "StandardDv2Family" --subscription-id "D7EC67B3-7657-4966-BFFC-41EFD36BAAB3" + - name: Quotas_Request_PutForMachineLearningServices_LowPriorityResource + text: |- + az quota create --properties "{\\"name\\":{\\"value\\":\\"TotalLowPriorityCores\\"},\\"limit\\":200,\\"r\ +esourceType\\":\\"lowPriority\\",\\"unit\\":\\"Count\\"}" --location "eastus" --provider-id \ +"Microsoft.MachineLearningServices" --resource-name "TotalLowPriorityCores" --subscription-id \ +"D7EC67B3-7657-4966-BFFC-41EFD36BAAB3" +""" + +helps['quota update'] = """ + type: command + short-summary: "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." + examples: + - name: Quotas_Request_PatchForCompute + text: |- + az quota update --properties "{\\"name\\":{\\"value\\":\\"standardFSv2Family\\"},\\"limit\\":200,\\"unit\ +\\":\\"Count\\"}" --location "eastus" --provider-id "Microsoft.Compute" --resource-name "standardFSv2Family" \ +--subscription-id "D7EC67B3-7657-4966-BFFC-41EFD36BAAB3" +""" + +helps['quota wait'] = """ + type: command + short-summary: Place the CLI in a waiting state until a condition of the quota is met. + examples: + - name: Pause executing next line of CLI script until the quota is successfully created. + text: |- + az quota wait --location "eastus" --provider-id "Microsoft.Compute" --resource-name "standardNDSFamily" \ +--subscription-id "00000000-0000-0000-0000-000000000000" --created + - name: Pause executing next line of CLI script until the quota is successfully updated. + text: |- + az quota wait --location "eastus" --provider-id "Microsoft.Compute" --resource-name "standardNDSFamily" \ +--subscription-id "00000000-0000-0000-0000-000000000000" --updated +""" + +helps['quota quota-request-status'] = """ + type: group + short-summary: Manage quota request status with quota +""" + +helps['quota quota-request-status list'] = """ + type: command + short-summary: "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." + examples: + - name: QuotaRequestHistory + text: |- + az quota quota-request-status list --location "eastus" --provider-id "Microsoft.Compute" \ +--subscription-id "3f75fdf7-977e-44ad-990d-99f14f0f299f" +""" + +helps['quota quota-request-status show'] = """ + type: command + short-summary: "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." + examples: + - name: QuotaRequestFailed + text: |- + az quota quota-request-status show --id "2B5C8515-37D8-4B6A-879B-CD641A2CF605" --location "eastus" \ +--provider-id "Microsoft.Compute" --subscription-id "00000000-0000-0000-0000-000000000000" + - name: QuotaRequestInProgress + text: |- + az quota quota-request-status show --id "2B5C8515-37D8-4B6A-879B-CD641A2CF605" --location "eastus" \ +--provider-id "Microsoft.Compute" --subscription-id "00000000-0000-0000-0000-000000000000" + - name: QuotaRequestStatus + text: |- + az quota quota-request-status show --id "2B5C8515-37D8-4B6A-879B-CD641A2CF605" --location "eastus" \ +--provider-id "Microsoft.Compute" --subscription-id "00000000-0000-0000-0000-000000000000" +""" diff --git a/src/reservations/azext_reservations/generated/_params.py b/src/reservations/azext_reservations/generated/_params.py new file mode 100644 index 00000000000..dfd8e41b7f6 --- /dev/null +++ b/src/reservations/azext_reservations/generated/_params.py @@ -0,0 +1,262 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=too-many-lines +# pylint: disable=too-many-statements + +from azure.cli.core.commands.parameters import ( + get_three_state_flag, + get_enum_type, + get_location_type +) +from azure.cli.core.commands.validators import validate_file_or_dict +from azext_reservations.action import ( + AddProperties, + AddReservationsToPurchase, + AddReservationsToExchange +) + + +def load_arguments(self, _): + + with self.argument_context('quota reservation list') as c: + c.argument('reservation_order_id', type=str, help='Order Id of the reservation') + + with self.argument_context('quota reservation show') as c: + c.argument('reservation_id', type=str, help='Id of the Reservation Item') + c.argument('reservation_order_id', type=str, help='Order Id of the reservation') + c.argument('expand', type=str, help='Supported value of this query is renewProperties') + + with self.argument_context('quota reservation update') as c: + c.argument('reservation_order_id', type=str, help='Order Id of the reservation') + c.argument('reservation_id', type=str, help='Id of the Reservation Item') + c.argument('applied_scope_type', arg_type=get_enum_type(['Single', 'Shared']), help='Type of the Applied ' + 'Scope.') + c.argument('applied_scopes', nargs='+', help='List of the subscriptions that the benefit will be applied. Do ' + 'not specify if AppliedScopeType is Shared.') + c.argument('instance_flexibility', arg_type=get_enum_type(['On', 'Off']), help='Turning this on will apply the ' + 'reservation discount to other VMs in the same VM size group. Only specify for VirtualMachines ' + 'reserved resource type.') + c.argument('name', type=str, help='Name of the Reservation') + c.argument('renew', arg_type=get_three_state_flag(), help='Setting this to true will automatically purchase a ' + 'new reservation on the expiration date time.') + c.argument('location', arg_type=get_location_type(self.cli_ctx)) + c.argument('reserved_resource_type', arg_type=get_enum_type(['VirtualMachines', 'SqlDatabases', 'SuseLinux', + 'CosmosDb', 'RedHat', 'SqlDataWarehouse', + 'VMwareCloudSimple', 'RedHatOsa', 'Databricks', + 'AppService', 'ManagedDisk', 'BlockBlob', + 'RedisCache', 'AzureDataExplorer', 'MySql', + 'MariaDb', 'PostgreSql', 'DedicatedHost', + 'SapHana', 'SqlAzureHybridBenefit']), help='The ' + 'type of the resource that is being reserved.', arg_group='Renew Properties Purchase Properties ' + 'Properties') + c.argument('billing_scope_id', type=str, help='Subscription that will be charged for purchasing Reservation', + arg_group='Renew Properties Purchase Properties Properties') + c.argument('term', arg_type=get_enum_type(['P1Y', 'P3Y']), help='Represent the term of Reservation.', + arg_group='Renew Properties Purchase Properties Properties') + c.argument('billing_plan', arg_type=get_enum_type(['Upfront', 'Monthly']), help='Represent the billing plans.', + arg_group='Renew Properties Purchase Properties Properties') + c.argument('quantity', type=int, help='Quantity of the SKUs that are part of the Reservation. Must be greater ' + 'than zero.', arg_group='Renew Properties Purchase Properties Properties') + c.argument('display_name', type=str, help='Friendly name of the Reservation', arg_group='Renew Properties ' + 'Purchase Properties Properties') + c.argument('applied_scope_type_applied_scope_type', arg_type=get_enum_type(['Single', 'Shared']), help='Type ' + 'of the Applied Scope.', arg_group='Renew Properties Purchase Properties Properties') + c.argument('applied_scopes1', nargs='+', help='List of the subscriptions that the benefit will be applied. Do ' + 'not specify if AppliedScopeType is Shared.', arg_group='Renew Properties Purchase Properties ' + 'Properties') + c.argument('renew1', arg_type=get_three_state_flag(), help='Setting this to true will automatically purchase a ' + 'new reservation on the expiration date time.', arg_group='Renew Properties Purchase Properties ' + 'Properties') + c.argument('instance_flexibility1', arg_type=get_enum_type(['On', 'Off']), help='Turning this on will apply ' + 'the reservation discount to other VMs in the same VM size group. Only specify for VirtualMachines ' + 'reserved resource type.', arg_group='Renew Properties Purchase Properties Properties Reserved ' + 'Resource Properties') + c.argument('sku_name', type=str, help='', arg_group='Renew Properties Purchase Properties Sku') + + with self.argument_context('quota reservation available-scope') as c: + c.argument('reservation_order_id', type=str, help='Order Id of the reservation') + c.argument('reservation_id', type=str, help='Id of the Reservation Item') + c.argument('properties', action=AddProperties, nargs='+', help='Available scope request properties') + + with self.argument_context('quota reservation list-revision') as c: + c.argument('reservation_id', type=str, help='Id of the Reservation Item') + c.argument('reservation_order_id', type=str, help='Order Id of the reservation') + + with self.argument_context('quota reservation merge') as c: + c.argument('reservation_order_id', type=str, help='Order Id of the reservation') + c.argument('sources', nargs='+', help='Format of the resource id should be /providers/Microsoft.Capacity/reserv' + 'ationOrders/{reservationOrderId}/reservations/{reservationId}') + + with self.argument_context('quota reservation split') as c: + c.argument('reservation_order_id', type=str, help='Order Id of the reservation') + c.argument('quantities', nargs='+', help='List of the quantities in the new reservations to create.') + c.argument('reservation_id', type=str, help='Resource id of the reservation to be split. Format of the ' + 'resource id should be /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservat' + 'ions/{reservationId}') + + with self.argument_context('quota reservation wait') as c: + c.argument('reservation_id', type=str, help='Id of the Reservation Item') + c.argument('reservation_order_id', type=str, help='Order Id of the reservation') + c.argument('expand', type=str, help='Supported value of this query is renewProperties') + + with self.argument_context('quota show-applied-reservation-list') as c: + c.argument('subscription_id', type=str, help='Id of the subscription', id_part='subscription') + + with self.argument_context('quota show-catalog') as c: + c.argument('subscription_id', type=str, help='Id of the subscription', id_part='subscription') + c.argument('reserved_resource_type', type=str, help='The type of the resource for which the skus should be ' + 'provided.') + c.argument('location', arg_type=get_location_type(self.cli_ctx)) + + with self.argument_context('quota reservation-order show') as c: + c.argument('reservation_order_id', type=str, help='Order Id of the reservation') + c.argument('expand', type=str, help='May be used to expand the planInformation.') + + with self.argument_context('quota reservation-order calculate') as c: + c.argument('location', arg_type=get_location_type(self.cli_ctx)) + c.argument('reserved_resource_type', arg_type=get_enum_type(['VirtualMachines', 'SqlDatabases', 'SuseLinux', + 'CosmosDb', 'RedHat', 'SqlDataWarehouse', + 'VMwareCloudSimple', 'RedHatOsa', 'Databricks', + 'AppService', 'ManagedDisk', 'BlockBlob', + 'RedisCache', 'AzureDataExplorer', 'MySql', + 'MariaDb', 'PostgreSql', 'DedicatedHost', + 'SapHana', 'SqlAzureHybridBenefit']), help='The ' + 'type of the resource that is being reserved.') + c.argument('billing_scope_id', type=str, help='Subscription that will be charged for purchasing Reservation') + c.argument('term', arg_type=get_enum_type(['P1Y', 'P3Y']), help='Represent the term of Reservation.') + c.argument('billing_plan', arg_type=get_enum_type(['Upfront', 'Monthly']), + help='Represent the billing plans.') + c.argument('quantity', type=int, help='Quantity of the SKUs that are part of the Reservation. Must be greater ' + 'than zero.') + c.argument('display_name', type=str, help='Friendly name of the Reservation') + c.argument('applied_scope_type', arg_type=get_enum_type(['Single', 'Shared']), help='Type of the Applied ' + 'Scope.') + c.argument('applied_scopes', nargs='+', help='List of the subscriptions that the benefit will be applied. Do ' + 'not specify if AppliedScopeType is Shared.') + c.argument('renew', arg_type=get_three_state_flag(), help='Setting this to true will automatically purchase a ' + 'new reservation on the expiration date time.') + c.argument('instance_flexibility', arg_type=get_enum_type(['On', 'Off']), help='Turning this on will apply the ' + 'reservation discount to other VMs in the same VM size group. Only specify for VirtualMachines ' + 'reserved resource type.', arg_group='Reserved Resource Properties') + c.argument('name', type=str, help='', arg_group='Sku') + + with self.argument_context('quota reservation-order purchase') as c: + c.argument('reservation_order_id', type=str, help='Order Id of the reservation') + c.argument('location', arg_type=get_location_type(self.cli_ctx)) + c.argument('reserved_resource_type', arg_type=get_enum_type(['VirtualMachines', 'SqlDatabases', 'SuseLinux', + 'CosmosDb', 'RedHat', 'SqlDataWarehouse', + 'VMwareCloudSimple', 'RedHatOsa', 'Databricks', + 'AppService', 'ManagedDisk', 'BlockBlob', + 'RedisCache', 'AzureDataExplorer', 'MySql', + 'MariaDb', 'PostgreSql', 'DedicatedHost', + 'SapHana', 'SqlAzureHybridBenefit']), help='The ' + 'type of the resource that is being reserved.') + c.argument('billing_scope_id', type=str, help='Subscription that will be charged for purchasing Reservation') + c.argument('term', arg_type=get_enum_type(['P1Y', 'P3Y']), help='Represent the term of Reservation.') + c.argument('billing_plan', arg_type=get_enum_type(['Upfront', 'Monthly']), + help='Represent the billing plans.') + c.argument('quantity', type=int, help='Quantity of the SKUs that are part of the Reservation. Must be greater ' + 'than zero.') + c.argument('display_name', type=str, help='Friendly name of the Reservation') + c.argument('applied_scope_type', arg_type=get_enum_type(['Single', 'Shared']), help='Type of the Applied ' + 'Scope.') + c.argument('applied_scopes', nargs='+', help='List of the subscriptions that the benefit will be applied. Do ' + 'not specify if AppliedScopeType is Shared.') + c.argument('renew', arg_type=get_three_state_flag(), help='Setting this to true will automatically purchase a ' + 'new reservation on the expiration date time.') + c.argument('instance_flexibility', arg_type=get_enum_type(['On', 'Off']), help='Turning this on will apply the ' + 'reservation discount to other VMs in the same VM size group. Only specify for VirtualMachines ' + 'reserved resource type.', arg_group='Reserved Resource Properties') + c.argument('name', type=str, help='', arg_group='Sku') + + with self.argument_context('quota reservation-order wait') as c: + c.argument('reservation_order_id', type=str, help='Order Id of the reservation') + c.argument('expand', type=str, help='May be used to expand the planInformation.') + + with self.argument_context('quota calculate-exchange post') as c: + c.argument('reservations_to_purchase', action=AddReservationsToPurchase, nargs='+', help='List of reservations ' + 'that are being purchased in this exchange.') + c.argument('reservations_to_exchange', action=AddReservationsToExchange, nargs='+', help='List of reservations ' + 'that are being returned in this exchange.') + + with self.argument_context('quota exchange post') as c: + c.argument('session_id', type=str, help='SessionId that was returned by CalculateExchange API.') + + with self.argument_context('quota list') as c: + c.argument('subscription_id', type=str, help='Azure subscription ID.') + c.argument('provider_id', type=str, help='Azure resource provider ID.') + c.argument('location', arg_type=get_location_type(self.cli_ctx)) + + with self.argument_context('quota show') as c: + c.argument('subscription_id', type=str, help='Azure subscription ID.', id_part='subscription') + c.argument('provider_id', type=str, help='Azure resource provider ID.', id_part='name') + c.argument('location', arg_type=get_location_type(self.cli_ctx), id_part='child_name_1') + c.argument('resource_name', type=str, help='The resource name for a resource provider, such as SKU name for ' + 'Microsoft.Compute, Sku or TotalLowPriorityCores for Microsoft.MachineLearningServices', + id_part='child_name_2') + + with self.argument_context('quota create') as c: + c.argument('subscription_id', type=str, help='Azure subscription ID.') + c.argument('provider_id', type=str, help='Azure resource provider ID.') + c.argument('location', arg_type=get_location_type(self.cli_ctx)) + c.argument('resource_name', type=str, help='The resource name for a resource provider, such as SKU name for ' + 'Microsoft.Compute, Sku or TotalLowPriorityCores for Microsoft.MachineLearningServices') + c.argument('limit', type=int, help='Quota properties.') + c.argument('unit', type=str, help=' The limit units, such as **count** and **bytes**. Use the unit field ' + 'provided in the response of the GET quota operation.') + c.argument('resource_type', arg_type=get_enum_type(['standard', 'dedicated', 'lowPriority', 'shared', + 'serviceSpecific']), + help='The name of the resource type.') + c.argument('properties', type=validate_file_or_dict, help='Additional properties for the specified resource ' + 'provider. Expected value: json-string/@json-file.') + c.argument('value', type=str, help='Resource name.', arg_group='Name') + + with self.argument_context('quota update') as c: + c.argument('subscription_id', type=str, help='Azure subscription ID.', id_part='subscription') + c.argument('provider_id', type=str, help='Azure resource provider ID.', id_part='name') + c.argument('location', arg_type=get_location_type(self.cli_ctx), id_part='child_name_1') + c.argument('resource_name', type=str, help='The resource name for a resource provider, such as SKU name for ' + 'Microsoft.Compute, Sku or TotalLowPriorityCores for Microsoft.MachineLearningServices', + id_part='child_name_2') + c.argument('limit', type=int, help='Quota properties.') + c.argument('unit', type=str, help=' The limit units, such as **count** and **bytes**. Use the unit field ' + 'provided in the response of the GET quota operation.') + c.argument('resource_type', arg_type=get_enum_type(['standard', 'dedicated', 'lowPriority', 'shared', + 'serviceSpecific']), + help='The name of the resource type.') + c.argument('properties', type=validate_file_or_dict, help='Additional properties for the specified resource ' + 'provider. Expected value: json-string/@json-file.') + c.argument('value', type=str, help='Resource name.', arg_group='Name') + + with self.argument_context('quota wait') as c: + c.argument('subscription_id', type=str, help='Azure subscription ID.', id_part='subscription') + c.argument('provider_id', type=str, help='Azure resource provider ID.', id_part='name') + c.argument('location', arg_type=get_location_type(self.cli_ctx), id_part='child_name_1') + c.argument('resource_name', type=str, help='The resource name for a resource provider, such as SKU name for ' + 'Microsoft.Compute, Sku or TotalLowPriorityCores for Microsoft.MachineLearningServices', + id_part='child_name_2') + + with self.argument_context('quota quota-request-status list') as c: + c.argument('subscription_id', type=str, help='Azure subscription ID.') + c.argument('provider_id', type=str, help='Azure resource provider ID.') + c.argument('location', arg_type=get_location_type(self.cli_ctx)) + c.argument('filter_', options_list=['--filter'], type=str, help='| Field | Supported ' + 'operators |---------------------|------------------------ |requestSubmitTime | ge, le, eq, gt, ' + 'lt') + c.argument('top', type=int, help='Number of records to return.') + c.argument('skiptoken', type=str, help='Skiptoken is only used if a previous operation returned a partial ' + 'result. If a previous response contains a nextLink element, the value of the nextLink element ' + 'includes a skiptoken parameter that specifies a starting point to use for subsequent calls.') + + with self.argument_context('quota quota-request-status show') as c: + c.argument('subscription_id', type=str, help='Azure subscription ID.', id_part='subscription') + c.argument('provider_id', type=str, help='Azure resource provider ID.', id_part='name') + c.argument('location', arg_type=get_location_type(self.cli_ctx), id_part='child_name_1') + c.argument('id_', options_list=['--id'], type=str, help='Quota Request ID.', id_part='child_name_2') diff --git a/src/reservations/azext_reservations/generated/_validators.py b/src/reservations/azext_reservations/generated/_validators.py new file mode 100644 index 00000000000..b33a44c1ebf --- /dev/null +++ b/src/reservations/azext_reservations/generated/_validators.py @@ -0,0 +1,9 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- diff --git a/src/reservations/azext_reservations/generated/action.py b/src/reservations/azext_reservations/generated/action.py new file mode 100644 index 00000000000..b8e1a9627a0 --- /dev/null +++ b/src/reservations/azext_reservations/generated/action.py @@ -0,0 +1,116 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=protected-access + +import argparse +from collections import defaultdict +from knack.util import CLIError + + +class AddProperties(argparse.Action): + def __call__(self, parser, namespace, values, option_string=None): + action = self.get_action(values, option_string) + namespace.properties = action + + def get_action(self, values, option_string): # pylint: disable=no-self-use + try: + properties = defaultdict(list) + for (k, v) in (x.split('=', 1) for x in values): + properties[k].append(v) + properties = dict(properties) + except ValueError: + raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string)) + d = {} + for k in properties: + kl = k.lower() + v = properties[k] + if kl == 'scopes': + d['scopes'] = v + else: + raise CLIError('Unsupported Key {} is provided for parameter properties. All possible keys are: scopes' + .format(k)) + return d + + +class AddReservationsToPurchase(argparse._AppendAction): + def __call__(self, parser, namespace, values, option_string=None): + action = self.get_action(values, option_string) + super(AddReservationsToPurchase, self).__call__(parser, namespace, action, option_string) + + def get_action(self, values, option_string): # pylint: disable=no-self-use + try: + properties = defaultdict(list) + for (k, v) in (x.split('=', 1) for x in values): + properties[k].append(v) + properties = dict(properties) + except ValueError: + raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string)) + d = {} + d['renew'] = False + for k in properties: + kl = k.lower() + v = properties[k] + if kl == 'location': + d['location'] = v[0] + elif kl == 'reserved-resource-type': + d['reserved_resource_type'] = v[0] + elif kl == 'billing-scope-id': + d['billing_scope_id'] = v[0] + elif kl == 'term': + d['term'] = v[0] + elif kl == 'billing-plan': + d['billing_plan'] = v[0] + elif kl == 'quantity': + d['quantity'] = v[0] + elif kl == 'display-name': + d['display_name'] = v[0] + elif kl == 'applied-scope-type': + d['applied_scope_type'] = v[0] + elif kl == 'applied-scopes': + d['applied_scopes'] = v + elif kl == 'renew': + d['renew'] = v[0] + elif kl == 'instance-flexibility': + d['instance_flexibility'] = v[0] + elif kl == 'name': + d['name'] = v[0] + else: + raise CLIError('Unsupported Key {} is provided for parameter reservations_to_purchase. All possible ' + 'keys are: location, reserved-resource-type, billing-scope-id, term, billing-plan, ' + 'quantity, display-name, applied-scope-type, applied-scopes, renew, ' + 'instance-flexibility, name'.format(k)) + return d + + +class AddReservationsToExchange(argparse._AppendAction): + def __call__(self, parser, namespace, values, option_string=None): + action = self.get_action(values, option_string) + super(AddReservationsToExchange, self).__call__(parser, namespace, action, option_string) + + def get_action(self, values, option_string): # pylint: disable=no-self-use + try: + properties = defaultdict(list) + for (k, v) in (x.split('=', 1) for x in values): + properties[k].append(v) + properties = dict(properties) + except ValueError: + raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string)) + d = {} + for k in properties: + kl = k.lower() + v = properties[k] + if kl == 'reservation-id': + d['reservation_id'] = v[0] + elif kl == 'quantity': + d['quantity'] = v[0] + else: + raise CLIError('Unsupported Key {} is provided for parameter reservations_to_exchange. All possible ' + 'keys are: reservation-id, quantity'.format(k)) + return d diff --git a/src/reservations/azext_reservations/generated/commands.py b/src/reservations/azext_reservations/generated/commands.py new file mode 100644 index 00000000000..fe6bbca9536 --- /dev/null +++ b/src/reservations/azext_reservations/generated/commands.py @@ -0,0 +1,98 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=too-many-statements +# pylint: disable=too-many-locals + +from azure.cli.core.commands import CliCommandType + + +def load_command_table(self, _): + + from azext_reservations.generated._client_factory import cf_reservation + quota_reservation = CliCommandType( + operations_tmpl='azext_reservations.vendored_sdks.quota.operations._reservation_operations#ReservationOperation' + 's.{}', + client_factory=cf_reservation) + with self.command_group('quota reservation', quota_reservation, client_factory=cf_reservation) as g: + g.custom_command('list', 'quota_reservation_list') + g.custom_show_command('show', 'quota_reservation_show') + g.custom_command('update', 'quota_reservation_update', supports_no_wait=True) + g.custom_command('available-scope', 'quota_reservation_available_scope', supports_no_wait=True) + g.custom_command('list-revision', 'quota_reservation_list_revision') + g.custom_command('merge', 'quota_reservation_merge', supports_no_wait=True) + g.custom_command('split', 'quota_reservation_split', supports_no_wait=True) + g.custom_wait_command('wait', 'quota_reservation_show') + + from azext_reservations.generated._client_factory import cf_quota + quota_ = CliCommandType( + operations_tmpl='azext_reservations.vendored_sdks.quota.operations._model_operations#AzureReservationAPIOperati' + 'onsMixin.{}', + client_factory=cf_quota) + with self.command_group('quota', quota_, client_factory=cf_quota, is_experimental=True) as g: + g.custom_command('show-applied-reservation-list', 'quota_show_applied_reservation_list') + g.custom_command('show-catalog', 'quota_show_catalog') + + from azext_reservations.generated._client_factory import cf_reservation_order + quota_reservation_order = CliCommandType( + operations_tmpl='azext_reservations.vendored_sdks.quota.operations._reservation_order_operations#ReservationOrd' + 'erOperations.{}', + client_factory=cf_reservation_order) + with self.command_group('quota reservation-order', quota_reservation_order, + client_factory=cf_reservation_order) as g: + g.custom_command('list', 'quota_reservation_order_list') + g.custom_show_command('show', 'quota_reservation_order_show') + g.custom_command('calculate', 'quota_reservation_order_calculate') + g.custom_command('purchase', 'quota_reservation_order_purchase', supports_no_wait=True) + g.custom_wait_command('wait', 'quota_reservation_order_show') + + from azext_reservations.generated._client_factory import cf_operation + quota_operation = CliCommandType( + operations_tmpl='azext_reservations.vendored_sdks.quota.operations._operation_operations#OperationOperations.{}' + '', + client_factory=cf_operation) + with self.command_group('quota operation', quota_operation, client_factory=cf_operation) as g: + g.custom_command('list', 'quota_operation_list') + + from azext_reservations.generated._client_factory import cf_calculate_exchange + quota_calculate_exchange = CliCommandType( + operations_tmpl='azext_reservations.vendored_sdks.quota.operations._calculate_exchange_operations#CalculateExch' + 'angeOperations.{}', + client_factory=cf_calculate_exchange) + with self.command_group('quota calculate-exchange', quota_calculate_exchange, + client_factory=cf_calculate_exchange) as g: + g.custom_command('post', 'quota_calculate_exchange_post') + + from azext_reservations.generated._client_factory import cf_exchange + quota_exchange = CliCommandType( + operations_tmpl='azext_reservations.vendored_sdks.quota.operations._exchange_operations#ExchangeOperations.{}', + client_factory=cf_exchange) + with self.command_group('quota exchange', quota_exchange, client_factory=cf_exchange) as g: + g.custom_command('post', 'quota_exchange_post') + + from azext_reservations.generated._client_factory import cf_quota + quota_quota = CliCommandType( + operations_tmpl='azext_reservations.vendored_sdks.quota.operations._quota_operations#QuotaOperations.{}', + client_factory=cf_quota) + with self.command_group('quota', quota_quota, client_factory=cf_quota, is_experimental=True) as g: + g.custom_command('list', 'quota_list') + g.custom_show_command('show', 'quota_show') + g.custom_command('create', 'quota_create', supports_no_wait=True) + g.custom_command('update', 'quota_update', supports_no_wait=True) + g.custom_wait_command('wait', 'quota_show') + + from azext_reservations.generated._client_factory import cf_quota_request_status + quota_quota_request_status = CliCommandType( + operations_tmpl='azext_reservations.vendored_sdks.quota.operations._quota_request_status_operations#QuotaReques' + 'tStatusOperations.{}', + client_factory=cf_quota_request_status) + with self.command_group('quota quota-request-status', quota_quota_request_status, + client_factory=cf_quota_request_status) as g: + g.custom_command('list', 'quota_quota_request_status_list') + g.custom_show_command('show', 'quota_quota_request_status_show') diff --git a/src/reservations/azext_reservations/generated/custom.py b/src/reservations/azext_reservations/generated/custom.py new file mode 100644 index 00000000000..975b7e467a4 --- /dev/null +++ b/src/reservations/azext_reservations/generated/custom.py @@ -0,0 +1,343 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=too-many-lines + +from azure.cli.core.util import sdk_no_wait + + +def quota_reservation_list(client, + reservation_order_id): + return client.list(reservation_order_id=reservation_order_id) + + +def quota_reservation_show(client, + reservation_id, + reservation_order_id, + expand=None): + return client.get(reservation_id=reservation_id, + reservation_order_id=reservation_order_id, + expand=expand) + + +def quota_reservation_update(client, + reservation_order_id, + reservation_id, + applied_scope_type=None, + applied_scopes=None, + instance_flexibility=None, + name=None, + renew=None, + location=None, + reserved_resource_type=None, + billing_scope_id=None, + term=None, + billing_plan=None, + quantity=None, + display_name=None, + applied_scope_type_applied_scope_type=None, + applied_scopes1=None, + renew1=None, + instance_flexibility1=None, + sku_name=None, + no_wait=False): + if renew is None: + renew = False + if renew1 is None: + renew1 = False + parameters = {} + parameters['applied_scope_type'] = applied_scope_type + parameters['applied_scopes'] = applied_scopes + parameters['instance_flexibility'] = instance_flexibility + parameters['name'] = name + parameters['renew'] = False if renew is None else renew + parameters['purchase_properties'] = {} + parameters['purchase_properties']['location'] = location + parameters['purchase_properties']['reserved_resource_type'] = reserved_resource_type + parameters['purchase_properties']['billing_scope_id'] = billing_scope_id + parameters['purchase_properties']['term'] = term + parameters['purchase_properties']['billing_plan'] = billing_plan + parameters['purchase_properties']['quantity'] = quantity + parameters['purchase_properties']['display_name'] = display_name + parameters['purchase_properties']['applied_scope_type'] = applied_scope_type_applied_scope_type + parameters['purchase_properties']['applied_scopes'] = applied_scopes1 + parameters['purchase_properties']['renew'] = False if renew1 is None else renew1 + parameters = sku_name + return sdk_no_wait(no_wait, + client.begin_update, + reservation_order_id=reservation_order_id, + reservation_id=reservation_id, + parameters=parameters) + + +def quota_reservation_available_scope(client, + reservation_order_id, + reservation_id, + properties=None, + no_wait=False): + body = {} + body['properties'] = properties + return sdk_no_wait(no_wait, + client.begin_available_scopes, + reservation_order_id=reservation_order_id, + reservation_id=reservation_id, + body=body) + + +def quota_reservation_list_revision(client, + reservation_id, + reservation_order_id): + return client.list_revisions(reservation_id=reservation_id, + reservation_order_id=reservation_order_id) + + +def quota_reservation_merge(client, + reservation_order_id, + sources=None, + no_wait=False): + body = {} + body['sources'] = sources + return sdk_no_wait(no_wait, + client.begin_merge, + reservation_order_id=reservation_order_id, + body=body) + + +def quota_reservation_split(client, + reservation_order_id, + quantities=None, + reservation_id=None, + no_wait=False): + body = {} + body['quantities'] = quantities + body['reservation_id'] = reservation_id + return sdk_no_wait(no_wait, + client.begin_split, + reservation_order_id=reservation_order_id, + body=body) + + +def quota_show_applied_reservation_list(client, + subscription_id): + return client.get_applied_reservation_list(subscription_id=subscription_id) + + +def quota_show_catalog(client, + subscription_id, + reserved_resource_type, + location=None): + return client.get_catalog(subscription_id=subscription_id, + reserved_resource_type=reserved_resource_type, + location=location) + + +def quota_reservation_order_list(client): + return client.list() + + +def quota_reservation_order_show(client, + reservation_order_id, + expand=None): + return client.get(reservation_order_id=reservation_order_id, + expand=expand) + + +def quota_reservation_order_calculate(client, + location=None, + reserved_resource_type=None, + billing_scope_id=None, + term=None, + billing_plan=None, + quantity=None, + display_name=None, + applied_scope_type=None, + applied_scopes=None, + renew=None, + instance_flexibility=None, + name=None): + if renew is None: + renew = False + body = {} + body['location'] = location + body['reserved_resource_type'] = reserved_resource_type + body['billing_scope_id'] = billing_scope_id + body['term'] = term + body['billing_plan'] = billing_plan + body['quantity'] = quantity + body['display_name'] = display_name + body['applied_scope_type'] = applied_scope_type + body['applied_scopes'] = applied_scopes + body['renew'] = False if renew is None else renew + body['reserved_resource_properties'] = {} + body['reserved_resource_properties']['instance_flexibility'] = instance_flexibility + body['sku'] = {} + body['sku']['name'] = name + return client.calculate(body=body) + + +def quota_reservation_order_purchase(client, + reservation_order_id, + location=None, + reserved_resource_type=None, + billing_scope_id=None, + term=None, + billing_plan=None, + quantity=None, + display_name=None, + applied_scope_type=None, + applied_scopes=None, + renew=None, + instance_flexibility=None, + name=None, + no_wait=False): + if renew is None: + renew = False + body = {} + body['location'] = location + body['reserved_resource_type'] = reserved_resource_type + body['billing_scope_id'] = billing_scope_id + body['term'] = term + body['billing_plan'] = billing_plan + body['quantity'] = quantity + body['display_name'] = display_name + body['applied_scope_type'] = applied_scope_type + body['applied_scopes'] = applied_scopes + body['renew'] = False if renew is None else renew + body['reserved_resource_properties'] = {} + body['reserved_resource_properties']['instance_flexibility'] = instance_flexibility + body['sku'] = {} + body['sku']['name'] = name + return sdk_no_wait(no_wait, + client.begin_purchase, + reservation_order_id=reservation_order_id, + body=body) + + +def quota_operation_list(client): + return client.list() + + +def quota_calculate_exchange_post(client, + reservations_to_purchase=None, + reservations_to_exchange=None): + body = {} + body['properties'] = {} + body['properties']['reservations_to_purchase'] = reservations_to_purchase + body['properties']['reservations_to_exchange'] = reservations_to_exchange + return client.begin_post(body=body) + + +def quota_exchange_post(client, + session_id=None): + body = {} + body['properties'] = {} + body['properties']['session_id'] = session_id + return client.begin_post(body=body) + + +def quota_list(client, + subscription_id, + provider_id, + location): + return client.list(subscription_id=subscription_id, + provider_id=provider_id, + location=location) + + +def quota_show(client, + subscription_id, + provider_id, + location, + resource_name): + return client.get(subscription_id=subscription_id, + provider_id=provider_id, + location=location, + resource_name=resource_name) + + +def quota_create(client, + subscription_id, + provider_id, + location, + resource_name, + limit=None, + unit=None, + resource_type=None, + properties=None, + value=None, + no_wait=False): + create_quota_request = {} + create_quota_request['properties'] = {} + create_quota_request['properties']['limit'] = limit + create_quota_request['properties']['unit'] = unit + create_quota_request['properties']['resource_type'] = resource_type + create_quota_request['properties']['properties'] = properties + create_quota_request['properties']['name'] = {} + create_quota_request['properties']['name']['value'] = value + return sdk_no_wait(no_wait, + client.begin_create_or_update, + subscription_id=subscription_id, + provider_id=provider_id, + location=location, + resource_name=resource_name, + create_quota_request=create_quota_request) + + +def quota_update(client, + subscription_id, + provider_id, + location, + resource_name, + limit=None, + unit=None, + resource_type=None, + properties=None, + value=None, + no_wait=False): + create_quota_request = {} + create_quota_request['properties'] = {} + create_quota_request['properties']['limit'] = limit + create_quota_request['properties']['unit'] = unit + create_quota_request['properties']['resource_type'] = resource_type + create_quota_request['properties']['properties'] = properties + create_quota_request['properties']['name'] = {} + create_quota_request['properties']['name']['value'] = value + return sdk_no_wait(no_wait, + client.begin_update, + subscription_id=subscription_id, + provider_id=provider_id, + location=location, + resource_name=resource_name, + create_quota_request=create_quota_request) + + +def quota_quota_request_status_list(client, + subscription_id, + provider_id, + location, + filter_=None, + top=None, + skiptoken=None): + return client.list(subscription_id=subscription_id, + provider_id=provider_id, + location=location, + filter=filter_, + top=top, + skiptoken=skiptoken) + + +def quota_quota_request_status_show(client, + subscription_id, + provider_id, + location, + id_): + return client.get(subscription_id=subscription_id, + provider_id=provider_id, + location=location, + id=id_) diff --git a/src/reservations/azext_reservations/manual/__init__.py b/src/reservations/azext_reservations/manual/__init__.py new file mode 100644 index 00000000000..c9cfdc73e77 --- /dev/null +++ b/src/reservations/azext_reservations/manual/__init__.py @@ -0,0 +1,12 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/src/reservations/azext_reservations/tests/__init__.py b/src/reservations/azext_reservations/tests/__init__.py new file mode 100644 index 00000000000..70488e93851 --- /dev/null +++ b/src/reservations/azext_reservations/tests/__init__.py @@ -0,0 +1,116 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- +import inspect +import logging +import os +import sys +import traceback +import datetime as dt + +from azure.core.exceptions import AzureError +from azure.cli.testsdk.exceptions import CliTestError, CliExecutionError, JMESPathCheckAssertionError + + +logger = logging.getLogger('azure.cli.testsdk') +logger.addHandler(logging.StreamHandler()) +__path__ = __import__('pkgutil').extend_path(__path__, __name__) +exceptions = [] +test_map = dict() +SUCCESSED = "successed" +FAILED = "failed" + + +def try_manual(func): + def import_manual_function(origin_func): + from importlib import import_module + decorated_path = inspect.getfile(origin_func).lower() + module_path = __path__[0].lower() + if not decorated_path.startswith(module_path): + raise Exception("Decorator can only be used in submodules!") + manual_path = os.path.join( + decorated_path[module_path.rfind(os.path.sep) + 1:]) + manual_file_path, manual_file_name = os.path.split(manual_path) + module_name, _ = os.path.splitext(manual_file_name) + manual_module = "..manual." + \ + ".".join(manual_file_path.split(os.path.sep) + [module_name, ]) + return getattr(import_module(manual_module, package=__name__), origin_func.__name__) + + def get_func_to_call(): + func_to_call = func + try: + func_to_call = import_manual_function(func) + logger.info("Found manual override for %s(...)", func.__name__) + except (ImportError, AttributeError): + pass + return func_to_call + + def wrapper(*args, **kwargs): + func_to_call = get_func_to_call() + logger.info("running %s()...", func.__name__) + try: + test_map[func.__name__] = dict() + test_map[func.__name__]["result"] = SUCCESSED + test_map[func.__name__]["error_message"] = "" + test_map[func.__name__]["error_stack"] = "" + test_map[func.__name__]["error_normalized"] = "" + test_map[func.__name__]["start_dt"] = dt.datetime.utcnow() + ret = func_to_call(*args, **kwargs) + except (AssertionError, AzureError, CliTestError, CliExecutionError, SystemExit, + JMESPathCheckAssertionError) as e: + use_exception_cache = os.getenv("TEST_EXCEPTION_CACHE") + if use_exception_cache is None or use_exception_cache.lower() != "true": + raise + test_map[func.__name__]["end_dt"] = dt.datetime.utcnow() + test_map[func.__name__]["result"] = FAILED + test_map[func.__name__]["error_message"] = str(e).replace("\r\n", " ").replace("\n", " ")[:500] + test_map[func.__name__]["error_stack"] = traceback.format_exc().replace( + "\r\n", " ").replace("\n", " ")[:500] + logger.info("--------------------------------------") + logger.info("step exception: %s", e) + logger.error("--------------------------------------") + logger.error("step exception in %s: %s", func.__name__, e) + logger.info(traceback.format_exc()) + exceptions.append((func.__name__, sys.exc_info())) + else: + test_map[func.__name__]["end_dt"] = dt.datetime.utcnow() + return ret + + if inspect.isclass(func): + return get_func_to_call() + return wrapper + + +def calc_coverage(filename): + filename = filename.split(".")[0] + coverage_name = filename + "_coverage.md" + with open(coverage_name, "w") as f: + f.write("|Scenario|Result|ErrorMessage|ErrorStack|ErrorNormalized|StartDt|EndDt|\n") + total = len(test_map) + covered = 0 + for k, v in test_map.items(): + if not k.startswith("step_"): + total -= 1 + continue + if v["result"] == SUCCESSED: + covered += 1 + f.write("|{step_name}|{result}|{error_message}|{error_stack}|{error_normalized}|{start_dt}|" + "{end_dt}|\n".format(step_name=k, **v)) + f.write("Coverage: {}/{}\n".format(covered, total)) + print("Create coverage\n", file=sys.stderr) + + +def raise_if(): + if exceptions: + if len(exceptions) <= 1: + raise exceptions[0][1][1] + message = "{}\nFollowed with exceptions in other steps:\n".format(str(exceptions[0][1][1])) + message += "\n".join(["{}: {}".format(h[0], h[1][1]) for h in exceptions[1:]]) + raise exceptions[0][1][0](message).with_traceback(exceptions[0][1][2]) diff --git a/src/reservations/azext_reservations/tests/latest/__init__.py b/src/reservations/azext_reservations/tests/latest/__init__.py new file mode 100644 index 00000000000..c9cfdc73e77 --- /dev/null +++ b/src/reservations/azext_reservations/tests/latest/__init__.py @@ -0,0 +1,12 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/src/reservations/azext_reservations/tests/latest/example_steps.py b/src/reservations/azext_reservations/tests/latest/example_steps.py new file mode 100644 index 00000000000..d339b47d450 --- /dev/null +++ b/src/reservations/azext_reservations/tests/latest/example_steps.py @@ -0,0 +1,357 @@ +# -------------------------------------------------------------------------- +# 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 .. import try_manual + + +# EXAMPLE: /CalculateExchange/post/CalculateExchange +@try_manual +def step_calculate_exchange_post(test, checks=None): + if checks is None: + checks = [] + test.cmd('az quota calculate-exchange post ' + '--reservations-to-exchange quantity=1 reservation-id="/providers/microsoft.capacity/reservationOrders/1f1' + '4354c-dc12-4c8d-8090-6f295a3a34aa/reservations/c8c926bd-fc5d-4e29-9d43-b68340ac23a6" ' + '--reservations-to-purchase location="westus" reserved-resource-type="VirtualMachines" ' + 'billing-scope-id="/subscriptions/{subscription_id}" term="P1Y" billing-plan="Upfront" quantity=1 ' + 'display-name="testDisplayName" applied-scope-type="Shared" applied-scopes=null renew=false ' + 'instance-flexibility="On" name="Standard_B1ls"', + checks=checks) + + +# EXAMPLE: /Exchange/post/Exchange +@try_manual +def step_exchange_post(test, checks=None): + if checks is None: + checks = [] + test.cmd('az quota exchange post ' + '--session-id "66e2ac8f-439e-4345-8235-6fef07608081"', + checks=checks) + + +# EXAMPLE: /Operation/get/GetOperations +@try_manual +def step_operation_list(test, checks=None): + if checks is None: + checks = [] + test.cmd('az quota operation list', + checks=checks) + + +# EXAMPLE: /quota/get/AppliedReservationList +@try_manual +def step_show_applied_reservation_list(test, checks=None): + if checks is None: + checks = [] + test.cmd('az quota show-applied-reservation-list ' + '--subscription-id "23bc208b-083f-4901-ae85-4f98c0c3b4b6"', + checks=checks) + + +# EXAMPLE: /quota/get/Catalog +@try_manual +def step_show_catalog(test, checks=None): + if checks is None: + checks = [] + test.cmd('az quota show-catalog ' + '--location "eastus" ' + '--reserved-resource-type "VirtualMachines" ' + '--subscription-id "23bc208b-083f-4901-ae85-4f98c0c3b4b6"', + checks=checks) + + +# EXAMPLE: /Quota/put/Quotas_Request_PutForCompute +@try_manual +def step_create(test, checks=None): + if checks is None: + checks = [] + test.cmd('az quota create ' + '--properties "{{\\"name\\":{{\\"value\\":\\"standardFSv2Family\\"}},\\"limit\\":200,\\"unit\\":\\"Count\\' + '"}}" ' + '--location "eastus" ' + '--provider-id "Microsoft.Compute" ' + '--resource-name "standardFSv2Family" ' + '--subscription-id "D7EC67B3-7657-4966-BFFC-41EFD36BAAB3"', + checks=checks) + + +# EXAMPLE: /Quota/put/Quotas_Request_PutForMachineLearningServices_DedicatedResource +@try_manual +def step_create2(test, checks=None): + if checks is None: + checks = [] + test.cmd('az quota create ' + '--properties "{{\\"name\\":{{\\"value\\":\\"StandardDv2Family\\"}},\\"limit\\":200,\\"resourceType\\":\\"' + 'dedicated\\",\\"unit\\":\\"Count\\"}}" ' + '--location "eastus" ' + '--provider-id "Microsoft.MachineLearningServices" ' + '--resource-name "StandardDv2Family" ' + '--subscription-id "D7EC67B3-7657-4966-BFFC-41EFD36BAAB3"', + checks=checks) + + +# EXAMPLE: /Quota/put/Quotas_Request_PutForMachineLearningServices_LowPriorityResource +@try_manual +def step_create3(test, checks=None): + if checks is None: + checks = [] + test.cmd('az quota create ' + '--properties "{{\\"name\\":{{\\"value\\":\\"TotalLowPriorityCores\\"}},\\"limit\\":200,\\"resourceType\\"' + ':\\"lowPriority\\",\\"unit\\":\\"Count\\"}}" ' + '--location "eastus" ' + '--provider-id "Microsoft.MachineLearningServices" ' + '--resource-name "TotalLowPriorityCores" ' + '--subscription-id "D7EC67B3-7657-4966-BFFC-41EFD36BAAB3"', + checks=checks) + + +# EXAMPLE: /Quota/get/Quotas_listUsagesForCompute +@try_manual +def step_list(test, checks=None): + if checks is None: + checks = [] + test.cmd('az quota list ' + '--location "eastus" ' + '--provider-id "Microsoft.Compute" ' + '--subscription-id "00000000-0000-0000-0000-000000000000"', + checks=checks) + + +# EXAMPLE: /Quota/get/Quotas_listUsagesMachineLearningServices +@try_manual +def step_list2(test, checks=None): + if checks is None: + checks = [] + test.cmd('az quota list ' + '--location "eastus" ' + '--provider-id "Microsoft.MachineLearningServices" ' + '--subscription-id "00000000-0000-0000-0000-000000000000"', + checks=checks) + + +# EXAMPLE: /Quota/get/Quotas_Request_ForCompute +@try_manual +def step_show(test, checks=None): + if checks is None: + checks = [] + test.cmd('az quota show ' + '--location "eastus" ' + '--provider-id "Microsoft.Compute" ' + '--resource-name "standardNDSFamily" ' + '--subscription-id "00000000-0000-0000-0000-000000000000"', + checks=checks) + + +# EXAMPLE: /Quota/patch/Quotas_Request_PatchForCompute +@try_manual +def step_update(test, checks=None): + if checks is None: + checks = [] + test.cmd('az quota update ' + '--properties "{{\\"name\\":{{\\"value\\":\\"standardFSv2Family\\"}},\\"limit\\":200,\\"unit\\":\\"Count\\' + '"}}" ' + '--location "eastus" ' + '--provider-id "Microsoft.Compute" ' + '--resource-name "standardFSv2Family" ' + '--subscription-id "D7EC67B3-7657-4966-BFFC-41EFD36BAAB3"', + checks=checks) + + +# EXAMPLE: /QuotaRequestStatus/get/QuotaRequestFailed +@try_manual +def step_quota_request_status_show(test, checks=None): + if checks is None: + checks = [] + test.cmd('az quota quota-request-status show ' + '--id "2B5C8515-37D8-4B6A-879B-CD641A2CF605" ' + '--location "eastus" ' + '--provider-id "Microsoft.Compute" ' + '--subscription-id "00000000-0000-0000-0000-000000000000"', + checks=checks) + + +# EXAMPLE: /QuotaRequestStatus/get/QuotaRequestHistory +@try_manual +def step_quota_request_status_list(test, checks=None): + if checks is None: + checks = [] + test.cmd('az quota quota-request-status list ' + '--location "eastus" ' + '--provider-id "Microsoft.Compute" ' + '--subscription-id "3f75fdf7-977e-44ad-990d-99f14f0f299f"', + checks=checks) + + +# EXAMPLE: /QuotaRequestStatus/get/QuotaRequestInProgress +@try_manual +def step_quota_request_status_show2(test, checks=None): + return step_quota_request_status_show(test, checks) + + +# EXAMPLE: /QuotaRequestStatus/get/QuotaRequestStatus +@try_manual +def step_quota_request_status_show3(test, checks=None): + return step_quota_request_status_show(test, checks) + + +# EXAMPLE: /Reservation/get/GetReservation +@try_manual +def step_reservation_show(test, checks=None): + if checks is None: + checks = [] + test.cmd('az quota reservation show ' + '--expand "renewProperties" ' + '--reservation-id "6ef59113-3482-40da-8d79-787f823e34bc" ' + '--reservation-order-id "276e7ae4-84d0-4da6-ab4b-d6b94f3557da"', + checks=checks) + + +# EXAMPLE: /Reservation/get/ReservationList +@try_manual +def step_reservation_list(test, checks=None): + if checks is None: + checks = [] + test.cmd('az quota reservation list ' + '--reservation-order-id "276e7ae4-84d0-4da6-ab4b-d6b94f3557da"', + checks=checks) + + +# EXAMPLE: /Reservation/get/ReservationRevisions +@try_manual +def step_reservation_list_revision(test, checks=None): + if checks is None: + checks = [] + test.cmd('az quota reservation list-revision ' + '--reservation-id "6ef59113-3482-40da-8d79-787f823e34bc" ' + '--reservation-order-id "276e7ae4-84d0-4da6-ab4b-d6b94f3557da"', + checks=checks) + + +# EXAMPLE: /Reservation/patch/PatchReservation +@try_manual +def step_reservation_update(test, checks=None): + if checks is None: + checks = [] + test.cmd('az quota reservation update ' + '--applied-scope-type "Shared" ' + '--instance-flexibility "Off" ' + '--reservation-id "6ef59113-3482-40da-8d79-787f823e34bc" ' + '--reservation-order-id "276e7ae4-84d0-4da6-ab4b-d6b94f3557da"', + checks=checks) + + +# EXAMPLE: /Reservation/post/AvailableScopes +@try_manual +def step_reservation_available_scope(test, checks=None): + if checks is None: + checks = [] + test.cmd('az quota reservation available-scope ' + '--properties scopes="/subscriptions/{subscription_id}" ' + '--reservation-id "356e7ae4-84d0-4da6-ab4b-d6b94f3557da" ' + '--reservation-order-id "276e7ae4-84d0-4da6-ab4b-d6b94f3557da"', + checks=checks) + + +# EXAMPLE: /Reservation/post/Merge +@try_manual +def step_reservation_merge(test, checks=None): + if checks is None: + checks = [] + test.cmd('az quota reservation merge ' + '--sources "/providers/Microsoft.Capacity/reservationOrders/c0565a8a-4491-4e77-b07b-5e6d66718e1c/reservati' + 'ons/cea04232-932e-47db-acb5-e29a945ecc73" "/providers/Microsoft.Capacity/reservationOrders/c0565a8a-4491-' + '4e77-b07b-5e6d66718e1c/reservations/5bf54dc7-dacd-4f46-a16b-7b78f4a59799" ' + '--reservation-order-id "276e7ae4-84d0-4da6-ab4b-d6b94f3557da"', + checks=checks) + + +# EXAMPLE: /Reservation/post/Split +@try_manual +def step_reservation_split(test, checks=None): + if checks is None: + checks = [] + test.cmd('az quota reservation split ' + '--quantities 1 2 ' + '--reservation-id "/providers/Microsoft.Capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/re' + 'servations/bcae77cd-3119-4766-919f-b50d36c75c7a" ' + '--reservation-order-id "276e7ae4-84d0-4da6-ab4b-d6b94f3557da"', + checks=checks) + + +# EXAMPLE: /ReservationOrder/put/Purchase +@try_manual +def step_reservation_order_purchase(test, checks=None): + if checks is None: + checks = [] + test.cmd('az quota reservation-order purchase ' + '--location "westus" ' + '--applied-scope-type "Shared" ' + '--billing-plan "Monthly" ' + '--billing-scope-id "/subscriptions/{subscription_id}" ' + '--display-name "TestReservationOrder" ' + '--quantity 1 ' + '--renew false ' + '--instance-flexibility "On" ' + '--reserved-resource-type "VirtualMachines" ' + '--term "P1Y" ' + '--name "{myQuota}" ' + '--reservation-order-id "a075419f-44cc-497f-b68a-14ee811d48b9"', + checks=checks) + + +# EXAMPLE: /ReservationOrder/get/GetReservation +@try_manual +def step_reservation_order_show(test, checks=None): + if checks is None: + checks = [] + test.cmd('az quota reservation-order show ' + '--reservation-order-id "a075419f-44cc-497f-b68a-14ee811d48b9"', + checks=checks) + + +# EXAMPLE: /ReservationOrder/get/GetReservationWithExpandPayments +@try_manual +def step_reservation_order_show2(test, checks=None): + if checks is None: + checks = [] + test.cmd('az quota reservation-order show ' + '--expand "schedule" ' + '--reservation-order-id "a075419f-44cc-497f-b68a-14ee811d48b9"', + checks=checks) + + +# EXAMPLE: /ReservationOrder/get/ReservationOrderList +@try_manual +def step_reservation_order_list(test, checks=None): + if checks is None: + checks = [] + test.cmd('az quota reservation-order list', + checks=checks) + + +# EXAMPLE: /ReservationOrder/post/Purchase +@try_manual +def step_reservation_order_calculate(test, checks=None): + if checks is None: + checks = [] + test.cmd('az quota reservation-order calculate ' + '--location "westus" ' + '--applied-scope-type "Shared" ' + '--billing-plan "Monthly" ' + '--billing-scope-id "/subscriptions/{subscription_id}" ' + '--display-name "TestReservationOrder" ' + '--quantity 1 ' + '--instance-flexibility "On" ' + '--reserved-resource-type "VirtualMachines" ' + '--term "P1Y" ' + '--name "{myQuota}"', + checks=checks) + diff --git a/src/reservations/azext_reservations/tests/latest/test_quota_scenario.py b/src/reservations/azext_reservations/tests/latest/test_quota_scenario.py new file mode 100644 index 00000000000..81f1c016038 --- /dev/null +++ b/src/reservations/azext_reservations/tests/latest/test_quota_scenario.py @@ -0,0 +1,145 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +import os +from azure.cli.testsdk import ScenarioTest +from .example_steps import step_operation_list +from .example_steps import step_create +from .example_steps import step_create2 +from .example_steps import step_create3 +from .example_steps import step_list +from .example_steps import step_list2 +from .example_steps import step_show +from .example_steps import step_update +from .example_steps import step_quota_request_status_show +from .example_steps import step_quota_request_status_list +from .example_steps import step_quota_request_status_show2 +from .example_steps import step_quota_request_status_show3 +from .example_steps import step_calculate_exchange_post +from .example_steps import step_exchange_post +from .example_steps import step_show_applied_reservation_list +from .example_steps import step_show_catalog +from .example_steps import step_reservation_show +from .example_steps import step_reservation_list +from .example_steps import step_reservation_list_revision +from .example_steps import step_reservation_update +from .example_steps import step_reservation_available_scope +from .example_steps import step_reservation_merge +from .example_steps import step_reservation_split +from .example_steps import step_reservation_order_purchase +from .example_steps import step_reservation_order_show +from .example_steps import step_reservation_order_show2 +from .example_steps import step_reservation_order_list +from .example_steps import step_reservation_order_calculate +from .. import ( + try_manual, + raise_if, + calc_coverage +) + + +TEST_DIR = os.path.abspath(os.path.join(os.path.abspath(__file__), '..')) + + +# Env setup_scenario +@try_manual +def setup_scenario(test): + pass + + +# Env undefined +@try_manual +def undefined(test): + pass + + +# Env undefined +@try_manual +def undefined(test): + pass + + +# Env undefined +@try_manual +def undefined(test): + pass + + +# Env undefined +@try_manual +def undefined(test): + pass + + +# Env cleanup_scenario +@try_manual +def cleanup_scenario(test): + pass + + +# Testcase: Scenario +@try_manual +def call_scenario(test): + setup_scenario(test) + step_operation_list(test, checks=[]) + undefined(test) + step_create(test, checks=[]) + step_create2(test, checks=[]) + step_create3(test, checks=[]) + step_list(test, checks=[]) + step_list2(test, checks=[]) + step_show(test, checks=[]) + step_update(test, checks=[]) + undefined(test) + step_quota_request_status_show(test, checks=[]) + step_quota_request_status_list(test, checks=[]) + step_quota_request_status_show2(test, checks=[]) + step_quota_request_status_show3(test, checks=[]) + undefined(test) + step_calculate_exchange_post(test, checks=[]) + step_exchange_post(test, checks=[]) + step_show_applied_reservation_list(test, checks=[]) + step_show_catalog(test, checks=[]) + undefined(test) + step_reservation_show(test, checks=[]) + step_reservation_list(test, checks=[]) + step_reservation_list_revision(test, checks=[]) + step_reservation_update(test, checks=[]) + step_reservation_available_scope(test, checks=[]) + step_reservation_merge(test, checks=[]) + step_reservation_split(test, checks=[]) + step_reservation_order_purchase(test, checks=[]) + step_reservation_order_show(test, checks=[]) + step_reservation_order_show2(test, checks=[]) + step_reservation_order_list(test, checks=[]) + step_reservation_order_calculate(test, checks=[]) + cleanup_scenario(test) + + +# Test class for Scenario +@try_manual +class QuotaScenarioTest(ScenarioTest): + + def __init__(self, *args, **kwargs): + super(QuotaScenarioTest, self).__init__(*args, **kwargs) + self.kwargs.update({ + 'subscription_id': self.get_subscription_id() + }) + + self.kwargs.update({ + 'myQuota': 'standard_D1', + }) + + + def test_quota_Scenario(self): + call_scenario(self) + calc_coverage(__file__) + raise_if() + diff --git a/src/reservations/azext_reservations/vendored_sdks/__init__.py b/src/reservations/azext_reservations/vendored_sdks/__init__.py new file mode 100644 index 00000000000..c9cfdc73e77 --- /dev/null +++ b/src/reservations/azext_reservations/vendored_sdks/__init__.py @@ -0,0 +1,12 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/src/reservations/azext_reservations/vendored_sdks/quota/__init__.py b/src/reservations/azext_reservations/vendored_sdks/quota/__init__.py new file mode 100644 index 00000000000..edfa581cea0 --- /dev/null +++ b/src/reservations/azext_reservations/vendored_sdks/quota/__init__.py @@ -0,0 +1,16 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._azure_reservation_api import AzureReservationAPI +__all__ = ['AzureReservationAPI'] + +try: + from ._patch import patch_sdk # type: ignore + patch_sdk() +except ImportError: + pass diff --git a/src/reservations/azext_reservations/vendored_sdks/quota/_azure_reservation_api.py b/src/reservations/azext_reservations/vendored_sdks/quota/_azure_reservation_api.py new file mode 100644 index 00000000000..e55e284f2ea --- /dev/null +++ b/src/reservations/azext_reservations/vendored_sdks/quota/_azure_reservation_api.py @@ -0,0 +1,97 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.credentials import TokenCredential + +from ._configuration import AzureReservationAPIConfiguration +from .operations import ReservationOperations +from .operations import AzureReservationAPIOperationsMixin +from .operations import ReservationOrderOperations +from .operations import OperationOperations +from .operations import CalculateExchangeOperations +from .operations import ExchangeOperations +from .operations import QuotaOperations +from .operations import QuotaRequestStatusOperations +from . import models + + +class AzureReservationAPI(AzureReservationAPIOperationsMixin): + """This API describe Azure Reservation. + + :ivar reservation: ReservationOperations operations + :vartype reservation: azure_reservation_api.operations.ReservationOperations + :ivar reservation_order: ReservationOrderOperations operations + :vartype reservation_order: azure_reservation_api.operations.ReservationOrderOperations + :ivar operation: OperationOperations operations + :vartype operation: azure_reservation_api.operations.OperationOperations + :ivar calculate_exchange: CalculateExchangeOperations operations + :vartype calculate_exchange: azure_reservation_api.operations.CalculateExchangeOperations + :ivar exchange: ExchangeOperations operations + :vartype exchange: azure_reservation_api.operations.ExchangeOperations + :ivar quota: QuotaOperations operations + :vartype quota: azure_reservation_api.operations.QuotaOperations + :ivar quota_request_status: QuotaRequestStatusOperations operations + :vartype quota_request_status: azure_reservation_api.operations.QuotaRequestStatusOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param str base_url: Service URL + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + """ + + def __init__( + self, + credential, # type: "TokenCredential" + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = 'https://management.azure.com' + self._config = AzureReservationAPIConfiguration(credential, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + 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 close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> AzureReservationAPI + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/src/reservations/azext_reservations/vendored_sdks/quota/_configuration.py b/src/reservations/azext_reservations/vendored_sdks/quota/_configuration.py new file mode 100644 index 00000000000..25769e3f68a --- /dev/null +++ b/src/reservations/azext_reservations/vendored_sdks/quota/_configuration.py @@ -0,0 +1,63 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class AzureReservationAPIConfiguration(Configuration): + """Configuration for AzureReservationAPI. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + """ + + def __init__( + self, + credential, # type: "TokenCredential" + **kwargs # type: Any + ): + # type: (...) -> None + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + super(AzureReservationAPIConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'azurereservationapi/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/src/reservations/azext_reservations/vendored_sdks/quota/aio/__init__.py b/src/reservations/azext_reservations/vendored_sdks/quota/aio/__init__.py new file mode 100644 index 00000000000..5c26f62f1e0 --- /dev/null +++ b/src/reservations/azext_reservations/vendored_sdks/quota/aio/__init__.py @@ -0,0 +1,10 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._azure_reservation_api import AzureReservationAPI +__all__ = ['AzureReservationAPI'] diff --git a/src/reservations/azext_reservations/vendored_sdks/quota/aio/_azure_reservation_api.py b/src/reservations/azext_reservations/vendored_sdks/quota/aio/_azure_reservation_api.py new file mode 100644 index 00000000000..9e5da37111d --- /dev/null +++ b/src/reservations/azext_reservations/vendored_sdks/quota/aio/_azure_reservation_api.py @@ -0,0 +1,91 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional, TYPE_CHECKING + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +from ._configuration import AzureReservationAPIConfiguration +from .operations import ReservationOperations +from .operations import AzureReservationAPIOperationsMixin +from .operations import ReservationOrderOperations +from .operations import OperationOperations +from .operations import CalculateExchangeOperations +from .operations import ExchangeOperations +from .operations import QuotaOperations +from .operations import QuotaRequestStatusOperations +from .. import models + + +class AzureReservationAPI(AzureReservationAPIOperationsMixin): + """This API describe Azure Reservation. + + :ivar reservation: ReservationOperations operations + :vartype reservation: azure_reservation_api.aio.operations.ReservationOperations + :ivar reservation_order: ReservationOrderOperations operations + :vartype reservation_order: azure_reservation_api.aio.operations.ReservationOrderOperations + :ivar operation: OperationOperations operations + :vartype operation: azure_reservation_api.aio.operations.OperationOperations + :ivar calculate_exchange: CalculateExchangeOperations operations + :vartype calculate_exchange: azure_reservation_api.aio.operations.CalculateExchangeOperations + :ivar exchange: ExchangeOperations operations + :vartype exchange: azure_reservation_api.aio.operations.ExchangeOperations + :ivar quota: QuotaOperations operations + :vartype quota: azure_reservation_api.aio.operations.QuotaOperations + :ivar quota_request_status: QuotaRequestStatusOperations operations + :vartype quota_request_status: azure_reservation_api.aio.operations.QuotaRequestStatusOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param str base_url: Service URL + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + base_url: Optional[str] = None, + **kwargs: Any + ) -> None: + if not base_url: + base_url = 'https://management.azure.com' + self._config = AzureReservationAPIConfiguration(credential, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + 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) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "AzureReservationAPI": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/src/reservations/azext_reservations/vendored_sdks/quota/aio/_configuration.py b/src/reservations/azext_reservations/vendored_sdks/quota/aio/_configuration.py new file mode 100644 index 00000000000..badfeeff6f4 --- /dev/null +++ b/src/reservations/azext_reservations/vendored_sdks/quota/aio/_configuration.py @@ -0,0 +1,59 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +VERSION = "unknown" + +class AzureReservationAPIConfiguration(Configuration): + """Configuration for AzureReservationAPI. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + **kwargs: Any + ) -> None: + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + super(AzureReservationAPIConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'azurereservationapi/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/src/reservations/azext_reservations/vendored_sdks/quota/aio/operations/__init__.py b/src/reservations/azext_reservations/vendored_sdks/quota/aio/operations/__init__.py new file mode 100644 index 00000000000..5cf631a610f --- /dev/null +++ b/src/reservations/azext_reservations/vendored_sdks/quota/aio/operations/__init__.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._reservation_operations import ReservationOperations +from ._azure_reservation_api_operations import AzureReservationAPIOperationsMixin +from ._reservation_order_operations import ReservationOrderOperations +from ._operation_operations import OperationOperations +from ._calculate_exchange_operations import CalculateExchangeOperations +from ._exchange_operations import ExchangeOperations +from ._quota_operations import QuotaOperations +from ._quota_request_status_operations import QuotaRequestStatusOperations + +__all__ = [ + 'ReservationOperations', + 'AzureReservationAPIOperationsMixin', + 'ReservationOrderOperations', + 'OperationOperations', + 'CalculateExchangeOperations', + 'ExchangeOperations', + 'QuotaOperations', + 'QuotaRequestStatusOperations', +] diff --git a/src/reservations/azext_reservations/vendored_sdks/quota/aio/operations/_azure_reservation_api_operations.py b/src/reservations/azext_reservations/vendored_sdks/quota/aio/operations/_azure_reservation_api_operations.py new file mode 100644 index 00000000000..1bb6ad46490 --- /dev/null +++ b/src/reservations/azext_reservations/vendored_sdks/quota/aio/operations/_azure_reservation_api_operations.py @@ -0,0 +1,145 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class AzureReservationAPIOperationsMixin: + + async def get_catalog( + self, + subscription_id: str, + reserved_resource_type: str, + location: Optional[str] = None, + **kwargs + ) -> List["models.Catalog"]: + """Get the regions and skus that are available for RI purchase for the specified Azure subscription. + + Get the regions and skus that are available for RI purchase for the specified Azure + subscription. + + :param subscription_id: Id of the subscription. + :type subscription_id: str + :param reserved_resource_type: The type of the resource for which the skus should be provided. + :type reserved_resource_type: str + :param location: Filters the skus based on the location specified in this parameter. This can + be an azure region or global. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of Catalog, or the result of cls(response) + :rtype: list[~azure_reservation_api.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', {})) + api_version = "2020-10-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_catalog.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + query_parameters['reservedResourceType'] = self._serialize.query("reserved_resource_type", reserved_resource_type, 'str') + if location is not None: + query_parameters['location'] = self._serialize.query("location", location, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('[Catalog]', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_catalog.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/catalogs'} # type: ignore + + async def get_applied_reservation_list( + self, + subscription_id: str, + **kwargs + ) -> "models.AppliedReservations": + """Get list of applicable ``Reservation``\ s. + + Get applicable ``Reservation``\ s that are applied to this subscription or a resource group + under this subscription. + + :param subscription_id: Id of the subscription. + :type subscription_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AppliedReservations, or the result of cls(response) + :rtype: ~azure_reservation_api.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', {})) + api_version = "2020-10-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_applied_reservation_list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AppliedReservations', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_applied_reservation_list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/appliedReservations'} # type: ignore diff --git a/src/reservations/azext_reservations/vendored_sdks/quota/aio/operations/_calculate_exchange_operations.py b/src/reservations/azext_reservations/vendored_sdks/quota/aio/operations/_calculate_exchange_operations.py new file mode 100644 index 00000000000..2cb5445b090 --- /dev/null +++ b/src/reservations/azext_reservations/vendored_sdks/quota/aio/operations/_calculate_exchange_operations.py @@ -0,0 +1,156 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure_reservation_api.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. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def _post_initial( + self, + body: "models.CalculateExchangeRequest", + **kwargs + ) -> Optional["models.CalculateExchangeOperationResultResponse"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.CalculateExchangeOperationResultResponse"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._post_initial.metadata['url'] # type: ignore + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(body, 'CalculateExchangeRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('CalculateExchangeOperationResultResponse', pipeline_response) + + if response.status_code == 202: + response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + _post_initial.metadata = {'url': '/providers/Microsoft.Capacity/calculateExchange'} # type: ignore + + async def begin_post( + self, + body: "models.CalculateExchangeRequest", + **kwargs + ) -> AsyncLROPoller["models.CalculateExchangeOperationResultResponse"]: + """Calculates the refund amounts and price of the new purchases. + + Calculates price for exchanging ``Reservations`` if there are no policy errors. + + :param body: Request containing purchases and refunds that need to be executed. + :type body: ~azure_reservation_api.models.CalculateExchangeRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either CalculateExchangeOperationResultResponse or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure_reservation_api.models.CalculateExchangeOperationResultResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + 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( + body=body, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_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() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_post.metadata = {'url': '/providers/Microsoft.Capacity/calculateExchange'} # type: ignore diff --git a/src/reservations/azext_reservations/vendored_sdks/quota/aio/operations/_exchange_operations.py b/src/reservations/azext_reservations/vendored_sdks/quota/aio/operations/_exchange_operations.py new file mode 100644 index 00000000000..694cedb08b8 --- /dev/null +++ b/src/reservations/azext_reservations/vendored_sdks/quota/aio/operations/_exchange_operations.py @@ -0,0 +1,156 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure_reservation_api.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. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def _post_initial( + self, + body: "models.ExchangeRequest", + **kwargs + ) -> Optional["models.ExchangeOperationResultResponse"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.ExchangeOperationResultResponse"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._post_initial.metadata['url'] # type: ignore + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(body, 'ExchangeRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ExchangeOperationResultResponse', pipeline_response) + + if response.status_code == 202: + response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + _post_initial.metadata = {'url': '/providers/Microsoft.Capacity/exchange'} # type: ignore + + async def begin_post( + self, + body: "models.ExchangeRequest", + **kwargs + ) -> AsyncLROPoller["models.ExchangeOperationResultResponse"]: + """Exchange Reservation(s). + + Returns one or more ``Reservations`` in exchange for one or more ``Reservation`` purchases. + + :param body: Request containing the refunds and purchases that need to be executed. + :type body: ~azure_reservation_api.models.ExchangeRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ExchangeOperationResultResponse or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure_reservation_api.models.ExchangeOperationResultResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + 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( + body=body, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_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() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_post.metadata = {'url': '/providers/Microsoft.Capacity/exchange'} # type: ignore diff --git a/src/reservations/azext_reservations/vendored_sdks/quota/aio/operations/_operation_operations.py b/src/reservations/azext_reservations/vendored_sdks/quota/aio/operations/_operation_operations.py new file mode 100644 index 00000000000..699d14ce36b --- /dev/null +++ b/src/reservations/azext_reservations/vendored_sdks/quota/aio/operations/_operation_operations.py @@ -0,0 +1,107 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure_reservation_api.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. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs + ) -> AsyncIterable["models.OperationList"]: + """Get operations. + + List all the operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure_reservation_api.models.OperationList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.OperationList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('OperationList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.Error, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Capacity/operations'} # type: ignore diff --git a/src/reservations/azext_reservations/vendored_sdks/quota/aio/operations/_quota_operations.py b/src/reservations/azext_reservations/vendored_sdks/quota/aio/operations/_quota_operations.py new file mode 100644 index 00000000000..0ad8b4c7e84 --- /dev/null +++ b/src/reservations/azext_reservations/vendored_sdks/quota/aio/operations/_quota_operations.py @@ -0,0 +1,498 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure_reservation_api.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. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def get( + self, + subscription_id: str, + provider_id: str, + location: str, + resource_name: str, + **kwargs + ) -> "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. + + :param subscription_id: Azure subscription ID. + :type subscription_id: str + :param provider_id: Azure resource provider ID. + :type provider_id: str + :param location: Azure region. + :type location: str + :param resource_name: The resource name for a resource provider, such as SKU name for + Microsoft.Compute, Sku or TotalLowPriorityCores for Microsoft.MachineLearningServices. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CurrentQuotaLimitBase, or the result of cls(response) + :rtype: ~azure_reservation_api.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', {})) + api_version = "2020-10-25" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + 'providerId': self._serialize.url("provider_id", provider_id, 'str'), + 'location': self._serialize.url("location", location, 'str'), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ExceptionResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('CurrentQuotaLimitBase', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/resourceProviders/{providerId}/locations/{location}/serviceLimits/{resourceName}'} # type: ignore + + async def _create_or_update_initial( + self, + subscription_id: str, + provider_id: str, + location: str, + resource_name: str, + create_quota_request: "models.CurrentQuotaLimitBase", + **kwargs + ) -> Union["models.QuotaRequestOneResourceSubmitResponse", "models.QuotaRequestSubmitResponse201"]: + cls = kwargs.pop('cls', None) # type: ClsType[Union["models.QuotaRequestOneResourceSubmitResponse", "models.QuotaRequestSubmitResponse201"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-25" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + 'providerId': self._serialize.url("provider_id", provider_id, 'str'), + 'location': self._serialize.url("location", location, 'str'), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(create_quota_request, 'CurrentQuotaLimitBase') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ExceptionResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('QuotaRequestOneResourceSubmitResponse', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('QuotaRequestSubmitResponse201', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/resourceProviders/{providerId}/locations/{location}/serviceLimits/{resourceName}'} # type: ignore + + async def begin_create_or_update( + self, + subscription_id: str, + provider_id: str, + location: str, + resource_name: str, + create_quota_request: "models.CurrentQuotaLimitBase", + **kwargs + ) -> AsyncLROPoller[Union["models.QuotaRequestOneResourceSubmitResponse", "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. + The Create quota request may be constructed as follows. The PUT operation can be used to + update the quota. + + :param subscription_id: Azure subscription ID. + :type subscription_id: str + :param provider_id: Azure resource provider ID. + :type provider_id: str + :param location: Azure region. + :type location: str + :param resource_name: The resource name for a resource provider, such as SKU name for + Microsoft.Compute, Sku or TotalLowPriorityCores for Microsoft.MachineLearningServices. + :type resource_name: str + :param create_quota_request: Quota requests payload. + :type create_quota_request: ~azure_reservation_api.models.CurrentQuotaLimitBase + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either QuotaRequestOneResourceSubmitResponse or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure_reservation_api.models.QuotaRequestOneResourceSubmitResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[Union["models.QuotaRequestOneResourceSubmitResponse", "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( + subscription_id=subscription_id, + provider_id=provider_id, + location=location, + resource_name=resource_name, + create_quota_request=create_quota_request, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('QuotaRequestOneResourceSubmitResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + 'providerId': self._serialize.url("provider_id", provider_id, 'str'), + 'location': self._serialize.url("location", location, 'str'), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/resourceProviders/{providerId}/locations/{location}/serviceLimits/{resourceName}'} # type: ignore + + async def _update_initial( + self, + subscription_id: str, + provider_id: str, + location: str, + resource_name: str, + create_quota_request: "models.CurrentQuotaLimitBase", + **kwargs + ) -> Union["models.QuotaRequestOneResourceSubmitResponse", "models.QuotaRequestSubmitResponse201"]: + cls = kwargs.pop('cls', None) # type: ClsType[Union["models.QuotaRequestOneResourceSubmitResponse", "models.QuotaRequestSubmitResponse201"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-25" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + 'providerId': self._serialize.url("provider_id", provider_id, 'str'), + 'location': self._serialize.url("location", location, 'str'), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(create_quota_request, 'CurrentQuotaLimitBase') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ExceptionResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('QuotaRequestOneResourceSubmitResponse', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('QuotaRequestSubmitResponse201', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/resourceProviders/{providerId}/locations/{location}/serviceLimits/{resourceName}'} # type: ignore + + async def begin_update( + self, + subscription_id: str, + provider_id: str, + location: str, + resource_name: str, + create_quota_request: "models.CurrentQuotaLimitBase", + **kwargs + ) -> AsyncLROPoller[Union["models.QuotaRequestOneResourceSubmitResponse", "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. + + :param subscription_id: Azure subscription ID. + :type subscription_id: str + :param provider_id: Azure resource provider ID. + :type provider_id: str + :param location: Azure region. + :type location: str + :param resource_name: The resource name for a resource provider, such as SKU name for + Microsoft.Compute, Sku or TotalLowPriorityCores for Microsoft.MachineLearningServices. + :type resource_name: str + :param create_quota_request: Payload for the quota request. + :type create_quota_request: ~azure_reservation_api.models.CurrentQuotaLimitBase + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either QuotaRequestOneResourceSubmitResponse or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure_reservation_api.models.QuotaRequestOneResourceSubmitResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[Union["models.QuotaRequestOneResourceSubmitResponse", "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( + subscription_id=subscription_id, + provider_id=provider_id, + location=location, + resource_name=resource_name, + create_quota_request=create_quota_request, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('QuotaRequestOneResourceSubmitResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + 'providerId': self._serialize.url("provider_id", provider_id, 'str'), + 'location': self._serialize.url("location", location, 'str'), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/resourceProviders/{providerId}/locations/{location}/serviceLimits/{resourceName}'} # type: ignore + + def list( + self, + subscription_id: str, + provider_id: str, + location: str, + **kwargs + ) -> 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. + + :param subscription_id: Azure subscription ID. + :type subscription_id: str + :param provider_id: Azure resource provider ID. + :type provider_id: str + :param location: Azure region. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either QuotaLimits or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure_reservation_api.models.QuotaLimits] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.QuotaLimits"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-25" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + 'providerId': self._serialize.url("provider_id", provider_id, 'str'), + 'location': self._serialize.url("location", location, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('QuotaLimits', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ExceptionResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/resourceProviders/{providerId}/locations/{location}/serviceLimits'} # type: ignore diff --git a/src/reservations/azext_reservations/vendored_sdks/quota/aio/operations/_quota_request_status_operations.py b/src/reservations/azext_reservations/vendored_sdks/quota/aio/operations/_quota_request_status_operations.py new file mode 100644 index 00000000000..a7feeb0072f --- /dev/null +++ b/src/reservations/azext_reservations/vendored_sdks/quota/aio/operations/_quota_request_status_operations.py @@ -0,0 +1,215 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure_reservation_api.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. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def get( + self, + subscription_id: str, + provider_id: str, + location: str, + id: str, + **kwargs + ) -> "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. + + :param subscription_id: Azure subscription ID. + :type subscription_id: str + :param provider_id: Azure resource provider ID. + :type provider_id: str + :param location: Azure region. + :type location: str + :param id: Quota Request ID. + :type id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: QuotaRequestDetails, or the result of cls(response) + :rtype: ~azure_reservation_api.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', {})) + api_version = "2020-10-25" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + 'providerId': self._serialize.url("provider_id", provider_id, 'str'), + 'location': self._serialize.url("location", location, 'str'), + 'id': self._serialize.url("id", id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ExceptionResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('QuotaRequestDetails', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/resourceProviders/{providerId}/locations/{location}/serviceLimitsRequests/{id}'} # type: ignore + + def list( + self, + subscription_id: str, + provider_id: str, + location: str, + filter: Optional[str] = None, + top: Optional[int] = None, + skiptoken: Optional[str] = None, + **kwargs + ) -> 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. + + :param subscription_id: Azure subscription ID. + :type subscription_id: str + :param provider_id: Azure resource provider ID. + :type provider_id: str + :param location: Azure region. + :type location: str + :param filter: .. list-table:: + :header-rows: 1 + + * - Field + - Supported operators + * - + + + |requestSubmitTime | ge, le, eq, gt, lt. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skiptoken: Skiptoken is only used if a previous operation returned a partial result. If + a previous response contains a nextLink element, the value of the nextLink element includes a + skiptoken parameter that specifies a starting point to use for subsequent calls. + :type skiptoken: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either QuotaRequestDetailsList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure_reservation_api.models.QuotaRequestDetailsList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.QuotaRequestDetailsList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-25" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + 'providerId': self._serialize.url("provider_id", provider_id, 'str'), + 'location': self._serialize.url("location", location, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skiptoken is not None: + query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('QuotaRequestDetailsList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ExceptionResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/resourceProviders/{providerId}/locations/{location}/serviceLimitsRequests'} # type: ignore diff --git a/src/reservations/azext_reservations/vendored_sdks/quota/aio/operations/_reservation_operations.py b/src/reservations/azext_reservations/vendored_sdks/quota/aio/operations/_reservation_operations.py new file mode 100644 index 00000000000..2a1ee09e234 --- /dev/null +++ b/src/reservations/azext_reservations/vendored_sdks/quota/aio/operations/_reservation_operations.py @@ -0,0 +1,750 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, List, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure_reservation_api.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. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def _available_scopes_initial( + self, + reservation_order_id: str, + reservation_id: str, + body: "models.AvailableScopeRequest", + **kwargs + ) -> "models.AvailableScopeProperties": + cls = kwargs.pop('cls', None) # type: ClsType["models.AvailableScopeProperties"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._available_scopes_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'reservationOrderId': self._serialize.url("reservation_order_id", reservation_order_id, 'str'), + 'reservationId': self._serialize.url("reservation_id", reservation_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(body, 'AvailableScopeRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AvailableScopeProperties', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _available_scopes_initial.metadata = {'url': '/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}/availableScopes'} # type: ignore + + async def begin_available_scopes( + self, + reservation_order_id: str, + reservation_id: str, + body: "models.AvailableScopeRequest", + **kwargs + ) -> AsyncLROPoller["models.AvailableScopeProperties"]: + """Get Available Scopes for ``Reservation``. + + Get Available Scopes for ``Reservation``. + + :param reservation_order_id: Order Id of the reservation. + :type reservation_order_id: str + :param reservation_id: Id of the Reservation Item. + :type reservation_id: str + :param body: + :type body: ~azure_reservation_api.models.AvailableScopeRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either AvailableScopeProperties or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure_reservation_api.models.AvailableScopeProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + 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( + reservation_order_id=reservation_order_id, + reservation_id=reservation_id, + body=body, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('AvailableScopeProperties', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'reservationOrderId': self._serialize.url("reservation_order_id", reservation_order_id, 'str'), + 'reservationId': self._serialize.url("reservation_id", reservation_id, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_available_scopes.metadata = {'url': '/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}/availableScopes'} # type: ignore + + async def _split_initial( + self, + reservation_order_id: str, + body: "models.SplitRequest", + **kwargs + ) -> Optional[List["models.ReservationResponse"]]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional[List["models.ReservationResponse"]]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._split_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'reservationOrderId': self._serialize.url("reservation_order_id", reservation_order_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(body, 'SplitRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('[ReservationResponse]', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _split_initial.metadata = {'url': '/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/split'} # type: ignore + + async def begin_split( + self, + reservation_order_id: str, + body: "models.SplitRequest", + **kwargs + ) -> AsyncLROPoller[List["models.ReservationResponse"]]: + """Split the ``Reservation``. + + Split a ``Reservation`` into two ``Reservation``\ s with specified quantity distribution. + + :param reservation_order_id: Order Id of the reservation. + :type reservation_order_id: str + :param body: Information needed to Split a reservation item. + :type body: ~azure_reservation_api.models.SplitRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either list of ReservationResponse or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[list[~azure_reservation_api.models.ReservationResponse]] + :raises ~azure.core.exceptions.HttpResponseError: + """ + 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( + reservation_order_id=reservation_order_id, + body=body, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('[ReservationResponse]', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'reservationOrderId': self._serialize.url("reservation_order_id", reservation_order_id, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_split.metadata = {'url': '/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/split'} # type: ignore + + async def _merge_initial( + self, + reservation_order_id: str, + body: "models.MergeRequest", + **kwargs + ) -> Optional[List["models.ReservationResponse"]]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional[List["models.ReservationResponse"]]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._merge_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'reservationOrderId': self._serialize.url("reservation_order_id", reservation_order_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(body, 'MergeRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('[ReservationResponse]', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _merge_initial.metadata = {'url': '/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/merge'} # type: ignore + + async def begin_merge( + self, + reservation_order_id: str, + body: "models.MergeRequest", + **kwargs + ) -> AsyncLROPoller[List["models.ReservationResponse"]]: + """Merges two ``Reservation``\ s. + + Merge the specified ``Reservation``\ s into a new ``Reservation``. The two ``Reservation``\ s + being merged must have same properties. + + :param reservation_order_id: Order Id of the reservation. + :type reservation_order_id: str + :param body: Information needed for commercial request for a reservation. + :type body: ~azure_reservation_api.models.MergeRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either list of ReservationResponse or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[list[~azure_reservation_api.models.ReservationResponse]] + :raises ~azure.core.exceptions.HttpResponseError: + """ + 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( + reservation_order_id=reservation_order_id, + body=body, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('[ReservationResponse]', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'reservationOrderId': self._serialize.url("reservation_order_id", reservation_order_id, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_merge.metadata = {'url': '/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/merge'} # type: ignore + + def list( + self, + reservation_order_id: str, + **kwargs + ) -> AsyncIterable["models.ReservationList"]: + """Get ``Reservation``\ s in a given reservation Order. + + List ``Reservation``\ s within a single ``ReservationOrder``. + + :param reservation_order_id: Order Id of the reservation. + :type reservation_order_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ReservationList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure_reservation_api.models.ReservationList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ReservationList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'reservationOrderId': self._serialize.url("reservation_order_id", reservation_order_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ReservationList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.Error, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations'} # type: ignore + + async def get( + self, + reservation_id: str, + reservation_order_id: str, + expand: Optional[str] = None, + **kwargs + ) -> "models.ReservationResponse": + """Get ``Reservation`` details. + + Get specific ``Reservation`` details. + + :param reservation_id: Id of the Reservation Item. + :type reservation_id: str + :param reservation_order_id: Order Id of the reservation. + :type reservation_order_id: str + :param expand: Supported value of this query is renewProperties. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ReservationResponse, or the result of cls(response) + :rtype: ~azure_reservation_api.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', {})) + api_version = "2020-10-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'reservationId': self._serialize.url("reservation_id", reservation_id, 'str'), + 'reservationOrderId': self._serialize.url("reservation_order_id", reservation_order_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if expand is not None: + query_parameters['expand'] = self._serialize.query("expand", expand, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ReservationResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}'} # type: ignore + + async def _update_initial( + self, + reservation_order_id: str, + reservation_id: str, + parameters: "models.Patch", + **kwargs + ) -> Optional["models.ReservationResponse"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.ReservationResponse"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'reservationOrderId': self._serialize.url("reservation_order_id", reservation_order_id, 'str'), + 'reservationId': self._serialize.url("reservation_id", reservation_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'Patch') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ReservationResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _update_initial.metadata = {'url': '/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}'} # type: ignore + + async def begin_update( + self, + reservation_order_id: str, + reservation_id: str, + parameters: "models.Patch", + **kwargs + ) -> AsyncLROPoller["models.ReservationResponse"]: + """Updates a ``Reservation``. + + Updates the applied scopes of the ``Reservation``. + + :param reservation_order_id: Order Id of the reservation. + :type reservation_order_id: str + :param reservation_id: Id of the Reservation Item. + :type reservation_id: str + :param parameters: Information needed to patch a reservation item. + :type parameters: ~azure_reservation_api.models.Patch + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ReservationResponse or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure_reservation_api.models.ReservationResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + 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( + reservation_order_id=reservation_order_id, + reservation_id=reservation_id, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ReservationResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'reservationOrderId': self._serialize.url("reservation_order_id", reservation_order_id, 'str'), + 'reservationId': self._serialize.url("reservation_id", reservation_id, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}'} # type: ignore + + def list_revisions( + self, + reservation_id: str, + reservation_order_id: str, + **kwargs + ) -> AsyncIterable["models.ReservationList"]: + """Get ``Reservation`` revisions. + + List of all the revisions for the ``Reservation``. + + :param reservation_id: Id of the Reservation Item. + :type reservation_id: str + :param reservation_order_id: Order Id of the reservation. + :type reservation_order_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ReservationList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure_reservation_api.models.ReservationList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ReservationList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_revisions.metadata['url'] # type: ignore + path_format_arguments = { + 'reservationId': self._serialize.url("reservation_id", reservation_id, 'str'), + 'reservationOrderId': self._serialize.url("reservation_order_id", reservation_order_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ReservationList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.Error, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list_revisions.metadata = {'url': '/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}/revisions'} # type: ignore diff --git a/src/reservations/azext_reservations/vendored_sdks/quota/aio/operations/_reservation_order_operations.py b/src/reservations/azext_reservations/vendored_sdks/quota/aio/operations/_reservation_order_operations.py new file mode 100644 index 00000000000..8056966f7f4 --- /dev/null +++ b/src/reservations/azext_reservations/vendored_sdks/quota/aio/operations/_reservation_order_operations.py @@ -0,0 +1,349 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure_reservation_api.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. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def calculate( + self, + body: "models.PurchaseRequest", + **kwargs + ) -> "models.CalculatePriceResponse": + """Calculate price for a ``ReservationOrder``. + + Calculate price for placing a ``ReservationOrder``. + + :param body: Information needed for calculate or purchase reservation. + :type body: ~azure_reservation_api.models.PurchaseRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CalculatePriceResponse, or the result of cls(response) + :rtype: ~azure_reservation_api.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', {})) + api_version = "2020-10-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.calculate.metadata['url'] # type: ignore + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(body, 'PurchaseRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('CalculatePriceResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + calculate.metadata = {'url': '/providers/Microsoft.Capacity/calculatePrice'} # type: ignore + + def list( + self, + **kwargs + ) -> AsyncIterable["models.ReservationOrderList"]: + """Get all ``ReservationOrder``\ s. + + List of all the ``ReservationOrder``\ s that the user has access to in the current tenant. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ReservationOrderList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure_reservation_api.models.ReservationOrderList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ReservationOrderList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('ReservationOrderList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.Error, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Capacity/reservationOrders'} # type: ignore + + async def _purchase_initial( + self, + reservation_order_id: str, + body: "models.PurchaseRequest", + **kwargs + ) -> "models.ReservationOrderResponse": + cls = kwargs.pop('cls', None) # type: ClsType["models.ReservationOrderResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._purchase_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'reservationOrderId': self._serialize.url("reservation_order_id", reservation_order_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(body, 'PurchaseRequest') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ReservationOrderResponse', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('ReservationOrderResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _purchase_initial.metadata = {'url': '/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}'} # type: ignore + + async def begin_purchase( + self, + reservation_order_id: str, + body: "models.PurchaseRequest", + **kwargs + ) -> AsyncLROPoller["models.ReservationOrderResponse"]: + """Purchase ``ReservationOrder``. + + Purchase ``ReservationOrder`` and create resource under the specified URI. + + :param reservation_order_id: Order Id of the reservation. + :type reservation_order_id: str + :param body: Information needed for calculate or purchase reservation. + :type body: ~azure_reservation_api.models.PurchaseRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ReservationOrderResponse or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure_reservation_api.models.ReservationOrderResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + 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( + reservation_order_id=reservation_order_id, + body=body, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ReservationOrderResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'reservationOrderId': self._serialize.url("reservation_order_id", reservation_order_id, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_purchase.metadata = {'url': '/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}'} # type: ignore + + async def get( + self, + reservation_order_id: str, + expand: Optional[str] = None, + **kwargs + ) -> "models.ReservationOrderResponse": + """Get a specific ``ReservationOrder``. + + Get the details of the ``ReservationOrder``. + + :param reservation_order_id: Order Id of the reservation. + :type reservation_order_id: str + :param expand: May be used to expand the planInformation. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ReservationOrderResponse, or the result of cls(response) + :rtype: ~azure_reservation_api.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', {})) + api_version = "2020-10-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'reservationOrderId': self._serialize.url("reservation_order_id", reservation_order_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ReservationOrderResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}'} # type: ignore diff --git a/src/reservations/azext_reservations/vendored_sdks/quota/models/__init__.py b/src/reservations/azext_reservations/vendored_sdks/quota/models/__init__.py new file mode 100644 index 00000000000..80330d1c804 --- /dev/null +++ b/src/reservations/azext_reservations/vendored_sdks/quota/models/__init__.py @@ -0,0 +1,264 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +try: + from ._models_py3 import AppliedReservationList + from ._models_py3 import AppliedReservations + from ._models_py3 import AvailableScopeProperties + from ._models_py3 import AvailableScopeRequest + from ._models_py3 import AvailableScopeRequestProperties + from ._models_py3 import BillingInformation + from ._models_py3 import CalculateExchangeOperationResultResponse + from ._models_py3 import CalculateExchangeRequest + from ._models_py3 import CalculateExchangeRequestProperties + from ._models_py3 import CalculateExchangeResponseProperties + from ._models_py3 import CalculatePriceResponse + from ._models_py3 import CalculatePriceResponseProperties + from ._models_py3 import CalculatePriceResponsePropertiesBillingCurrencyTotal + from ._models_py3 import CalculatePriceResponsePropertiesPricingCurrencyTotal + from ._models_py3 import Catalog + from ._models_py3 import CreateGenericQuotaRequestParameters + from ._models_py3 import CurrentQuotaLimit + from ._models_py3 import CurrentQuotaLimitBase + from ._models_py3 import Error + from ._models_py3 import ExceptionResponse + from ._models_py3 import ExchangeOperationResultResponse + from ._models_py3 import ExchangePolicyError + from ._models_py3 import ExchangePolicyErrors + from ._models_py3 import ExchangeRequest + from ._models_py3 import ExchangeRequestProperties + from ._models_py3 import ExchangeResponseProperties + from ._models_py3 import ExtendedErrorInfo + from ._models_py3 import ExtendedStatusInfo + from ._models_py3 import MergeRequest + from ._models_py3 import OperationDisplay + from ._models_py3 import OperationList + from ._models_py3 import OperationResponse + from ._models_py3 import OperationResultError + from ._models_py3 import Patch + from ._models_py3 import PatchPropertiesRenewProperties + from ._models_py3 import PaymentDetail + from ._models_py3 import Price + from ._models_py3 import PurchaseRequest + from ._models_py3 import PurchaseRequestPropertiesReservedResourceProperties + from ._models_py3 import QuotaLimits + from ._models_py3 import QuotaLimitsResponse + from ._models_py3 import QuotaProperties + from ._models_py3 import QuotaRequestDetails + from ._models_py3 import QuotaRequestDetailsList + from ._models_py3 import QuotaRequestOneResourceSubmitResponse + from ._models_py3 import QuotaRequestProperties + from ._models_py3 import QuotaRequestSubmitResponse + from ._models_py3 import QuotaRequestSubmitResponse201 + from ._models_py3 import RenewPropertiesResponse + from ._models_py3 import RenewPropertiesResponseBillingCurrencyTotal + from ._models_py3 import RenewPropertiesResponsePricingCurrencyTotal + from ._models_py3 import ReservationList + from ._models_py3 import ReservationMergeProperties + from ._models_py3 import ReservationOrderBillingPlanInformation + from ._models_py3 import ReservationOrderList + from ._models_py3 import ReservationOrderResponse + from ._models_py3 import ReservationProperties + from ._models_py3 import ReservationResponse + from ._models_py3 import ReservationSplitProperties + from ._models_py3 import ReservationToExchange + from ._models_py3 import ReservationToPurchaseCalculateExchange + from ._models_py3 import ReservationToPurchaseExchange + from ._models_py3 import ReservationToReturn + from ._models_py3 import ReservationToReturnForExchange + from ._models_py3 import ResourceName + from ._models_py3 import ScopeProperties + from ._models_py3 import ServiceError + from ._models_py3 import ServiceErrorDetail + from ._models_py3 import SkuName + from ._models_py3 import SkuProperty + from ._models_py3 import SkuRestriction + from ._models_py3 import SplitRequest + from ._models_py3 import SubRequest + from ._models_py3 import SubscriptionScopeProperties +except (SyntaxError, ImportError): + from ._models import AppliedReservationList # type: ignore + from ._models import AppliedReservations # type: ignore + from ._models import AvailableScopeProperties # type: ignore + from ._models import AvailableScopeRequest # type: ignore + from ._models import AvailableScopeRequestProperties # type: ignore + from ._models import BillingInformation # type: ignore + from ._models import CalculateExchangeOperationResultResponse # type: ignore + from ._models import CalculateExchangeRequest # type: ignore + from ._models import CalculateExchangeRequestProperties # type: ignore + from ._models import CalculateExchangeResponseProperties # type: ignore + from ._models import CalculatePriceResponse # type: ignore + from ._models import CalculatePriceResponseProperties # type: ignore + from ._models import CalculatePriceResponsePropertiesBillingCurrencyTotal # type: ignore + from ._models import CalculatePriceResponsePropertiesPricingCurrencyTotal # type: ignore + from ._models import Catalog # type: ignore + from ._models import CreateGenericQuotaRequestParameters # type: ignore + from ._models import CurrentQuotaLimit # type: ignore + from ._models import CurrentQuotaLimitBase # type: ignore + from ._models import Error # type: ignore + from ._models import ExceptionResponse # type: ignore + from ._models import ExchangeOperationResultResponse # type: ignore + from ._models import ExchangePolicyError # type: ignore + from ._models import ExchangePolicyErrors # type: ignore + from ._models import ExchangeRequest # type: ignore + from ._models import ExchangeRequestProperties # type: ignore + from ._models import ExchangeResponseProperties # type: ignore + from ._models import ExtendedErrorInfo # type: ignore + from ._models import ExtendedStatusInfo # type: ignore + from ._models import MergeRequest # type: ignore + from ._models import OperationDisplay # type: ignore + from ._models import OperationList # type: ignore + from ._models import OperationResponse # type: ignore + from ._models import OperationResultError # type: ignore + from ._models import Patch # type: ignore + from ._models import PatchPropertiesRenewProperties # type: ignore + from ._models import PaymentDetail # type: ignore + from ._models import Price # type: ignore + from ._models import PurchaseRequest # type: ignore + from ._models import PurchaseRequestPropertiesReservedResourceProperties # type: ignore + from ._models import QuotaLimits # type: ignore + from ._models import QuotaLimitsResponse # type: ignore + from ._models import QuotaProperties # type: ignore + from ._models import QuotaRequestDetails # type: ignore + from ._models import QuotaRequestDetailsList # type: ignore + from ._models import QuotaRequestOneResourceSubmitResponse # type: ignore + from ._models import QuotaRequestProperties # type: ignore + from ._models import QuotaRequestSubmitResponse # type: ignore + from ._models import QuotaRequestSubmitResponse201 # type: ignore + from ._models import RenewPropertiesResponse # type: ignore + from ._models import RenewPropertiesResponseBillingCurrencyTotal # type: ignore + from ._models import RenewPropertiesResponsePricingCurrencyTotal # type: ignore + from ._models import ReservationList # type: ignore + from ._models import ReservationMergeProperties # type: ignore + from ._models import ReservationOrderBillingPlanInformation # type: ignore + from ._models import ReservationOrderList # type: ignore + from ._models import ReservationOrderResponse # type: ignore + from ._models import ReservationProperties # type: ignore + from ._models import ReservationResponse # type: ignore + from ._models import ReservationSplitProperties # type: ignore + from ._models import ReservationToExchange # type: ignore + from ._models import ReservationToPurchaseCalculateExchange # type: ignore + from ._models import ReservationToPurchaseExchange # type: ignore + from ._models import ReservationToReturn # type: ignore + from ._models import ReservationToReturnForExchange # type: ignore + from ._models import ResourceName # type: ignore + from ._models import ScopeProperties # type: ignore + from ._models import ServiceError # type: ignore + from ._models import ServiceErrorDetail # type: ignore + from ._models import SkuName # type: ignore + from ._models import SkuProperty # type: ignore + from ._models import SkuRestriction # type: ignore + from ._models import SplitRequest # type: ignore + from ._models import SubRequest # type: ignore + from ._models import SubscriptionScopeProperties # type: ignore + +from ._azure_reservation_api_enums import ( + AppliedScopeType, + CalculateExchangeOperationResultStatus, + ErrorResponseCode, + ExchangeOperationResultStatus, + InstanceFlexibility, + OperationStatus, + PaymentStatus, + QuotaRequestState, + ReservationBillingPlan, + ReservationStatusCode, + ReservationTerm, + ReservedResourceType, + ResourceType, +) + +__all__ = [ + 'AppliedReservationList', + 'AppliedReservations', + 'AvailableScopeProperties', + 'AvailableScopeRequest', + 'AvailableScopeRequestProperties', + 'BillingInformation', + 'CalculateExchangeOperationResultResponse', + 'CalculateExchangeRequest', + 'CalculateExchangeRequestProperties', + 'CalculateExchangeResponseProperties', + 'CalculatePriceResponse', + 'CalculatePriceResponseProperties', + 'CalculatePriceResponsePropertiesBillingCurrencyTotal', + 'CalculatePriceResponsePropertiesPricingCurrencyTotal', + 'Catalog', + 'CreateGenericQuotaRequestParameters', + 'CurrentQuotaLimit', + 'CurrentQuotaLimitBase', + 'Error', + 'ExceptionResponse', + 'ExchangeOperationResultResponse', + 'ExchangePolicyError', + 'ExchangePolicyErrors', + 'ExchangeRequest', + 'ExchangeRequestProperties', + 'ExchangeResponseProperties', + 'ExtendedErrorInfo', + 'ExtendedStatusInfo', + 'MergeRequest', + 'OperationDisplay', + 'OperationList', + 'OperationResponse', + 'OperationResultError', + 'Patch', + 'PatchPropertiesRenewProperties', + 'PaymentDetail', + 'Price', + 'PurchaseRequest', + 'PurchaseRequestPropertiesReservedResourceProperties', + 'QuotaLimits', + 'QuotaLimitsResponse', + 'QuotaProperties', + 'QuotaRequestDetails', + 'QuotaRequestDetailsList', + 'QuotaRequestOneResourceSubmitResponse', + 'QuotaRequestProperties', + 'QuotaRequestSubmitResponse', + 'QuotaRequestSubmitResponse201', + 'RenewPropertiesResponse', + 'RenewPropertiesResponseBillingCurrencyTotal', + 'RenewPropertiesResponsePricingCurrencyTotal', + 'ReservationList', + 'ReservationMergeProperties', + 'ReservationOrderBillingPlanInformation', + 'ReservationOrderList', + 'ReservationOrderResponse', + 'ReservationProperties', + 'ReservationResponse', + 'ReservationSplitProperties', + 'ReservationToExchange', + 'ReservationToPurchaseCalculateExchange', + 'ReservationToPurchaseExchange', + 'ReservationToReturn', + 'ReservationToReturnForExchange', + 'ResourceName', + 'ScopeProperties', + 'ServiceError', + 'ServiceErrorDetail', + 'SkuName', + 'SkuProperty', + 'SkuRestriction', + 'SplitRequest', + 'SubRequest', + 'SubscriptionScopeProperties', + 'AppliedScopeType', + 'CalculateExchangeOperationResultStatus', + 'ErrorResponseCode', + 'ExchangeOperationResultStatus', + 'InstanceFlexibility', + 'OperationStatus', + 'PaymentStatus', + 'QuotaRequestState', + 'ReservationBillingPlan', + 'ReservationStatusCode', + 'ReservationTerm', + 'ReservedResourceType', + 'ResourceType', +] diff --git a/src/reservations/azext_reservations/vendored_sdks/quota/models/_azure_reservation_api_enums.py b/src/reservations/azext_reservations/vendored_sdks/quota/models/_azure_reservation_api_enums.py new file mode 100644 index 00000000000..249f82334c6 --- /dev/null +++ b/src/reservations/azext_reservations/vendored_sdks/quota/models/_azure_reservation_api_enums.py @@ -0,0 +1,208 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum, EnumMeta +from six import with_metaclass + +class _CaseInsensitiveEnumMeta(EnumMeta): + def __getitem__(self, name): + return super().__getitem__(name.upper()) + + def __getattr__(cls, name): + """Return the enum member matching `name` + We use __getattr__ instead of descriptors or inserting into the enum + class' __dict__ in order to support `name` and `value` being both + properties for enum members (which live in the class' __dict__) and + enum members themselves. + """ + try: + return cls._member_map_[name.upper()] + except KeyError: + raise AttributeError(name) + + +class AppliedScopeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Type of the Applied Scope. + """ + + SINGLE = "Single" + SHARED = "Shared" + +class CalculateExchangeOperationResultStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Status of the operation. + """ + + SUCCEEDED = "Succeeded" + FAILED = "Failed" + CANCELLED = "Cancelled" + PENDING = "Pending" + +class ErrorResponseCode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + + NOT_SPECIFIED = "NotSpecified" + INTERNAL_SERVER_ERROR = "InternalServerError" + SERVER_TIMEOUT = "ServerTimeout" + AUTHORIZATION_FAILED = "AuthorizationFailed" + BAD_REQUEST = "BadRequest" + CLIENT_CERTIFICATE_THUMBPRINT_NOT_SET = "ClientCertificateThumbprintNotSet" + INVALID_REQUEST_CONTENT = "InvalidRequestContent" + OPERATION_FAILED = "OperationFailed" + HTTP_METHOD_NOT_SUPPORTED = "HttpMethodNotSupported" + INVALID_REQUEST_URI = "InvalidRequestUri" + MISSING_TENANT_ID = "MissingTenantId" + INVALID_TENANT_ID = "InvalidTenantId" + INVALID_RESERVATION_ORDER_ID = "InvalidReservationOrderId" + INVALID_RESERVATION_ID = "InvalidReservationId" + RESERVATION_ID_NOT_IN_RESERVATION_ORDER = "ReservationIdNotInReservationOrder" + RESERVATION_ORDER_NOT_FOUND = "ReservationOrderNotFound" + INVALID_SUBSCRIPTION_ID = "InvalidSubscriptionId" + INVALID_ACCESS_TOKEN = "InvalidAccessToken" + INVALID_LOCATION_ID = "InvalidLocationId" + UNAUTHENTICATED_REQUESTS_THROTTLED = "UnauthenticatedRequestsThrottled" + INVALID_HEALTH_CHECK_TYPE = "InvalidHealthCheckType" + FORBIDDEN = "Forbidden" + BILLING_SCOPE_ID_CANNOT_BE_CHANGED = "BillingScopeIdCannotBeChanged" + APPLIED_SCOPES_NOT_ASSOCIATED_WITH_COMMERCE_ACCOUNT = "AppliedScopesNotAssociatedWithCommerceAccount" + PATCH_VALUES_SAME_AS_EXISTING = "PatchValuesSameAsExisting" + ROLE_ASSIGNMENT_CREATION_FAILED = "RoleAssignmentCreationFailed" + RESERVATION_ORDER_CREATION_FAILED = "ReservationOrderCreationFailed" + RESERVATION_ORDER_NOT_ENABLED = "ReservationOrderNotEnabled" + CAPACITY_UPDATE_SCOPES_FAILED = "CapacityUpdateScopesFailed" + UNSUPPORTED_RESERVATION_TERM = "UnsupportedReservationTerm" + RESERVATION_ORDER_ID_ALREADY_EXISTS = "ReservationOrderIdAlreadyExists" + RISK_CHECK_FAILED = "RiskCheckFailed" + CREATE_QUOTE_FAILED = "CreateQuoteFailed" + ACTIVATE_QUOTE_FAILED = "ActivateQuoteFailed" + NONSUPPORTED_ACCOUNT_ID = "NonsupportedAccountId" + PAYMENT_INSTRUMENT_NOT_FOUND = "PaymentInstrumentNotFound" + MISSING_APPLIED_SCOPES_FOR_SINGLE = "MissingAppliedScopesForSingle" + NO_VALID_RESERVATIONS_TO_RE_RATE = "NoValidReservationsToReRate" + RE_RATE_ONLY_ALLOWED_FOR_EA = "ReRateOnlyAllowedForEA" + OPERATION_CANNOT_BE_PERFORMED_IN_CURRENT_STATE = "OperationCannotBePerformedInCurrentState" + INVALID_SINGLE_APPLIED_SCOPES_COUNT = "InvalidSingleAppliedScopesCount" + INVALID_FULFILLMENT_REQUEST_PARAMETERS = "InvalidFulfillmentRequestParameters" + NOT_SUPPORTED_COUNTRY = "NotSupportedCountry" + INVALID_REFUND_QUANTITY = "InvalidRefundQuantity" + PURCHASE_ERROR = "PurchaseError" + BILLING_CUSTOMER_INPUT_ERROR = "BillingCustomerInputError" + BILLING_PAYMENT_INSTRUMENT_SOFT_ERROR = "BillingPaymentInstrumentSoftError" + BILLING_PAYMENT_INSTRUMENT_HARD_ERROR = "BillingPaymentInstrumentHardError" + BILLING_TRANSIENT_ERROR = "BillingTransientError" + BILLING_ERROR = "BillingError" + FULFILLMENT_CONFIGURATION_ERROR = "FulfillmentConfigurationError" + FULFILLMENT_OUT_OF_STOCK_ERROR = "FulfillmentOutOfStockError" + FULFILLMENT_TRANSIENT_ERROR = "FulfillmentTransientError" + FULFILLMENT_ERROR = "FulfillmentError" + CALCULATE_PRICE_FAILED = "CalculatePriceFailed" + +class ExchangeOperationResultStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Status of the operation. + """ + + SUCCEEDED = "Succeeded" + FAILED = "Failed" + CANCELLED = "Cancelled" + PENDING_REFUNDS = "PendingRefunds" + PENDING_PURCHASES = "PendingPurchases" + +class InstanceFlexibility(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Turning this on will apply the reservation discount to other VMs in the same VM size group. + Only specify for VirtualMachines reserved resource type. + """ + + ON = "On" + OFF = "Off" + +class OperationStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Status of the individual operation. + """ + + SUCCEEDED = "Succeeded" + FAILED = "Failed" + CANCELLED = "Cancelled" + PENDING = "Pending" + +class PaymentStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Describes whether the payment is completed, failed, cancelled or scheduled in the future. + """ + + SUCCEEDED = "Succeeded" + FAILED = "Failed" + SCHEDULED = "Scheduled" + CANCELLED = "Cancelled" + +class QuotaRequestState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The quota request status. + """ + + ACCEPTED = "Accepted" + INVALID = "Invalid" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + IN_PROGRESS = "InProgress" + +class ReservationBillingPlan(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Represent the billing plans. + """ + + UPFRONT = "Upfront" + MONTHLY = "Monthly" + +class ReservationStatusCode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + + NONE = "None" + PENDING = "Pending" + ACTIVE = "Active" + PURCHASE_ERROR = "PurchaseError" + PAYMENT_INSTRUMENT_ERROR = "PaymentInstrumentError" + SPLIT = "Split" + MERGED = "Merged" + EXPIRED = "Expired" + SUCCEEDED = "Succeeded" + +class ReservationTerm(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Represent the term of Reservation. + """ + + P1_Y = "P1Y" + P3_Y = "P3Y" + +class ReservedResourceType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The type of the resource that is being reserved. + """ + + VIRTUAL_MACHINES = "VirtualMachines" + SQL_DATABASES = "SqlDatabases" + SUSE_LINUX = "SuseLinux" + COSMOS_DB = "CosmosDb" + RED_HAT = "RedHat" + SQL_DATA_WAREHOUSE = "SqlDataWarehouse" + V_MWARE_CLOUD_SIMPLE = "VMwareCloudSimple" + RED_HAT_OSA = "RedHatOsa" + DATABRICKS = "Databricks" + APP_SERVICE = "AppService" + MANAGED_DISK = "ManagedDisk" + BLOCK_BLOB = "BlockBlob" + REDIS_CACHE = "RedisCache" + AZURE_DATA_EXPLORER = "AzureDataExplorer" + MY_SQL = "MySql" + MARIA_DB = "MariaDb" + POSTGRE_SQL = "PostgreSql" + DEDICATED_HOST = "DedicatedHost" + SAP_HANA = "SapHana" + SQL_AZURE_HYBRID_BENEFIT = "SqlAzureHybridBenefit" + +class ResourceType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The resource types. + """ + + STANDARD = "standard" + DEDICATED = "dedicated" + LOW_PRIORITY = "lowPriority" + SHARED = "shared" + SERVICE_SPECIFIC = "serviceSpecific" diff --git a/src/reservations/azext_reservations/vendored_sdks/quota/models/_models.py b/src/reservations/azext_reservations/vendored_sdks/quota/models/_models.py new file mode 100644 index 00000000000..b2b5e3139f7 --- /dev/null +++ b/src/reservations/azext_reservations/vendored_sdks/quota/models/_models.py @@ -0,0 +1,2401 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + + +class AppliedReservationList(msrest.serialization.Model): + """AppliedReservationList. + + :param value: + :type value: list[str] + :param next_link: Url to get the next page of reservations. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[str]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(AppliedReservationList, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class AppliedReservations(msrest.serialization.Model): + """AppliedReservations. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Identifier of the applied reservations. + :vartype id: str + :ivar name: Name of resource. + :vartype name: str + :ivar type: Type of resource. "Microsoft.Capacity/AppliedReservations". + :vartype type: str + :param reservation_order_ids: + :type reservation_order_ids: ~azure_reservation_api.models.AppliedReservationList + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'reservation_order_ids': {'key': 'properties.reservationOrderIds', 'type': 'AppliedReservationList'}, + } + + def __init__( + self, + **kwargs + ): + super(AppliedReservations, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.reservation_order_ids = kwargs.get('reservation_order_ids', None) + + +class AvailableScopeProperties(msrest.serialization.Model): + """AvailableScopeProperties. + + :param properties: + :type properties: ~azure_reservation_api.models.SubscriptionScopeProperties + """ + + _attribute_map = { + 'properties': {'key': 'properties', 'type': 'SubscriptionScopeProperties'}, + } + + def __init__( + self, + **kwargs + ): + super(AvailableScopeProperties, self).__init__(**kwargs) + self.properties = kwargs.get('properties', None) + + +class AvailableScopeRequest(msrest.serialization.Model): + """Available scope. + + :param properties: Available scope request properties. + :type properties: ~azure_reservation_api.models.AvailableScopeRequestProperties + """ + + _attribute_map = { + 'properties': {'key': 'properties', 'type': 'AvailableScopeRequestProperties'}, + } + + def __init__( + self, + **kwargs + ): + super(AvailableScopeRequest, self).__init__(**kwargs) + self.properties = kwargs.get('properties', None) + + +class AvailableScopeRequestProperties(msrest.serialization.Model): + """Available scope request properties. + + :param scopes: + :type scopes: list[str] + """ + + _attribute_map = { + 'scopes': {'key': 'scopes', 'type': '[str]'}, + } + + def __init__( + self, + **kwargs + ): + super(AvailableScopeRequestProperties, self).__init__(**kwargs) + self.scopes = kwargs.get('scopes', None) + + +class BillingInformation(msrest.serialization.Model): + """billing information. + + :param billing_currency_total_paid_amount: + :type billing_currency_total_paid_amount: ~azure_reservation_api.models.Price + :param billing_currency_prorated_amount: + :type billing_currency_prorated_amount: ~azure_reservation_api.models.Price + :param billing_currency_remaining_commitment_amount: + :type billing_currency_remaining_commitment_amount: ~azure_reservation_api.models.Price + """ + + _attribute_map = { + 'billing_currency_total_paid_amount': {'key': 'billingCurrencyTotalPaidAmount', 'type': 'Price'}, + 'billing_currency_prorated_amount': {'key': 'billingCurrencyProratedAmount', 'type': 'Price'}, + 'billing_currency_remaining_commitment_amount': {'key': 'billingCurrencyRemainingCommitmentAmount', 'type': 'Price'}, + } + + def __init__( + self, + **kwargs + ): + super(BillingInformation, self).__init__(**kwargs) + self.billing_currency_total_paid_amount = kwargs.get('billing_currency_total_paid_amount', None) + self.billing_currency_prorated_amount = kwargs.get('billing_currency_prorated_amount', None) + self.billing_currency_remaining_commitment_amount = kwargs.get('billing_currency_remaining_commitment_amount', None) + + +class CalculateExchangeOperationResultResponse(msrest.serialization.Model): + """CalculateExchange operation result. + + :param id: It should match what is used to GET the operation result. + :type id: str + :param name: It must match the last segment of the id field, and will typically be a GUID / + system generated value. + :type name: str + :param status: Status of the operation. Possible values include: "Succeeded", "Failed", + "Cancelled", "Pending". + :type status: str or ~azure_reservation_api.models.CalculateExchangeOperationResultStatus + :param properties: CalculateExchange response properties. + :type properties: ~azure_reservation_api.models.CalculateExchangeResponseProperties + :param error: Required if status == failed or status == canceled. + :type error: ~azure_reservation_api.models.OperationResultError + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'CalculateExchangeResponseProperties'}, + 'error': {'key': 'error', 'type': 'OperationResultError'}, + } + + def __init__( + self, + **kwargs + ): + super(CalculateExchangeOperationResultResponse, self).__init__(**kwargs) + self.id = kwargs.get('id', None) + self.name = kwargs.get('name', None) + self.status = kwargs.get('status', None) + self.properties = kwargs.get('properties', None) + self.error = kwargs.get('error', None) + + +class CalculateExchangeRequest(msrest.serialization.Model): + """Calculate exchange request. + + :param properties: Calculate exchange request properties. + :type properties: ~azure_reservation_api.models.CalculateExchangeRequestProperties + """ + + _attribute_map = { + 'properties': {'key': 'properties', 'type': 'CalculateExchangeRequestProperties'}, + } + + def __init__( + self, + **kwargs + ): + super(CalculateExchangeRequest, self).__init__(**kwargs) + self.properties = kwargs.get('properties', None) + + +class CalculateExchangeRequestProperties(msrest.serialization.Model): + """Calculate exchange request properties. + + :param reservations_to_purchase: List of reservations that are being purchased in this + exchange. + :type reservations_to_purchase: list[~azure_reservation_api.models.PurchaseRequest] + :param reservations_to_exchange: List of reservations that are being returned in this exchange. + :type reservations_to_exchange: list[~azure_reservation_api.models.ReservationToReturn] + """ + + _attribute_map = { + 'reservations_to_purchase': {'key': 'reservationsToPurchase', 'type': '[PurchaseRequest]'}, + 'reservations_to_exchange': {'key': 'reservationsToExchange', 'type': '[ReservationToReturn]'}, + } + + def __init__( + self, + **kwargs + ): + super(CalculateExchangeRequestProperties, self).__init__(**kwargs) + self.reservations_to_purchase = kwargs.get('reservations_to_purchase', None) + self.reservations_to_exchange = kwargs.get('reservations_to_exchange', None) + + +class CalculateExchangeResponseProperties(msrest.serialization.Model): + """CalculateExchange response properties. + + :param session_id: Exchange session identifier. + :type session_id: str + :param net_payable: + :type net_payable: ~azure_reservation_api.models.Price + :param refunds_total: + :type refunds_total: ~azure_reservation_api.models.Price + :param purchases_total: + :type purchases_total: ~azure_reservation_api.models.Price + :param reservations_to_purchase: Details of the reservations being purchased. + :type reservations_to_purchase: + list[~azure_reservation_api.models.ReservationToPurchaseCalculateExchange] + :param reservations_to_exchange: Details of the reservations being returned. + :type reservations_to_exchange: list[~azure_reservation_api.models.ReservationToExchange] + :param policy_result: Exchange policy errors. + :type policy_result: ~azure_reservation_api.models.ExchangePolicyErrors + """ + + _attribute_map = { + 'session_id': {'key': 'sessionId', 'type': 'str'}, + 'net_payable': {'key': 'netPayable', 'type': 'Price'}, + 'refunds_total': {'key': 'refundsTotal', 'type': 'Price'}, + 'purchases_total': {'key': 'purchasesTotal', 'type': 'Price'}, + 'reservations_to_purchase': {'key': 'reservationsToPurchase', 'type': '[ReservationToPurchaseCalculateExchange]'}, + 'reservations_to_exchange': {'key': 'reservationsToExchange', 'type': '[ReservationToExchange]'}, + 'policy_result': {'key': 'policyResult', 'type': 'ExchangePolicyErrors'}, + } + + def __init__( + self, + **kwargs + ): + super(CalculateExchangeResponseProperties, self).__init__(**kwargs) + self.session_id = kwargs.get('session_id', None) + self.net_payable = kwargs.get('net_payable', None) + self.refunds_total = kwargs.get('refunds_total', None) + self.purchases_total = kwargs.get('purchases_total', None) + self.reservations_to_purchase = kwargs.get('reservations_to_purchase', None) + self.reservations_to_exchange = kwargs.get('reservations_to_exchange', None) + self.policy_result = kwargs.get('policy_result', None) + + +class CalculatePriceResponse(msrest.serialization.Model): + """CalculatePriceResponse. + + :param properties: + :type properties: ~azure_reservation_api.models.CalculatePriceResponseProperties + """ + + _attribute_map = { + 'properties': {'key': 'properties', 'type': 'CalculatePriceResponseProperties'}, + } + + def __init__( + self, + **kwargs + ): + super(CalculatePriceResponse, self).__init__(**kwargs) + self.properties = kwargs.get('properties', None) + + +class CalculatePriceResponseProperties(msrest.serialization.Model): + """CalculatePriceResponseProperties. + + :param billing_currency_total: Currency and amount that customer will be charged in customer's + local currency. Tax is not included. + :type billing_currency_total: + ~azure_reservation_api.models.CalculatePriceResponsePropertiesBillingCurrencyTotal + :param is_billing_partner_managed: True if billing is managed by Microsoft Partner. Used only + for CSP accounts. + :type is_billing_partner_managed: bool + :param reservation_order_id: GUID that represents reservation order that can be placed after + calculating price. + :type reservation_order_id: str + :param sku_title: Title of SKU that is being purchased. + :type sku_title: str + :param sku_description: Description of SKU that is being purchased. + :type sku_description: str + :param pricing_currency_total: Amount that Microsoft uses for record. Used during refund for + calculating refund limit. Tax is not included. + :type pricing_currency_total: + ~azure_reservation_api.models.CalculatePriceResponsePropertiesPricingCurrencyTotal + :param payment_schedule: + :type payment_schedule: list[~azure_reservation_api.models.PaymentDetail] + """ + + _attribute_map = { + 'billing_currency_total': {'key': 'billingCurrencyTotal', 'type': 'CalculatePriceResponsePropertiesBillingCurrencyTotal'}, + 'is_billing_partner_managed': {'key': 'isBillingPartnerManaged', 'type': 'bool'}, + 'reservation_order_id': {'key': 'reservationOrderId', 'type': 'str'}, + 'sku_title': {'key': 'skuTitle', 'type': 'str'}, + 'sku_description': {'key': 'skuDescription', 'type': 'str'}, + 'pricing_currency_total': {'key': 'pricingCurrencyTotal', 'type': 'CalculatePriceResponsePropertiesPricingCurrencyTotal'}, + 'payment_schedule': {'key': 'paymentSchedule', 'type': '[PaymentDetail]'}, + } + + def __init__( + self, + **kwargs + ): + super(CalculatePriceResponseProperties, self).__init__(**kwargs) + self.billing_currency_total = kwargs.get('billing_currency_total', None) + self.is_billing_partner_managed = kwargs.get('is_billing_partner_managed', None) + self.reservation_order_id = kwargs.get('reservation_order_id', None) + self.sku_title = kwargs.get('sku_title', None) + self.sku_description = kwargs.get('sku_description', None) + self.pricing_currency_total = kwargs.get('pricing_currency_total', None) + self.payment_schedule = kwargs.get('payment_schedule', None) + + +class CalculatePriceResponsePropertiesBillingCurrencyTotal(msrest.serialization.Model): + """Currency and amount that customer will be charged in customer's local currency. Tax is not included. + + :param currency_code: + :type currency_code: str + :param amount: + :type amount: float + """ + + _attribute_map = { + 'currency_code': {'key': 'currencyCode', 'type': 'str'}, + 'amount': {'key': 'amount', 'type': 'float'}, + } + + def __init__( + self, + **kwargs + ): + super(CalculatePriceResponsePropertiesBillingCurrencyTotal, self).__init__(**kwargs) + self.currency_code = kwargs.get('currency_code', None) + self.amount = kwargs.get('amount', None) + + +class CalculatePriceResponsePropertiesPricingCurrencyTotal(msrest.serialization.Model): + """Amount that Microsoft uses for record. Used during refund for calculating refund limit. Tax is not included. + + :param currency_code: + :type currency_code: str + :param amount: + :type amount: float + """ + + _attribute_map = { + 'currency_code': {'key': 'currencyCode', 'type': 'str'}, + 'amount': {'key': 'amount', 'type': 'float'}, + } + + def __init__( + self, + **kwargs + ): + super(CalculatePriceResponsePropertiesPricingCurrencyTotal, self).__init__(**kwargs) + self.currency_code = kwargs.get('currency_code', None) + self.amount = kwargs.get('amount', None) + + +class Catalog(msrest.serialization.Model): + """Catalog. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar resource_type: The type of resource the SKU applies to. + :vartype resource_type: str + :ivar name: The name of SKU. + :vartype name: str + :param billing_plans: The billing plan options available for this SKU. + :type billing_plans: dict[str, list[str or + ~azure_reservation_api.models.ReservationBillingPlan]] + :ivar terms: Available reservation terms for this resource. + :vartype terms: list[str or ~azure_reservation_api.models.ReservationTerm] + :ivar locations: + :vartype locations: list[str] + :ivar sku_properties: + :vartype sku_properties: list[~azure_reservation_api.models.SkuProperty] + :ivar restrictions: + :vartype restrictions: list[~azure_reservation_api.models.SkuRestriction] + """ + + _validation = { + 'resource_type': {'readonly': True}, + 'name': {'readonly': True}, + 'terms': {'readonly': True}, + 'locations': {'readonly': True}, + 'sku_properties': {'readonly': True}, + 'restrictions': {'readonly': True}, + } + + _attribute_map = { + 'resource_type': {'key': 'resourceType', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'billing_plans': {'key': 'billingPlans', 'type': '{[str]}'}, + 'terms': {'key': 'terms', 'type': '[str]'}, + 'locations': {'key': 'locations', 'type': '[str]'}, + 'sku_properties': {'key': 'skuProperties', 'type': '[SkuProperty]'}, + 'restrictions': {'key': 'restrictions', 'type': '[SkuRestriction]'}, + } + + def __init__( + self, + **kwargs + ): + super(Catalog, self).__init__(**kwargs) + self.resource_type = None + self.name = None + self.billing_plans = kwargs.get('billing_plans', None) + self.terms = None + self.locations = None + self.sku_properties = None + self.restrictions = None + + +class CreateGenericQuotaRequestParameters(msrest.serialization.Model): + """Quota change requests information. + + :param value: Quota change requests. + :type value: list[~azure_reservation_api.models.CurrentQuotaLimitBase] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[CurrentQuotaLimitBase]'}, + } + + def __init__( + self, + **kwargs + ): + super(CreateGenericQuotaRequestParameters, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + + +class CurrentQuotaLimit(msrest.serialization.Model): + """Current quota limits. + + 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: + "Accepted", "Invalid", "Succeeded", "Failed", "InProgress". + :vartype provisioning_state: str or ~azure_reservation_api.models.QuotaRequestState + :ivar message: A user friendly message. + :vartype message: str + :param properties: Quota properties for the resource. + :type properties: ~azure_reservation_api.models.QuotaProperties + """ + + _validation = { + 'provisioning_state': {'readonly': True}, + 'message': {'readonly': True}, + } + + _attribute_map = { + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'message': {'key': 'properties.message', 'type': 'str'}, + 'properties': {'key': 'quotaInformation.properties', 'type': 'QuotaProperties'}, + } + + def __init__( + self, + **kwargs + ): + super(CurrentQuotaLimit, self).__init__(**kwargs) + self.provisioning_state = None + self.message = None + self.properties = kwargs.get('properties', None) + + +class CurrentQuotaLimitBase(msrest.serialization.Model): + """Quota properties. + + :param properties: Quota properties for the resource. + :type properties: ~azure_reservation_api.models.QuotaProperties + """ + + _attribute_map = { + 'properties': {'key': 'properties', 'type': 'QuotaProperties'}, + } + + def __init__( + self, + **kwargs + ): + super(CurrentQuotaLimitBase, self).__init__(**kwargs) + self.properties = kwargs.get('properties', None) + + +class Error(msrest.serialization.Model): + """Error. + + :param error: + :type error: ~azure_reservation_api.models.ExtendedErrorInfo + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ExtendedErrorInfo'}, + } + + def __init__( + self, + **kwargs + ): + super(Error, self).__init__(**kwargs) + self.error = kwargs.get('error', None) + + +class ExceptionResponse(msrest.serialization.Model): + """The API error. + + :param error: The API error details. + :type error: ~azure_reservation_api.models.ServiceError + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ServiceError'}, + } + + def __init__( + self, + **kwargs + ): + super(ExceptionResponse, self).__init__(**kwargs) + self.error = kwargs.get('error', None) + + +class ExchangeOperationResultResponse(msrest.serialization.Model): + """Exchange operation result. + + :param id: It should match what is used to GET the operation result. + :type id: str + :param name: It must match the last segment of the id field, and will typically be a GUID / + system generated value. + :type name: str + :param status: Status of the operation. Possible values include: "Succeeded", "Failed", + "Cancelled", "PendingRefunds", "PendingPurchases". + :type status: str or ~azure_reservation_api.models.ExchangeOperationResultStatus + :param properties: Exchange response properties. + :type properties: ~azure_reservation_api.models.ExchangeResponseProperties + :param error: Required if status == failed or status == canceled. + :type error: ~azure_reservation_api.models.OperationResultError + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'ExchangeResponseProperties'}, + 'error': {'key': 'error', 'type': 'OperationResultError'}, + } + + def __init__( + self, + **kwargs + ): + super(ExchangeOperationResultResponse, self).__init__(**kwargs) + self.id = kwargs.get('id', None) + self.name = kwargs.get('name', None) + self.status = kwargs.get('status', None) + self.properties = kwargs.get('properties', None) + self.error = kwargs.get('error', None) + + +class ExchangePolicyError(msrest.serialization.Model): + """error details. + + :param code: + :type code: str + :param message: + :type message: str + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ExchangePolicyError, self).__init__(**kwargs) + self.code = kwargs.get('code', None) + self.message = kwargs.get('message', None) + + +class ExchangePolicyErrors(msrest.serialization.Model): + """Exchange policy errors. + + :param policy_errors: Exchange Policy errors. + :type policy_errors: list[~azure_reservation_api.models.ExchangePolicyError] + """ + + _attribute_map = { + 'policy_errors': {'key': 'policyErrors', 'type': '[ExchangePolicyError]'}, + } + + def __init__( + self, + **kwargs + ): + super(ExchangePolicyErrors, self).__init__(**kwargs) + self.policy_errors = kwargs.get('policy_errors', None) + + +class ExchangeRequest(msrest.serialization.Model): + """Exchange request. + + :param properties: Exchange request properties. + :type properties: ~azure_reservation_api.models.ExchangeRequestProperties + """ + + _attribute_map = { + 'properties': {'key': 'properties', 'type': 'ExchangeRequestProperties'}, + } + + def __init__( + self, + **kwargs + ): + super(ExchangeRequest, self).__init__(**kwargs) + self.properties = kwargs.get('properties', None) + + +class ExchangeRequestProperties(msrest.serialization.Model): + """Exchange request properties. + + :param session_id: SessionId that was returned by CalculateExchange API. + :type session_id: str + """ + + _attribute_map = { + 'session_id': {'key': 'sessionId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ExchangeRequestProperties, self).__init__(**kwargs) + self.session_id = kwargs.get('session_id', None) + + +class ExchangeResponseProperties(msrest.serialization.Model): + """Exchange response properties. + + :param session_id: Exchange session identifier. + :type session_id: str + :param net_payable: + :type net_payable: ~azure_reservation_api.models.Price + :param refunds_total: + :type refunds_total: ~azure_reservation_api.models.Price + :param purchases_total: + :type purchases_total: ~azure_reservation_api.models.Price + :param reservations_to_purchase: Details of the reservations being purchased. + :type reservations_to_purchase: + list[~azure_reservation_api.models.ReservationToPurchaseExchange] + :param reservations_to_exchange: Details of the reservations being returned. + :type reservations_to_exchange: + list[~azure_reservation_api.models.ReservationToReturnForExchange] + :param policy_result: Exchange policy errors. + :type policy_result: ~azure_reservation_api.models.ExchangePolicyErrors + """ + + _attribute_map = { + 'session_id': {'key': 'sessionId', 'type': 'str'}, + 'net_payable': {'key': 'netPayable', 'type': 'Price'}, + 'refunds_total': {'key': 'refundsTotal', 'type': 'Price'}, + 'purchases_total': {'key': 'purchasesTotal', 'type': 'Price'}, + 'reservations_to_purchase': {'key': 'reservationsToPurchase', 'type': '[ReservationToPurchaseExchange]'}, + 'reservations_to_exchange': {'key': 'reservationsToExchange', 'type': '[ReservationToReturnForExchange]'}, + 'policy_result': {'key': 'policyResult', 'type': 'ExchangePolicyErrors'}, + } + + def __init__( + self, + **kwargs + ): + super(ExchangeResponseProperties, self).__init__(**kwargs) + self.session_id = kwargs.get('session_id', None) + self.net_payable = kwargs.get('net_payable', None) + self.refunds_total = kwargs.get('refunds_total', None) + self.purchases_total = kwargs.get('purchases_total', None) + self.reservations_to_purchase = kwargs.get('reservations_to_purchase', None) + self.reservations_to_exchange = kwargs.get('reservations_to_exchange', None) + self.policy_result = kwargs.get('policy_result', None) + + +class ExtendedErrorInfo(msrest.serialization.Model): + """ExtendedErrorInfo. + + :param code: Possible values include: "NotSpecified", "InternalServerError", "ServerTimeout", + "AuthorizationFailed", "BadRequest", "ClientCertificateThumbprintNotSet", + "InvalidRequestContent", "OperationFailed", "HttpMethodNotSupported", "InvalidRequestUri", + "MissingTenantId", "InvalidTenantId", "InvalidReservationOrderId", "InvalidReservationId", + "ReservationIdNotInReservationOrder", "ReservationOrderNotFound", "InvalidSubscriptionId", + "InvalidAccessToken", "InvalidLocationId", "UnauthenticatedRequestsThrottled", + "InvalidHealthCheckType", "Forbidden", "BillingScopeIdCannotBeChanged", + "AppliedScopesNotAssociatedWithCommerceAccount", "PatchValuesSameAsExisting", + "RoleAssignmentCreationFailed", "ReservationOrderCreationFailed", "ReservationOrderNotEnabled", + "CapacityUpdateScopesFailed", "UnsupportedReservationTerm", "ReservationOrderIdAlreadyExists", + "RiskCheckFailed", "CreateQuoteFailed", "ActivateQuoteFailed", "NonsupportedAccountId", + "PaymentInstrumentNotFound", "MissingAppliedScopesForSingle", "NoValidReservationsToReRate", + "ReRateOnlyAllowedForEA", "OperationCannotBePerformedInCurrentState", + "InvalidSingleAppliedScopesCount", "InvalidFulfillmentRequestParameters", + "NotSupportedCountry", "InvalidRefundQuantity", "PurchaseError", "BillingCustomerInputError", + "BillingPaymentInstrumentSoftError", "BillingPaymentInstrumentHardError", + "BillingTransientError", "BillingError", "FulfillmentConfigurationError", + "FulfillmentOutOfStockError", "FulfillmentTransientError", "FulfillmentError", + "CalculatePriceFailed". + :type code: str or ~azure_reservation_api.models.ErrorResponseCode + :param message: + :type message: str + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ExtendedErrorInfo, self).__init__(**kwargs) + self.code = kwargs.get('code', None) + self.message = kwargs.get('message', None) + + +class ExtendedStatusInfo(msrest.serialization.Model): + """ExtendedStatusInfo. + + :param status_code: Possible values include: "None", "Pending", "Active", "PurchaseError", + "PaymentInstrumentError", "Split", "Merged", "Expired", "Succeeded". + :type status_code: str or ~azure_reservation_api.models.ReservationStatusCode + :param message: The message giving detailed information about the status code. + :type message: str + """ + + _attribute_map = { + 'status_code': {'key': 'statusCode', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ExtendedStatusInfo, self).__init__(**kwargs) + self.status_code = kwargs.get('status_code', None) + self.message = kwargs.get('message', None) + + +class MergeRequest(msrest.serialization.Model): + """MergeRequest. + + :param sources: Format of the resource id should be + /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}. + :type sources: list[str] + """ + + _attribute_map = { + 'sources': {'key': 'properties.sources', 'type': '[str]'}, + } + + def __init__( + self, + **kwargs + ): + super(MergeRequest, self).__init__(**kwargs) + self.sources = kwargs.get('sources', None) + + +class OperationDisplay(msrest.serialization.Model): + """OperationDisplay. + + :param provider: + :type provider: str + :param resource: + :type resource: str + :param operation: + :type operation: str + :param description: + :type description: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationDisplay, self).__init__(**kwargs) + self.provider = kwargs.get('provider', None) + self.resource = kwargs.get('resource', None) + self.operation = kwargs.get('operation', None) + self.description = kwargs.get('description', None) + + +class OperationList(msrest.serialization.Model): + """OperationList. + + :param value: + :type value: list[~azure_reservation_api.models.OperationResponse] + :param next_link: Url to get the next page of items. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[OperationResponse]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationList, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class OperationResponse(msrest.serialization.Model): + """OperationResponse. + + :param name: + :type name: str + :param display: + :type display: ~azure_reservation_api.models.OperationDisplay + :param origin: + :type origin: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + 'origin': {'key': 'origin', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationResponse, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.display = kwargs.get('display', None) + self.origin = kwargs.get('origin', None) + + +class OperationResultError(msrest.serialization.Model): + """Required if status == failed or status == canceled. + + :param code: Required if status == failed or status == cancelled. If status == failed, provide + an invariant error code used for error troubleshooting, aggregation, and analysis. + :type code: str + :param message: Required if status == failed. Localized. If status == failed, provide an + actionable error message indicating what error occurred, and what the user can do to address + the issue. + :type message: str + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationResultError, self).__init__(**kwargs) + self.code = kwargs.get('code', None) + self.message = kwargs.get('message', None) + + +class Patch(msrest.serialization.Model): + """Patch. + + :param applied_scope_type: Type of the Applied Scope. Possible values include: "Single", + "Shared". + :type applied_scope_type: str or ~azure_reservation_api.models.AppliedScopeType + :param applied_scopes: List of the subscriptions that the benefit will be applied. Do not + specify if AppliedScopeType is Shared. + :type applied_scopes: list[str] + :param 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". + :type instance_flexibility: str or ~azure_reservation_api.models.InstanceFlexibility + :param name: Name of the Reservation. + :type name: str + :param renew: Setting this to true will automatically purchase a new reservation on the + expiration date time. + :type renew: bool + :param renew_properties: + :type renew_properties: ~azure_reservation_api.models.PatchPropertiesRenewProperties + """ + + _attribute_map = { + 'applied_scope_type': {'key': 'properties.appliedScopeType', 'type': 'str'}, + 'applied_scopes': {'key': 'properties.appliedScopes', 'type': '[str]'}, + 'instance_flexibility': {'key': 'properties.instanceFlexibility', 'type': 'str'}, + 'name': {'key': 'properties.name', 'type': 'str'}, + 'renew': {'key': 'properties.renew', 'type': 'bool'}, + 'renew_properties': {'key': 'properties.renewProperties', 'type': 'PatchPropertiesRenewProperties'}, + } + + def __init__( + self, + **kwargs + ): + super(Patch, self).__init__(**kwargs) + self.applied_scope_type = kwargs.get('applied_scope_type', None) + self.applied_scopes = kwargs.get('applied_scopes', None) + self.instance_flexibility = kwargs.get('instance_flexibility', None) + self.name = kwargs.get('name', None) + self.renew = kwargs.get('renew', False) + self.renew_properties = kwargs.get('renew_properties', None) + + +class PatchPropertiesRenewProperties(msrest.serialization.Model): + """PatchPropertiesRenewProperties. + + :param purchase_properties: + :type purchase_properties: ~azure_reservation_api.models.PurchaseRequest + """ + + _attribute_map = { + 'purchase_properties': {'key': 'purchaseProperties', 'type': 'PurchaseRequest'}, + } + + def __init__( + self, + **kwargs + ): + super(PatchPropertiesRenewProperties, self).__init__(**kwargs) + self.purchase_properties = kwargs.get('purchase_properties', None) + + +class PaymentDetail(msrest.serialization.Model): + """Information about payment related to a reservation order. + + :param due_date: Date when the payment needs to be done. + :type due_date: ~datetime.date + :param payment_date: Date when the transaction is completed. Is null when it is scheduled. + :type payment_date: ~datetime.date + :param pricing_currency_total: Amount in pricing currency. Tax not included. + :type pricing_currency_total: ~azure_reservation_api.models.Price + :param billing_currency_total: Amount charged in Billing currency. Tax not included. Is null + for future payments. + :type billing_currency_total: ~azure_reservation_api.models.Price + :param billing_account: Shows the Account that is charged for this payment. + :type billing_account: str + :param status: Describes whether the payment is completed, failed, cancelled or scheduled in + the future. Possible values include: "Succeeded", "Failed", "Scheduled", "Cancelled". + :type status: str or ~azure_reservation_api.models.PaymentStatus + :param extended_status_info: + :type extended_status_info: ~azure_reservation_api.models.ExtendedStatusInfo + """ + + _attribute_map = { + 'due_date': {'key': 'dueDate', 'type': 'date'}, + 'payment_date': {'key': 'paymentDate', 'type': 'date'}, + 'pricing_currency_total': {'key': 'pricingCurrencyTotal', 'type': 'Price'}, + 'billing_currency_total': {'key': 'billingCurrencyTotal', 'type': 'Price'}, + 'billing_account': {'key': 'billingAccount', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'extended_status_info': {'key': 'extendedStatusInfo', 'type': 'ExtendedStatusInfo'}, + } + + def __init__( + self, + **kwargs + ): + super(PaymentDetail, self).__init__(**kwargs) + self.due_date = kwargs.get('due_date', None) + self.payment_date = kwargs.get('payment_date', None) + self.pricing_currency_total = kwargs.get('pricing_currency_total', None) + self.billing_currency_total = kwargs.get('billing_currency_total', None) + self.billing_account = kwargs.get('billing_account', None) + self.status = kwargs.get('status', None) + self.extended_status_info = kwargs.get('extended_status_info', None) + + +class Price(msrest.serialization.Model): + """Price. + + :param currency_code: The ISO 4217 3-letter currency code for the currency used by this + purchase record. + :type currency_code: str + :param amount: + :type amount: float + """ + + _attribute_map = { + 'currency_code': {'key': 'currencyCode', 'type': 'str'}, + 'amount': {'key': 'amount', 'type': 'float'}, + } + + def __init__( + self, + **kwargs + ): + super(Price, self).__init__(**kwargs) + self.currency_code = kwargs.get('currency_code', None) + self.amount = kwargs.get('amount', None) + + +class PurchaseRequest(msrest.serialization.Model): + """PurchaseRequest. + + :param sku: + :type sku: ~azure_reservation_api.models.SkuName + :param location: The Azure Region where the reserved resource lives. + :type location: str + :param 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". + :type reserved_resource_type: str or ~azure_reservation_api.models.ReservedResourceType + :param billing_scope_id: Subscription that will be charged for purchasing Reservation. + :type billing_scope_id: str + :param term: Represent the term of Reservation. Possible values include: "P1Y", "P3Y". + :type term: str or ~azure_reservation_api.models.ReservationTerm + :param billing_plan: Represent the billing plans. Possible values include: "Upfront", + "Monthly". + :type billing_plan: str or ~azure_reservation_api.models.ReservationBillingPlan + :param quantity: Quantity of the SKUs that are part of the Reservation. Must be greater than + zero. + :type quantity: int + :param display_name: Friendly name of the Reservation. + :type display_name: str + :param applied_scope_type: Type of the Applied Scope. Possible values include: "Single", + "Shared". + :type applied_scope_type: str or ~azure_reservation_api.models.AppliedScopeType + :param applied_scopes: List of the subscriptions that the benefit will be applied. Do not + specify if AppliedScopeType is Shared. + :type applied_scopes: list[str] + :param renew: Setting this to true will automatically purchase a new reservation on the + expiration date time. + :type renew: bool + :param reserved_resource_properties: Properties specific to each reserved resource type. Not + required if not applicable. + :type reserved_resource_properties: + ~azure_reservation_api.models.PurchaseRequestPropertiesReservedResourceProperties + """ + + _attribute_map = { + 'sku': {'key': 'sku', 'type': 'SkuName'}, + 'location': {'key': 'location', 'type': 'str'}, + 'reserved_resource_type': {'key': 'properties.reservedResourceType', 'type': 'str'}, + 'billing_scope_id': {'key': 'properties.billingScopeId', 'type': 'str'}, + 'term': {'key': 'properties.term', 'type': 'str'}, + 'billing_plan': {'key': 'properties.billingPlan', 'type': 'str'}, + 'quantity': {'key': 'properties.quantity', 'type': 'int'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'applied_scope_type': {'key': 'properties.appliedScopeType', 'type': 'str'}, + 'applied_scopes': {'key': 'properties.appliedScopes', 'type': '[str]'}, + 'renew': {'key': 'properties.renew', 'type': 'bool'}, + 'reserved_resource_properties': {'key': 'properties.reservedResourceProperties', 'type': 'PurchaseRequestPropertiesReservedResourceProperties'}, + } + + def __init__( + self, + **kwargs + ): + super(PurchaseRequest, self).__init__(**kwargs) + self.sku = kwargs.get('sku', None) + self.location = kwargs.get('location', None) + self.reserved_resource_type = kwargs.get('reserved_resource_type', None) + self.billing_scope_id = kwargs.get('billing_scope_id', None) + self.term = kwargs.get('term', None) + self.billing_plan = kwargs.get('billing_plan', None) + self.quantity = kwargs.get('quantity', None) + self.display_name = kwargs.get('display_name', None) + self.applied_scope_type = kwargs.get('applied_scope_type', None) + self.applied_scopes = kwargs.get('applied_scopes', None) + self.renew = kwargs.get('renew', False) + self.reserved_resource_properties = kwargs.get('reserved_resource_properties', None) + + +class PurchaseRequestPropertiesReservedResourceProperties(msrest.serialization.Model): + """Properties specific to each reserved resource type. Not required if not applicable. + + :param 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". + :type instance_flexibility: str or ~azure_reservation_api.models.InstanceFlexibility + """ + + _attribute_map = { + 'instance_flexibility': {'key': 'instanceFlexibility', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(PurchaseRequestPropertiesReservedResourceProperties, self).__init__(**kwargs) + self.instance_flexibility = kwargs.get('instance_flexibility', None) + + +class QuotaLimits(msrest.serialization.Model): + """Quota limits. + + :param value: List of quotas (service limits). + :type value: list[~azure_reservation_api.models.CurrentQuotaLimitBase] + :param next_link: The URI for fetching the next page of quotas (service limits). When no more + pages exist, the value is null. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[CurrentQuotaLimitBase]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(QuotaLimits, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class QuotaLimitsResponse(msrest.serialization.Model): + """Quotas (service limits) in the request response. + + :param value: List of quotas with the quota request status. + :type value: list[~azure_reservation_api.models.CurrentQuotaLimit] + :param next_link: The URI for fetching the next page of quota limits. When no more pages exist, + the value is null. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[CurrentQuotaLimit]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(QuotaLimitsResponse, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class QuotaProperties(msrest.serialization.Model): + """Quota properties for the resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param limit: Quota properties. + :type limit: int + :ivar current_value: Current usage value for the resource. + :vartype current_value: int + :param unit: The limit units, such as **count** and **bytes**. Use the unit field provided in + the response of the GET quota operation. + :type unit: str + :param name: Name of the resource provide by the resource provider. Use this property for + quotaRequests resource operations. + :type name: ~azure_reservation_api.models.ResourceName + :param resource_type: The name of the resource type. Possible values include: "standard", + "dedicated", "lowPriority", "shared", "serviceSpecific". + :type resource_type: str or ~azure_reservation_api.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 + optional because, for some resources such as compute, the time period is irrelevant. + :vartype quota_period: str + :param properties: Additional properties for the specified resource provider. + :type properties: object + """ + + _validation = { + 'current_value': {'readonly': True}, + 'quota_period': {'readonly': True}, + } + + _attribute_map = { + 'limit': {'key': 'limit', 'type': 'int'}, + 'current_value': {'key': 'currentValue', 'type': 'int'}, + 'unit': {'key': 'unit', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'ResourceName'}, + 'resource_type': {'key': 'resourceType', 'type': 'str'}, + 'quota_period': {'key': 'quotaPeriod', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'object'}, + } + + def __init__( + self, + **kwargs + ): + super(QuotaProperties, self).__init__(**kwargs) + self.limit = kwargs.get('limit', None) + self.current_value = None + self.unit = kwargs.get('unit', None) + self.name = kwargs.get('name', None) + self.resource_type = kwargs.get('resource_type', None) + self.quota_period = None + self.properties = kwargs.get('properties', None) + + +class QuotaRequestDetails(msrest.serialization.Model): + """Quota request details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Quota request ID. + :vartype id: str + :ivar name: Quota request name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :param provisioning_state: The quota request status. Possible values include: "Accepted", + "Invalid", "Succeeded", "Failed", "InProgress". + :type provisioning_state: str or ~azure_reservation_api.models.QuotaRequestState + :ivar message: User friendly status message. + :vartype message: str + :ivar request_submit_time: The time when the quota request was submitted using format: yyyy-MM- + ddTHH:mm:ssZ as specified by the ISO 8601 standard. + :vartype request_submit_time: ~datetime.datetime + :param value: The quotaRequests. + :type value: list[~azure_reservation_api.models.SubRequest] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'message': {'readonly': True}, + 'request_submit_time': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'message': {'key': 'properties.message', 'type': 'str'}, + 'request_submit_time': {'key': 'properties.requestSubmitTime', 'type': 'iso-8601'}, + 'value': {'key': 'properties.value', 'type': '[SubRequest]'}, + } + + def __init__( + self, + **kwargs + ): + super(QuotaRequestDetails, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.provisioning_state = kwargs.get('provisioning_state', None) + self.message = None + self.request_submit_time = None + self.value = kwargs.get('value', None) + + +class QuotaRequestDetailsList(msrest.serialization.Model): + """Quota request details. + + :param value: The quota requests. + :type value: list[~azure_reservation_api.models.QuotaRequestDetails] + :param next_link: The URI to fetch the next page of quota limits. When there are no more pages, + this is null. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[QuotaRequestDetails]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(QuotaRequestDetailsList, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class QuotaRequestOneResourceSubmitResponse(msrest.serialization.Model): + """Response for the quota submission request. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The quota request ID. + :vartype id: str + :ivar name: The name of the quota request. + :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". + :vartype provisioning_state: str or ~azure_reservation_api.models.QuotaRequestState + :ivar message: User friendly status message. + :vartype message: str + :ivar request_submit_time: The time when the quota request was submitted using format: yyyy-MM- + ddTHH:mm:ssZ as specified by the ISO 8601 standard. + :vartype request_submit_time: ~datetime.datetime + :param properties: Quota properties for the resource. + :type properties: ~azure_reservation_api.models.QuotaProperties + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'message': {'readonly': True}, + 'request_submit_time': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'message': {'key': 'properties.message', 'type': 'str'}, + 'request_submit_time': {'key': 'properties.requestSubmitTime', 'type': 'iso-8601'}, + 'properties': {'key': 'properties.properties.properties', 'type': 'QuotaProperties'}, + } + + def __init__( + self, + **kwargs + ): + super(QuotaRequestOneResourceSubmitResponse, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.provisioning_state = None + self.message = None + self.request_submit_time = None + self.properties = kwargs.get('properties', None) + + +class QuotaRequestProperties(msrest.serialization.Model): + """The details of quota request. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param provisioning_state: The quota request status. Possible values include: "Accepted", + "Invalid", "Succeeded", "Failed", "InProgress". + :type provisioning_state: str or ~azure_reservation_api.models.QuotaRequestState + :ivar message: User friendly status message. + :vartype message: str + :ivar request_submit_time: The time when the quota request was submitted using format: yyyy-MM- + ddTHH:mm:ssZ as specified by the ISO 8601 standard. + :vartype request_submit_time: ~datetime.datetime + :param value: The quotaRequests. + :type value: list[~azure_reservation_api.models.SubRequest] + """ + + _validation = { + 'message': {'readonly': True}, + 'request_submit_time': {'readonly': True}, + } + + _attribute_map = { + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'request_submit_time': {'key': 'requestSubmitTime', 'type': 'iso-8601'}, + 'value': {'key': 'value', 'type': '[SubRequest]'}, + } + + def __init__( + self, + **kwargs + ): + super(QuotaRequestProperties, self).__init__(**kwargs) + self.provisioning_state = kwargs.get('provisioning_state', None) + self.message = None + self.request_submit_time = None + self.value = kwargs.get('value', None) + + +class QuotaRequestSubmitResponse(msrest.serialization.Model): + """Response for the quota submission request. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The quota request ID. + :vartype id: str + :ivar name: The name of the quota request. + :vartype name: str + :param properties: The quota request details. + :type properties: ~azure_reservation_api.models.QuotaRequestProperties + :ivar type: Type of resource. "Microsoft.Capacity/serviceLimits". + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'QuotaRequestProperties'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(QuotaRequestSubmitResponse, self).__init__(**kwargs) + self.id = None + self.name = None + self.properties = kwargs.get('properties', None) + self.type = None + + +class QuotaRequestSubmitResponse201(msrest.serialization.Model): + """Response with request ID that the quota request was accepted. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The quota request ID. Use the requestId parameter to check the request status. + :vartype id: str + :ivar name: Operation ID. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar provisioning_state: The details of the quota request status. Possible values include: + "Accepted", "Invalid", "Succeeded", "Failed", "InProgress". + :vartype provisioning_state: str or ~azure_reservation_api.models.QuotaRequestState + :ivar message: A user friendly message. + :vartype message: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'message': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'message': {'key': 'properties.message', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(QuotaRequestSubmitResponse201, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.provisioning_state = None + self.message = None + + +class RenewPropertiesResponse(msrest.serialization.Model): + """RenewPropertiesResponse. + + :param purchase_properties: + :type purchase_properties: ~azure_reservation_api.models.PurchaseRequest + :param pricing_currency_total: Amount that Microsoft uses for record. Used during refund for + calculating refund limit. Tax is not included. This is locked price 30 days before expiry. + :type pricing_currency_total: + ~azure_reservation_api.models.RenewPropertiesResponsePricingCurrencyTotal + :param billing_currency_total: Currency and amount that customer will be charged in customer's + local currency for renewal purchase. Tax is not included. + :type billing_currency_total: + ~azure_reservation_api.models.RenewPropertiesResponseBillingCurrencyTotal + """ + + _attribute_map = { + 'purchase_properties': {'key': 'purchaseProperties', 'type': 'PurchaseRequest'}, + 'pricing_currency_total': {'key': 'pricingCurrencyTotal', 'type': 'RenewPropertiesResponsePricingCurrencyTotal'}, + 'billing_currency_total': {'key': 'billingCurrencyTotal', 'type': 'RenewPropertiesResponseBillingCurrencyTotal'}, + } + + def __init__( + self, + **kwargs + ): + super(RenewPropertiesResponse, self).__init__(**kwargs) + self.purchase_properties = kwargs.get('purchase_properties', None) + self.pricing_currency_total = kwargs.get('pricing_currency_total', None) + self.billing_currency_total = kwargs.get('billing_currency_total', None) + + +class RenewPropertiesResponseBillingCurrencyTotal(msrest.serialization.Model): + """Currency and amount that customer will be charged in customer's local currency for renewal purchase. Tax is not included. + + :param currency_code: + :type currency_code: str + :param amount: + :type amount: float + """ + + _attribute_map = { + 'currency_code': {'key': 'currencyCode', 'type': 'str'}, + 'amount': {'key': 'amount', 'type': 'float'}, + } + + def __init__( + self, + **kwargs + ): + super(RenewPropertiesResponseBillingCurrencyTotal, self).__init__(**kwargs) + self.currency_code = kwargs.get('currency_code', None) + self.amount = kwargs.get('amount', None) + + +class RenewPropertiesResponsePricingCurrencyTotal(msrest.serialization.Model): + """Amount that Microsoft uses for record. Used during refund for calculating refund limit. Tax is not included. This is locked price 30 days before expiry. + + :param currency_code: + :type currency_code: str + :param amount: + :type amount: float + """ + + _attribute_map = { + 'currency_code': {'key': 'currencyCode', 'type': 'str'}, + 'amount': {'key': 'amount', 'type': 'float'}, + } + + def __init__( + self, + **kwargs + ): + super(RenewPropertiesResponsePricingCurrencyTotal, self).__init__(**kwargs) + self.currency_code = kwargs.get('currency_code', None) + self.amount = kwargs.get('amount', None) + + +class ReservationList(msrest.serialization.Model): + """ReservationList. + + :param value: + :type value: list[~azure_reservation_api.models.ReservationResponse] + :param next_link: Url to get the next page of reservations. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ReservationResponse]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ReservationList, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class ReservationMergeProperties(msrest.serialization.Model): + """ReservationMergeProperties. + + :param merge_destination: Reservation Resource Id Created due to the merge. Format of the + resource Id is + /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}. + :type merge_destination: str + :param merge_sources: Resource Ids of the Source Reservation's merged to form this Reservation. + Format of the resource Id is + /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}. + :type merge_sources: list[str] + """ + + _attribute_map = { + 'merge_destination': {'key': 'mergeDestination', 'type': 'str'}, + 'merge_sources': {'key': 'mergeSources', 'type': '[str]'}, + } + + def __init__( + self, + **kwargs + ): + super(ReservationMergeProperties, self).__init__(**kwargs) + self.merge_destination = kwargs.get('merge_destination', None) + self.merge_sources = kwargs.get('merge_sources', None) + + +class ReservationOrderBillingPlanInformation(msrest.serialization.Model): + """Information describing the type of billing plan for this reservation. + + :param pricing_currency_total: Amount of money to be paid for the Order. Tax is not included. + :type pricing_currency_total: ~azure_reservation_api.models.Price + :param start_date: Date when the billing plan has started. + :type start_date: ~datetime.date + :param next_payment_due_date: For recurring billing plans, indicates the date when next payment + will be processed. Null when total is paid off. + :type next_payment_due_date: ~datetime.date + :param transactions: + :type transactions: list[~azure_reservation_api.models.PaymentDetail] + """ + + _attribute_map = { + 'pricing_currency_total': {'key': 'pricingCurrencyTotal', 'type': 'Price'}, + 'start_date': {'key': 'startDate', 'type': 'date'}, + 'next_payment_due_date': {'key': 'nextPaymentDueDate', 'type': 'date'}, + 'transactions': {'key': 'transactions', 'type': '[PaymentDetail]'}, + } + + def __init__( + self, + **kwargs + ): + super(ReservationOrderBillingPlanInformation, self).__init__(**kwargs) + self.pricing_currency_total = kwargs.get('pricing_currency_total', None) + self.start_date = kwargs.get('start_date', None) + self.next_payment_due_date = kwargs.get('next_payment_due_date', None) + self.transactions = kwargs.get('transactions', None) + + +class ReservationOrderList(msrest.serialization.Model): + """ReservationOrderList. + + :param value: + :type value: list[~azure_reservation_api.models.ReservationOrderResponse] + :param next_link: Url to get the next page of reservationOrders. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ReservationOrderResponse]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ReservationOrderList, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = kwargs.get('next_link', None) + + +class ReservationOrderResponse(msrest.serialization.Model): + """ReservationOrderResponse. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param etag: + :type etag: int + :ivar id: Identifier of the reservation. + :vartype id: str + :ivar name: Name of the reservation. + :vartype name: str + :ivar type: Type of resource. "Microsoft.Capacity/reservations". + :vartype type: str + :param display_name: Friendly name for user to easily identified the reservation. + :type display_name: str + :param request_date_time: This is the DateTime when the reservation was initially requested for + purchase. + :type request_date_time: ~datetime.datetime + :param created_date_time: This is the DateTime when the reservation was created. + :type created_date_time: ~datetime.datetime + :param expiry_date: This is the date when the Reservation will expire. + :type expiry_date: ~datetime.date + :param original_quantity: Quantity of the SKUs that are part of the Reservation. Must be + greater than zero. + :type original_quantity: int + :param term: Represent the term of Reservation. Possible values include: "P1Y", "P3Y". + :type term: str or ~azure_reservation_api.models.ReservationTerm + :param provisioning_state: Current state of the reservation. + :type provisioning_state: str + :param billing_plan: Represent the billing plans. Possible values include: "Upfront", + "Monthly". + :type billing_plan: str or ~azure_reservation_api.models.ReservationBillingPlan + :param plan_information: Information describing the type of billing plan for this reservation. + :type plan_information: ~azure_reservation_api.models.ReservationOrderBillingPlanInformation + :param reservations: + :type reservations: list[~azure_reservation_api.models.ReservationResponse] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'etag': {'key': 'etag', 'type': 'int'}, + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'request_date_time': {'key': 'properties.requestDateTime', 'type': 'iso-8601'}, + 'created_date_time': {'key': 'properties.createdDateTime', 'type': 'iso-8601'}, + 'expiry_date': {'key': 'properties.expiryDate', 'type': 'date'}, + 'original_quantity': {'key': 'properties.originalQuantity', 'type': 'int'}, + 'term': {'key': 'properties.term', 'type': 'str'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'billing_plan': {'key': 'properties.billingPlan', 'type': 'str'}, + 'plan_information': {'key': 'properties.planInformation', 'type': 'ReservationOrderBillingPlanInformation'}, + 'reservations': {'key': 'properties.reservations', 'type': '[ReservationResponse]'}, + } + + def __init__( + self, + **kwargs + ): + super(ReservationOrderResponse, self).__init__(**kwargs) + self.etag = kwargs.get('etag', None) + self.id = None + self.name = None + self.type = None + self.display_name = kwargs.get('display_name', None) + self.request_date_time = kwargs.get('request_date_time', None) + self.created_date_time = kwargs.get('created_date_time', None) + self.expiry_date = kwargs.get('expiry_date', None) + self.original_quantity = kwargs.get('original_quantity', None) + self.term = kwargs.get('term', None) + self.provisioning_state = kwargs.get('provisioning_state', None) + self.billing_plan = kwargs.get('billing_plan', None) + self.plan_information = kwargs.get('plan_information', None) + self.reservations = kwargs.get('reservations', None) + + +class ReservationProperties(msrest.serialization.Model): + """ReservationProperties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param 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". + :type reserved_resource_type: str or ~azure_reservation_api.models.ReservedResourceType + :param 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". + :type instance_flexibility: str or ~azure_reservation_api.models.InstanceFlexibility + :param display_name: Friendly name for user to easily identify the reservation. + :type display_name: str + :param applied_scopes: List of the subscriptions that the benefit will be applied. Do not + specify if AppliedScopeType is Shared. + :type applied_scopes: list[str] + :param applied_scope_type: Type of the Applied Scope. Possible values include: "Single", + "Shared". + :type applied_scope_type: str or ~azure_reservation_api.models.AppliedScopeType + :param quantity: Quantity of the SKUs that are part of the Reservation. Must be greater than + zero. + :type quantity: int + :param provisioning_state: Current state of the reservation. + :type provisioning_state: str + :param effective_date_time: DateTime of the Reservation starting when this version is effective + from. + :type effective_date_time: ~datetime.datetime + :ivar last_updated_date_time: DateTime of the last time the Reservation was updated. + :vartype last_updated_date_time: ~datetime.datetime + :param expiry_date: This is the date when the Reservation will expire. + :type expiry_date: ~datetime.date + :param sku_description: Description of the SKU in english. + :type sku_description: str + :param extended_status_info: + :type extended_status_info: ~azure_reservation_api.models.ExtendedStatusInfo + :param billing_plan: Represent the billing plans. Possible values include: "Upfront", + "Monthly". + :type billing_plan: str or ~azure_reservation_api.models.ReservationBillingPlan + :param split_properties: + :type split_properties: ~azure_reservation_api.models.ReservationSplitProperties + :param merge_properties: + :type merge_properties: ~azure_reservation_api.models.ReservationMergeProperties + :param billing_scope_id: Subscription that will be charged for purchasing Reservation. + :type billing_scope_id: str + :param renew: Setting this to true will automatically purchase a new reservation on the + expiration date time. + :type renew: bool + :param renew_source: Reservation Id of the reservation from which this reservation is renewed. + Format of the resource Id is + /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}. + :type renew_source: str + :param renew_destination: Reservation Id of the reservation which is purchased because of + renew. Format of the resource Id is + /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}. + :type renew_destination: str + :param renew_properties: + :type renew_properties: ~azure_reservation_api.models.RenewPropertiesResponse + :param term: Represent the term of Reservation. Possible values include: "P1Y", "P3Y". + :type term: str or ~azure_reservation_api.models.ReservationTerm + """ + + _validation = { + 'last_updated_date_time': {'readonly': True}, + } + + _attribute_map = { + 'reserved_resource_type': {'key': 'reservedResourceType', 'type': 'str'}, + 'instance_flexibility': {'key': 'instanceFlexibility', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'applied_scopes': {'key': 'appliedScopes', 'type': '[str]'}, + 'applied_scope_type': {'key': 'appliedScopeType', 'type': 'str'}, + 'quantity': {'key': 'quantity', 'type': 'int'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'effective_date_time': {'key': 'effectiveDateTime', 'type': 'iso-8601'}, + 'last_updated_date_time': {'key': 'lastUpdatedDateTime', 'type': 'iso-8601'}, + 'expiry_date': {'key': 'expiryDate', 'type': 'date'}, + 'sku_description': {'key': 'skuDescription', 'type': 'str'}, + 'extended_status_info': {'key': 'extendedStatusInfo', 'type': 'ExtendedStatusInfo'}, + 'billing_plan': {'key': 'billingPlan', 'type': 'str'}, + 'split_properties': {'key': 'splitProperties', 'type': 'ReservationSplitProperties'}, + 'merge_properties': {'key': 'mergeProperties', 'type': 'ReservationMergeProperties'}, + 'billing_scope_id': {'key': 'billingScopeId', 'type': 'str'}, + 'renew': {'key': 'renew', 'type': 'bool'}, + 'renew_source': {'key': 'renewSource', 'type': 'str'}, + 'renew_destination': {'key': 'renewDestination', 'type': 'str'}, + 'renew_properties': {'key': 'renewProperties', 'type': 'RenewPropertiesResponse'}, + 'term': {'key': 'term', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ReservationProperties, self).__init__(**kwargs) + self.reserved_resource_type = kwargs.get('reserved_resource_type', None) + self.instance_flexibility = kwargs.get('instance_flexibility', None) + self.display_name = kwargs.get('display_name', None) + self.applied_scopes = kwargs.get('applied_scopes', None) + self.applied_scope_type = kwargs.get('applied_scope_type', None) + self.quantity = kwargs.get('quantity', None) + self.provisioning_state = kwargs.get('provisioning_state', None) + self.effective_date_time = kwargs.get('effective_date_time', None) + self.last_updated_date_time = None + self.expiry_date = kwargs.get('expiry_date', None) + self.sku_description = kwargs.get('sku_description', None) + self.extended_status_info = kwargs.get('extended_status_info', None) + self.billing_plan = kwargs.get('billing_plan', None) + self.split_properties = kwargs.get('split_properties', None) + self.merge_properties = kwargs.get('merge_properties', None) + self.billing_scope_id = kwargs.get('billing_scope_id', None) + self.renew = kwargs.get('renew', False) + self.renew_source = kwargs.get('renew_source', None) + self.renew_destination = kwargs.get('renew_destination', None) + self.renew_properties = kwargs.get('renew_properties', None) + self.term = kwargs.get('term', None) + + +class ReservationResponse(msrest.serialization.Model): + """ReservationResponse. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar location: The Azure Region where the reserved resource lives. + :vartype location: str + :param etag: + :type etag: int + :ivar id: Identifier of the reservation. + :vartype id: str + :ivar name: Name of the reservation. + :vartype name: str + :param sku: + :type sku: ~azure_reservation_api.models.SkuName + :param properties: + :type properties: ~azure_reservation_api.models.ReservationProperties + :ivar type: Type of resource. "Microsoft.Capacity/reservationOrders/reservations". + :vartype type: str + """ + + _validation = { + 'location': {'readonly': True}, + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'location': {'key': 'location', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'int'}, + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'SkuName'}, + 'properties': {'key': 'properties', 'type': 'ReservationProperties'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ReservationResponse, self).__init__(**kwargs) + self.location = None + self.etag = kwargs.get('etag', None) + self.id = None + self.name = None + self.sku = kwargs.get('sku', None) + self.properties = kwargs.get('properties', None) + self.type = None + + +class ReservationSplitProperties(msrest.serialization.Model): + """ReservationSplitProperties. + + :param split_destinations: List of destination Resource Id that are created due to split. + Format of the resource Id is + /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}. + :type split_destinations: list[str] + :param split_source: Resource Id of the Reservation from which this is split. Format of the + resource Id is + /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}. + :type split_source: str + """ + + _attribute_map = { + 'split_destinations': {'key': 'splitDestinations', 'type': '[str]'}, + 'split_source': {'key': 'splitSource', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ReservationSplitProperties, self).__init__(**kwargs) + self.split_destinations = kwargs.get('split_destinations', None) + self.split_source = kwargs.get('split_source', None) + + +class ReservationToExchange(msrest.serialization.Model): + """Reservation refund details. + + :param reservation_id: Fully qualified id of the Reservation being returned. + :type reservation_id: str + :param quantity: Quantity to be returned. + :type quantity: int + :param billing_refund_amount: + :type billing_refund_amount: ~azure_reservation_api.models.Price + :param billing_information: billing information. + :type billing_information: ~azure_reservation_api.models.BillingInformation + """ + + _attribute_map = { + 'reservation_id': {'key': 'reservationId', 'type': 'str'}, + 'quantity': {'key': 'quantity', 'type': 'int'}, + 'billing_refund_amount': {'key': 'billingRefundAmount', 'type': 'Price'}, + 'billing_information': {'key': 'billingInformation', 'type': 'BillingInformation'}, + } + + def __init__( + self, + **kwargs + ): + super(ReservationToExchange, self).__init__(**kwargs) + self.reservation_id = kwargs.get('reservation_id', None) + self.quantity = kwargs.get('quantity', None) + self.billing_refund_amount = kwargs.get('billing_refund_amount', None) + self.billing_information = kwargs.get('billing_information', None) + + +class ReservationToPurchaseCalculateExchange(msrest.serialization.Model): + """Reservation purchase details. + + :param properties: + :type properties: ~azure_reservation_api.models.PurchaseRequest + :param billing_currency_total: + :type billing_currency_total: ~azure_reservation_api.models.Price + """ + + _attribute_map = { + 'properties': {'key': 'properties', 'type': 'PurchaseRequest'}, + 'billing_currency_total': {'key': 'billingCurrencyTotal', 'type': 'Price'}, + } + + def __init__( + self, + **kwargs + ): + super(ReservationToPurchaseCalculateExchange, self).__init__(**kwargs) + self.properties = kwargs.get('properties', None) + self.billing_currency_total = kwargs.get('billing_currency_total', None) + + +class ReservationToPurchaseExchange(msrest.serialization.Model): + """Reservation purchase details. + + :param reservation_order_id: Fully qualified id of the ReservationOrder being purchased. + :type reservation_order_id: str + :param reservation_id: Fully qualified id of the Reservation being purchased. This value is + only guaranteed to be non-null if the purchase is successful. + :type reservation_id: str + :param properties: + :type properties: ~azure_reservation_api.models.PurchaseRequest + :param billing_currency_total: + :type billing_currency_total: ~azure_reservation_api.models.Price + :param status: Status of the individual operation. Possible values include: "Succeeded", + "Failed", "Cancelled", "Pending". + :type status: str or ~azure_reservation_api.models.OperationStatus + """ + + _attribute_map = { + 'reservation_order_id': {'key': 'reservationOrderId', 'type': 'str'}, + 'reservation_id': {'key': 'reservationId', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'PurchaseRequest'}, + 'billing_currency_total': {'key': 'billingCurrencyTotal', 'type': 'Price'}, + 'status': {'key': 'status', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ReservationToPurchaseExchange, self).__init__(**kwargs) + self.reservation_order_id = kwargs.get('reservation_order_id', None) + self.reservation_id = kwargs.get('reservation_id', None) + self.properties = kwargs.get('properties', None) + self.billing_currency_total = kwargs.get('billing_currency_total', None) + self.status = kwargs.get('status', None) + + +class ReservationToReturn(msrest.serialization.Model): + """Reservation to return. + + :param reservation_id: Fully qualified identifier of the Reservation being returned. + :type reservation_id: str + :param quantity: Quantity to be returned. Must be greater than zero. + :type quantity: int + """ + + _attribute_map = { + 'reservation_id': {'key': 'reservationId', 'type': 'str'}, + 'quantity': {'key': 'quantity', 'type': 'int'}, + } + + def __init__( + self, + **kwargs + ): + super(ReservationToReturn, self).__init__(**kwargs) + self.reservation_id = kwargs.get('reservation_id', None) + self.quantity = kwargs.get('quantity', None) + + +class ReservationToReturnForExchange(msrest.serialization.Model): + """Reservation refund details. + + :param reservation_id: Fully qualified id of the Reservation being returned. + :type reservation_id: str + :param quantity: Quantity to be returned. + :type quantity: int + :param billing_refund_amount: + :type billing_refund_amount: ~azure_reservation_api.models.Price + :param billing_information: billing information. + :type billing_information: ~azure_reservation_api.models.BillingInformation + :param status: Status of the individual operation. Possible values include: "Succeeded", + "Failed", "Cancelled", "Pending". + :type status: str or ~azure_reservation_api.models.OperationStatus + """ + + _attribute_map = { + 'reservation_id': {'key': 'reservationId', 'type': 'str'}, + 'quantity': {'key': 'quantity', 'type': 'int'}, + 'billing_refund_amount': {'key': 'billingRefundAmount', 'type': 'Price'}, + 'billing_information': {'key': 'billingInformation', 'type': 'BillingInformation'}, + 'status': {'key': 'status', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ReservationToReturnForExchange, self).__init__(**kwargs) + self.reservation_id = kwargs.get('reservation_id', None) + self.quantity = kwargs.get('quantity', None) + self.billing_refund_amount = kwargs.get('billing_refund_amount', None) + self.billing_information = kwargs.get('billing_information', None) + self.status = kwargs.get('status', None) + + +class ResourceName(msrest.serialization.Model): + """Resource name provided by the resource provider. Use this property for quotaRequest parameter. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param value: Resource name. + :type value: str + :ivar localized_value: Resource display localized name. + :vartype localized_value: str + """ + + _validation = { + 'localized_value': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': 'str'}, + 'localized_value': {'key': 'localizedValue', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ResourceName, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.localized_value = None + + +class ScopeProperties(msrest.serialization.Model): + """ScopeProperties. + + :param scope: + :type scope: str + :param valid: + :type valid: bool + """ + + _attribute_map = { + 'scope': {'key': 'scope', 'type': 'str'}, + 'valid': {'key': 'valid', 'type': 'bool'}, + } + + def __init__( + self, + **kwargs + ): + super(ScopeProperties, self).__init__(**kwargs) + self.scope = kwargs.get('scope', None) + self.valid = kwargs.get('valid', None) + + +class ServiceError(msrest.serialization.Model): + """The API error details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param code: The error code. + :type code: str + :param message: The error message text. + :type message: str + :ivar details: The list of error details. + :vartype details: list[~azure_reservation_api.models.ServiceErrorDetail] + """ + + _validation = { + 'details': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[ServiceErrorDetail]'}, + } + + def __init__( + self, + **kwargs + ): + super(ServiceError, self).__init__(**kwargs) + self.code = kwargs.get('code', None) + self.message = kwargs.get('message', None) + self.details = None + + +class ServiceErrorDetail(msrest.serialization.Model): + """The error details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + """ + + _validation = { + 'code': {'readonly': True}, + 'message': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ServiceErrorDetail, self).__init__(**kwargs) + self.code = None + self.message = None + + +class SkuName(msrest.serialization.Model): + """SkuName. + + :param name: + :type name: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(SkuName, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + + +class SkuProperty(msrest.serialization.Model): + """SkuProperty. + + :param name: An invariant to describe the feature. + :type name: str + :param value: An invariant if the feature is measured by quantity. + :type value: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(SkuProperty, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.value = kwargs.get('value', None) + + +class SkuRestriction(msrest.serialization.Model): + """SkuRestriction. + + :param type: The type of restrictions. + :type type: str + :param values: The value of restrictions. If the restriction type is set to location. This + would be different locations where the SKU is restricted. + :type values: list[str] + :param reason_code: The reason for restriction. + :type reason_code: str + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'values': {'key': 'values', 'type': '[str]'}, + 'reason_code': {'key': 'reasonCode', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(SkuRestriction, self).__init__(**kwargs) + self.type = kwargs.get('type', None) + self.values = kwargs.get('values', None) + self.reason_code = kwargs.get('reason_code', None) + + +class SplitRequest(msrest.serialization.Model): + """SplitRequest. + + :param quantities: List of the quantities in the new reservations to create. + :type quantities: list[int] + :param reservation_id: Resource id of the reservation to be split. Format of the resource id + should be + /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}. + :type reservation_id: str + """ + + _attribute_map = { + 'quantities': {'key': 'properties.quantities', 'type': '[int]'}, + 'reservation_id': {'key': 'properties.reservationId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(SplitRequest, self).__init__(**kwargs) + self.quantities = kwargs.get('quantities', None) + self.reservation_id = kwargs.get('reservation_id', None) + + +class SubRequest(msrest.serialization.Model): + """The sub-request submitted with the quota request. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar limit: Quota (resource limit). + :vartype limit: int + :param name: The resource name. + :type name: ~azure_reservation_api.models.ResourceName + :ivar resource_type: Resource type for which the quota check was made. + :vartype resource_type: str + :param unit: The limit units, such as **count** and **bytes**. Use the unit field provided in + the response of the GET quota operation. + :type unit: str + :param provisioning_state: The quota request status. Possible values include: "Accepted", + "Invalid", "Succeeded", "Failed", "InProgress". + :type provisioning_state: str or ~azure_reservation_api.models.QuotaRequestState + :ivar message: User-friendly status message. + :vartype message: str + :ivar sub_request_id: Sub request ID for individual request. + :vartype sub_request_id: str + """ + + _validation = { + 'limit': {'readonly': True}, + 'resource_type': {'readonly': True}, + 'message': {'readonly': True}, + 'sub_request_id': {'readonly': True}, + } + + _attribute_map = { + 'limit': {'key': 'limit', 'type': 'int'}, + 'name': {'key': 'name', 'type': 'ResourceName'}, + 'resource_type': {'key': 'resourceType', 'type': 'str'}, + 'unit': {'key': 'unit', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'sub_request_id': {'key': 'subRequestId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(SubRequest, self).__init__(**kwargs) + self.limit = None + self.name = kwargs.get('name', None) + self.resource_type = None + self.unit = kwargs.get('unit', None) + self.provisioning_state = kwargs.get('provisioning_state', None) + self.message = None + self.sub_request_id = None + + +class SubscriptionScopeProperties(msrest.serialization.Model): + """SubscriptionScopeProperties. + + :param scopes: + :type scopes: list[~azure_reservation_api.models.ScopeProperties] + """ + + _attribute_map = { + 'scopes': {'key': 'scopes', 'type': '[ScopeProperties]'}, + } + + def __init__( + self, + **kwargs + ): + super(SubscriptionScopeProperties, self).__init__(**kwargs) + self.scopes = kwargs.get('scopes', None) diff --git a/src/reservations/azext_reservations/vendored_sdks/quota/models/_models_py3.py b/src/reservations/azext_reservations/vendored_sdks/quota/models/_models_py3.py new file mode 100644 index 00000000000..17327ff07dd --- /dev/null +++ b/src/reservations/azext_reservations/vendored_sdks/quota/models/_models_py3.py @@ -0,0 +1,2687 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +import datetime +from typing import Dict, List, Optional, Union + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + +from ._azure_reservation_api_enums import * + + +class AppliedReservationList(msrest.serialization.Model): + """AppliedReservationList. + + :param value: + :type value: list[str] + :param next_link: Url to get the next page of reservations. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[str]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List[str]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(AppliedReservationList, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class AppliedReservations(msrest.serialization.Model): + """AppliedReservations. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Identifier of the applied reservations. + :vartype id: str + :ivar name: Name of resource. + :vartype name: str + :ivar type: Type of resource. "Microsoft.Capacity/AppliedReservations". + :vartype type: str + :param reservation_order_ids: + :type reservation_order_ids: ~azure_reservation_api.models.AppliedReservationList + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'reservation_order_ids': {'key': 'properties.reservationOrderIds', 'type': 'AppliedReservationList'}, + } + + def __init__( + self, + *, + reservation_order_ids: Optional["AppliedReservationList"] = None, + **kwargs + ): + super(AppliedReservations, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.reservation_order_ids = reservation_order_ids + + +class AvailableScopeProperties(msrest.serialization.Model): + """AvailableScopeProperties. + + :param properties: + :type properties: ~azure_reservation_api.models.SubscriptionScopeProperties + """ + + _attribute_map = { + 'properties': {'key': 'properties', 'type': 'SubscriptionScopeProperties'}, + } + + def __init__( + self, + *, + properties: Optional["SubscriptionScopeProperties"] = None, + **kwargs + ): + super(AvailableScopeProperties, self).__init__(**kwargs) + self.properties = properties + + +class AvailableScopeRequest(msrest.serialization.Model): + """Available scope. + + :param properties: Available scope request properties. + :type properties: ~azure_reservation_api.models.AvailableScopeRequestProperties + """ + + _attribute_map = { + 'properties': {'key': 'properties', 'type': 'AvailableScopeRequestProperties'}, + } + + def __init__( + self, + *, + properties: Optional["AvailableScopeRequestProperties"] = None, + **kwargs + ): + super(AvailableScopeRequest, self).__init__(**kwargs) + self.properties = properties + + +class AvailableScopeRequestProperties(msrest.serialization.Model): + """Available scope request properties. + + :param scopes: + :type scopes: list[str] + """ + + _attribute_map = { + 'scopes': {'key': 'scopes', 'type': '[str]'}, + } + + def __init__( + self, + *, + scopes: Optional[List[str]] = None, + **kwargs + ): + super(AvailableScopeRequestProperties, self).__init__(**kwargs) + self.scopes = scopes + + +class BillingInformation(msrest.serialization.Model): + """billing information. + + :param billing_currency_total_paid_amount: + :type billing_currency_total_paid_amount: ~azure_reservation_api.models.Price + :param billing_currency_prorated_amount: + :type billing_currency_prorated_amount: ~azure_reservation_api.models.Price + :param billing_currency_remaining_commitment_amount: + :type billing_currency_remaining_commitment_amount: ~azure_reservation_api.models.Price + """ + + _attribute_map = { + 'billing_currency_total_paid_amount': {'key': 'billingCurrencyTotalPaidAmount', 'type': 'Price'}, + 'billing_currency_prorated_amount': {'key': 'billingCurrencyProratedAmount', 'type': 'Price'}, + 'billing_currency_remaining_commitment_amount': {'key': 'billingCurrencyRemainingCommitmentAmount', 'type': 'Price'}, + } + + 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, + **kwargs + ): + super(BillingInformation, self).__init__(**kwargs) + self.billing_currency_total_paid_amount = billing_currency_total_paid_amount + self.billing_currency_prorated_amount = billing_currency_prorated_amount + self.billing_currency_remaining_commitment_amount = billing_currency_remaining_commitment_amount + + +class CalculateExchangeOperationResultResponse(msrest.serialization.Model): + """CalculateExchange operation result. + + :param id: It should match what is used to GET the operation result. + :type id: str + :param name: It must match the last segment of the id field, and will typically be a GUID / + system generated value. + :type name: str + :param status: Status of the operation. Possible values include: "Succeeded", "Failed", + "Cancelled", "Pending". + :type status: str or ~azure_reservation_api.models.CalculateExchangeOperationResultStatus + :param properties: CalculateExchange response properties. + :type properties: ~azure_reservation_api.models.CalculateExchangeResponseProperties + :param error: Required if status == failed or status == canceled. + :type error: ~azure_reservation_api.models.OperationResultError + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'CalculateExchangeResponseProperties'}, + 'error': {'key': 'error', 'type': 'OperationResultError'}, + } + + def __init__( + self, + *, + id: Optional[str] = None, + name: Optional[str] = None, + status: Optional[Union[str, "CalculateExchangeOperationResultStatus"]] = None, + properties: Optional["CalculateExchangeResponseProperties"] = None, + error: Optional["OperationResultError"] = None, + **kwargs + ): + super(CalculateExchangeOperationResultResponse, self).__init__(**kwargs) + self.id = id + self.name = name + self.status = status + self.properties = properties + self.error = error + + +class CalculateExchangeRequest(msrest.serialization.Model): + """Calculate exchange request. + + :param properties: Calculate exchange request properties. + :type properties: ~azure_reservation_api.models.CalculateExchangeRequestProperties + """ + + _attribute_map = { + 'properties': {'key': 'properties', 'type': 'CalculateExchangeRequestProperties'}, + } + + def __init__( + self, + *, + properties: Optional["CalculateExchangeRequestProperties"] = None, + **kwargs + ): + super(CalculateExchangeRequest, self).__init__(**kwargs) + self.properties = properties + + +class CalculateExchangeRequestProperties(msrest.serialization.Model): + """Calculate exchange request properties. + + :param reservations_to_purchase: List of reservations that are being purchased in this + exchange. + :type reservations_to_purchase: list[~azure_reservation_api.models.PurchaseRequest] + :param reservations_to_exchange: List of reservations that are being returned in this exchange. + :type reservations_to_exchange: list[~azure_reservation_api.models.ReservationToReturn] + """ + + _attribute_map = { + 'reservations_to_purchase': {'key': 'reservationsToPurchase', 'type': '[PurchaseRequest]'}, + 'reservations_to_exchange': {'key': 'reservationsToExchange', 'type': '[ReservationToReturn]'}, + } + + def __init__( + self, + *, + reservations_to_purchase: Optional[List["PurchaseRequest"]] = None, + reservations_to_exchange: Optional[List["ReservationToReturn"]] = None, + **kwargs + ): + super(CalculateExchangeRequestProperties, self).__init__(**kwargs) + self.reservations_to_purchase = reservations_to_purchase + self.reservations_to_exchange = reservations_to_exchange + + +class CalculateExchangeResponseProperties(msrest.serialization.Model): + """CalculateExchange response properties. + + :param session_id: Exchange session identifier. + :type session_id: str + :param net_payable: + :type net_payable: ~azure_reservation_api.models.Price + :param refunds_total: + :type refunds_total: ~azure_reservation_api.models.Price + :param purchases_total: + :type purchases_total: ~azure_reservation_api.models.Price + :param reservations_to_purchase: Details of the reservations being purchased. + :type reservations_to_purchase: + list[~azure_reservation_api.models.ReservationToPurchaseCalculateExchange] + :param reservations_to_exchange: Details of the reservations being returned. + :type reservations_to_exchange: list[~azure_reservation_api.models.ReservationToExchange] + :param policy_result: Exchange policy errors. + :type policy_result: ~azure_reservation_api.models.ExchangePolicyErrors + """ + + _attribute_map = { + 'session_id': {'key': 'sessionId', 'type': 'str'}, + 'net_payable': {'key': 'netPayable', 'type': 'Price'}, + 'refunds_total': {'key': 'refundsTotal', 'type': 'Price'}, + 'purchases_total': {'key': 'purchasesTotal', 'type': 'Price'}, + 'reservations_to_purchase': {'key': 'reservationsToPurchase', 'type': '[ReservationToPurchaseCalculateExchange]'}, + 'reservations_to_exchange': {'key': 'reservationsToExchange', 'type': '[ReservationToExchange]'}, + 'policy_result': {'key': 'policyResult', 'type': 'ExchangePolicyErrors'}, + } + + 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, + **kwargs + ): + super(CalculateExchangeResponseProperties, self).__init__(**kwargs) + self.session_id = session_id + self.net_payable = net_payable + self.refunds_total = refunds_total + self.purchases_total = purchases_total + self.reservations_to_purchase = reservations_to_purchase + self.reservations_to_exchange = reservations_to_exchange + self.policy_result = policy_result + + +class CalculatePriceResponse(msrest.serialization.Model): + """CalculatePriceResponse. + + :param properties: + :type properties: ~azure_reservation_api.models.CalculatePriceResponseProperties + """ + + _attribute_map = { + 'properties': {'key': 'properties', 'type': 'CalculatePriceResponseProperties'}, + } + + def __init__( + self, + *, + properties: Optional["CalculatePriceResponseProperties"] = None, + **kwargs + ): + super(CalculatePriceResponse, self).__init__(**kwargs) + self.properties = properties + + +class CalculatePriceResponseProperties(msrest.serialization.Model): + """CalculatePriceResponseProperties. + + :param billing_currency_total: Currency and amount that customer will be charged in customer's + local currency. Tax is not included. + :type billing_currency_total: + ~azure_reservation_api.models.CalculatePriceResponsePropertiesBillingCurrencyTotal + :param is_billing_partner_managed: True if billing is managed by Microsoft Partner. Used only + for CSP accounts. + :type is_billing_partner_managed: bool + :param reservation_order_id: GUID that represents reservation order that can be placed after + calculating price. + :type reservation_order_id: str + :param sku_title: Title of SKU that is being purchased. + :type sku_title: str + :param sku_description: Description of SKU that is being purchased. + :type sku_description: str + :param pricing_currency_total: Amount that Microsoft uses for record. Used during refund for + calculating refund limit. Tax is not included. + :type pricing_currency_total: + ~azure_reservation_api.models.CalculatePriceResponsePropertiesPricingCurrencyTotal + :param payment_schedule: + :type payment_schedule: list[~azure_reservation_api.models.PaymentDetail] + """ + + _attribute_map = { + 'billing_currency_total': {'key': 'billingCurrencyTotal', 'type': 'CalculatePriceResponsePropertiesBillingCurrencyTotal'}, + 'is_billing_partner_managed': {'key': 'isBillingPartnerManaged', 'type': 'bool'}, + 'reservation_order_id': {'key': 'reservationOrderId', 'type': 'str'}, + 'sku_title': {'key': 'skuTitle', 'type': 'str'}, + 'sku_description': {'key': 'skuDescription', 'type': 'str'}, + 'pricing_currency_total': {'key': 'pricingCurrencyTotal', 'type': 'CalculatePriceResponsePropertiesPricingCurrencyTotal'}, + 'payment_schedule': {'key': 'paymentSchedule', 'type': '[PaymentDetail]'}, + } + + def __init__( + self, + *, + billing_currency_total: Optional["CalculatePriceResponsePropertiesBillingCurrencyTotal"] = None, + is_billing_partner_managed: Optional[bool] = None, + 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, + **kwargs + ): + super(CalculatePriceResponseProperties, self).__init__(**kwargs) + self.billing_currency_total = billing_currency_total + self.is_billing_partner_managed = is_billing_partner_managed + self.reservation_order_id = reservation_order_id + self.sku_title = sku_title + self.sku_description = sku_description + self.pricing_currency_total = pricing_currency_total + self.payment_schedule = payment_schedule + + +class CalculatePriceResponsePropertiesBillingCurrencyTotal(msrest.serialization.Model): + """Currency and amount that customer will be charged in customer's local currency. Tax is not included. + + :param currency_code: + :type currency_code: str + :param amount: + :type amount: float + """ + + _attribute_map = { + 'currency_code': {'key': 'currencyCode', 'type': 'str'}, + 'amount': {'key': 'amount', 'type': 'float'}, + } + + def __init__( + self, + *, + currency_code: Optional[str] = None, + amount: Optional[float] = None, + **kwargs + ): + super(CalculatePriceResponsePropertiesBillingCurrencyTotal, self).__init__(**kwargs) + self.currency_code = currency_code + self.amount = amount + + +class CalculatePriceResponsePropertiesPricingCurrencyTotal(msrest.serialization.Model): + """Amount that Microsoft uses for record. Used during refund for calculating refund limit. Tax is not included. + + :param currency_code: + :type currency_code: str + :param amount: + :type amount: float + """ + + _attribute_map = { + 'currency_code': {'key': 'currencyCode', 'type': 'str'}, + 'amount': {'key': 'amount', 'type': 'float'}, + } + + def __init__( + self, + *, + currency_code: Optional[str] = None, + amount: Optional[float] = None, + **kwargs + ): + super(CalculatePriceResponsePropertiesPricingCurrencyTotal, self).__init__(**kwargs) + self.currency_code = currency_code + self.amount = amount + + +class Catalog(msrest.serialization.Model): + """Catalog. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar resource_type: The type of resource the SKU applies to. + :vartype resource_type: str + :ivar name: The name of SKU. + :vartype name: str + :param billing_plans: The billing plan options available for this SKU. + :type billing_plans: dict[str, list[str or + ~azure_reservation_api.models.ReservationBillingPlan]] + :ivar terms: Available reservation terms for this resource. + :vartype terms: list[str or ~azure_reservation_api.models.ReservationTerm] + :ivar locations: + :vartype locations: list[str] + :ivar sku_properties: + :vartype sku_properties: list[~azure_reservation_api.models.SkuProperty] + :ivar restrictions: + :vartype restrictions: list[~azure_reservation_api.models.SkuRestriction] + """ + + _validation = { + 'resource_type': {'readonly': True}, + 'name': {'readonly': True}, + 'terms': {'readonly': True}, + 'locations': {'readonly': True}, + 'sku_properties': {'readonly': True}, + 'restrictions': {'readonly': True}, + } + + _attribute_map = { + 'resource_type': {'key': 'resourceType', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'billing_plans': {'key': 'billingPlans', 'type': '{[str]}'}, + 'terms': {'key': 'terms', 'type': '[str]'}, + 'locations': {'key': 'locations', 'type': '[str]'}, + 'sku_properties': {'key': 'skuProperties', 'type': '[SkuProperty]'}, + 'restrictions': {'key': 'restrictions', 'type': '[SkuRestriction]'}, + } + + def __init__( + self, + *, + billing_plans: Optional[Dict[str, List[Union[str, "ReservationBillingPlan"]]]] = None, + **kwargs + ): + super(Catalog, self).__init__(**kwargs) + self.resource_type = None + self.name = None + self.billing_plans = billing_plans + self.terms = None + self.locations = None + self.sku_properties = None + self.restrictions = None + + +class CreateGenericQuotaRequestParameters(msrest.serialization.Model): + """Quota change requests information. + + :param value: Quota change requests. + :type value: list[~azure_reservation_api.models.CurrentQuotaLimitBase] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[CurrentQuotaLimitBase]'}, + } + + def __init__( + self, + *, + value: Optional[List["CurrentQuotaLimitBase"]] = None, + **kwargs + ): + super(CreateGenericQuotaRequestParameters, self).__init__(**kwargs) + self.value = value + + +class CurrentQuotaLimit(msrest.serialization.Model): + """Current quota limits. + + 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: + "Accepted", "Invalid", "Succeeded", "Failed", "InProgress". + :vartype provisioning_state: str or ~azure_reservation_api.models.QuotaRequestState + :ivar message: A user friendly message. + :vartype message: str + :param properties: Quota properties for the resource. + :type properties: ~azure_reservation_api.models.QuotaProperties + """ + + _validation = { + 'provisioning_state': {'readonly': True}, + 'message': {'readonly': True}, + } + + _attribute_map = { + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'message': {'key': 'properties.message', 'type': 'str'}, + 'properties': {'key': 'quotaInformation.properties', 'type': 'QuotaProperties'}, + } + + def __init__( + self, + *, + properties: Optional["QuotaProperties"] = None, + **kwargs + ): + super(CurrentQuotaLimit, self).__init__(**kwargs) + self.provisioning_state = None + self.message = None + self.properties = properties + + +class CurrentQuotaLimitBase(msrest.serialization.Model): + """Quota properties. + + :param properties: Quota properties for the resource. + :type properties: ~azure_reservation_api.models.QuotaProperties + """ + + _attribute_map = { + 'properties': {'key': 'properties', 'type': 'QuotaProperties'}, + } + + def __init__( + self, + *, + properties: Optional["QuotaProperties"] = None, + **kwargs + ): + super(CurrentQuotaLimitBase, self).__init__(**kwargs) + self.properties = properties + + +class Error(msrest.serialization.Model): + """Error. + + :param error: + :type error: ~azure_reservation_api.models.ExtendedErrorInfo + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ExtendedErrorInfo'}, + } + + def __init__( + self, + *, + error: Optional["ExtendedErrorInfo"] = None, + **kwargs + ): + super(Error, self).__init__(**kwargs) + self.error = error + + +class ExceptionResponse(msrest.serialization.Model): + """The API error. + + :param error: The API error details. + :type error: ~azure_reservation_api.models.ServiceError + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ServiceError'}, + } + + def __init__( + self, + *, + error: Optional["ServiceError"] = None, + **kwargs + ): + super(ExceptionResponse, self).__init__(**kwargs) + self.error = error + + +class ExchangeOperationResultResponse(msrest.serialization.Model): + """Exchange operation result. + + :param id: It should match what is used to GET the operation result. + :type id: str + :param name: It must match the last segment of the id field, and will typically be a GUID / + system generated value. + :type name: str + :param status: Status of the operation. Possible values include: "Succeeded", "Failed", + "Cancelled", "PendingRefunds", "PendingPurchases". + :type status: str or ~azure_reservation_api.models.ExchangeOperationResultStatus + :param properties: Exchange response properties. + :type properties: ~azure_reservation_api.models.ExchangeResponseProperties + :param error: Required if status == failed or status == canceled. + :type error: ~azure_reservation_api.models.OperationResultError + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'ExchangeResponseProperties'}, + 'error': {'key': 'error', 'type': 'OperationResultError'}, + } + + def __init__( + self, + *, + id: Optional[str] = None, + name: Optional[str] = None, + status: Optional[Union[str, "ExchangeOperationResultStatus"]] = None, + properties: Optional["ExchangeResponseProperties"] = None, + error: Optional["OperationResultError"] = None, + **kwargs + ): + super(ExchangeOperationResultResponse, self).__init__(**kwargs) + self.id = id + self.name = name + self.status = status + self.properties = properties + self.error = error + + +class ExchangePolicyError(msrest.serialization.Model): + """error details. + + :param code: + :type code: str + :param message: + :type message: str + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + **kwargs + ): + super(ExchangePolicyError, self).__init__(**kwargs) + self.code = code + self.message = message + + +class ExchangePolicyErrors(msrest.serialization.Model): + """Exchange policy errors. + + :param policy_errors: Exchange Policy errors. + :type policy_errors: list[~azure_reservation_api.models.ExchangePolicyError] + """ + + _attribute_map = { + 'policy_errors': {'key': 'policyErrors', 'type': '[ExchangePolicyError]'}, + } + + def __init__( + self, + *, + policy_errors: Optional[List["ExchangePolicyError"]] = None, + **kwargs + ): + super(ExchangePolicyErrors, self).__init__(**kwargs) + self.policy_errors = policy_errors + + +class ExchangeRequest(msrest.serialization.Model): + """Exchange request. + + :param properties: Exchange request properties. + :type properties: ~azure_reservation_api.models.ExchangeRequestProperties + """ + + _attribute_map = { + 'properties': {'key': 'properties', 'type': 'ExchangeRequestProperties'}, + } + + def __init__( + self, + *, + properties: Optional["ExchangeRequestProperties"] = None, + **kwargs + ): + super(ExchangeRequest, self).__init__(**kwargs) + self.properties = properties + + +class ExchangeRequestProperties(msrest.serialization.Model): + """Exchange request properties. + + :param session_id: SessionId that was returned by CalculateExchange API. + :type session_id: str + """ + + _attribute_map = { + 'session_id': {'key': 'sessionId', 'type': 'str'}, + } + + def __init__( + self, + *, + session_id: Optional[str] = None, + **kwargs + ): + super(ExchangeRequestProperties, self).__init__(**kwargs) + self.session_id = session_id + + +class ExchangeResponseProperties(msrest.serialization.Model): + """Exchange response properties. + + :param session_id: Exchange session identifier. + :type session_id: str + :param net_payable: + :type net_payable: ~azure_reservation_api.models.Price + :param refunds_total: + :type refunds_total: ~azure_reservation_api.models.Price + :param purchases_total: + :type purchases_total: ~azure_reservation_api.models.Price + :param reservations_to_purchase: Details of the reservations being purchased. + :type reservations_to_purchase: + list[~azure_reservation_api.models.ReservationToPurchaseExchange] + :param reservations_to_exchange: Details of the reservations being returned. + :type reservations_to_exchange: + list[~azure_reservation_api.models.ReservationToReturnForExchange] + :param policy_result: Exchange policy errors. + :type policy_result: ~azure_reservation_api.models.ExchangePolicyErrors + """ + + _attribute_map = { + 'session_id': {'key': 'sessionId', 'type': 'str'}, + 'net_payable': {'key': 'netPayable', 'type': 'Price'}, + 'refunds_total': {'key': 'refundsTotal', 'type': 'Price'}, + 'purchases_total': {'key': 'purchasesTotal', 'type': 'Price'}, + 'reservations_to_purchase': {'key': 'reservationsToPurchase', 'type': '[ReservationToPurchaseExchange]'}, + 'reservations_to_exchange': {'key': 'reservationsToExchange', 'type': '[ReservationToReturnForExchange]'}, + 'policy_result': {'key': 'policyResult', 'type': 'ExchangePolicyErrors'}, + } + + 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, + **kwargs + ): + super(ExchangeResponseProperties, self).__init__(**kwargs) + self.session_id = session_id + self.net_payable = net_payable + self.refunds_total = refunds_total + self.purchases_total = purchases_total + self.reservations_to_purchase = reservations_to_purchase + self.reservations_to_exchange = reservations_to_exchange + self.policy_result = policy_result + + +class ExtendedErrorInfo(msrest.serialization.Model): + """ExtendedErrorInfo. + + :param code: Possible values include: "NotSpecified", "InternalServerError", "ServerTimeout", + "AuthorizationFailed", "BadRequest", "ClientCertificateThumbprintNotSet", + "InvalidRequestContent", "OperationFailed", "HttpMethodNotSupported", "InvalidRequestUri", + "MissingTenantId", "InvalidTenantId", "InvalidReservationOrderId", "InvalidReservationId", + "ReservationIdNotInReservationOrder", "ReservationOrderNotFound", "InvalidSubscriptionId", + "InvalidAccessToken", "InvalidLocationId", "UnauthenticatedRequestsThrottled", + "InvalidHealthCheckType", "Forbidden", "BillingScopeIdCannotBeChanged", + "AppliedScopesNotAssociatedWithCommerceAccount", "PatchValuesSameAsExisting", + "RoleAssignmentCreationFailed", "ReservationOrderCreationFailed", "ReservationOrderNotEnabled", + "CapacityUpdateScopesFailed", "UnsupportedReservationTerm", "ReservationOrderIdAlreadyExists", + "RiskCheckFailed", "CreateQuoteFailed", "ActivateQuoteFailed", "NonsupportedAccountId", + "PaymentInstrumentNotFound", "MissingAppliedScopesForSingle", "NoValidReservationsToReRate", + "ReRateOnlyAllowedForEA", "OperationCannotBePerformedInCurrentState", + "InvalidSingleAppliedScopesCount", "InvalidFulfillmentRequestParameters", + "NotSupportedCountry", "InvalidRefundQuantity", "PurchaseError", "BillingCustomerInputError", + "BillingPaymentInstrumentSoftError", "BillingPaymentInstrumentHardError", + "BillingTransientError", "BillingError", "FulfillmentConfigurationError", + "FulfillmentOutOfStockError", "FulfillmentTransientError", "FulfillmentError", + "CalculatePriceFailed". + :type code: str or ~azure_reservation_api.models.ErrorResponseCode + :param message: + :type message: str + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__( + self, + *, + code: Optional[Union[str, "ErrorResponseCode"]] = None, + message: Optional[str] = None, + **kwargs + ): + super(ExtendedErrorInfo, self).__init__(**kwargs) + self.code = code + self.message = message + + +class ExtendedStatusInfo(msrest.serialization.Model): + """ExtendedStatusInfo. + + :param status_code: Possible values include: "None", "Pending", "Active", "PurchaseError", + "PaymentInstrumentError", "Split", "Merged", "Expired", "Succeeded". + :type status_code: str or ~azure_reservation_api.models.ReservationStatusCode + :param message: The message giving detailed information about the status code. + :type message: str + """ + + _attribute_map = { + 'status_code': {'key': 'statusCode', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__( + self, + *, + status_code: Optional[Union[str, "ReservationStatusCode"]] = None, + message: Optional[str] = None, + **kwargs + ): + super(ExtendedStatusInfo, self).__init__(**kwargs) + self.status_code = status_code + self.message = message + + +class MergeRequest(msrest.serialization.Model): + """MergeRequest. + + :param sources: Format of the resource id should be + /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}. + :type sources: list[str] + """ + + _attribute_map = { + 'sources': {'key': 'properties.sources', 'type': '[str]'}, + } + + def __init__( + self, + *, + sources: Optional[List[str]] = None, + **kwargs + ): + super(MergeRequest, self).__init__(**kwargs) + self.sources = sources + + +class OperationDisplay(msrest.serialization.Model): + """OperationDisplay. + + :param provider: + :type provider: str + :param resource: + :type resource: str + :param operation: + :type operation: str + :param description: + :type description: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): + super(OperationDisplay, self).__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + self.description = description + + +class OperationList(msrest.serialization.Model): + """OperationList. + + :param value: + :type value: list[~azure_reservation_api.models.OperationResponse] + :param next_link: Url to get the next page of items. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[OperationResponse]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["OperationResponse"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(OperationList, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class OperationResponse(msrest.serialization.Model): + """OperationResponse. + + :param name: + :type name: str + :param display: + :type display: ~azure_reservation_api.models.OperationDisplay + :param origin: + :type origin: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + 'origin': {'key': 'origin', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["OperationDisplay"] = None, + origin: Optional[str] = None, + **kwargs + ): + super(OperationResponse, self).__init__(**kwargs) + self.name = name + self.display = display + self.origin = origin + + +class OperationResultError(msrest.serialization.Model): + """Required if status == failed or status == canceled. + + :param code: Required if status == failed or status == cancelled. If status == failed, provide + an invariant error code used for error troubleshooting, aggregation, and analysis. + :type code: str + :param message: Required if status == failed. Localized. If status == failed, provide an + actionable error message indicating what error occurred, and what the user can do to address + the issue. + :type message: str + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + **kwargs + ): + super(OperationResultError, self).__init__(**kwargs) + self.code = code + self.message = message + + +class Patch(msrest.serialization.Model): + """Patch. + + :param applied_scope_type: Type of the Applied Scope. Possible values include: "Single", + "Shared". + :type applied_scope_type: str or ~azure_reservation_api.models.AppliedScopeType + :param applied_scopes: List of the subscriptions that the benefit will be applied. Do not + specify if AppliedScopeType is Shared. + :type applied_scopes: list[str] + :param 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". + :type instance_flexibility: str or ~azure_reservation_api.models.InstanceFlexibility + :param name: Name of the Reservation. + :type name: str + :param renew: Setting this to true will automatically purchase a new reservation on the + expiration date time. + :type renew: bool + :param renew_properties: + :type renew_properties: ~azure_reservation_api.models.PatchPropertiesRenewProperties + """ + + _attribute_map = { + 'applied_scope_type': {'key': 'properties.appliedScopeType', 'type': 'str'}, + 'applied_scopes': {'key': 'properties.appliedScopes', 'type': '[str]'}, + 'instance_flexibility': {'key': 'properties.instanceFlexibility', 'type': 'str'}, + 'name': {'key': 'properties.name', 'type': 'str'}, + 'renew': {'key': 'properties.renew', 'type': 'bool'}, + 'renew_properties': {'key': 'properties.renewProperties', 'type': 'PatchPropertiesRenewProperties'}, + } + + def __init__( + self, + *, + applied_scope_type: Optional[Union[str, "AppliedScopeType"]] = None, + applied_scopes: Optional[List[str]] = None, + instance_flexibility: Optional[Union[str, "InstanceFlexibility"]] = None, + name: Optional[str] = None, + renew: Optional[bool] = False, + renew_properties: Optional["PatchPropertiesRenewProperties"] = None, + **kwargs + ): + super(Patch, self).__init__(**kwargs) + self.applied_scope_type = applied_scope_type + self.applied_scopes = applied_scopes + self.instance_flexibility = instance_flexibility + self.name = name + self.renew = renew + self.renew_properties = renew_properties + + +class PatchPropertiesRenewProperties(msrest.serialization.Model): + """PatchPropertiesRenewProperties. + + :param purchase_properties: + :type purchase_properties: ~azure_reservation_api.models.PurchaseRequest + """ + + _attribute_map = { + 'purchase_properties': {'key': 'purchaseProperties', 'type': 'PurchaseRequest'}, + } + + def __init__( + self, + *, + purchase_properties: Optional["PurchaseRequest"] = None, + **kwargs + ): + super(PatchPropertiesRenewProperties, self).__init__(**kwargs) + self.purchase_properties = purchase_properties + + +class PaymentDetail(msrest.serialization.Model): + """Information about payment related to a reservation order. + + :param due_date: Date when the payment needs to be done. + :type due_date: ~datetime.date + :param payment_date: Date when the transaction is completed. Is null when it is scheduled. + :type payment_date: ~datetime.date + :param pricing_currency_total: Amount in pricing currency. Tax not included. + :type pricing_currency_total: ~azure_reservation_api.models.Price + :param billing_currency_total: Amount charged in Billing currency. Tax not included. Is null + for future payments. + :type billing_currency_total: ~azure_reservation_api.models.Price + :param billing_account: Shows the Account that is charged for this payment. + :type billing_account: str + :param status: Describes whether the payment is completed, failed, cancelled or scheduled in + the future. Possible values include: "Succeeded", "Failed", "Scheduled", "Cancelled". + :type status: str or ~azure_reservation_api.models.PaymentStatus + :param extended_status_info: + :type extended_status_info: ~azure_reservation_api.models.ExtendedStatusInfo + """ + + _attribute_map = { + 'due_date': {'key': 'dueDate', 'type': 'date'}, + 'payment_date': {'key': 'paymentDate', 'type': 'date'}, + 'pricing_currency_total': {'key': 'pricingCurrencyTotal', 'type': 'Price'}, + 'billing_currency_total': {'key': 'billingCurrencyTotal', 'type': 'Price'}, + 'billing_account': {'key': 'billingAccount', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'extended_status_info': {'key': 'extendedStatusInfo', 'type': 'ExtendedStatusInfo'}, + } + + def __init__( + self, + *, + due_date: Optional[datetime.date] = None, + payment_date: Optional[datetime.date] = None, + pricing_currency_total: Optional["Price"] = None, + billing_currency_total: Optional["Price"] = None, + billing_account: Optional[str] = None, + status: Optional[Union[str, "PaymentStatus"]] = None, + extended_status_info: Optional["ExtendedStatusInfo"] = None, + **kwargs + ): + super(PaymentDetail, self).__init__(**kwargs) + self.due_date = due_date + self.payment_date = payment_date + self.pricing_currency_total = pricing_currency_total + self.billing_currency_total = billing_currency_total + self.billing_account = billing_account + self.status = status + self.extended_status_info = extended_status_info + + +class Price(msrest.serialization.Model): + """Price. + + :param currency_code: The ISO 4217 3-letter currency code for the currency used by this + purchase record. + :type currency_code: str + :param amount: + :type amount: float + """ + + _attribute_map = { + 'currency_code': {'key': 'currencyCode', 'type': 'str'}, + 'amount': {'key': 'amount', 'type': 'float'}, + } + + def __init__( + self, + *, + currency_code: Optional[str] = None, + amount: Optional[float] = None, + **kwargs + ): + super(Price, self).__init__(**kwargs) + self.currency_code = currency_code + self.amount = amount + + +class PurchaseRequest(msrest.serialization.Model): + """PurchaseRequest. + + :param sku: + :type sku: ~azure_reservation_api.models.SkuName + :param location: The Azure Region where the reserved resource lives. + :type location: str + :param 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". + :type reserved_resource_type: str or ~azure_reservation_api.models.ReservedResourceType + :param billing_scope_id: Subscription that will be charged for purchasing Reservation. + :type billing_scope_id: str + :param term: Represent the term of Reservation. Possible values include: "P1Y", "P3Y". + :type term: str or ~azure_reservation_api.models.ReservationTerm + :param billing_plan: Represent the billing plans. Possible values include: "Upfront", + "Monthly". + :type billing_plan: str or ~azure_reservation_api.models.ReservationBillingPlan + :param quantity: Quantity of the SKUs that are part of the Reservation. Must be greater than + zero. + :type quantity: int + :param display_name: Friendly name of the Reservation. + :type display_name: str + :param applied_scope_type: Type of the Applied Scope. Possible values include: "Single", + "Shared". + :type applied_scope_type: str or ~azure_reservation_api.models.AppliedScopeType + :param applied_scopes: List of the subscriptions that the benefit will be applied. Do not + specify if AppliedScopeType is Shared. + :type applied_scopes: list[str] + :param renew: Setting this to true will automatically purchase a new reservation on the + expiration date time. + :type renew: bool + :param reserved_resource_properties: Properties specific to each reserved resource type. Not + required if not applicable. + :type reserved_resource_properties: + ~azure_reservation_api.models.PurchaseRequestPropertiesReservedResourceProperties + """ + + _attribute_map = { + 'sku': {'key': 'sku', 'type': 'SkuName'}, + 'location': {'key': 'location', 'type': 'str'}, + 'reserved_resource_type': {'key': 'properties.reservedResourceType', 'type': 'str'}, + 'billing_scope_id': {'key': 'properties.billingScopeId', 'type': 'str'}, + 'term': {'key': 'properties.term', 'type': 'str'}, + 'billing_plan': {'key': 'properties.billingPlan', 'type': 'str'}, + 'quantity': {'key': 'properties.quantity', 'type': 'int'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'applied_scope_type': {'key': 'properties.appliedScopeType', 'type': 'str'}, + 'applied_scopes': {'key': 'properties.appliedScopes', 'type': '[str]'}, + 'renew': {'key': 'properties.renew', 'type': 'bool'}, + 'reserved_resource_properties': {'key': 'properties.reservedResourceProperties', 'type': 'PurchaseRequestPropertiesReservedResourceProperties'}, + } + + def __init__( + self, + *, + sku: Optional["SkuName"] = None, + location: Optional[str] = None, + reserved_resource_type: Optional[Union[str, "ReservedResourceType"]] = None, + billing_scope_id: Optional[str] = None, + term: Optional[Union[str, "ReservationTerm"]] = None, + billing_plan: Optional[Union[str, "ReservationBillingPlan"]] = None, + quantity: Optional[int] = None, + display_name: Optional[str] = None, + applied_scope_type: Optional[Union[str, "AppliedScopeType"]] = None, + applied_scopes: Optional[List[str]] = None, + renew: Optional[bool] = False, + reserved_resource_properties: Optional["PurchaseRequestPropertiesReservedResourceProperties"] = None, + **kwargs + ): + super(PurchaseRequest, self).__init__(**kwargs) + self.sku = sku + self.location = location + self.reserved_resource_type = reserved_resource_type + self.billing_scope_id = billing_scope_id + self.term = term + self.billing_plan = billing_plan + self.quantity = quantity + self.display_name = display_name + self.applied_scope_type = applied_scope_type + self.applied_scopes = applied_scopes + self.renew = renew + self.reserved_resource_properties = reserved_resource_properties + + +class PurchaseRequestPropertiesReservedResourceProperties(msrest.serialization.Model): + """Properties specific to each reserved resource type. Not required if not applicable. + + :param 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". + :type instance_flexibility: str or ~azure_reservation_api.models.InstanceFlexibility + """ + + _attribute_map = { + 'instance_flexibility': {'key': 'instanceFlexibility', 'type': 'str'}, + } + + def __init__( + self, + *, + instance_flexibility: Optional[Union[str, "InstanceFlexibility"]] = None, + **kwargs + ): + super(PurchaseRequestPropertiesReservedResourceProperties, self).__init__(**kwargs) + self.instance_flexibility = instance_flexibility + + +class QuotaLimits(msrest.serialization.Model): + """Quota limits. + + :param value: List of quotas (service limits). + :type value: list[~azure_reservation_api.models.CurrentQuotaLimitBase] + :param next_link: The URI for fetching the next page of quotas (service limits). When no more + pages exist, the value is null. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[CurrentQuotaLimitBase]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["CurrentQuotaLimitBase"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(QuotaLimits, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class QuotaLimitsResponse(msrest.serialization.Model): + """Quotas (service limits) in the request response. + + :param value: List of quotas with the quota request status. + :type value: list[~azure_reservation_api.models.CurrentQuotaLimit] + :param next_link: The URI for fetching the next page of quota limits. When no more pages exist, + the value is null. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[CurrentQuotaLimit]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["CurrentQuotaLimit"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(QuotaLimitsResponse, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class QuotaProperties(msrest.serialization.Model): + """Quota properties for the resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param limit: Quota properties. + :type limit: int + :ivar current_value: Current usage value for the resource. + :vartype current_value: int + :param unit: The limit units, such as **count** and **bytes**. Use the unit field provided in + the response of the GET quota operation. + :type unit: str + :param name: Name of the resource provide by the resource provider. Use this property for + quotaRequests resource operations. + :type name: ~azure_reservation_api.models.ResourceName + :param resource_type: The name of the resource type. Possible values include: "standard", + "dedicated", "lowPriority", "shared", "serviceSpecific". + :type resource_type: str or ~azure_reservation_api.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 + optional because, for some resources such as compute, the time period is irrelevant. + :vartype quota_period: str + :param properties: Additional properties for the specified resource provider. + :type properties: object + """ + + _validation = { + 'current_value': {'readonly': True}, + 'quota_period': {'readonly': True}, + } + + _attribute_map = { + 'limit': {'key': 'limit', 'type': 'int'}, + 'current_value': {'key': 'currentValue', 'type': 'int'}, + 'unit': {'key': 'unit', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'ResourceName'}, + 'resource_type': {'key': 'resourceType', 'type': 'str'}, + 'quota_period': {'key': 'quotaPeriod', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'object'}, + } + + def __init__( + self, + *, + limit: Optional[int] = None, + unit: Optional[str] = None, + name: Optional["ResourceName"] = None, + resource_type: Optional[Union[str, "ResourceType"]] = None, + properties: Optional[object] = None, + **kwargs + ): + super(QuotaProperties, self).__init__(**kwargs) + self.limit = limit + self.current_value = None + self.unit = unit + self.name = name + self.resource_type = resource_type + self.quota_period = None + self.properties = properties + + +class QuotaRequestDetails(msrest.serialization.Model): + """Quota request details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Quota request ID. + :vartype id: str + :ivar name: Quota request name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :param provisioning_state: The quota request status. Possible values include: "Accepted", + "Invalid", "Succeeded", "Failed", "InProgress". + :type provisioning_state: str or ~azure_reservation_api.models.QuotaRequestState + :ivar message: User friendly status message. + :vartype message: str + :ivar request_submit_time: The time when the quota request was submitted using format: yyyy-MM- + ddTHH:mm:ssZ as specified by the ISO 8601 standard. + :vartype request_submit_time: ~datetime.datetime + :param value: The quotaRequests. + :type value: list[~azure_reservation_api.models.SubRequest] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'message': {'readonly': True}, + 'request_submit_time': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'message': {'key': 'properties.message', 'type': 'str'}, + 'request_submit_time': {'key': 'properties.requestSubmitTime', 'type': 'iso-8601'}, + 'value': {'key': 'properties.value', 'type': '[SubRequest]'}, + } + + def __init__( + self, + *, + provisioning_state: Optional[Union[str, "QuotaRequestState"]] = None, + value: Optional[List["SubRequest"]] = None, + **kwargs + ): + super(QuotaRequestDetails, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.provisioning_state = provisioning_state + self.message = None + self.request_submit_time = None + self.value = value + + +class QuotaRequestDetailsList(msrest.serialization.Model): + """Quota request details. + + :param value: The quota requests. + :type value: list[~azure_reservation_api.models.QuotaRequestDetails] + :param next_link: The URI to fetch the next page of quota limits. When there are no more pages, + this is null. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[QuotaRequestDetails]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["QuotaRequestDetails"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(QuotaRequestDetailsList, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class QuotaRequestOneResourceSubmitResponse(msrest.serialization.Model): + """Response for the quota submission request. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The quota request ID. + :vartype id: str + :ivar name: The name of the quota request. + :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". + :vartype provisioning_state: str or ~azure_reservation_api.models.QuotaRequestState + :ivar message: User friendly status message. + :vartype message: str + :ivar request_submit_time: The time when the quota request was submitted using format: yyyy-MM- + ddTHH:mm:ssZ as specified by the ISO 8601 standard. + :vartype request_submit_time: ~datetime.datetime + :param properties: Quota properties for the resource. + :type properties: ~azure_reservation_api.models.QuotaProperties + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'message': {'readonly': True}, + 'request_submit_time': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'message': {'key': 'properties.message', 'type': 'str'}, + 'request_submit_time': {'key': 'properties.requestSubmitTime', 'type': 'iso-8601'}, + 'properties': {'key': 'properties.properties.properties', 'type': 'QuotaProperties'}, + } + + def __init__( + self, + *, + properties: Optional["QuotaProperties"] = None, + **kwargs + ): + super(QuotaRequestOneResourceSubmitResponse, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.provisioning_state = None + self.message = None + self.request_submit_time = None + self.properties = properties + + +class QuotaRequestProperties(msrest.serialization.Model): + """The details of quota request. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param provisioning_state: The quota request status. Possible values include: "Accepted", + "Invalid", "Succeeded", "Failed", "InProgress". + :type provisioning_state: str or ~azure_reservation_api.models.QuotaRequestState + :ivar message: User friendly status message. + :vartype message: str + :ivar request_submit_time: The time when the quota request was submitted using format: yyyy-MM- + ddTHH:mm:ssZ as specified by the ISO 8601 standard. + :vartype request_submit_time: ~datetime.datetime + :param value: The quotaRequests. + :type value: list[~azure_reservation_api.models.SubRequest] + """ + + _validation = { + 'message': {'readonly': True}, + 'request_submit_time': {'readonly': True}, + } + + _attribute_map = { + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'request_submit_time': {'key': 'requestSubmitTime', 'type': 'iso-8601'}, + 'value': {'key': 'value', 'type': '[SubRequest]'}, + } + + def __init__( + self, + *, + provisioning_state: Optional[Union[str, "QuotaRequestState"]] = None, + value: Optional[List["SubRequest"]] = None, + **kwargs + ): + super(QuotaRequestProperties, self).__init__(**kwargs) + self.provisioning_state = provisioning_state + self.message = None + self.request_submit_time = None + self.value = value + + +class QuotaRequestSubmitResponse(msrest.serialization.Model): + """Response for the quota submission request. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The quota request ID. + :vartype id: str + :ivar name: The name of the quota request. + :vartype name: str + :param properties: The quota request details. + :type properties: ~azure_reservation_api.models.QuotaRequestProperties + :ivar type: Type of resource. "Microsoft.Capacity/serviceLimits". + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'QuotaRequestProperties'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + *, + properties: Optional["QuotaRequestProperties"] = None, + **kwargs + ): + super(QuotaRequestSubmitResponse, self).__init__(**kwargs) + self.id = None + self.name = None + self.properties = properties + self.type = None + + +class QuotaRequestSubmitResponse201(msrest.serialization.Model): + """Response with request ID that the quota request was accepted. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The quota request ID. Use the requestId parameter to check the request status. + :vartype id: str + :ivar name: Operation ID. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar provisioning_state: The details of the quota request status. Possible values include: + "Accepted", "Invalid", "Succeeded", "Failed", "InProgress". + :vartype provisioning_state: str or ~azure_reservation_api.models.QuotaRequestState + :ivar message: A user friendly message. + :vartype message: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'message': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'message': {'key': 'properties.message', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(QuotaRequestSubmitResponse201, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.provisioning_state = None + self.message = None + + +class RenewPropertiesResponse(msrest.serialization.Model): + """RenewPropertiesResponse. + + :param purchase_properties: + :type purchase_properties: ~azure_reservation_api.models.PurchaseRequest + :param pricing_currency_total: Amount that Microsoft uses for record. Used during refund for + calculating refund limit. Tax is not included. This is locked price 30 days before expiry. + :type pricing_currency_total: + ~azure_reservation_api.models.RenewPropertiesResponsePricingCurrencyTotal + :param billing_currency_total: Currency and amount that customer will be charged in customer's + local currency for renewal purchase. Tax is not included. + :type billing_currency_total: + ~azure_reservation_api.models.RenewPropertiesResponseBillingCurrencyTotal + """ + + _attribute_map = { + 'purchase_properties': {'key': 'purchaseProperties', 'type': 'PurchaseRequest'}, + 'pricing_currency_total': {'key': 'pricingCurrencyTotal', 'type': 'RenewPropertiesResponsePricingCurrencyTotal'}, + 'billing_currency_total': {'key': 'billingCurrencyTotal', 'type': 'RenewPropertiesResponseBillingCurrencyTotal'}, + } + + def __init__( + self, + *, + purchase_properties: Optional["PurchaseRequest"] = None, + pricing_currency_total: Optional["RenewPropertiesResponsePricingCurrencyTotal"] = None, + billing_currency_total: Optional["RenewPropertiesResponseBillingCurrencyTotal"] = None, + **kwargs + ): + super(RenewPropertiesResponse, self).__init__(**kwargs) + self.purchase_properties = purchase_properties + self.pricing_currency_total = pricing_currency_total + self.billing_currency_total = billing_currency_total + + +class RenewPropertiesResponseBillingCurrencyTotal(msrest.serialization.Model): + """Currency and amount that customer will be charged in customer's local currency for renewal purchase. Tax is not included. + + :param currency_code: + :type currency_code: str + :param amount: + :type amount: float + """ + + _attribute_map = { + 'currency_code': {'key': 'currencyCode', 'type': 'str'}, + 'amount': {'key': 'amount', 'type': 'float'}, + } + + def __init__( + self, + *, + currency_code: Optional[str] = None, + amount: Optional[float] = None, + **kwargs + ): + super(RenewPropertiesResponseBillingCurrencyTotal, self).__init__(**kwargs) + self.currency_code = currency_code + self.amount = amount + + +class RenewPropertiesResponsePricingCurrencyTotal(msrest.serialization.Model): + """Amount that Microsoft uses for record. Used during refund for calculating refund limit. Tax is not included. This is locked price 30 days before expiry. + + :param currency_code: + :type currency_code: str + :param amount: + :type amount: float + """ + + _attribute_map = { + 'currency_code': {'key': 'currencyCode', 'type': 'str'}, + 'amount': {'key': 'amount', 'type': 'float'}, + } + + def __init__( + self, + *, + currency_code: Optional[str] = None, + amount: Optional[float] = None, + **kwargs + ): + super(RenewPropertiesResponsePricingCurrencyTotal, self).__init__(**kwargs) + self.currency_code = currency_code + self.amount = amount + + +class ReservationList(msrest.serialization.Model): + """ReservationList. + + :param value: + :type value: list[~azure_reservation_api.models.ReservationResponse] + :param next_link: Url to get the next page of reservations. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ReservationResponse]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["ReservationResponse"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(ReservationList, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ReservationMergeProperties(msrest.serialization.Model): + """ReservationMergeProperties. + + :param merge_destination: Reservation Resource Id Created due to the merge. Format of the + resource Id is + /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}. + :type merge_destination: str + :param merge_sources: Resource Ids of the Source Reservation's merged to form this Reservation. + Format of the resource Id is + /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}. + :type merge_sources: list[str] + """ + + _attribute_map = { + 'merge_destination': {'key': 'mergeDestination', 'type': 'str'}, + 'merge_sources': {'key': 'mergeSources', 'type': '[str]'}, + } + + def __init__( + self, + *, + merge_destination: Optional[str] = None, + merge_sources: Optional[List[str]] = None, + **kwargs + ): + super(ReservationMergeProperties, self).__init__(**kwargs) + self.merge_destination = merge_destination + self.merge_sources = merge_sources + + +class ReservationOrderBillingPlanInformation(msrest.serialization.Model): + """Information describing the type of billing plan for this reservation. + + :param pricing_currency_total: Amount of money to be paid for the Order. Tax is not included. + :type pricing_currency_total: ~azure_reservation_api.models.Price + :param start_date: Date when the billing plan has started. + :type start_date: ~datetime.date + :param next_payment_due_date: For recurring billing plans, indicates the date when next payment + will be processed. Null when total is paid off. + :type next_payment_due_date: ~datetime.date + :param transactions: + :type transactions: list[~azure_reservation_api.models.PaymentDetail] + """ + + _attribute_map = { + 'pricing_currency_total': {'key': 'pricingCurrencyTotal', 'type': 'Price'}, + 'start_date': {'key': 'startDate', 'type': 'date'}, + 'next_payment_due_date': {'key': 'nextPaymentDueDate', 'type': 'date'}, + 'transactions': {'key': 'transactions', 'type': '[PaymentDetail]'}, + } + + def __init__( + self, + *, + pricing_currency_total: Optional["Price"] = None, + start_date: Optional[datetime.date] = None, + next_payment_due_date: Optional[datetime.date] = None, + transactions: Optional[List["PaymentDetail"]] = None, + **kwargs + ): + super(ReservationOrderBillingPlanInformation, self).__init__(**kwargs) + self.pricing_currency_total = pricing_currency_total + self.start_date = start_date + self.next_payment_due_date = next_payment_due_date + self.transactions = transactions + + +class ReservationOrderList(msrest.serialization.Model): + """ReservationOrderList. + + :param value: + :type value: list[~azure_reservation_api.models.ReservationOrderResponse] + :param next_link: Url to get the next page of reservationOrders. + :type next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ReservationOrderResponse]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["ReservationOrderResponse"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + super(ReservationOrderList, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ReservationOrderResponse(msrest.serialization.Model): + """ReservationOrderResponse. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param etag: + :type etag: int + :ivar id: Identifier of the reservation. + :vartype id: str + :ivar name: Name of the reservation. + :vartype name: str + :ivar type: Type of resource. "Microsoft.Capacity/reservations". + :vartype type: str + :param display_name: Friendly name for user to easily identified the reservation. + :type display_name: str + :param request_date_time: This is the DateTime when the reservation was initially requested for + purchase. + :type request_date_time: ~datetime.datetime + :param created_date_time: This is the DateTime when the reservation was created. + :type created_date_time: ~datetime.datetime + :param expiry_date: This is the date when the Reservation will expire. + :type expiry_date: ~datetime.date + :param original_quantity: Quantity of the SKUs that are part of the Reservation. Must be + greater than zero. + :type original_quantity: int + :param term: Represent the term of Reservation. Possible values include: "P1Y", "P3Y". + :type term: str or ~azure_reservation_api.models.ReservationTerm + :param provisioning_state: Current state of the reservation. + :type provisioning_state: str + :param billing_plan: Represent the billing plans. Possible values include: "Upfront", + "Monthly". + :type billing_plan: str or ~azure_reservation_api.models.ReservationBillingPlan + :param plan_information: Information describing the type of billing plan for this reservation. + :type plan_information: ~azure_reservation_api.models.ReservationOrderBillingPlanInformation + :param reservations: + :type reservations: list[~azure_reservation_api.models.ReservationResponse] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'etag': {'key': 'etag', 'type': 'int'}, + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'request_date_time': {'key': 'properties.requestDateTime', 'type': 'iso-8601'}, + 'created_date_time': {'key': 'properties.createdDateTime', 'type': 'iso-8601'}, + 'expiry_date': {'key': 'properties.expiryDate', 'type': 'date'}, + 'original_quantity': {'key': 'properties.originalQuantity', 'type': 'int'}, + 'term': {'key': 'properties.term', 'type': 'str'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'billing_plan': {'key': 'properties.billingPlan', 'type': 'str'}, + 'plan_information': {'key': 'properties.planInformation', 'type': 'ReservationOrderBillingPlanInformation'}, + 'reservations': {'key': 'properties.reservations', 'type': '[ReservationResponse]'}, + } + + def __init__( + self, + *, + etag: Optional[int] = None, + display_name: Optional[str] = None, + request_date_time: Optional[datetime.datetime] = None, + created_date_time: Optional[datetime.datetime] = None, + expiry_date: Optional[datetime.date] = None, + original_quantity: Optional[int] = None, + term: Optional[Union[str, "ReservationTerm"]] = None, + provisioning_state: Optional[str] = None, + billing_plan: Optional[Union[str, "ReservationBillingPlan"]] = None, + plan_information: Optional["ReservationOrderBillingPlanInformation"] = None, + reservations: Optional[List["ReservationResponse"]] = None, + **kwargs + ): + super(ReservationOrderResponse, self).__init__(**kwargs) + self.etag = etag + self.id = None + self.name = None + self.type = None + self.display_name = display_name + self.request_date_time = request_date_time + self.created_date_time = created_date_time + self.expiry_date = expiry_date + self.original_quantity = original_quantity + self.term = term + self.provisioning_state = provisioning_state + self.billing_plan = billing_plan + self.plan_information = plan_information + self.reservations = reservations + + +class ReservationProperties(msrest.serialization.Model): + """ReservationProperties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param 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". + :type reserved_resource_type: str or ~azure_reservation_api.models.ReservedResourceType + :param 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". + :type instance_flexibility: str or ~azure_reservation_api.models.InstanceFlexibility + :param display_name: Friendly name for user to easily identify the reservation. + :type display_name: str + :param applied_scopes: List of the subscriptions that the benefit will be applied. Do not + specify if AppliedScopeType is Shared. + :type applied_scopes: list[str] + :param applied_scope_type: Type of the Applied Scope. Possible values include: "Single", + "Shared". + :type applied_scope_type: str or ~azure_reservation_api.models.AppliedScopeType + :param quantity: Quantity of the SKUs that are part of the Reservation. Must be greater than + zero. + :type quantity: int + :param provisioning_state: Current state of the reservation. + :type provisioning_state: str + :param effective_date_time: DateTime of the Reservation starting when this version is effective + from. + :type effective_date_time: ~datetime.datetime + :ivar last_updated_date_time: DateTime of the last time the Reservation was updated. + :vartype last_updated_date_time: ~datetime.datetime + :param expiry_date: This is the date when the Reservation will expire. + :type expiry_date: ~datetime.date + :param sku_description: Description of the SKU in english. + :type sku_description: str + :param extended_status_info: + :type extended_status_info: ~azure_reservation_api.models.ExtendedStatusInfo + :param billing_plan: Represent the billing plans. Possible values include: "Upfront", + "Monthly". + :type billing_plan: str or ~azure_reservation_api.models.ReservationBillingPlan + :param split_properties: + :type split_properties: ~azure_reservation_api.models.ReservationSplitProperties + :param merge_properties: + :type merge_properties: ~azure_reservation_api.models.ReservationMergeProperties + :param billing_scope_id: Subscription that will be charged for purchasing Reservation. + :type billing_scope_id: str + :param renew: Setting this to true will automatically purchase a new reservation on the + expiration date time. + :type renew: bool + :param renew_source: Reservation Id of the reservation from which this reservation is renewed. + Format of the resource Id is + /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}. + :type renew_source: str + :param renew_destination: Reservation Id of the reservation which is purchased because of + renew. Format of the resource Id is + /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}. + :type renew_destination: str + :param renew_properties: + :type renew_properties: ~azure_reservation_api.models.RenewPropertiesResponse + :param term: Represent the term of Reservation. Possible values include: "P1Y", "P3Y". + :type term: str or ~azure_reservation_api.models.ReservationTerm + """ + + _validation = { + 'last_updated_date_time': {'readonly': True}, + } + + _attribute_map = { + 'reserved_resource_type': {'key': 'reservedResourceType', 'type': 'str'}, + 'instance_flexibility': {'key': 'instanceFlexibility', 'type': 'str'}, + 'display_name': {'key': 'displayName', 'type': 'str'}, + 'applied_scopes': {'key': 'appliedScopes', 'type': '[str]'}, + 'applied_scope_type': {'key': 'appliedScopeType', 'type': 'str'}, + 'quantity': {'key': 'quantity', 'type': 'int'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'effective_date_time': {'key': 'effectiveDateTime', 'type': 'iso-8601'}, + 'last_updated_date_time': {'key': 'lastUpdatedDateTime', 'type': 'iso-8601'}, + 'expiry_date': {'key': 'expiryDate', 'type': 'date'}, + 'sku_description': {'key': 'skuDescription', 'type': 'str'}, + 'extended_status_info': {'key': 'extendedStatusInfo', 'type': 'ExtendedStatusInfo'}, + 'billing_plan': {'key': 'billingPlan', 'type': 'str'}, + 'split_properties': {'key': 'splitProperties', 'type': 'ReservationSplitProperties'}, + 'merge_properties': {'key': 'mergeProperties', 'type': 'ReservationMergeProperties'}, + 'billing_scope_id': {'key': 'billingScopeId', 'type': 'str'}, + 'renew': {'key': 'renew', 'type': 'bool'}, + 'renew_source': {'key': 'renewSource', 'type': 'str'}, + 'renew_destination': {'key': 'renewDestination', 'type': 'str'}, + 'renew_properties': {'key': 'renewProperties', 'type': 'RenewPropertiesResponse'}, + 'term': {'key': 'term', 'type': 'str'}, + } + + def __init__( + self, + *, + reserved_resource_type: Optional[Union[str, "ReservedResourceType"]] = None, + instance_flexibility: Optional[Union[str, "InstanceFlexibility"]] = None, + display_name: Optional[str] = None, + applied_scopes: Optional[List[str]] = None, + applied_scope_type: Optional[Union[str, "AppliedScopeType"]] = None, + quantity: Optional[int] = None, + provisioning_state: Optional[str] = None, + effective_date_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, + split_properties: Optional["ReservationSplitProperties"] = None, + merge_properties: Optional["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, + **kwargs + ): + super(ReservationProperties, self).__init__(**kwargs) + self.reserved_resource_type = reserved_resource_type + self.instance_flexibility = instance_flexibility + self.display_name = display_name + self.applied_scopes = applied_scopes + self.applied_scope_type = applied_scope_type + self.quantity = quantity + self.provisioning_state = provisioning_state + self.effective_date_time = effective_date_time + self.last_updated_date_time = None + self.expiry_date = expiry_date + self.sku_description = sku_description + self.extended_status_info = extended_status_info + self.billing_plan = billing_plan + self.split_properties = split_properties + self.merge_properties = merge_properties + self.billing_scope_id = billing_scope_id + self.renew = renew + self.renew_source = renew_source + self.renew_destination = renew_destination + self.renew_properties = renew_properties + self.term = term + + +class ReservationResponse(msrest.serialization.Model): + """ReservationResponse. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar location: The Azure Region where the reserved resource lives. + :vartype location: str + :param etag: + :type etag: int + :ivar id: Identifier of the reservation. + :vartype id: str + :ivar name: Name of the reservation. + :vartype name: str + :param sku: + :type sku: ~azure_reservation_api.models.SkuName + :param properties: + :type properties: ~azure_reservation_api.models.ReservationProperties + :ivar type: Type of resource. "Microsoft.Capacity/reservationOrders/reservations". + :vartype type: str + """ + + _validation = { + 'location': {'readonly': True}, + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'location': {'key': 'location', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'int'}, + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'sku': {'key': 'sku', 'type': 'SkuName'}, + 'properties': {'key': 'properties', 'type': 'ReservationProperties'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + *, + etag: Optional[int] = None, + sku: Optional["SkuName"] = None, + properties: Optional["ReservationProperties"] = None, + **kwargs + ): + super(ReservationResponse, self).__init__(**kwargs) + self.location = None + self.etag = etag + self.id = None + self.name = None + self.sku = sku + self.properties = properties + self.type = None + + +class ReservationSplitProperties(msrest.serialization.Model): + """ReservationSplitProperties. + + :param split_destinations: List of destination Resource Id that are created due to split. + Format of the resource Id is + /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}. + :type split_destinations: list[str] + :param split_source: Resource Id of the Reservation from which this is split. Format of the + resource Id is + /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}. + :type split_source: str + """ + + _attribute_map = { + 'split_destinations': {'key': 'splitDestinations', 'type': '[str]'}, + 'split_source': {'key': 'splitSource', 'type': 'str'}, + } + + def __init__( + self, + *, + split_destinations: Optional[List[str]] = None, + split_source: Optional[str] = None, + **kwargs + ): + super(ReservationSplitProperties, self).__init__(**kwargs) + self.split_destinations = split_destinations + self.split_source = split_source + + +class ReservationToExchange(msrest.serialization.Model): + """Reservation refund details. + + :param reservation_id: Fully qualified id of the Reservation being returned. + :type reservation_id: str + :param quantity: Quantity to be returned. + :type quantity: int + :param billing_refund_amount: + :type billing_refund_amount: ~azure_reservation_api.models.Price + :param billing_information: billing information. + :type billing_information: ~azure_reservation_api.models.BillingInformation + """ + + _attribute_map = { + 'reservation_id': {'key': 'reservationId', 'type': 'str'}, + 'quantity': {'key': 'quantity', 'type': 'int'}, + 'billing_refund_amount': {'key': 'billingRefundAmount', 'type': 'Price'}, + 'billing_information': {'key': 'billingInformation', 'type': 'BillingInformation'}, + } + + def __init__( + self, + *, + reservation_id: Optional[str] = None, + quantity: Optional[int] = None, + billing_refund_amount: Optional["Price"] = None, + billing_information: Optional["BillingInformation"] = None, + **kwargs + ): + super(ReservationToExchange, self).__init__(**kwargs) + self.reservation_id = reservation_id + self.quantity = quantity + self.billing_refund_amount = billing_refund_amount + self.billing_information = billing_information + + +class ReservationToPurchaseCalculateExchange(msrest.serialization.Model): + """Reservation purchase details. + + :param properties: + :type properties: ~azure_reservation_api.models.PurchaseRequest + :param billing_currency_total: + :type billing_currency_total: ~azure_reservation_api.models.Price + """ + + _attribute_map = { + 'properties': {'key': 'properties', 'type': 'PurchaseRequest'}, + 'billing_currency_total': {'key': 'billingCurrencyTotal', 'type': 'Price'}, + } + + def __init__( + self, + *, + properties: Optional["PurchaseRequest"] = None, + billing_currency_total: Optional["Price"] = None, + **kwargs + ): + super(ReservationToPurchaseCalculateExchange, self).__init__(**kwargs) + self.properties = properties + self.billing_currency_total = billing_currency_total + + +class ReservationToPurchaseExchange(msrest.serialization.Model): + """Reservation purchase details. + + :param reservation_order_id: Fully qualified id of the ReservationOrder being purchased. + :type reservation_order_id: str + :param reservation_id: Fully qualified id of the Reservation being purchased. This value is + only guaranteed to be non-null if the purchase is successful. + :type reservation_id: str + :param properties: + :type properties: ~azure_reservation_api.models.PurchaseRequest + :param billing_currency_total: + :type billing_currency_total: ~azure_reservation_api.models.Price + :param status: Status of the individual operation. Possible values include: "Succeeded", + "Failed", "Cancelled", "Pending". + :type status: str or ~azure_reservation_api.models.OperationStatus + """ + + _attribute_map = { + 'reservation_order_id': {'key': 'reservationOrderId', 'type': 'str'}, + 'reservation_id': {'key': 'reservationId', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'PurchaseRequest'}, + 'billing_currency_total': {'key': 'billingCurrencyTotal', 'type': 'Price'}, + 'status': {'key': 'status', 'type': 'str'}, + } + + def __init__( + self, + *, + 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, + **kwargs + ): + super(ReservationToPurchaseExchange, self).__init__(**kwargs) + self.reservation_order_id = reservation_order_id + self.reservation_id = reservation_id + self.properties = properties + self.billing_currency_total = billing_currency_total + self.status = status + + +class ReservationToReturn(msrest.serialization.Model): + """Reservation to return. + + :param reservation_id: Fully qualified identifier of the Reservation being returned. + :type reservation_id: str + :param quantity: Quantity to be returned. Must be greater than zero. + :type quantity: int + """ + + _attribute_map = { + 'reservation_id': {'key': 'reservationId', 'type': 'str'}, + 'quantity': {'key': 'quantity', 'type': 'int'}, + } + + def __init__( + self, + *, + reservation_id: Optional[str] = None, + quantity: Optional[int] = None, + **kwargs + ): + super(ReservationToReturn, self).__init__(**kwargs) + self.reservation_id = reservation_id + self.quantity = quantity + + +class ReservationToReturnForExchange(msrest.serialization.Model): + """Reservation refund details. + + :param reservation_id: Fully qualified id of the Reservation being returned. + :type reservation_id: str + :param quantity: Quantity to be returned. + :type quantity: int + :param billing_refund_amount: + :type billing_refund_amount: ~azure_reservation_api.models.Price + :param billing_information: billing information. + :type billing_information: ~azure_reservation_api.models.BillingInformation + :param status: Status of the individual operation. Possible values include: "Succeeded", + "Failed", "Cancelled", "Pending". + :type status: str or ~azure_reservation_api.models.OperationStatus + """ + + _attribute_map = { + 'reservation_id': {'key': 'reservationId', 'type': 'str'}, + 'quantity': {'key': 'quantity', 'type': 'int'}, + 'billing_refund_amount': {'key': 'billingRefundAmount', 'type': 'Price'}, + 'billing_information': {'key': 'billingInformation', 'type': 'BillingInformation'}, + 'status': {'key': 'status', 'type': 'str'}, + } + + def __init__( + self, + *, + 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, + **kwargs + ): + super(ReservationToReturnForExchange, self).__init__(**kwargs) + self.reservation_id = reservation_id + self.quantity = quantity + self.billing_refund_amount = billing_refund_amount + self.billing_information = billing_information + self.status = status + + +class ResourceName(msrest.serialization.Model): + """Resource name provided by the resource provider. Use this property for quotaRequest parameter. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param value: Resource name. + :type value: str + :ivar localized_value: Resource display localized name. + :vartype localized_value: str + """ + + _validation = { + 'localized_value': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': 'str'}, + 'localized_value': {'key': 'localizedValue', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[str] = None, + **kwargs + ): + super(ResourceName, self).__init__(**kwargs) + self.value = value + self.localized_value = None + + +class ScopeProperties(msrest.serialization.Model): + """ScopeProperties. + + :param scope: + :type scope: str + :param valid: + :type valid: bool + """ + + _attribute_map = { + 'scope': {'key': 'scope', 'type': 'str'}, + 'valid': {'key': 'valid', 'type': 'bool'}, + } + + def __init__( + self, + *, + scope: Optional[str] = None, + valid: Optional[bool] = None, + **kwargs + ): + super(ScopeProperties, self).__init__(**kwargs) + self.scope = scope + self.valid = valid + + +class ServiceError(msrest.serialization.Model): + """The API error details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param code: The error code. + :type code: str + :param message: The error message text. + :type message: str + :ivar details: The list of error details. + :vartype details: list[~azure_reservation_api.models.ServiceErrorDetail] + """ + + _validation = { + 'details': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[ServiceErrorDetail]'}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + **kwargs + ): + super(ServiceError, self).__init__(**kwargs) + self.code = code + self.message = message + self.details = None + + +class ServiceErrorDetail(msrest.serialization.Model): + """The error details. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + """ + + _validation = { + 'code': {'readonly': True}, + 'message': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ServiceErrorDetail, self).__init__(**kwargs) + self.code = None + self.message = None + + +class SkuName(msrest.serialization.Model): + """SkuName. + + :param name: + :type name: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + **kwargs + ): + super(SkuName, self).__init__(**kwargs) + self.name = name + + +class SkuProperty(msrest.serialization.Model): + """SkuProperty. + + :param name: An invariant to describe the feature. + :type name: str + :param value: An invariant if the feature is measured by quantity. + :type value: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + value: Optional[str] = None, + **kwargs + ): + super(SkuProperty, self).__init__(**kwargs) + self.name = name + self.value = value + + +class SkuRestriction(msrest.serialization.Model): + """SkuRestriction. + + :param type: The type of restrictions. + :type type: str + :param values: The value of restrictions. If the restriction type is set to location. This + would be different locations where the SKU is restricted. + :type values: list[str] + :param reason_code: The reason for restriction. + :type reason_code: str + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'values': {'key': 'values', 'type': '[str]'}, + 'reason_code': {'key': 'reasonCode', 'type': 'str'}, + } + + def __init__( + self, + *, + type: Optional[str] = None, + values: Optional[List[str]] = None, + reason_code: Optional[str] = None, + **kwargs + ): + super(SkuRestriction, self).__init__(**kwargs) + self.type = type + self.values = values + self.reason_code = reason_code + + +class SplitRequest(msrest.serialization.Model): + """SplitRequest. + + :param quantities: List of the quantities in the new reservations to create. + :type quantities: list[int] + :param reservation_id: Resource id of the reservation to be split. Format of the resource id + should be + /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}. + :type reservation_id: str + """ + + _attribute_map = { + 'quantities': {'key': 'properties.quantities', 'type': '[int]'}, + 'reservation_id': {'key': 'properties.reservationId', 'type': 'str'}, + } + + def __init__( + self, + *, + quantities: Optional[List[int]] = None, + reservation_id: Optional[str] = None, + **kwargs + ): + super(SplitRequest, self).__init__(**kwargs) + self.quantities = quantities + self.reservation_id = reservation_id + + +class SubRequest(msrest.serialization.Model): + """The sub-request submitted with the quota request. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar limit: Quota (resource limit). + :vartype limit: int + :param name: The resource name. + :type name: ~azure_reservation_api.models.ResourceName + :ivar resource_type: Resource type for which the quota check was made. + :vartype resource_type: str + :param unit: The limit units, such as **count** and **bytes**. Use the unit field provided in + the response of the GET quota operation. + :type unit: str + :param provisioning_state: The quota request status. Possible values include: "Accepted", + "Invalid", "Succeeded", "Failed", "InProgress". + :type provisioning_state: str or ~azure_reservation_api.models.QuotaRequestState + :ivar message: User-friendly status message. + :vartype message: str + :ivar sub_request_id: Sub request ID for individual request. + :vartype sub_request_id: str + """ + + _validation = { + 'limit': {'readonly': True}, + 'resource_type': {'readonly': True}, + 'message': {'readonly': True}, + 'sub_request_id': {'readonly': True}, + } + + _attribute_map = { + 'limit': {'key': 'limit', 'type': 'int'}, + 'name': {'key': 'name', 'type': 'ResourceName'}, + 'resource_type': {'key': 'resourceType', 'type': 'str'}, + 'unit': {'key': 'unit', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'sub_request_id': {'key': 'subRequestId', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional["ResourceName"] = None, + unit: Optional[str] = None, + provisioning_state: Optional[Union[str, "QuotaRequestState"]] = None, + **kwargs + ): + super(SubRequest, self).__init__(**kwargs) + self.limit = None + self.name = name + self.resource_type = None + self.unit = unit + self.provisioning_state = provisioning_state + self.message = None + self.sub_request_id = None + + +class SubscriptionScopeProperties(msrest.serialization.Model): + """SubscriptionScopeProperties. + + :param scopes: + :type scopes: list[~azure_reservation_api.models.ScopeProperties] + """ + + _attribute_map = { + 'scopes': {'key': 'scopes', 'type': '[ScopeProperties]'}, + } + + def __init__( + self, + *, + scopes: Optional[List["ScopeProperties"]] = None, + **kwargs + ): + super(SubscriptionScopeProperties, self).__init__(**kwargs) + self.scopes = scopes diff --git a/src/reservations/azext_reservations/vendored_sdks/quota/operations/__init__.py b/src/reservations/azext_reservations/vendored_sdks/quota/operations/__init__.py new file mode 100644 index 00000000000..5cf631a610f --- /dev/null +++ b/src/reservations/azext_reservations/vendored_sdks/quota/operations/__init__.py @@ -0,0 +1,27 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._reservation_operations import ReservationOperations +from ._azure_reservation_api_operations import AzureReservationAPIOperationsMixin +from ._reservation_order_operations import ReservationOrderOperations +from ._operation_operations import OperationOperations +from ._calculate_exchange_operations import CalculateExchangeOperations +from ._exchange_operations import ExchangeOperations +from ._quota_operations import QuotaOperations +from ._quota_request_status_operations import QuotaRequestStatusOperations + +__all__ = [ + 'ReservationOperations', + 'AzureReservationAPIOperationsMixin', + 'ReservationOrderOperations', + 'OperationOperations', + 'CalculateExchangeOperations', + 'ExchangeOperations', + 'QuotaOperations', + 'QuotaRequestStatusOperations', +] diff --git a/src/reservations/azext_reservations/vendored_sdks/quota/operations/_azure_reservation_api_operations.py b/src/reservations/azext_reservations/vendored_sdks/quota/operations/_azure_reservation_api_operations.py new file mode 100644 index 00000000000..f00cec32bbd --- /dev/null +++ b/src/reservations/azext_reservations/vendored_sdks/quota/operations/_azure_reservation_api_operations.py @@ -0,0 +1,151 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class AzureReservationAPIOperationsMixin(object): + + def get_catalog( + self, + subscription_id, # type: str + reserved_resource_type, # type: str + location=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> List["models.Catalog"] + """Get the regions and skus that are available for RI purchase for the specified Azure subscription. + + Get the regions and skus that are available for RI purchase for the specified Azure + subscription. + + :param subscription_id: Id of the subscription. + :type subscription_id: str + :param reserved_resource_type: The type of the resource for which the skus should be provided. + :type reserved_resource_type: str + :param location: Filters the skus based on the location specified in this parameter. This can + be an azure region or global. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: list of Catalog, or the result of cls(response) + :rtype: list[~azure_reservation_api.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', {})) + api_version = "2020-10-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_catalog.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + query_parameters['reservedResourceType'] = self._serialize.query("reserved_resource_type", reserved_resource_type, 'str') + if location is not None: + query_parameters['location'] = self._serialize.query("location", location, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('[Catalog]', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_catalog.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/catalogs'} # type: ignore + + def get_applied_reservation_list( + self, + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.AppliedReservations" + """Get list of applicable ``Reservation``\ s. + + Get applicable ``Reservation``\ s that are applied to this subscription or a resource group + under this subscription. + + :param subscription_id: Id of the subscription. + :type subscription_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AppliedReservations, or the result of cls(response) + :rtype: ~azure_reservation_api.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', {})) + api_version = "2020-10-01-preview" + accept = "application/json" + + # Construct URL + url = self.get_applied_reservation_list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AppliedReservations', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_applied_reservation_list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/appliedReservations'} # type: ignore diff --git a/src/reservations/azext_reservations/vendored_sdks/quota/operations/_calculate_exchange_operations.py b/src/reservations/azext_reservations/vendored_sdks/quota/operations/_calculate_exchange_operations.py new file mode 100644 index 00000000000..d73a882dd14 --- /dev/null +++ b/src/reservations/azext_reservations/vendored_sdks/quota/operations/_calculate_exchange_operations.py @@ -0,0 +1,162 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure_reservation_api.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. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def _post_initial( + self, + body, # type: "models.CalculateExchangeRequest" + **kwargs # type: Any + ): + # type: (...) -> Optional["models.CalculateExchangeOperationResultResponse"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.CalculateExchangeOperationResultResponse"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._post_initial.metadata['url'] # type: ignore + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(body, 'CalculateExchangeRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('CalculateExchangeOperationResultResponse', pipeline_response) + + if response.status_code == 202: + response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + _post_initial.metadata = {'url': '/providers/Microsoft.Capacity/calculateExchange'} # type: ignore + + def begin_post( + self, + body, # type: "models.CalculateExchangeRequest" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["models.CalculateExchangeOperationResultResponse"] + """Calculates the refund amounts and price of the new purchases. + + Calculates price for exchanging ``Reservations`` if there are no policy errors. + + :param body: Request containing purchases and refunds that need to be executed. + :type body: ~azure_reservation_api.models.CalculateExchangeRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either CalculateExchangeOperationResultResponse or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure_reservation_api.models.CalculateExchangeOperationResultResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + 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( + body=body, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_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() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_post.metadata = {'url': '/providers/Microsoft.Capacity/calculateExchange'} # type: ignore diff --git a/src/reservations/azext_reservations/vendored_sdks/quota/operations/_exchange_operations.py b/src/reservations/azext_reservations/vendored_sdks/quota/operations/_exchange_operations.py new file mode 100644 index 00000000000..8dec96df551 --- /dev/null +++ b/src/reservations/azext_reservations/vendored_sdks/quota/operations/_exchange_operations.py @@ -0,0 +1,162 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure_reservation_api.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. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def _post_initial( + self, + body, # type: "models.ExchangeRequest" + **kwargs # type: Any + ): + # type: (...) -> Optional["models.ExchangeOperationResultResponse"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.ExchangeOperationResultResponse"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._post_initial.metadata['url'] # type: ignore + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(body, 'ExchangeRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ExchangeOperationResultResponse', pipeline_response) + + if response.status_code == 202: + response_headers['Azure-AsyncOperation']=self._deserialize('str', response.headers.get('Azure-AsyncOperation')) + response_headers['Location']=self._deserialize('str', response.headers.get('Location')) + response_headers['Retry-After']=self._deserialize('int', response.headers.get('Retry-After')) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + _post_initial.metadata = {'url': '/providers/Microsoft.Capacity/exchange'} # type: ignore + + def begin_post( + self, + body, # type: "models.ExchangeRequest" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["models.ExchangeOperationResultResponse"] + """Exchange Reservation(s). + + Returns one or more ``Reservations`` in exchange for one or more ``Reservation`` purchases. + + :param body: Request containing the refunds and purchases that need to be executed. + :type body: ~azure_reservation_api.models.ExchangeRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either ExchangeOperationResultResponse or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure_reservation_api.models.ExchangeOperationResultResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + 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( + body=body, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_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() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_post.metadata = {'url': '/providers/Microsoft.Capacity/exchange'} # type: ignore diff --git a/src/reservations/azext_reservations/vendored_sdks/quota/operations/_operation_operations.py b/src/reservations/azext_reservations/vendored_sdks/quota/operations/_operation_operations.py new file mode 100644 index 00000000000..c3e46c53bb8 --- /dev/null +++ b/src/reservations/azext_reservations/vendored_sdks/quota/operations/_operation_operations.py @@ -0,0 +1,112 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure_reservation_api.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. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.OperationList"] + """Get operations. + + List all the operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationList or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure_reservation_api.models.OperationList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.OperationList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('OperationList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.Error, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Capacity/operations'} # type: ignore diff --git a/src/reservations/azext_reservations/vendored_sdks/quota/operations/_quota_operations.py b/src/reservations/azext_reservations/vendored_sdks/quota/operations/_quota_operations.py new file mode 100644 index 00000000000..8623aa69d7d --- /dev/null +++ b/src/reservations/azext_reservations/vendored_sdks/quota/operations/_quota_operations.py @@ -0,0 +1,508 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure_reservation_api.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. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def get( + self, + subscription_id, # type: str + provider_id, # type: str + location, # type: str + resource_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "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. + + :param subscription_id: Azure subscription ID. + :type subscription_id: str + :param provider_id: Azure resource provider ID. + :type provider_id: str + :param location: Azure region. + :type location: str + :param resource_name: The resource name for a resource provider, such as SKU name for + Microsoft.Compute, Sku or TotalLowPriorityCores for Microsoft.MachineLearningServices. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CurrentQuotaLimitBase, or the result of cls(response) + :rtype: ~azure_reservation_api.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', {})) + api_version = "2020-10-25" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + 'providerId': self._serialize.url("provider_id", provider_id, 'str'), + 'location': self._serialize.url("location", location, 'str'), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ExceptionResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + deserialized = self._deserialize('CurrentQuotaLimitBase', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/resourceProviders/{providerId}/locations/{location}/serviceLimits/{resourceName}'} # type: ignore + + def _create_or_update_initial( + self, + subscription_id, # type: str + provider_id, # type: str + location, # type: str + resource_name, # type: str + create_quota_request, # type: "models.CurrentQuotaLimitBase" + **kwargs # type: Any + ): + # type: (...) -> Union["models.QuotaRequestOneResourceSubmitResponse", "models.QuotaRequestSubmitResponse201"] + cls = kwargs.pop('cls', None) # type: ClsType[Union["models.QuotaRequestOneResourceSubmitResponse", "models.QuotaRequestSubmitResponse201"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-25" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + 'providerId': self._serialize.url("provider_id", provider_id, 'str'), + 'location': self._serialize.url("location", location, 'str'), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(create_quota_request, 'CurrentQuotaLimitBase') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ExceptionResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('QuotaRequestOneResourceSubmitResponse', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('QuotaRequestSubmitResponse201', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/resourceProviders/{providerId}/locations/{location}/serviceLimits/{resourceName}'} # type: ignore + + def begin_create_or_update( + self, + subscription_id, # type: str + provider_id, # type: str + location, # type: str + resource_name, # type: str + create_quota_request, # type: "models.CurrentQuotaLimitBase" + **kwargs # type: Any + ): + # type: (...) -> LROPoller[Union["models.QuotaRequestOneResourceSubmitResponse", "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. + The Create quota request may be constructed as follows. The PUT operation can be used to + update the quota. + + :param subscription_id: Azure subscription ID. + :type subscription_id: str + :param provider_id: Azure resource provider ID. + :type provider_id: str + :param location: Azure region. + :type location: str + :param resource_name: The resource name for a resource provider, such as SKU name for + Microsoft.Compute, Sku or TotalLowPriorityCores for Microsoft.MachineLearningServices. + :type resource_name: str + :param create_quota_request: Quota requests payload. + :type create_quota_request: ~azure_reservation_api.models.CurrentQuotaLimitBase + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either QuotaRequestOneResourceSubmitResponse or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure_reservation_api.models.QuotaRequestOneResourceSubmitResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[Union["models.QuotaRequestOneResourceSubmitResponse", "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( + subscription_id=subscription_id, + provider_id=provider_id, + location=location, + resource_name=resource_name, + create_quota_request=create_quota_request, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('QuotaRequestOneResourceSubmitResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + 'providerId': self._serialize.url("provider_id", provider_id, 'str'), + 'location': self._serialize.url("location", location, 'str'), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/resourceProviders/{providerId}/locations/{location}/serviceLimits/{resourceName}'} # type: ignore + + def _update_initial( + self, + subscription_id, # type: str + provider_id, # type: str + location, # type: str + resource_name, # type: str + create_quota_request, # type: "models.CurrentQuotaLimitBase" + **kwargs # type: Any + ): + # type: (...) -> Union["models.QuotaRequestOneResourceSubmitResponse", "models.QuotaRequestSubmitResponse201"] + cls = kwargs.pop('cls', None) # type: ClsType[Union["models.QuotaRequestOneResourceSubmitResponse", "models.QuotaRequestSubmitResponse201"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-25" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + 'providerId': self._serialize.url("provider_id", provider_id, 'str'), + 'location': self._serialize.url("location", location, 'str'), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(create_quota_request, 'CurrentQuotaLimitBase') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ExceptionResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('QuotaRequestOneResourceSubmitResponse', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('QuotaRequestSubmitResponse201', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/resourceProviders/{providerId}/locations/{location}/serviceLimits/{resourceName}'} # type: ignore + + def begin_update( + self, + subscription_id, # type: str + provider_id, # type: str + location, # type: str + resource_name, # type: str + create_quota_request, # type: "models.CurrentQuotaLimitBase" + **kwargs # type: Any + ): + # type: (...) -> LROPoller[Union["models.QuotaRequestOneResourceSubmitResponse", "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. + + :param subscription_id: Azure subscription ID. + :type subscription_id: str + :param provider_id: Azure resource provider ID. + :type provider_id: str + :param location: Azure region. + :type location: str + :param resource_name: The resource name for a resource provider, such as SKU name for + Microsoft.Compute, Sku or TotalLowPriorityCores for Microsoft.MachineLearningServices. + :type resource_name: str + :param create_quota_request: Payload for the quota request. + :type create_quota_request: ~azure_reservation_api.models.CurrentQuotaLimitBase + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either QuotaRequestOneResourceSubmitResponse or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure_reservation_api.models.QuotaRequestOneResourceSubmitResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[Union["models.QuotaRequestOneResourceSubmitResponse", "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( + subscription_id=subscription_id, + provider_id=provider_id, + location=location, + resource_name=resource_name, + create_quota_request=create_quota_request, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('QuotaRequestOneResourceSubmitResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + 'providerId': self._serialize.url("provider_id", provider_id, 'str'), + 'location': self._serialize.url("location", location, 'str'), + 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/resourceProviders/{providerId}/locations/{location}/serviceLimits/{resourceName}'} # type: ignore + + def list( + self, + subscription_id, # type: str + provider_id, # type: str + location, # type: str + **kwargs # type: Any + ): + # type: (...) -> 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. + + :param subscription_id: Azure subscription ID. + :type subscription_id: str + :param provider_id: Azure resource provider ID. + :type provider_id: str + :param location: Azure region. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either QuotaLimits or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure_reservation_api.models.QuotaLimits] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.QuotaLimits"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-25" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + 'providerId': self._serialize.url("provider_id", provider_id, 'str'), + 'location': self._serialize.url("location", location, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('QuotaLimits', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ExceptionResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/resourceProviders/{providerId}/locations/{location}/serviceLimits'} # type: ignore diff --git a/src/reservations/azext_reservations/vendored_sdks/quota/operations/_quota_request_status_operations.py b/src/reservations/azext_reservations/vendored_sdks/quota/operations/_quota_request_status_operations.py new file mode 100644 index 00000000000..94281521c33 --- /dev/null +++ b/src/reservations/azext_reservations/vendored_sdks/quota/operations/_quota_request_status_operations.py @@ -0,0 +1,221 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure_reservation_api.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. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def get( + self, + subscription_id, # type: str + provider_id, # type: str + location, # type: str + id, # type: str + **kwargs # type: Any + ): + # type: (...) -> "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. + + :param subscription_id: Azure subscription ID. + :type subscription_id: str + :param provider_id: Azure resource provider ID. + :type provider_id: str + :param location: Azure region. + :type location: str + :param id: Quota Request ID. + :type id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: QuotaRequestDetails, or the result of cls(response) + :rtype: ~azure_reservation_api.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', {})) + api_version = "2020-10-25" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + 'providerId': self._serialize.url("provider_id", provider_id, 'str'), + 'location': self._serialize.url("location", location, 'str'), + 'id': self._serialize.url("id", id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ExceptionResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('QuotaRequestDetails', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/resourceProviders/{providerId}/locations/{location}/serviceLimitsRequests/{id}'} # type: ignore + + def list( + self, + subscription_id, # type: str + provider_id, # type: str + location, # type: str + filter=None, # type: Optional[str] + top=None, # type: Optional[int] + skiptoken=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> 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. + + :param subscription_id: Azure subscription ID. + :type subscription_id: str + :param provider_id: Azure resource provider ID. + :type provider_id: str + :param location: Azure region. + :type location: str + :param filter: .. list-table:: + :header-rows: 1 + + * - Field + - Supported operators + * - + + + |requestSubmitTime | ge, le, eq, gt, lt. + :type filter: str + :param top: Number of records to return. + :type top: int + :param skiptoken: Skiptoken is only used if a previous operation returned a partial result. If + a previous response contains a nextLink element, the value of the nextLink element includes a + skiptoken parameter that specifies a starting point to use for subsequent calls. + :type skiptoken: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either QuotaRequestDetailsList or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure_reservation_api.models.QuotaRequestDetailsList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.QuotaRequestDetailsList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-25" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), + 'providerId': self._serialize.url("provider_id", provider_id, 'str'), + 'location': self._serialize.url("location", location, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') + if top is not None: + query_parameters['$top'] = self._serialize.query("top", top, 'int', minimum=1) + if skiptoken is not None: + query_parameters['$skiptoken'] = self._serialize.query("skiptoken", skiptoken, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('QuotaRequestDetailsList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ExceptionResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/resourceProviders/{providerId}/locations/{location}/serviceLimitsRequests'} # type: ignore diff --git a/src/reservations/azext_reservations/vendored_sdks/quota/operations/_reservation_operations.py b/src/reservations/azext_reservations/vendored_sdks/quota/operations/_reservation_operations.py new file mode 100644 index 00000000000..62ad145dad3 --- /dev/null +++ b/src/reservations/azext_reservations/vendored_sdks/quota/operations/_reservation_operations.py @@ -0,0 +1,765 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure_reservation_api.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. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def _available_scopes_initial( + self, + reservation_order_id, # type: str + reservation_id, # type: str + body, # type: "models.AvailableScopeRequest" + **kwargs # type: Any + ): + # type: (...) -> "models.AvailableScopeProperties" + cls = kwargs.pop('cls', None) # type: ClsType["models.AvailableScopeProperties"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._available_scopes_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'reservationOrderId': self._serialize.url("reservation_order_id", reservation_order_id, 'str'), + 'reservationId': self._serialize.url("reservation_id", reservation_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(body, 'AvailableScopeRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('AvailableScopeProperties', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _available_scopes_initial.metadata = {'url': '/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}/availableScopes'} # type: ignore + + def begin_available_scopes( + self, + reservation_order_id, # type: str + reservation_id, # type: str + body, # type: "models.AvailableScopeRequest" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["models.AvailableScopeProperties"] + """Get Available Scopes for ``Reservation``. + + Get Available Scopes for ``Reservation``. + + :param reservation_order_id: Order Id of the reservation. + :type reservation_order_id: str + :param reservation_id: Id of the Reservation Item. + :type reservation_id: str + :param body: + :type body: ~azure_reservation_api.models.AvailableScopeRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either AvailableScopeProperties or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure_reservation_api.models.AvailableScopeProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + 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( + reservation_order_id=reservation_order_id, + reservation_id=reservation_id, + body=body, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('AvailableScopeProperties', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'reservationOrderId': self._serialize.url("reservation_order_id", reservation_order_id, 'str'), + 'reservationId': self._serialize.url("reservation_id", reservation_id, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_available_scopes.metadata = {'url': '/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}/availableScopes'} # type: ignore + + def _split_initial( + self, + reservation_order_id, # type: str + body, # type: "models.SplitRequest" + **kwargs # type: Any + ): + # type: (...) -> Optional[List["models.ReservationResponse"]] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[List["models.ReservationResponse"]]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._split_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'reservationOrderId': self._serialize.url("reservation_order_id", reservation_order_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(body, 'SplitRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('[ReservationResponse]', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _split_initial.metadata = {'url': '/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/split'} # type: ignore + + def begin_split( + self, + reservation_order_id, # type: str + body, # type: "models.SplitRequest" + **kwargs # type: Any + ): + # type: (...) -> LROPoller[List["models.ReservationResponse"]] + """Split the ``Reservation``. + + Split a ``Reservation`` into two ``Reservation``\ s with specified quantity distribution. + + :param reservation_order_id: Order Id of the reservation. + :type reservation_order_id: str + :param body: Information needed to Split a reservation item. + :type body: ~azure_reservation_api.models.SplitRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either list of ReservationResponse or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[list[~azure_reservation_api.models.ReservationResponse]] + :raises ~azure.core.exceptions.HttpResponseError: + """ + 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( + reservation_order_id=reservation_order_id, + body=body, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('[ReservationResponse]', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'reservationOrderId': self._serialize.url("reservation_order_id", reservation_order_id, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_split.metadata = {'url': '/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/split'} # type: ignore + + def _merge_initial( + self, + reservation_order_id, # type: str + body, # type: "models.MergeRequest" + **kwargs # type: Any + ): + # type: (...) -> Optional[List["models.ReservationResponse"]] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[List["models.ReservationResponse"]]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._merge_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'reservationOrderId': self._serialize.url("reservation_order_id", reservation_order_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(body, 'MergeRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('[ReservationResponse]', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _merge_initial.metadata = {'url': '/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/merge'} # type: ignore + + def begin_merge( + self, + reservation_order_id, # type: str + body, # type: "models.MergeRequest" + **kwargs # type: Any + ): + # type: (...) -> LROPoller[List["models.ReservationResponse"]] + """Merges two ``Reservation``\ s. + + Merge the specified ``Reservation``\ s into a new ``Reservation``. The two ``Reservation``\ s + being merged must have same properties. + + :param reservation_order_id: Order Id of the reservation. + :type reservation_order_id: str + :param body: Information needed for commercial request for a reservation. + :type body: ~azure_reservation_api.models.MergeRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either list of ReservationResponse or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[list[~azure_reservation_api.models.ReservationResponse]] + :raises ~azure.core.exceptions.HttpResponseError: + """ + 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( + reservation_order_id=reservation_order_id, + body=body, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('[ReservationResponse]', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'reservationOrderId': self._serialize.url("reservation_order_id", reservation_order_id, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_merge.metadata = {'url': '/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/merge'} # type: ignore + + def list( + self, + reservation_order_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ReservationList"] + """Get ``Reservation``\ s in a given reservation Order. + + List ``Reservation``\ s within a single ``ReservationOrder``. + + :param reservation_order_id: Order Id of the reservation. + :type reservation_order_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ReservationList or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure_reservation_api.models.ReservationList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ReservationList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'reservationOrderId': self._serialize.url("reservation_order_id", reservation_order_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('ReservationList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.Error, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations'} # type: ignore + + def get( + self, + reservation_id, # type: str + reservation_order_id, # type: str + expand=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.ReservationResponse" + """Get ``Reservation`` details. + + Get specific ``Reservation`` details. + + :param reservation_id: Id of the Reservation Item. + :type reservation_id: str + :param reservation_order_id: Order Id of the reservation. + :type reservation_order_id: str + :param expand: Supported value of this query is renewProperties. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ReservationResponse, or the result of cls(response) + :rtype: ~azure_reservation_api.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', {})) + api_version = "2020-10-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'reservationId': self._serialize.url("reservation_id", reservation_id, 'str'), + 'reservationOrderId': self._serialize.url("reservation_order_id", reservation_order_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if expand is not None: + query_parameters['expand'] = self._serialize.query("expand", expand, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ReservationResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}'} # type: ignore + + def _update_initial( + self, + reservation_order_id, # type: str + reservation_id, # type: str + parameters, # type: "models.Patch" + **kwargs # type: Any + ): + # type: (...) -> Optional["models.ReservationResponse"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.ReservationResponse"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'reservationOrderId': self._serialize.url("reservation_order_id", reservation_order_id, 'str'), + 'reservationId': self._serialize.url("reservation_id", reservation_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'Patch') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ReservationResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _update_initial.metadata = {'url': '/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}'} # type: ignore + + def begin_update( + self, + reservation_order_id, # type: str + reservation_id, # type: str + parameters, # type: "models.Patch" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["models.ReservationResponse"] + """Updates a ``Reservation``. + + Updates the applied scopes of the ``Reservation``. + + :param reservation_order_id: Order Id of the reservation. + :type reservation_order_id: str + :param reservation_id: Id of the Reservation Item. + :type reservation_id: str + :param parameters: Information needed to patch a reservation item. + :type parameters: ~azure_reservation_api.models.Patch + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either ReservationResponse or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure_reservation_api.models.ReservationResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + 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( + reservation_order_id=reservation_order_id, + reservation_id=reservation_id, + parameters=parameters, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ReservationResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'reservationOrderId': self._serialize.url("reservation_order_id", reservation_order_id, 'str'), + 'reservationId': self._serialize.url("reservation_id", reservation_id, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}'} # type: ignore + + def list_revisions( + self, + reservation_id, # type: str + reservation_order_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ReservationList"] + """Get ``Reservation`` revisions. + + List of all the revisions for the ``Reservation``. + + :param reservation_id: Id of the Reservation Item. + :type reservation_id: str + :param reservation_order_id: Order Id of the reservation. + :type reservation_order_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ReservationList or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure_reservation_api.models.ReservationList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ReservationList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_revisions.metadata['url'] # type: ignore + path_format_arguments = { + 'reservationId': self._serialize.url("reservation_id", reservation_id, 'str'), + 'reservationOrderId': self._serialize.url("reservation_order_id", reservation_order_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('ReservationList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.Error, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list_revisions.metadata = {'url': '/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}/revisions'} # type: ignore diff --git a/src/reservations/azext_reservations/vendored_sdks/quota/operations/_reservation_order_operations.py b/src/reservations/azext_reservations/vendored_sdks/quota/operations/_reservation_order_operations.py new file mode 100644 index 00000000000..dd65ec9b881 --- /dev/null +++ b/src/reservations/azext_reservations/vendored_sdks/quota/operations/_reservation_order_operations.py @@ -0,0 +1,358 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +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. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure_reservation_api.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. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def calculate( + self, + body, # type: "models.PurchaseRequest" + **kwargs # type: Any + ): + # type: (...) -> "models.CalculatePriceResponse" + """Calculate price for a ``ReservationOrder``. + + Calculate price for placing a ``ReservationOrder``. + + :param body: Information needed for calculate or purchase reservation. + :type body: ~azure_reservation_api.models.PurchaseRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CalculatePriceResponse, or the result of cls(response) + :rtype: ~azure_reservation_api.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', {})) + api_version = "2020-10-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.calculate.metadata['url'] # type: ignore + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(body, 'PurchaseRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('CalculatePriceResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + calculate.metadata = {'url': '/providers/Microsoft.Capacity/calculatePrice'} # type: ignore + + def list( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.ReservationOrderList"] + """Get all ``ReservationOrder``\ s. + + List of all the ``ReservationOrder``\ s that the user has access to in the current tenant. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ReservationOrderList or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure_reservation_api.models.ReservationOrderList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.ReservationOrderList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('ReservationOrderList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.Error, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.Capacity/reservationOrders'} # type: ignore + + def _purchase_initial( + self, + reservation_order_id, # type: str + body, # type: "models.PurchaseRequest" + **kwargs # type: Any + ): + # type: (...) -> "models.ReservationOrderResponse" + cls = kwargs.pop('cls', None) # type: ClsType["models.ReservationOrderResponse"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-01-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._purchase_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'reservationOrderId': self._serialize.url("reservation_order_id", reservation_order_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(body, 'PurchaseRequest') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ReservationOrderResponse', pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize('ReservationOrderResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + _purchase_initial.metadata = {'url': '/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}'} # type: ignore + + def begin_purchase( + self, + reservation_order_id, # type: str + body, # type: "models.PurchaseRequest" + **kwargs # type: Any + ): + # type: (...) -> LROPoller["models.ReservationOrderResponse"] + """Purchase ``ReservationOrder``. + + Purchase ``ReservationOrder`` and create resource under the specified URI. + + :param reservation_order_id: Order Id of the reservation. + :type reservation_order_id: str + :param body: Information needed for calculate or purchase reservation. + :type body: ~azure_reservation_api.models.PurchaseRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :return: An instance of LROPoller that returns either ReservationOrderResponse or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure_reservation_api.models.ReservationOrderResponse] + :raises ~azure.core.exceptions.HttpResponseError: + """ + 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( + reservation_order_id=reservation_order_id, + body=body, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ReservationOrderResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'reservationOrderId': self._serialize.url("reservation_order_id", reservation_order_id, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_purchase.metadata = {'url': '/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}'} # type: ignore + + def get( + self, + reservation_order_id, # type: str + expand=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> "models.ReservationOrderResponse" + """Get a specific ``ReservationOrder``. + + Get the details of the ``ReservationOrder``. + + :param reservation_order_id: Order Id of the reservation. + :type reservation_order_id: str + :param expand: May be used to expand the planInformation. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ReservationOrderResponse, or the result of cls(response) + :rtype: ~azure_reservation_api.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', {})) + api_version = "2020-10-01-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'reservationOrderId': self._serialize.url("reservation_order_id", reservation_order_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if expand is not None: + query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ReservationOrderResponse', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}'} # type: ignore diff --git a/src/reservations/azext_reservations/vendored_sdks/quota/py.typed b/src/reservations/azext_reservations/vendored_sdks/quota/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/src/reservations/azext_reservations/vendored_sdks/quota/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/src/reservations/report.md b/src/reservations/report.md new file mode 100644 index 00000000000..a5584a3c9c1 --- /dev/null +++ b/src/reservations/report.md @@ -0,0 +1,463 @@ +# Azure CLI Module Creation Report + +## EXTENSION +|CLI Extension|Command Groups| +|---------|------------| +|az quota|[groups](#CommandGroups) + +## GROUPS +### Command groups in `az quota` extension +|CLI Command Group|Group Swagger name|Commands| +|---------|------------|--------| +|az quota reservation|Reservation|[commands](#CommandsInReservation)| +|az quota||[commands](#CommandsIn)| +|az quota reservation-order|ReservationOrder|[commands](#CommandsInReservationOrder)| +|az quota operation|Operation|[commands](#CommandsInOperation)| +|az quota calculate-exchange|CalculateExchange|[commands](#CommandsInCalculateExchange)| +|az quota exchange|Exchange|[commands](#CommandsInExchange)| +|az quota|Quota|[commands](#CommandsInQuota)| +|az quota quota-request-status|QuotaRequestStatus|[commands](#CommandsInQuotaRequestStatus)| + +## COMMANDS +### Commands in `az quota` group +|CLI Command|Operation Swagger name|Parameters|Examples| +|---------|------------|--------|-----------| +|[az quota show-applied-reservation-list](#GetAppliedReservationList)|GetAppliedReservationList|[Parameters](#ParametersGetAppliedReservationList)|[Example](#ExamplesGetAppliedReservationList)| +|[az quota show-catalog](#GetCatalog)|GetCatalog|[Parameters](#ParametersGetCatalog)|[Example](#ExamplesGetCatalog)| + +### Commands in `az quota` group +|CLI Command|Operation Swagger name|Parameters|Examples| +|---------|------------|--------|-----------| +|[az quota list](#QuotaList)|List|[Parameters](#ParametersQuotaList)|[Example](#ExamplesQuotaList)| +|[az quota show](#QuotaGet)|Get|[Parameters](#ParametersQuotaGet)|[Example](#ExamplesQuotaGet)| +|[az quota create](#QuotaCreateOrUpdate#Create)|CreateOrUpdate#Create|[Parameters](#ParametersQuotaCreateOrUpdate#Create)|[Example](#ExamplesQuotaCreateOrUpdate#Create)| +|[az quota update](#QuotaUpdate)|Update|[Parameters](#ParametersQuotaUpdate)|[Example](#ExamplesQuotaUpdate)| + +### Commands in `az quota calculate-exchange` group +|CLI Command|Operation Swagger name|Parameters|Examples| +|---------|------------|--------|-----------| +|[az quota calculate-exchange post](#CalculateExchangePost)|Post|[Parameters](#ParametersCalculateExchangePost)|[Example](#ExamplesCalculateExchangePost)| + +### Commands in `az quota exchange` group +|CLI Command|Operation Swagger name|Parameters|Examples| +|---------|------------|--------|-----------| +|[az quota exchange post](#ExchangePost)|Post|[Parameters](#ParametersExchangePost)|[Example](#ExamplesExchangePost)| + +### Commands in `az quota operation` group +|CLI Command|Operation Swagger name|Parameters|Examples| +|---------|------------|--------|-----------| +|[az quota operation list](#OperationList)|List|[Parameters](#ParametersOperationList)|[Example](#ExamplesOperationList)| + +### Commands in `az quota quota-request-status` group +|CLI Command|Operation Swagger name|Parameters|Examples| +|---------|------------|--------|-----------| +|[az quota quota-request-status list](#QuotaRequestStatusList)|List|[Parameters](#ParametersQuotaRequestStatusList)|[Example](#ExamplesQuotaRequestStatusList)| +|[az quota quota-request-status show](#QuotaRequestStatusGet)|Get|[Parameters](#ParametersQuotaRequestStatusGet)|[Example](#ExamplesQuotaRequestStatusGet)| + +### Commands in `az quota reservation` group +|CLI Command|Operation Swagger name|Parameters|Examples| +|---------|------------|--------|-----------| +|[az quota reservation list](#ReservationList)|List|[Parameters](#ParametersReservationList)|[Example](#ExamplesReservationList)| +|[az quota reservation show](#ReservationGet)|Get|[Parameters](#ParametersReservationGet)|[Example](#ExamplesReservationGet)| +|[az quota reservation update](#ReservationUpdate)|Update|[Parameters](#ParametersReservationUpdate)|[Example](#ExamplesReservationUpdate)| +|[az quota reservation available-scope](#ReservationAvailableScopes)|AvailableScopes|[Parameters](#ParametersReservationAvailableScopes)|[Example](#ExamplesReservationAvailableScopes)| +|[az quota reservation list-revision](#ReservationListRevisions)|ListRevisions|[Parameters](#ParametersReservationListRevisions)|[Example](#ExamplesReservationListRevisions)| +|[az quota reservation merge](#ReservationMerge)|Merge|[Parameters](#ParametersReservationMerge)|[Example](#ExamplesReservationMerge)| +|[az quota reservation split](#ReservationSplit)|Split|[Parameters](#ParametersReservationSplit)|[Example](#ExamplesReservationSplit)| + +### Commands in `az quota reservation-order` group +|CLI Command|Operation Swagger name|Parameters|Examples| +|---------|------------|--------|-----------| +|[az quota reservation-order list](#ReservationOrderList)|List|[Parameters](#ParametersReservationOrderList)|[Example](#ExamplesReservationOrderList)| +|[az quota reservation-order show](#ReservationOrderGet)|Get|[Parameters](#ParametersReservationOrderGet)|[Example](#ExamplesReservationOrderGet)| +|[az quota reservation-order calculate](#ReservationOrderCalculate)|Calculate|[Parameters](#ParametersReservationOrderCalculate)|[Example](#ExamplesReservationOrderCalculate)| +|[az quota reservation-order purchase](#ReservationOrderPurchase)|Purchase|[Parameters](#ParametersReservationOrderPurchase)|[Example](#ExamplesReservationOrderPurchase)| + + +## COMMAND DETAILS + +### group `az quota` +#### Command `az quota show-applied-reservation-list` + +##### Example +``` +az quota show-applied-reservation-list --subscription-id "23bc208b-083f-4901-ae85-4f98c0c3b4b6" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--subscription-id**|string|Id of the subscription|subscription_id|subscriptionId| + +#### Command `az quota show-catalog` + +##### Example +``` +az quota show-catalog --location "eastus" --reserved-resource-type "VirtualMachines" --subscription-id \ +"23bc208b-083f-4901-ae85-4f98c0c3b4b6" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--subscription-id**|string|Id of the subscription|subscription_id|subscriptionId| +|**--reserved-resource-type**|string|The type of the resource for which the skus should be provided.|reserved_resource_type|reservedResourceType| +|**--location**|string|Filters the skus based on the location specified in this parameter. This can be an azure region or global|location|location| + +### group `az quota` +#### Command `az quota list` + +##### Example +``` +az quota list --location "eastus" --provider-id "Microsoft.Compute" --subscription-id "00000000-0000-0000-0000-00000000\ +0000" +``` +##### Example +``` +az quota list --location "eastus" --provider-id "Microsoft.MachineLearningServices" --subscription-id \ +"00000000-0000-0000-0000-000000000000" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--subscription-id**|string|Azure subscription ID.|subscription_id|subscriptionId| +|**--provider-id**|string|Azure resource provider ID.|provider_id|providerId| +|**--location**|string|Azure region.|location|location| + +#### Command `az quota show` + +##### Example +``` +az quota show --location "eastus" --provider-id "Microsoft.Compute" --resource-name "standardNDSFamily" \ +--subscription-id "00000000-0000-0000-0000-000000000000" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--subscription-id**|string|Azure subscription ID.|subscription_id|subscriptionId| +|**--provider-id**|string|Azure resource provider ID.|provider_id|providerId| +|**--location**|string|Azure region.|location|location| +|**--resource-name**|string|The resource name for a resource provider, such as SKU name for Microsoft.Compute, Sku or TotalLowPriorityCores for Microsoft.MachineLearningServices|resource_name|resourceName| + +#### Command `az quota create` + +##### Example +``` +az quota create --properties "{\\"name\\":{\\"value\\":\\"standardFSv2Family\\"},\\"limit\\":200,\\"unit\\":\\"Count\\"\ +}" --location "eastus" --provider-id "Microsoft.Compute" --resource-name "standardFSv2Family" --subscription-id \ +"D7EC67B3-7657-4966-BFFC-41EFD36BAAB3" +``` +##### Example +``` +az quota create --properties "{\\"name\\":{\\"value\\":\\"StandardDv2Family\\"},\\"limit\\":200,\\"resourceType\\":\\"d\ +edicated\\",\\"unit\\":\\"Count\\"}" --location "eastus" --provider-id "Microsoft.MachineLearningServices" \ +--resource-name "StandardDv2Family" --subscription-id "D7EC67B3-7657-4966-BFFC-41EFD36BAAB3" +``` +##### Example +``` +az quota create --properties "{\\"name\\":{\\"value\\":\\"TotalLowPriorityCores\\"},\\"limit\\":200,\\"resourceType\\":\ +\\"lowPriority\\",\\"unit\\":\\"Count\\"}" --location "eastus" --provider-id "Microsoft.MachineLearningServices" \ +--resource-name "TotalLowPriorityCores" --subscription-id "D7EC67B3-7657-4966-BFFC-41EFD36BAAB3" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--subscription-id**|string|Azure subscription ID.|subscription_id|subscriptionId| +|**--provider-id**|string|Azure resource provider ID.|provider_id|providerId| +|**--location**|string|Azure region.|location|location| +|**--resource-name**|string|The resource name for a resource provider, such as SKU name for Microsoft.Compute, Sku or TotalLowPriorityCores for Microsoft.MachineLearningServices|resource_name|resourceName| +|**--limit**|integer|Quota properties.|limit|limit| +|**--unit**|string| The limit units, such as **count** and **bytes**. Use the unit field provided in the response of the GET quota operation.|unit|unit| +|**--resource-type**|choice|The name of the resource type.|resource_type|resourceType| +|**--properties**|any|Additional properties for the specified resource provider.|properties|properties| +|**--value**|string|Resource name.|value|value| + +#### Command `az quota update` + +##### Example +``` +az quota update --properties "{\\"name\\":{\\"value\\":\\"standardFSv2Family\\"},\\"limit\\":200,\\"unit\\":\\"Count\\"\ +}" --location "eastus" --provider-id "Microsoft.Compute" --resource-name "standardFSv2Family" --subscription-id \ +"D7EC67B3-7657-4966-BFFC-41EFD36BAAB3" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--subscription-id**|string|Azure subscription ID.|subscription_id|subscriptionId| +|**--provider-id**|string|Azure resource provider ID.|provider_id|providerId| +|**--location**|string|Azure region.|location|location| +|**--resource-name**|string|The resource name for a resource provider, such as SKU name for Microsoft.Compute, Sku or TotalLowPriorityCores for Microsoft.MachineLearningServices|resource_name|resourceName| +|**--limit**|integer|Quota properties.|limit|limit| +|**--unit**|string| The limit units, such as **count** and **bytes**. Use the unit field provided in the response of the GET quota operation.|unit|unit| +|**--resource-type**|choice|The name of the resource type.|resource_type|resourceType| +|**--properties**|any|Additional properties for the specified resource provider.|properties|properties| +|**--value**|string|Resource name.|value|value| + +### group `az quota calculate-exchange` +#### Command `az quota calculate-exchange post` + +##### Example +``` +az quota calculate-exchange post --reservations-to-exchange quantity=1 reservation-id="/providers/microsoft.capacity/re\ +servationOrders/1f14354c-dc12-4c8d-8090-6f295a3a34aa/reservations/c8c926bd-fc5d-4e29-9d43-b68340ac23a6" \ +--reservations-to-purchase location="westus" reserved-resource-type="VirtualMachines" billing-scope-id="/subscriptions/\ +ed3a1871-612d-abcd-a849-c2542a68be83" term="P1Y" billing-plan="Upfront" quantity=1 display-name="testDisplayName" \ +applied-scope-type="Shared" applied-scopes=null renew=false instance-flexibility="On" name="Standard_B1ls" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--reservations-to-purchase**|array|List of reservations that are being purchased in this exchange.|reservations_to_purchase|reservationsToPurchase| +|**--reservations-to-exchange**|array|List of reservations that are being returned in this exchange.|reservations_to_exchange|reservationsToExchange| + +### group `az quota exchange` +#### Command `az quota exchange post` + +##### Example +``` +az quota exchange post --session-id "66e2ac8f-439e-4345-8235-6fef07608081" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--session-id**|string|SessionId that was returned by CalculateExchange API.|session_id|sessionId| + +### group `az quota operation` +#### Command `az quota operation list` + +##### Example +``` +az quota operation list +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +### group `az quota quota-request-status` +#### Command `az quota quota-request-status list` + +##### Example +``` +az quota quota-request-status list --location "eastus" --provider-id "Microsoft.Compute" --subscription-id \ +"3f75fdf7-977e-44ad-990d-99f14f0f299f" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--subscription-id**|string|Azure subscription ID.|subscription_id|subscriptionId| +|**--provider-id**|string|Azure resource provider ID.|provider_id|providerId| +|**--location**|string|Azure region.|location|location| +|**--filter**|string|| Field | Supported operators |---------------------|------------------------ |requestSubmitTime | ge, le, eq, gt, lt |filter|$filter| +|**--top**|integer|Number of records to return.|top|$top| +|**--skiptoken**|string|Skiptoken is only used if a previous operation returned a partial result. If a previous response contains a nextLink element, the value of the nextLink element includes a skiptoken parameter that specifies a starting point to use for subsequent calls.|skiptoken|$skiptoken| + +#### Command `az quota quota-request-status show` + +##### Example +``` +az quota quota-request-status show --id "2B5C8515-37D8-4B6A-879B-CD641A2CF605" --location "eastus" --provider-id \ +"Microsoft.Compute" --subscription-id "00000000-0000-0000-0000-000000000000" +``` +##### Example +``` +az quota quota-request-status show --id "2B5C8515-37D8-4B6A-879B-CD641A2CF605" --location "eastus" --provider-id \ +"Microsoft.Compute" --subscription-id "00000000-0000-0000-0000-000000000000" +``` +##### Example +``` +az quota quota-request-status show --id "2B5C8515-37D8-4B6A-879B-CD641A2CF605" --location "eastus" --provider-id \ +"Microsoft.Compute" --subscription-id "00000000-0000-0000-0000-000000000000" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--subscription-id**|string|Azure subscription ID.|subscription_id|subscriptionId| +|**--provider-id**|string|Azure resource provider ID.|provider_id|providerId| +|**--location**|string|Azure region.|location|location| +|**--id**|string|Quota Request ID.|id|id| + +### group `az quota reservation` +#### Command `az quota reservation list` + +##### Example +``` +az quota reservation list --reservation-order-id "276e7ae4-84d0-4da6-ab4b-d6b94f3557da" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--reservation-order-id**|string|Order Id of the reservation|reservation_order_id|reservationOrderId| + +#### Command `az quota reservation show` + +##### Example +``` +az quota reservation show --expand "renewProperties" --reservation-id "6ef59113-3482-40da-8d79-787f823e34bc" \ +--reservation-order-id "276e7ae4-84d0-4da6-ab4b-d6b94f3557da" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--reservation-id**|string|Id of the Reservation Item|reservation_id|reservationId| +|**--reservation-order-id**|string|Order Id of the reservation|reservation_order_id|reservationOrderId| +|**--expand**|string|Supported value of this query is renewProperties|expand|expand| + +#### Command `az quota reservation update` + +##### Example +``` +az quota reservation update --applied-scope-type "Shared" --instance-flexibility "Off" --reservation-id \ +"6ef59113-3482-40da-8d79-787f823e34bc" --reservation-order-id "276e7ae4-84d0-4da6-ab4b-d6b94f3557da" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--reservation-order-id**|string|Order Id of the reservation|reservation_order_id|reservationOrderId| +|**--reservation-id**|string|Id of the Reservation Item|reservation_id|reservationId| +|**--applied-scope-type**|choice|Type of the Applied Scope.|applied_scope_type|appliedScopeType| +|**--applied-scopes**|array|List of the subscriptions that the benefit will be applied. Do not specify if AppliedScopeType is Shared.|applied_scopes|appliedScopes| +|**--instance-flexibility**|choice|Turning this on will apply the reservation discount to other VMs in the same VM size group. Only specify for VirtualMachines reserved resource type.|instance_flexibility|instanceFlexibility| +|**--name**|string|Name of the Reservation|name|name| +|**--renew**|boolean|Setting this to true will automatically purchase a new reservation on the expiration date time.|renew|renew| +|**--location**|string|The Azure Region where the reserved resource lives.|location|location| +|**--reserved-resource-type**|choice|The type of the resource that is being reserved.|reserved_resource_type|reservedResourceType| +|**--billing-scope-id**|string|Subscription that will be charged for purchasing Reservation|billing_scope_id|billingScopeId| +|**--term**|choice|Represent the term of Reservation.|term|term| +|**--billing-plan**|choice|Represent the billing plans.|billing_plan|billingPlan| +|**--quantity**|integer|Quantity of the SKUs that are part of the Reservation. Must be greater than zero.|quantity|quantity| +|**--display-name**|string|Friendly name of the Reservation|display_name|displayName| +|**--applied-scope-type-applied-scope-type**|choice|Type of the Applied Scope.|applied_scope_type_applied_scope_type|appliedScopeType| +|**--applied-scopes1**|array|List of the subscriptions that the benefit will be applied. Do not specify if AppliedScopeType is Shared.|applied_scopes1|appliedScopes| +|**--renew1**|boolean|Setting this to true will automatically purchase a new reservation on the expiration date time.|renew1|renew| +|**--instance-flexibility1**|choice|Turning this on will apply the reservation discount to other VMs in the same VM size group. Only specify for VirtualMachines reserved resource type.|instance_flexibility1|instanceFlexibility| +|**--sku-name**|string||sku_name|name| + +#### Command `az quota reservation available-scope` + +##### Example +``` +az quota reservation available-scope --properties scopes="/subscriptions/efc7c997-7700-4a74-b731-55aec16c15e9" \ +--reservation-id "356e7ae4-84d0-4da6-ab4b-d6b94f3557da" --reservation-order-id "276e7ae4-84d0-4da6-ab4b-d6b94f3557da" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--reservation-order-id**|string|Order Id of the reservation|reservation_order_id|reservationOrderId| +|**--reservation-id**|string|Id of the Reservation Item|reservation_id|reservationId| +|**--properties**|object|Available scope request properties|properties|properties| + +#### Command `az quota reservation list-revision` + +##### Example +``` +az quota reservation list-revision --reservation-id "6ef59113-3482-40da-8d79-787f823e34bc" --reservation-order-id \ +"276e7ae4-84d0-4da6-ab4b-d6b94f3557da" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--reservation-id**|string|Id of the Reservation Item|reservation_id|reservationId| +|**--reservation-order-id**|string|Order Id of the reservation|reservation_order_id|reservationOrderId| + +#### Command `az quota reservation merge` + +##### Example +``` +az quota reservation merge --sources "/providers/Microsoft.Capacity/reservationOrders/c0565a8a-4491-4e77-b07b-5e6d66718\ +e1c/reservations/cea04232-932e-47db-acb5-e29a945ecc73" "/providers/Microsoft.Capacity/reservationOrders/c0565a8a-4491-4\ +e77-b07b-5e6d66718e1c/reservations/5bf54dc7-dacd-4f46-a16b-7b78f4a59799" --reservation-order-id \ +"276e7ae4-84d0-4da6-ab4b-d6b94f3557da" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--reservation-order-id**|string|Order Id of the reservation|reservation_order_id|reservationOrderId| +|**--sources**|array|Format of the resource id should be /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}|sources|sources| + +#### Command `az quota reservation split` + +##### Example +``` +az quota reservation split --quantities 1 2 --reservation-id "/providers/Microsoft.Capacity/reservationOrders/276e7ae4-\ +84d0-4da6-ab4b-d6b94f3557da/reservations/bcae77cd-3119-4766-919f-b50d36c75c7a" --reservation-order-id \ +"276e7ae4-84d0-4da6-ab4b-d6b94f3557da" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--reservation-order-id**|string|Order Id of the reservation|reservation_order_id|reservationOrderId| +|**--quantities**|array|List of the quantities in the new reservations to create.|quantities|quantities| +|**--reservation-id**|string|Resource id of the reservation to be split. Format of the resource id should be /providers/Microsoft.Capacity/reservationOrders/{reservationOrderId}/reservations/{reservationId}|reservation_id|reservationId| + +### group `az quota reservation-order` +#### Command `az quota reservation-order list` + +##### Example +``` +az quota reservation-order list +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +#### Command `az quota reservation-order show` + +##### Example +``` +az quota reservation-order show --reservation-order-id "a075419f-44cc-497f-b68a-14ee811d48b9" +``` +##### Example +``` +az quota reservation-order show --expand "schedule" --reservation-order-id "a075419f-44cc-497f-b68a-14ee811d48b9" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--reservation-order-id**|string|Order Id of the reservation|reservation_order_id|reservationOrderId| +|**--expand**|string|May be used to expand the planInformation.|expand|$expand| + +#### Command `az quota reservation-order calculate` + +##### Example +``` +az quota reservation-order calculate --location "westus" --applied-scope-type "Shared" --billing-plan "Monthly" \ +--billing-scope-id "/subscriptions/ed3a1871-612d-abcd-a849-c2542a68be83" --display-name "TestReservationOrder" \ +--quantity 1 --instance-flexibility "On" --reserved-resource-type "VirtualMachines" --term "P1Y" --name "standard_D1" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--location**|string|The Azure Region where the reserved resource lives.|location|location| +|**--reserved-resource-type**|choice|The type of the resource that is being reserved.|reserved_resource_type|reservedResourceType| +|**--billing-scope-id**|string|Subscription that will be charged for purchasing Reservation|billing_scope_id|billingScopeId| +|**--term**|choice|Represent the term of Reservation.|term|term| +|**--billing-plan**|choice|Represent the billing plans.|billing_plan|billingPlan| +|**--quantity**|integer|Quantity of the SKUs that are part of the Reservation. Must be greater than zero.|quantity|quantity| +|**--display-name**|string|Friendly name of the Reservation|display_name|displayName| +|**--applied-scope-type**|choice|Type of the Applied Scope.|applied_scope_type|appliedScopeType| +|**--applied-scopes**|array|List of the subscriptions that the benefit will be applied. Do not specify if AppliedScopeType is Shared.|applied_scopes|appliedScopes| +|**--renew**|boolean|Setting this to true will automatically purchase a new reservation on the expiration date time.|renew|renew| +|**--instance-flexibility**|choice|Turning this on will apply the reservation discount to other VMs in the same VM size group. Only specify for VirtualMachines reserved resource type.|instance_flexibility|instanceFlexibility| +|**--name**|string||name|name| + +#### Command `az quota reservation-order purchase` + +##### Example +``` +az quota reservation-order purchase --location "westus" --applied-scope-type "Shared" --billing-plan "Monthly" \ +--billing-scope-id "/subscriptions/ed3a1871-612d-abcd-a849-c2542a68be83" --display-name "TestReservationOrder" \ +--quantity 1 --renew false --instance-flexibility "On" --reserved-resource-type "VirtualMachines" --term "P1Y" --name \ +"standard_D1" --reservation-order-id "a075419f-44cc-497f-b68a-14ee811d48b9" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--reservation-order-id**|string|Order Id of the reservation|reservation_order_id|reservationOrderId| +|**--location**|string|The Azure Region where the reserved resource lives.|location|location| +|**--reserved-resource-type**|choice|The type of the resource that is being reserved.|reserved_resource_type|reservedResourceType| +|**--billing-scope-id**|string|Subscription that will be charged for purchasing Reservation|billing_scope_id|billingScopeId| +|**--term**|choice|Represent the term of Reservation.|term|term| +|**--billing-plan**|choice|Represent the billing plans.|billing_plan|billingPlan| +|**--quantity**|integer|Quantity of the SKUs that are part of the Reservation. Must be greater than zero.|quantity|quantity| +|**--display-name**|string|Friendly name of the Reservation|display_name|displayName| +|**--applied-scope-type**|choice|Type of the Applied Scope.|applied_scope_type|appliedScopeType| +|**--applied-scopes**|array|List of the subscriptions that the benefit will be applied. Do not specify if AppliedScopeType is Shared.|applied_scopes|appliedScopes| +|**--renew**|boolean|Setting this to true will automatically purchase a new reservation on the expiration date time.|renew|renew| +|**--instance-flexibility**|choice|Turning this on will apply the reservation discount to other VMs in the same VM size group. Only specify for VirtualMachines reserved resource type.|instance_flexibility|instanceFlexibility| +|**--name**|string||name|name| diff --git a/src/reservations/setup.cfg b/src/reservations/setup.cfg new file mode 100644 index 00000000000..2fdd96e5d39 --- /dev/null +++ b/src/reservations/setup.cfg @@ -0,0 +1 @@ +#setup.cfg \ No newline at end of file diff --git a/src/reservations/setup.py b/src/reservations/setup.py new file mode 100644 index 00000000000..0b289c7019c --- /dev/null +++ b/src/reservations/setup.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python + +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + + +from codecs import open +from setuptools import setup, find_packages + +# HISTORY.rst entry. +VERSION = '0.1.0' +try: + from azext_reservations.manual.version import VERSION +except ImportError: + pass + +# The full list of classifiers is available at +# https://pypi.python.org/pypi?%3Aaction=list_classifiers +CLASSIFIERS = [ + 'Development Status :: 4 - Beta', + 'Intended Audience :: Developers', + 'Intended Audience :: System Administrators', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'License :: OSI Approved :: MIT License', +] + +DEPENDENCIES = [] + +try: + from azext_reservations.manual.dependency import DEPENDENCIES +except ImportError: + pass + +with open('README.md', 'r', encoding='utf-8') as f: + README = f.read() +with open('HISTORY.rst', 'r', encoding='utf-8') as f: + HISTORY = f.read() + +setup( + name='quota', + version=VERSION, + description='Microsoft Azure Command-Line Tools AzureReservationAPI Extension', + author='Microsoft Corporation', + author_email='azpycli@microsoft.com', + url='https://github.com/Azure/azure-cli-extensions/tree/master/src/reservations', + long_description=README + '\n\n' + HISTORY, + license='MIT', + classifiers=CLASSIFIERS, + packages=find_packages(), + install_requires=DEPENDENCIES, + package_data={'azext_reservations': ['azext_metadata.json']}, +)