From d9719edc2053fb28cc6f5de8cc39e82b2da65ff8 Mon Sep 17 00:00:00 2001 From: Vivian Thiebaut Date: Mon, 12 Sep 2022 11:47:41 -0400 Subject: [PATCH 01/15] Remove RP calls to check resource type. Only make one call to azure resources --- src/ssh/azext_ssh/_params.py | 5 +- src/ssh/azext_ssh/constants.py | 24 ++++ src/ssh/azext_ssh/custom.py | 137 +++-------------------- src/ssh/azext_ssh/resource_type_utils.py | 80 +++++++++++++ src/ssh/azext_ssh/ssh_info.py | 6 +- 5 files changed, 129 insertions(+), 123 deletions(-) create mode 100644 src/ssh/azext_ssh/resource_type_utils.py diff --git a/src/ssh/azext_ssh/_params.py b/src/ssh/azext_ssh/_params.py index 59718ccd9ee..a2a50f4ef6c 100644 --- a/src/ssh/azext_ssh/_params.py +++ b/src/ssh/azext_ssh/_params.py @@ -20,7 +20,7 @@ def load_arguments(self, _): help='Path to a certificate file used for authentication when using local user credentials.') c.argument('port', options_list=['--port'], help='SSH port') c.argument('resource_type', options_list=['--resource-type'], - help='Resource type should be either Microsoft.Compute or Microsoft.HybridCompute', + help='Resource type should be either Microsoft.Compute/virtualMachines, Microsoft.HybridCompute/machines, or Microsoft.ConnectedVMwareSphere.', completer=["Microsoft.HybridCompute", "Microsoft.Compute"]) c.argument('ssh_client_folder', options_list=['--ssh-client-folder'], help='Folder path that contains ssh executables (ssh.exe, ssh-keygen.exe, etc). ' @@ -79,6 +79,9 @@ def load_arguments(self, _): help='The username for a local user') c.argument('cert_file', options_list=['--certificate-file', '-c'], help='Path to certificate file') c.argument('port', options_list=['--port'], help='Port to connect to on the remote host.') + c.argument('resource_type', options_list=['--resource-type'], + help='Resource type should be either Microsoft.Compute/virtualMachines, Microsoft.HybridCompute/machines, or Microsoft.ConnectedVMwareSphere.', + completer=["Microsoft.HybridCompute", "Microsoft.Compute"]) c.argument('ssh_client_folder', options_list=['--ssh-client-folder'], help='Folder path that contains ssh executables (ssh.exe, ssh-keygen.exe, etc). ' 'Default to ssh pre-installed if not provided.') diff --git a/src/ssh/azext_ssh/constants.py b/src/ssh/azext_ssh/constants.py index 4917411aeb6..3acf108d35e 100644 --- a/src/ssh/azext_ssh/constants.py +++ b/src/ssh/azext_ssh/constants.py @@ -18,3 +18,27 @@ RECOMMENDATION_RESOURCE_NOT_FOUND = (Fore.YELLOW + "Please ensure the active subscription is set properly " "and resource exists." + Style.RESET_ALL) RDP_TERMINATE_SSH_WAIT_TIME_IN_SECONDS = 30 + +ARC_RESOURCE_TYPE_PLACEHOLDER = "arc" + +SUPPORTED_RESOURCE_TYPES = ["microsoft.hybridcompute/machines", + "microsoft.compute/virtualmachines", + "microsoft.connectedvmwarevsphere/virtualmachines"] + +# Old version incorrectly used resource providers instead of resource type. +# Will continue to support to avoid breaking backwards compatibility. +LEGACY_SUPPORTED_RESOURCE_TYPES = ["microsoft.hybridcompute", + "microsoft.compute", + "microsoft.connectedvmwarevsphere"] + +RESOURCE_PROVIDER_TO_RESOURCE_TYPE = { + "microsoft.hybridcompute": "Microsoft.HybridCompute/machines", + "microsoft.compute": "Microsoft.Compute/virtualMachines", + "microsoft.connectedvmwarevsphere": "Microsoft.ConnectedVMwarevSphere/virtualMachines" +} + +RESOURCE_TYPE_LOWER_CASE_TO_CORRECT_CASE = { + "microsoft.hybridcompute/machines": "Microsoft.HybridCompute/machines", + "microsoft.compute/virtualmachines": "Microsoft.Compute/virtualMachines", + "microsoft.connectedvmwarevsphere/virtualmachines": "Microsoft.ConnectedVMwarevSphere/virtualMachines" +} diff --git a/src/ssh/azext_ssh/custom.py b/src/ssh/azext_ssh/custom.py index e396fcefcaa..a9b0899ffe9 100644 --- a/src/ssh/azext_ssh/custom.py +++ b/src/ssh/azext_ssh/custom.py @@ -27,6 +27,7 @@ from . import ssh_info from . import file_utils from . import constants as const +from . import resource_type_utils logger = log.get_logger(__name__) @@ -61,7 +62,7 @@ def ssh_vm(cmd, resource_group_name=None, vm_name=None, ssh_ip=None, public_key_ private_key_file, use_private_ip, local_user, cert_file, port, ssh_client_folder, ssh_args, delete_credentials, resource_type, ssh_proxy_folder, credentials_folder, winrdp) - ssh_session.resource_type = _decide_resource_type(cmd, ssh_session) + ssh_session.resource_type = resource_type_utils.decide_resource_type(cmd, ssh_session) _do_ssh_op(cmd, ssh_session, op_call) @@ -81,7 +82,7 @@ def ssh_config(cmd, config_path, resource_group_name=None, vm_name=None, ssh_ip= resource_type, credentials_folder, ssh_proxy_folder, ssh_client_folder) op_call = ssh_utils.write_ssh_config - config_session.resource_type = _decide_resource_type(cmd, config_session) + config_session.resource_type = resource_type_utils.decide_resource_type(cmd, config_session) # if the folder doesn't exist, this extension won't create a new one. config_folder = os.path.dirname(config_session.config_path) @@ -139,11 +140,14 @@ def ssh_cert(cmd, cert_path=None, public_key_file=None, ssh_client_folder=None): def ssh_arc(cmd, resource_group_name=None, vm_name=None, public_key_file=None, private_key_file=None, - local_user=None, cert_file=None, port=None, ssh_client_folder=None, delete_credentials=False, - ssh_proxy_folder=None, winrdp=False, ssh_args=None): + local_user=None, cert_file=None, port=None, resource_type=None, ssh_client_folder=None, + delete_credentials=False, ssh_proxy_folder=None, winrdp=False, ssh_args=None): + if not resource_type: + resource_type = const.ARC_RESOURCE_TYPE_PLACEHOLDER + ssh_vm(cmd, resource_group_name, vm_name, None, public_key_file, private_key_file, False, local_user, cert_file, - port, ssh_client_folder, delete_credentials, "Microsoft.HybridCompute", ssh_proxy_folder, winrdp, ssh_args) + port, ssh_client_folder, delete_credentials, resource_type, ssh_proxy_folder, winrdp, ssh_args) def _do_ssh_op(cmd, op_info, op_call): @@ -260,10 +264,14 @@ def _prepare_jwk_data(public_key_file): def _assert_args(resource_group, vm_name, ssh_ip, resource_type, cert_file, username): - if resource_type and resource_type.lower() != "microsoft.compute" \ - and resource_type.lower() != "microsoft.hybridcompute": - raise azclierror.InvalidArgumentValueError("--resource-type must be either \"Microsoft.Compute\" " - "for Azure VMs or \"Microsoft.HybridCompute\" for Arc Servers.") + + if resource_type and \ + resource_type.lower() not in const.SUPPORTED_RESOURCE_TYPES and \ + resource_type.lower() not in const.LEGACY_SUPPORTED_RESOURCE_TYPES: + raise azclierror.InvalidArgumentValueError("--resource-type must be either " + "\"Microsoft.Compute/virtualMachines\", " + "\"Microsoft.HybridCompute/machines\", " + "or \"Microsoft.ConnectedVMwareSphere/virtualMachines\".") if not (resource_group or vm_name or ssh_ip): raise azclierror.RequiredArgumentMissingError( @@ -352,114 +360,3 @@ def _get_modulus_exponent(public_key_file): exponent = parser.exponent return modulus, exponent - - -def _decide_resource_type(cmd, op_info): - # If the user provides an IP address the target will be treated as an Azure VM even if it is an - # Arc Server. Which just means that the Connectivity Proxy won't be used to establish connection. - is_arc_server = False - is_azure_vm = False - - if op_info.ip: - is_azure_vm = True - vm = None - - elif op_info.resource_type: - if op_info.resource_type.lower() == "microsoft.hybridcompute": - arc, arc_error, is_arc_server = _check_if_arc_server(cmd, op_info.resource_group_name, op_info.vm_name) - if not is_arc_server: - colorama.init() - if isinstance(arc_error, ResourceNotFoundError): - raise azclierror.ResourceNotFoundError(f"The resource {op_info.vm_name} in the resource group " - f"{op_info.resource_group_name} was not found.", - const.RECOMMENDATION_RESOURCE_NOT_FOUND) - raise azclierror.BadRequestError("Unable to determine that the target machine is an Arc Server. " - f"Error:\n{str(arc_error)}", const.RECOMMENDATION_RESOURCE_NOT_FOUND) - - elif op_info.resource_type.lower() == "microsoft.compute": - vm, vm_error, is_azure_vm = _check_if_azure_vm(cmd, op_info.resource_group_name, op_info.vm_name) - if not is_azure_vm: - colorama.init() - if isinstance(vm_error, ResourceNotFoundError): - raise azclierror.ResourceNotFoundError(f"The resource {op_info.vm_name} in the resource group " - f"{op_info.resource_group_name} was not found.", - const.RECOMMENDATION_RESOURCE_NOT_FOUND) - raise azclierror.BadRequestError("Unable to determine that the target machine is an Azure VM. " - f"Error:\n{str(vm_error)}", const.RECOMMENDATION_RESOURCE_NOT_FOUND) - - else: - vm, vm_error, is_azure_vm = _check_if_azure_vm(cmd, op_info.resource_group_name, op_info.vm_name) - arc, arc_error, is_arc_server = _check_if_arc_server(cmd, op_info.resource_group_name, op_info.vm_name) - - if is_azure_vm and is_arc_server: - colorama.init() - raise azclierror.BadRequestError(f"{op_info.resource_group_name} has Azure VM and Arc Server with the " - f"same name: {op_info.vm_name}.", - colorama.Fore.YELLOW + "Please provide a --resource-type." + - colorama.Style.RESET_ALL) - if not is_azure_vm and not is_arc_server: - colorama.init() - if isinstance(arc_error, ResourceNotFoundError) and isinstance(vm_error, ResourceNotFoundError): - raise azclierror.ResourceNotFoundError(f"The resource {op_info.vm_name} in the resource group " - f"{op_info.resource_group_name} was not found. ", - const.RECOMMENDATION_RESOURCE_NOT_FOUND) - raise azclierror.BadRequestError("Unable to determine the target machine type as Azure VM or " - f"Arc Server. Errors:\n{str(arc_error)}\n{str(vm_error)}", - const.RECOMMENDATION_RESOURCE_NOT_FOUND) - - # Note: We are not able to determine the os of the target if the user only provides an IP address. - os_type = None - if is_azure_vm and vm and vm.storage_profile and vm.storage_profile.os_disk and vm.storage_profile.os_disk.os_type: - os_type = vm.storage_profile.os_disk.os_type - - if is_arc_server and arc and arc.properties and arc.properties and arc.properties.os_name: - os_type = arc.properties.os_name - - if os_type: - telemetry.add_extension_event('ssh', {'Context.Default.AzureCLI.TargetOSType': os_type}) - - # Note 2: This is a temporary check while AAD login is not enabled for Windows. - if os_type and os_type.lower() == 'windows' and not op_info.local_user: - colorama.init() - raise azclierror.RequiredArgumentMissingError("SSH Login using AAD credentials is not currently supported " - "for Windows.", - colorama.Fore.YELLOW + "Please provide --local-user." + - colorama.Style.RESET_ALL) - - target_resource_type = "Microsoft.Compute" - if is_arc_server: - target_resource_type = "Microsoft.HybridCompute" - telemetry.add_extension_event('ssh', {'Context.Default.AzureCLI.TargetResourceType': target_resource_type}) - - return target_resource_type - - -def _check_if_azure_vm(cmd, resource_group_name, vm_name): - from azure.cli.core.commands import client_factory - from azure.cli.core import profiles - vm = None - try: - compute_client = client_factory.get_mgmt_service_client(cmd.cli_ctx, profiles.ResourceType.MGMT_COMPUTE) - vm = compute_client.virtual_machines.get(resource_group_name, vm_name) - except ResourceNotFoundError as e: - return None, e, False - # If user is not authorized to get the VM, it will throw a HttpResponseError - except HttpResponseError as e: - return None, e, False - - return vm, None, True - - -def _check_if_arc_server(cmd, resource_group_name, vm_name): - from azext_ssh._client_factory import cf_machine - client = cf_machine(cmd.cli_ctx) - arc = None - try: - arc = client.get(resource_group_name=resource_group_name, machine_name=vm_name) - except ResourceNotFoundError as e: - return None, e, False - # If user is not authorized to get the arc server, it will throw a HttpResponseError - except HttpResponseError as e: - return None, e, False - - return arc, None, True diff --git a/src/ssh/azext_ssh/resource_type_utils.py b/src/ssh/azext_ssh/resource_type_utils.py new file mode 100644 index 00000000000..49a753087c7 --- /dev/null +++ b/src/ssh/azext_ssh/resource_type_utils.py @@ -0,0 +1,80 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +import colorama + +from azure.cli.core import telemetry +from azure.cli.core import azclierror +from knack import log +from azure.mgmt.resource import ResourceManagementClient +from azure.cli.core.commands.client_factory import get_mgmt_service_client + +from . import constants as consts + +logger = log.get_logger(__name__) + + +def _list_types_of_resources_with_provided_name(cmd, op_info): + resource_client = get_mgmt_service_client(cmd.cli_ctx, ResourceManagementClient) + resources = resource_client.resources.list_by_resource_group(op_info.resource_group_name, filter=f"name eq '{op_info.vm_name}'") + + resource_types_present = {} + + while True: + try: + resource = resources.next() + if resource.type.lower() in consts.SUPPORTED_RESOURCE_TYPES: + resource_types_present.add(resource.type.lower()) + except StopIteration: + break + + return resource_types_present + + +def decide_resource_type(cmd, op_info): + + # If the user provides an IP address the target will be treated as an Azure VM even if it is an + # Arc Server. Which just means that the Connectivity Proxy won't be used to establish connection. + if op_info.ip: + return "Microsoft.Compute/virtualMachines" + + # Set of resource types in target resource group of resources + types_in_rg = _list_types_of_resources_with_provided_name(cmd, op_info) + target_resource_type = None + + if op_info.resource_type and op_info.resource_type != consts.ARC_RESOURCE_TYPE_PLACEHOLDER: + if op_info.resource_type.lower() in consts.LEGACY_SUPPORTED_RESOURCE_TYPES: + op_info.resource_type = consts.RESOURCE_PROVIDER_TO_RESOURCE_TYPE[op_info.resource_type.lower()] + if op_info.resource_type.lower() in types_in_rg: + target_resource_type = consts.RESOURCE_TYPE_LOWER_CASE_TO_CORRECT_CASE[op_info.resource_type.lower()] + else: + raise azclierror.ResourceNotFoundError(f"Unable to find resource {op_info.vm_name} of type " + f"{consts.RESOURCE_TYPE_LOWER_CASE_TO_CORRECT_CASE[op_info.resource_type.lower()]} " + f"under the resource group {op_info.resource_group}", + consts.RECOMMENDATION_RESOURCE_NOT_FOUND) + + else: + if op_info.resource_type == consts.ARC_RESOURCE_TYPE_PLACEHOLDER: + types_in_rg.discard("microsoft.compute/virtualmachines") + + if len(types_in_rg) > 1: + raise azclierror.BadRequestError(f"{op_info.resource_group_name} has more than one valid target with the " + f"same name: {op_info.vm_name}.", + colorama.Fore.YELLOW + "Please provide a --resource-type." + + colorama.Style.RESET_ALL) + + if len(types_in_rg) < 1: + raise azclierror.ResourceNotFoundError(f"A valid resource {op_info.vm_name} in the resource group " + f"{op_info.resource_group_name} was not found. ", + consts.RECOMMENDATION_RESOURCE_NOT_FOUND) + + target_resource_type = consts.RESOURCE_TYPE_LOWER_CASE_TO_CORRECT_CASE[types_in_rg.pop().lower()] + + telemetry.add_extension_event('ssh', {'Context.Default.AzureCLI.TargetResourceType': target_resource_type}) + return target_resource_type + + + + diff --git a/src/ssh/azext_ssh/ssh_info.py b/src/ssh/azext_ssh/ssh_info.py index 37672abc05e..ea42a809fbe 100644 --- a/src/ssh/azext_ssh/ssh_info.py +++ b/src/ssh/azext_ssh/ssh_info.py @@ -41,7 +41,8 @@ def __init__(self, resource_group_name, vm_name, ssh_ip, public_key_file, privat self.credentials_folder = os.path.abspath(credentials_folder) if credentials_folder else None def is_arc(self): - if self.resource_type == "Microsoft.HybridCompute": + if self.resource_type == "Microsoft.HybridCompute/machines" or\ + self.resource_type == "Microsoft.ConnectedVMwarevSphere/virtualMachines": return True return False @@ -100,7 +101,8 @@ def __init__(self, config_path, resource_group_name, vm_name, ssh_ip, public_key self.credentials_folder = os.path.abspath(credentials_folder) if credentials_folder else None def is_arc(self): - if self.resource_type == "Microsoft.HybridCompute": + if self.resource_type == "Microsoft.HybridCompute/machines" or\ + self.resource_type == "Microsoft.ConnectedVMwarevSphere/virtualMachines": return True return False From 1f004564aea87788271609895ff254598af22ab3 Mon Sep 17 00:00:00 2001 From: Vivian Thiebaut Date: Wed, 14 Sep 2022 13:50:52 -0400 Subject: [PATCH 02/15] Refactor code to facilitate adding support to new types, and added support for connectedvmware --- src/ssh/azext_ssh/_client_factory.py | 12 + src/ssh/azext_ssh/custom.py | 5 +- src/ssh/azext_ssh/resource_type_utils.py | 6 +- src/ssh/azext_ssh/target_os_utils.py | 83 + .../vendored_sdks/connectedvmware/__init__.py | 23 + ...azure_arc_vmware_management_service_api.py | 127 + .../connectedvmware/_configuration.py | 73 + .../vendored_sdks/connectedvmware/_patch.py | 19 + .../vendored_sdks/connectedvmware/_vendor.py | 27 + .../vendored_sdks/connectedvmware/_version.py | 9 + .../connectedvmware/aio/__init__.py | 20 + ...azure_arc_vmware_management_service_api.py | 159 + .../connectedvmware/aio/_configuration.py | 72 + .../connectedvmware/aio/_patch.py | 19 + .../aio/operations/__init__.py | 42 + .../aio/operations/_clusters_operations.py | 633 ++ .../aio/operations/_datastores_operations.py | 633 ++ .../operations/_guest_agents_operations.py | 490 ++ .../aio/operations/_hosts_operations.py | 630 ++ .../_hybrid_identity_metadata_operations.py | 354 ++ .../operations/_inventory_items_operations.py | 353 ++ .../_machine_extensions_operations.py | 633 ++ .../aio/operations/_operations.py | 122 + .../connectedvmware/aio/operations/_patch.py | 19 + .../operations/_resource_pools_operations.py | 633 ++ .../aio/operations/_vcenters_operations.py | 633 ++ .../_virtual_machine_templates_operations.py | 636 ++ .../_virtual_machines_operations.py | 1364 +++++ .../_virtual_networks_operations.py | 633 ++ .../connectedvmware/models/__init__.py | 235 + ...arc_vmware_management_service_api_enums.py | 230 + .../connectedvmware/models/_models_py3.py | 5263 +++++++++++++++++ .../connectedvmware/models/_patch.py | 19 + .../connectedvmware/operations/__init__.py | 20 + .../connectedvmware/operations/_operations.py | 151 + .../connectedvmware/operations/_patch.py | 19 + .../_virtual_machines_operations.py | 154 + .../vendored_sdks/connectedvmware/py.typed | 1 + 38 files changed, 14550 insertions(+), 4 deletions(-) create mode 100644 src/ssh/azext_ssh/target_os_utils.py create mode 100644 src/ssh/azext_ssh/vendored_sdks/connectedvmware/__init__.py create mode 100644 src/ssh/azext_ssh/vendored_sdks/connectedvmware/_azure_arc_vmware_management_service_api.py create mode 100644 src/ssh/azext_ssh/vendored_sdks/connectedvmware/_configuration.py create mode 100644 src/ssh/azext_ssh/vendored_sdks/connectedvmware/_patch.py create mode 100644 src/ssh/azext_ssh/vendored_sdks/connectedvmware/_vendor.py create mode 100644 src/ssh/azext_ssh/vendored_sdks/connectedvmware/_version.py create mode 100644 src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/__init__.py create mode 100644 src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/_azure_arc_vmware_management_service_api.py create mode 100644 src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/_configuration.py create mode 100644 src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/_patch.py create mode 100644 src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/__init__.py create mode 100644 src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_clusters_operations.py create mode 100644 src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_datastores_operations.py create mode 100644 src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_guest_agents_operations.py create mode 100644 src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_hosts_operations.py create mode 100644 src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_hybrid_identity_metadata_operations.py create mode 100644 src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_inventory_items_operations.py create mode 100644 src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_machine_extensions_operations.py create mode 100644 src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_operations.py create mode 100644 src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_patch.py create mode 100644 src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_resource_pools_operations.py create mode 100644 src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_vcenters_operations.py create mode 100644 src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_virtual_machine_templates_operations.py create mode 100644 src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_virtual_machines_operations.py create mode 100644 src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_virtual_networks_operations.py create mode 100644 src/ssh/azext_ssh/vendored_sdks/connectedvmware/models/__init__.py create mode 100644 src/ssh/azext_ssh/vendored_sdks/connectedvmware/models/_azure_arc_vmware_management_service_api_enums.py create mode 100644 src/ssh/azext_ssh/vendored_sdks/connectedvmware/models/_models_py3.py create mode 100644 src/ssh/azext_ssh/vendored_sdks/connectedvmware/models/_patch.py create mode 100644 src/ssh/azext_ssh/vendored_sdks/connectedvmware/operations/__init__.py create mode 100644 src/ssh/azext_ssh/vendored_sdks/connectedvmware/operations/_operations.py create mode 100644 src/ssh/azext_ssh/vendored_sdks/connectedvmware/operations/_patch.py create mode 100644 src/ssh/azext_ssh/vendored_sdks/connectedvmware/operations/_virtual_machines_operations.py create mode 100644 src/ssh/azext_ssh/vendored_sdks/connectedvmware/py.typed diff --git a/src/ssh/azext_ssh/_client_factory.py b/src/ssh/azext_ssh/_client_factory.py index e91e3a9b8bc..d6afedf250c 100644 --- a/src/ssh/azext_ssh/_client_factory.py +++ b/src/ssh/azext_ssh/_client_factory.py @@ -29,3 +29,15 @@ def cf_connectedmachine_cl(cli_ctx, *_): def cf_machine(cli_ctx, *_): return cf_connectedmachine_cl(cli_ctx).machines + + +def cf_connectedvmware_cl(cli_ctx, *_): + from azext_ssh.vendored_sdks.connectedvmware import AzureArcVMwareManagementServiceAPI + return get_mgmt_service_client(cli_ctx, + AzureArcVMwareManagementServiceAPI) + + +def cf_vmware(cli_ctx, *_): + return cf_connectedvmware_cl(cli_ctx).virtual_machines + + diff --git a/src/ssh/azext_ssh/custom.py b/src/ssh/azext_ssh/custom.py index a9b0899ffe9..caccbbc2a52 100644 --- a/src/ssh/azext_ssh/custom.py +++ b/src/ssh/azext_ssh/custom.py @@ -16,7 +16,6 @@ from knack import log from azure.cli.core import azclierror from azure.cli.core import telemetry -from azure.core.exceptions import ResourceNotFoundError, HttpResponseError from azure.cli.core.style import Style, print_styled_text from . import ip_utils @@ -28,6 +27,7 @@ from . import file_utils from . import constants as const from . import resource_type_utils +from . import target_os_utils logger = log.get_logger(__name__) @@ -63,6 +63,8 @@ def ssh_vm(cmd, resource_group_name=None, vm_name=None, ssh_ip=None, public_key_ ssh_client_folder, ssh_args, delete_credentials, resource_type, ssh_proxy_folder, credentials_folder, winrdp) ssh_session.resource_type = resource_type_utils.decide_resource_type(cmd, ssh_session) + target_os_utils.send_target_os_telemetry(cmd, ssh_session) + _do_ssh_op(cmd, ssh_session, op_call) @@ -83,6 +85,7 @@ def ssh_config(cmd, config_path, resource_group_name=None, vm_name=None, ssh_ip= op_call = ssh_utils.write_ssh_config config_session.resource_type = resource_type_utils.decide_resource_type(cmd, config_session) + target_os_utils.send_target_os_telemetry(cmd, config_session) # if the folder doesn't exist, this extension won't create a new one. config_folder = os.path.dirname(config_session.config_path) diff --git a/src/ssh/azext_ssh/resource_type_utils.py b/src/ssh/azext_ssh/resource_type_utils.py index 49a753087c7..36594fb8a43 100644 --- a/src/ssh/azext_ssh/resource_type_utils.py +++ b/src/ssh/azext_ssh/resource_type_utils.py @@ -19,8 +19,7 @@ def _list_types_of_resources_with_provided_name(cmd, op_info): resource_client = get_mgmt_service_client(cmd.cli_ctx, ResourceManagementClient) resources = resource_client.resources.list_by_resource_group(op_info.resource_group_name, filter=f"name eq '{op_info.vm_name}'") - - resource_types_present = {} + resource_types_present = set() while True: try: @@ -40,7 +39,7 @@ def decide_resource_type(cmd, op_info): if op_info.ip: return "Microsoft.Compute/virtualMachines" - # Set of resource types in target resource group of resources + # Set of resource types in target resource group of resources that match vm_name types_in_rg = _list_types_of_resources_with_provided_name(cmd, op_info) target_resource_type = None @@ -73,6 +72,7 @@ def decide_resource_type(cmd, op_info): target_resource_type = consts.RESOURCE_TYPE_LOWER_CASE_TO_CORRECT_CASE[types_in_rg.pop().lower()] telemetry.add_extension_event('ssh', {'Context.Default.AzureCLI.TargetResourceType': target_resource_type}) + print(target_resource_type) return target_resource_type diff --git a/src/ssh/azext_ssh/target_os_utils.py b/src/ssh/azext_ssh/target_os_utils.py new file mode 100644 index 00000000000..3fef5c58684 --- /dev/null +++ b/src/ssh/azext_ssh/target_os_utils.py @@ -0,0 +1,83 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +import colorama + +from azure.cli.core import telemetry +from azure.cli.core import azclierror +from knack import log + +from . import constants as consts + +logger = log.get_logger(__name__) + +def send_target_os_telemetry(cmd, op_info): + + os_type = None + + if op_info.resource_type.lower() == "microsoft.compute": + os_type = _get_azure_vm_os(cmd, op_info.resource_group_name, op_info.vm_name) + elif op_info.resource_type.lower() == "microsoft.hybridcompute": + os_type = _get_arc_server_os(cmd, op_info.resource_group_name, op_info.vm_name) + elif op_info.resource_type.lower() == "microsoft.connectedvmwarevsphere/virtualmachines": + os_type = _get_connected_vmware_os(cmd, op_info.resource_group_name, op_info.vm_name) + + if os_type: + logger.debug(f"Target OS Type: {os_type}") + telemetry.add_extension_event('ssh', {'Context.Default.AzureCLI.TargetOSType': os_type}) + + # Note 2: This is a temporary check while AAD login is not enabled for Windows. + if os_type and os_type.lower() == 'windows' and not op_info.local_user: + colorama.init() + error_message = "SSH Login using AAD credentials is not currently supported for Windows." + recommendation = colorama.Fore.YELLOW + "Please provide --local-user." + colorama.Style.RESET_ALL + raise azclierror.RequiredArgumentMissingError(error_message, recommendation) + + +def _get_azure_vm_os(cmd, resource_group_name, vm_name): + from azure.cli.core.commands import client_factory + from azure.cli.core import profiles + vm = None + os_type = None + try: + compute_client = client_factory.get_mgmt_service_client(cmd.cli_ctx, profiles.ResourceType.MGMT_COMPUTE) + vm = compute_client.virtual_machines.get(resource_group_name, vm_name) + + except Exception as e: + return None + + if vm and vm.storage_profile and vm.storage_profile.os_disk and vm.storage_profile.os_disk.os_type: + os_type = vm.storage_profile.os_disk.os_type + + +def _get_arc_server_os(cmd, resource_group_name, vm_name): + from azext_ssh._client_factory import cf_machine + client = cf_machine(cmd.cli_ctx) + arc = None + os_type = None + try: + arc = client.get(resource_group_name=resource_group_name, machine_name=vm_name) + except: + return None + + if arc and arc.properties and arc.properties and arc.properties.os_name: + os_type = arc.properties.os_name + + +def _get_connected_vmware_os(cmd, resource_group_name, vm_name): + from azext_ssh._client_factory import cf_vmware + client = cf_vmware(cmd.cli_ctx) + vmware = None + os_type = None + try: + vmware = client.get(resource_group_name=resource_group_name, virtual_machine_name=vm_name) + except: + return None + + if vmware and vmware.os_profile and vmware.os_profile.os_type: + os_type = vmware.os_profile.os_type + + return os_type + diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/__init__.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/__init__.py new file mode 100644 index 00000000000..7b5c68dfb4d --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/__init__.py @@ -0,0 +1,23 @@ +# 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_arc_vmware_management_service_api import AzureArcVMwareManagementServiceAPI +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk +__all__ = ['AzureArcVMwareManagementServiceAPI'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/_azure_arc_vmware_management_service_api.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/_azure_arc_vmware_management_service_api.py new file mode 100644 index 00000000000..8b1d12bc337 --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/_azure_arc_vmware_management_service_api.py @@ -0,0 +1,127 @@ +# 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 copy import deepcopy +from typing import Any, TYPE_CHECKING + +from msrest import Deserializer, Serializer + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models +from ._configuration import AzureArcVMwareManagementServiceAPIConfiguration +from .operations import Operations, VirtualMachinesOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +class AzureArcVMwareManagementServiceAPI: # pylint: disable=too-many-instance-attributes + """Self service experience for VMware. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.connectedvmware.operations.Operations + :ivar virtual_machines: VirtualMachinesOperations operations + :vartype virtual_machines: azure.mgmt.connectedvmware.operations.VirtualMachinesOperations + :ivar resource_pools: ResourcePoolsOperations operations + :vartype resource_pools: azure.mgmt.connectedvmware.operations.ResourcePoolsOperations + :ivar clusters: ClustersOperations operations + :vartype clusters: azure.mgmt.connectedvmware.operations.ClustersOperations + :ivar hosts: HostsOperations operations + :vartype hosts: azure.mgmt.connectedvmware.operations.HostsOperations + :ivar datastores: DatastoresOperations operations + :vartype datastores: azure.mgmt.connectedvmware.operations.DatastoresOperations + :ivar vcenters: VCentersOperations operations + :vartype vcenters: azure.mgmt.connectedvmware.operations.VCentersOperations + :ivar virtual_machine_templates: VirtualMachineTemplatesOperations operations + :vartype virtual_machine_templates: + azure.mgmt.connectedvmware.operations.VirtualMachineTemplatesOperations + :ivar virtual_networks: VirtualNetworksOperations operations + :vartype virtual_networks: azure.mgmt.connectedvmware.operations.VirtualNetworksOperations + :ivar inventory_items: InventoryItemsOperations operations + :vartype inventory_items: azure.mgmt.connectedvmware.operations.InventoryItemsOperations + :ivar hybrid_identity_metadata: HybridIdentityMetadataOperations operations + :vartype hybrid_identity_metadata: + azure.mgmt.connectedvmware.operations.HybridIdentityMetadataOperations + :ivar machine_extensions: MachineExtensionsOperations operations + :vartype machine_extensions: azure.mgmt.connectedvmware.operations.MachineExtensionsOperations + :ivar guest_agents: GuestAgentsOperations operations + :vartype guest_agents: azure.mgmt.connectedvmware.operations.GuestAgentsOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The Subscription ID. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2022-01-10-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = AzureArcVMwareManagementServiceAPIConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machines = VirtualMachinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> AzureArcVMwareManagementServiceAPI + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/_configuration.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/_configuration.py new file mode 100644 index 00000000000..8a8e8f9b946 --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/_configuration.py @@ -0,0 +1,73 @@ +# 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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class AzureArcVMwareManagementServiceAPIConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for AzureArcVMwareManagementServiceAPI. + + 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 + :param subscription_id: The Subscription ID. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-01-10-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(AzureArcVMwareManagementServiceAPIConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2022-01-10-preview") # type: str + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-connectedvmware/{}'.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 = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/_patch.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/_patch.py new file mode 100644 index 00000000000..0ad201a8c58 --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/_vendor.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/_vendor.py new file mode 100644 index 00000000000..138f663c53a --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/_version.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/_version.py new file mode 100644 index 00000000000..dfa6ee022f1 --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/_version.py @@ -0,0 +1,9 @@ +# 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. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b2" diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/__init__.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/__init__.py new file mode 100644 index 00000000000..93ed9911373 --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/__init__.py @@ -0,0 +1,20 @@ +# 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_arc_vmware_management_service_api import AzureArcVMwareManagementServiceAPI + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk +__all__ = ['AzureArcVMwareManagementServiceAPI'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/_azure_arc_vmware_management_service_api.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/_azure_arc_vmware_management_service_api.py new file mode 100644 index 00000000000..09359454d77 --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/_azure_arc_vmware_management_service_api.py @@ -0,0 +1,159 @@ +# 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 copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from msrest import Deserializer, Serializer + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models +from ._configuration import AzureArcVMwareManagementServiceAPIConfiguration +from .operations import ClustersOperations, DatastoresOperations, GuestAgentsOperations, HostsOperations, HybridIdentityMetadataOperations, InventoryItemsOperations, MachineExtensionsOperations, Operations, ResourcePoolsOperations, VCentersOperations, VirtualMachineTemplatesOperations, VirtualMachinesOperations, VirtualNetworksOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +class AzureArcVMwareManagementServiceAPI: # pylint: disable=too-many-instance-attributes + """Self service experience for VMware. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.connectedvmware.aio.operations.Operations + :ivar virtual_machines: VirtualMachinesOperations operations + :vartype virtual_machines: azure.mgmt.connectedvmware.aio.operations.VirtualMachinesOperations + :ivar resource_pools: ResourcePoolsOperations operations + :vartype resource_pools: azure.mgmt.connectedvmware.aio.operations.ResourcePoolsOperations + :ivar clusters: ClustersOperations operations + :vartype clusters: azure.mgmt.connectedvmware.aio.operations.ClustersOperations + :ivar hosts: HostsOperations operations + :vartype hosts: azure.mgmt.connectedvmware.aio.operations.HostsOperations + :ivar datastores: DatastoresOperations operations + :vartype datastores: azure.mgmt.connectedvmware.aio.operations.DatastoresOperations + :ivar vcenters: VCentersOperations operations + :vartype vcenters: azure.mgmt.connectedvmware.aio.operations.VCentersOperations + :ivar virtual_machine_templates: VirtualMachineTemplatesOperations operations + :vartype virtual_machine_templates: + azure.mgmt.connectedvmware.aio.operations.VirtualMachineTemplatesOperations + :ivar virtual_networks: VirtualNetworksOperations operations + :vartype virtual_networks: azure.mgmt.connectedvmware.aio.operations.VirtualNetworksOperations + :ivar inventory_items: InventoryItemsOperations operations + :vartype inventory_items: azure.mgmt.connectedvmware.aio.operations.InventoryItemsOperations + :ivar hybrid_identity_metadata: HybridIdentityMetadataOperations operations + :vartype hybrid_identity_metadata: + azure.mgmt.connectedvmware.aio.operations.HybridIdentityMetadataOperations + :ivar machine_extensions: MachineExtensionsOperations operations + :vartype machine_extensions: + azure.mgmt.connectedvmware.aio.operations.MachineExtensionsOperations + :ivar guest_agents: GuestAgentsOperations operations + :vartype guest_agents: azure.mgmt.connectedvmware.aio.operations.GuestAgentsOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The Subscription ID. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2022-01-10-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = AzureArcVMwareManagementServiceAPIConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machines = VirtualMachinesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.resource_pools = ResourcePoolsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.clusters = ClustersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.hosts = HostsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.datastores = DatastoresOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.vcenters = VCentersOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_machine_templates = VirtualMachineTemplatesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.virtual_networks = VirtualNetworksOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.inventory_items = InventoryItemsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.hybrid_identity_metadata = HybridIdentityMetadataOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.machine_extensions = MachineExtensionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.guest_agents = GuestAgentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "AzureArcVMwareManagementServiceAPI": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/_configuration.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/_configuration.py new file mode 100644 index 00000000000..a3e014206f2 --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/_configuration.py @@ -0,0 +1,72 @@ +# 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, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class AzureArcVMwareManagementServiceAPIConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for AzureArcVMwareManagementServiceAPI. + + 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 + :param subscription_id: The Subscription ID. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-01-10-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(AzureArcVMwareManagementServiceAPIConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2022-01-10-preview") # type: str + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-connectedvmware/{}'.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 = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/_patch.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/_patch.py new file mode 100644 index 00000000000..0ad201a8c58 --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/__init__.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/__init__.py new file mode 100644 index 00000000000..21604bbdbe2 --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/__init__.py @@ -0,0 +1,42 @@ +# 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 ._operations import Operations +from ._virtual_machines_operations import VirtualMachinesOperations +from ._resource_pools_operations import ResourcePoolsOperations +from ._clusters_operations import ClustersOperations +from ._hosts_operations import HostsOperations +from ._datastores_operations import DatastoresOperations +from ._vcenters_operations import VCentersOperations +from ._virtual_machine_templates_operations import VirtualMachineTemplatesOperations +from ._virtual_networks_operations import VirtualNetworksOperations +from ._inventory_items_operations import InventoryItemsOperations +from ._hybrid_identity_metadata_operations import HybridIdentityMetadataOperations +from ._machine_extensions_operations import MachineExtensionsOperations +from ._guest_agents_operations import GuestAgentsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'Operations', + 'VirtualMachinesOperations', + 'ResourcePoolsOperations', + 'ClustersOperations', + 'HostsOperations', + 'DatastoresOperations', + 'VCentersOperations', + 'VirtualMachineTemplatesOperations', + 'VirtualNetworksOperations', + 'InventoryItemsOperations', + 'HybridIdentityMetadataOperations', + 'MachineExtensionsOperations', + 'GuestAgentsOperations', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_clusters_operations.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_clusters_operations.py new file mode 100644 index 00000000000..ed42c74da29 --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_clusters_operations.py @@ -0,0 +1,633 @@ +# pylint: disable=too-many-lines +# 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, Optional, TypeVar, Union, cast + +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 +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._clusters_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_request, build_update_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ClustersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.connectedvmware.aio.AzureArcVMwareManagementServiceAPI`'s + :attr:`clusters` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + async def _create_initial( + self, + resource_group_name: str, + cluster_name: str, + body: Optional[_models.Cluster] = None, + **kwargs: Any + ) -> _models.Cluster: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Cluster] + + if body is not None: + _json = self._serialize.body(body, 'Cluster') + else: + _json = None + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Cluster', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Cluster', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}"} # type: ignore + + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + cluster_name: str, + body: Optional[_models.Cluster] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.Cluster]: + """Implements cluster PUT method. + + Create Or Update cluster. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param cluster_name: Name of the cluster. + :type cluster_name: str + :param body: Request payload. Default value is None. + :type body: ~azure.mgmt.connectedvmware.models.Cluster + :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: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Cluster or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.Cluster] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Cluster] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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_initial( # type: ignore + resource_group_name=resource_group_name, + cluster_name=cluster_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Cluster', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}"} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + cluster_name: str, + **kwargs: Any + ) -> _models.Cluster: + """Gets a cluster. + + Implements cluster GET method. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param cluster_name: Name of the cluster. + :type cluster_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Cluster, or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.Cluster + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Cluster] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Cluster', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}"} # type: ignore + + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + cluster_name: str, + body: Optional[_models.ResourcePatch] = None, + **kwargs: Any + ) -> _models.Cluster: + """Updates a cluster. + + API to update certain properties of the cluster resource. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param cluster_name: Name of the cluster. + :type cluster_name: str + :param body: Resource properties to update. Default value is None. + :type body: ~azure.mgmt.connectedvmware.models.ResourcePatch + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Cluster, or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.Cluster + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Cluster] + + if body is not None: + _json = self._serialize.body(body, 'ResourcePatch') + else: + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Cluster', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}"} # type: ignore + + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cluster_name: str, + force: Optional[bool] = None, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + cluster_name=cluster_name, + api_version=api_version, + force=force, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}"} # type: ignore + + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + cluster_name: str, + force: Optional[bool] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes an cluster. + + Implements cluster DELETE method. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param cluster_name: Name of the cluster. + :type cluster_name: str + :param force: Whether force delete was specified. Default value is None. + :type force: bool + :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: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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._delete_initial( # type: ignore + resource_group_name=resource_group_name, + cluster_name=cluster_name, + force=force, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}"} # type: ignore + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable[_models.ClustersList]: + """Implements GET clusters in a subscription. + + List of clusters in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ClustersList or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.ClustersList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ClustersList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ClustersList", 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/clusters"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.ClustersList]: + """Implements GET clusters in a resource group. + + List of clusters in a resource group. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ClustersList or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.ClustersList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ClustersList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ClustersList", 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters"} # type: ignore diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_datastores_operations.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_datastores_operations.py new file mode 100644 index 00000000000..88f72ed0920 --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_datastores_operations.py @@ -0,0 +1,633 @@ +# pylint: disable=too-many-lines +# 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, Optional, TypeVar, Union, cast + +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 +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._datastores_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_request, build_update_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class DatastoresOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.connectedvmware.aio.AzureArcVMwareManagementServiceAPI`'s + :attr:`datastores` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + async def _create_initial( + self, + resource_group_name: str, + datastore_name: str, + body: Optional[_models.Datastore] = None, + **kwargs: Any + ) -> _models.Datastore: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Datastore] + + if body is not None: + _json = self._serialize.body(body, 'Datastore') + else: + _json = None + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + datastore_name=datastore_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Datastore', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Datastore', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}"} # type: ignore + + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + datastore_name: str, + body: Optional[_models.Datastore] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.Datastore]: + """Implements datastore PUT method. + + Create Or Update datastore. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param datastore_name: Name of the datastore. + :type datastore_name: str + :param body: Request payload. Default value is None. + :type body: ~azure.mgmt.connectedvmware.models.Datastore + :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: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Datastore or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.Datastore] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Datastore] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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_initial( # type: ignore + resource_group_name=resource_group_name, + datastore_name=datastore_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Datastore', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}"} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + datastore_name: str, + **kwargs: Any + ) -> _models.Datastore: + """Gets a datastore. + + Implements datastore GET method. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param datastore_name: Name of the datastore. + :type datastore_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Datastore, or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.Datastore + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Datastore] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + datastore_name=datastore_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Datastore', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}"} # type: ignore + + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + datastore_name: str, + body: Optional[_models.ResourcePatch] = None, + **kwargs: Any + ) -> _models.Datastore: + """Updates a datastore. + + API to update certain properties of the datastore resource. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param datastore_name: Name of the datastore. + :type datastore_name: str + :param body: Resource properties to update. Default value is None. + :type body: ~azure.mgmt.connectedvmware.models.ResourcePatch + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Datastore, or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.Datastore + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Datastore] + + if body is not None: + _json = self._serialize.body(body, 'ResourcePatch') + else: + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + datastore_name=datastore_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Datastore', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}"} # type: ignore + + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + datastore_name: str, + force: Optional[bool] = None, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + datastore_name=datastore_name, + api_version=api_version, + force=force, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}"} # type: ignore + + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + datastore_name: str, + force: Optional[bool] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes an datastore. + + Implements datastore DELETE method. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param datastore_name: Name of the datastore. + :type datastore_name: str + :param force: Whether force delete was specified. Default value is None. + :type force: bool + :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: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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._delete_initial( # type: ignore + resource_group_name=resource_group_name, + datastore_name=datastore_name, + force=force, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}"} # type: ignore + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable[_models.DatastoresList]: + """Implements GET datastores in a subscription. + + List of datastores in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DatastoresList or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.DatastoresList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DatastoresList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DatastoresList", 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/datastores"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.DatastoresList]: + """Implements GET datastores in a resource group. + + List of datastores in a resource group. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DatastoresList or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.DatastoresList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.DatastoresList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DatastoresList", 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores"} # type: ignore diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_guest_agents_operations.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_guest_agents_operations.py new file mode 100644 index 00000000000..ef995f14e0b --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_guest_agents_operations.py @@ -0,0 +1,490 @@ +# pylint: disable=too-many-lines +# 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, Optional, TypeVar, Union, cast + +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 +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._guest_agents_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_by_vm_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class GuestAgentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.connectedvmware.aio.AzureArcVMwareManagementServiceAPI`'s + :attr:`guest_agents` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + async def _create_initial( + self, + resource_group_name: str, + virtual_machine_name: str, + name: str, + body: Optional[_models.GuestAgent] = None, + **kwargs: Any + ) -> _models.GuestAgent: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestAgent] + + if body is not None: + _json = self._serialize.body(body, 'GuestAgent') + else: + _json = None + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + name=name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('GuestAgent', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('GuestAgent', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents/{name}"} # type: ignore + + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + virtual_machine_name: str, + name: str, + body: Optional[_models.GuestAgent] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.GuestAgent]: + """Implements GuestAgent PUT method. + + Create Or Update GuestAgent. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param virtual_machine_name: Name of the vm. + :type virtual_machine_name: str + :param name: Name of the guestAgents. + :type name: str + :param body: Request payload. Default value is None. + :type body: ~azure.mgmt.connectedvmware.models.GuestAgent + :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: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either GuestAgent or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.GuestAgent] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestAgent] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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_initial( # type: ignore + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + name=name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('GuestAgent', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents/{name}"} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + virtual_machine_name: str, + name: str, + **kwargs: Any + ) -> _models.GuestAgent: + """Gets GuestAgent. + + Implements GuestAgent GET method. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param virtual_machine_name: Name of the vm. + :type virtual_machine_name: str + :param name: Name of the GuestAgent. + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: GuestAgent, or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.GuestAgent + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestAgent] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + name=name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('GuestAgent', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents/{name}"} # type: ignore + + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_machine_name: str, + name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + name=name, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents/{name}"} # type: ignore + + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_machine_name: str, + name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes an GuestAgent. + + Implements GuestAgent DELETE method. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param virtual_machine_name: Name of the vm. + :type virtual_machine_name: str + :param name: Name of the GuestAgent. + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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._delete_initial( # type: ignore + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + name=name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents/{name}"} # type: ignore + + @distributed_trace + def list_by_vm( + self, + resource_group_name: str, + virtual_machine_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.GuestAgentList]: + """Implements GET GuestAgent in a vm. + + Returns the list of GuestAgent of the given vm. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param virtual_machine_name: Name of the vm. + :type virtual_machine_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either GuestAgentList or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.GuestAgentList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestAgentList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_vm_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + api_version=api_version, + template_url=self.list_by_vm.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_vm_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("GuestAgentList", 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_vm.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents"} # type: ignore diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_hosts_operations.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_hosts_operations.py new file mode 100644 index 00000000000..3c14f97a77a --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_hosts_operations.py @@ -0,0 +1,630 @@ +# pylint: disable=too-many-lines +# 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, Optional, TypeVar, Union, cast + +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 +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._hosts_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_request, build_update_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class HostsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.connectedvmware.aio.AzureArcVMwareManagementServiceAPI`'s + :attr:`hosts` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + async def _create_initial( + self, + resource_group_name: str, + host_name: str, + body: Optional[_models.Host] = None, + **kwargs: Any + ) -> _models.Host: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Host] + + if body is not None: + _json = self._serialize.body(body, 'Host') + else: + _json = None + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + host_name=host_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('Host', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Host', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}"} # type: ignore + + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + host_name: str, + body: Optional[_models.Host] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.Host]: + """Implements host PUT method. + + Create Or Update host. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param host_name: Name of the host. + :type host_name: str + :param body: Request payload. Default value is None. + :type body: ~azure.mgmt.connectedvmware.models.Host + :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: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Host or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.Host] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Host] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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_initial( # type: ignore + resource_group_name=resource_group_name, + host_name=host_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Host', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}"} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + host_name: str, + **kwargs: Any + ) -> _models.Host: + """Gets a host. + + Implements host GET method. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param host_name: Name of the host. + :type host_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Host, or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.Host + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.Host] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + host_name=host_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Host', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}"} # type: ignore + + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + host_name: str, + body: Optional[_models.ResourcePatch] = None, + **kwargs: Any + ) -> _models.Host: + """Updates a host. + + API to update certain properties of the host resource. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param host_name: Name of the host. + :type host_name: str + :param body: Resource properties to update. Default value is None. + :type body: ~azure.mgmt.connectedvmware.models.ResourcePatch + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Host, or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.Host + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.Host] + + if body is not None: + _json = self._serialize.body(body, 'ResourcePatch') + else: + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + host_name=host_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('Host', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}"} # type: ignore + + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + host_name: str, + force: Optional[bool] = None, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + host_name=host_name, + api_version=api_version, + force=force, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}"} # type: ignore + + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + host_name: str, + force: Optional[bool] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes an host. + + Implements host DELETE method. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param host_name: Name of the host. + :type host_name: str + :param force: Whether force delete was specified. Default value is None. + :type force: bool + :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: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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._delete_initial( # type: ignore + resource_group_name=resource_group_name, + host_name=host_name, + force=force, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}"} # type: ignore + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable[_models.HostsList]: + """Implements GET hosts in a subscription. + + List of hosts in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either HostsList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.HostsList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.HostsList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("HostsList", 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/hosts"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.HostsList]: + """Implements GET hosts in a resource group. + + List of hosts in a resource group. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either HostsList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.HostsList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.HostsList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("HostsList", 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts"} # type: ignore diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_hybrid_identity_metadata_operations.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_hybrid_identity_metadata_operations.py new file mode 100644 index 00000000000..f3cab1c2c55 --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_hybrid_identity_metadata_operations.py @@ -0,0 +1,354 @@ +# pylint: disable=too-many-lines +# 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, Optional, TypeVar + +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 +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._hybrid_identity_metadata_operations import build_create_request, build_delete_request, build_get_request, build_list_by_vm_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class HybridIdentityMetadataOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.connectedvmware.aio.AzureArcVMwareManagementServiceAPI`'s + :attr:`hybrid_identity_metadata` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + virtual_machine_name: str, + metadata_name: str, + body: Optional[_models.HybridIdentityMetadata] = None, + **kwargs: Any + ) -> _models.HybridIdentityMetadata: + """Implements HybridIdentityMetadata PUT method. + + Create Or Update HybridIdentityMetadata. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param virtual_machine_name: Name of the vm. + :type virtual_machine_name: str + :param metadata_name: Name of the hybridIdentityMetadata. + :type metadata_name: str + :param body: Request payload. Default value is None. + :type body: ~azure.mgmt.connectedvmware.models.HybridIdentityMetadata + :keyword callable cls: A custom type or function that will be passed the direct response + :return: HybridIdentityMetadata, or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.HybridIdentityMetadata + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.HybridIdentityMetadata] + + if body is not None: + _json = self._serialize.body(body, 'HybridIdentityMetadata') + else: + _json = None + + request = build_create_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + metadata_name=metadata_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('HybridIdentityMetadata', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}"} # type: ignore + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + virtual_machine_name: str, + metadata_name: str, + **kwargs: Any + ) -> _models.HybridIdentityMetadata: + """Gets HybridIdentityMetadata. + + Implements HybridIdentityMetadata GET method. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param virtual_machine_name: Name of the vm. + :type virtual_machine_name: str + :param metadata_name: Name of the HybridIdentityMetadata. + :type metadata_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: HybridIdentityMetadata, or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.HybridIdentityMetadata + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.HybridIdentityMetadata] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + metadata_name=metadata_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('HybridIdentityMetadata', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_machine_name: str, + metadata_name: str, + **kwargs: Any + ) -> None: + """Deletes an HybridIdentityMetadata. + + Implements HybridIdentityMetadata DELETE method. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param virtual_machine_name: Name of the vm. + :type virtual_machine_name: str + :param metadata_name: Name of the HybridIdentityMetadata. + :type metadata_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + metadata_name=metadata_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}"} # type: ignore + + + @distributed_trace + def list_by_vm( + self, + resource_group_name: str, + virtual_machine_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.HybridIdentityMetadataList]: + """Implements GET HybridIdentityMetadata in a vm. + + Returns the list of HybridIdentityMetadata of the given vm. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param virtual_machine_name: Name of the vm. + :type virtual_machine_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either HybridIdentityMetadataList or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.HybridIdentityMetadataList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.HybridIdentityMetadataList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_vm_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + api_version=api_version, + template_url=self.list_by_vm.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_vm_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("HybridIdentityMetadataList", 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_vm.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/hybridIdentityMetadata"} # type: ignore diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_inventory_items_operations.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_inventory_items_operations.py new file mode 100644 index 00000000000..88ed9743339 --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_inventory_items_operations.py @@ -0,0 +1,353 @@ +# pylint: disable=too-many-lines +# 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, Optional, TypeVar + +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 +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._inventory_items_operations import build_create_request, build_delete_request, build_get_request, build_list_by_v_center_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class InventoryItemsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.connectedvmware.aio.AzureArcVMwareManagementServiceAPI`'s + :attr:`inventory_items` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + vcenter_name: str, + inventory_item_name: str, + body: Optional[_models.InventoryItem] = None, + **kwargs: Any + ) -> _models.InventoryItem: + """Implements InventoryItem PUT method. + + Create Or Update InventoryItem. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param vcenter_name: Name of the vCenter. + :type vcenter_name: str + :param inventory_item_name: Name of the inventoryItem. + :type inventory_item_name: str + :param body: Request payload. Default value is None. + :type body: ~azure.mgmt.connectedvmware.models.InventoryItem + :keyword callable cls: A custom type or function that will be passed the direct response + :return: InventoryItem, or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.InventoryItem + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.InventoryItem] + + if body is not None: + _json = self._serialize.body(body, 'InventoryItem') + else: + _json = None + + request = build_create_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vcenter_name=vcenter_name, + inventory_item_name=inventory_item_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('InventoryItem', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}/inventoryItems/{inventoryItemName}"} # type: ignore + + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + vcenter_name: str, + inventory_item_name: str, + **kwargs: Any + ) -> _models.InventoryItem: + """Gets InventoryItem. + + Implements InventoryItem GET method. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param vcenter_name: Name of the vCenter. + :type vcenter_name: str + :param inventory_item_name: Name of the inventoryItem. + :type inventory_item_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: InventoryItem, or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.InventoryItem + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.InventoryItem] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vcenter_name=vcenter_name, + inventory_item_name=inventory_item_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('InventoryItem', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}/inventoryItems/{inventoryItemName}"} # type: ignore + + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + vcenter_name: str, + inventory_item_name: str, + **kwargs: Any + ) -> None: + """Deletes an inventoryItem. + + Implements inventoryItem DELETE method. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param vcenter_name: Name of the vCenter. + :type vcenter_name: str + :param inventory_item_name: Name of the inventoryItem. + :type inventory_item_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vcenter_name=vcenter_name, + inventory_item_name=inventory_item_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}/inventoryItems/{inventoryItemName}"} # type: ignore + + + @distributed_trace + def list_by_v_center( + self, + resource_group_name: str, + vcenter_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.InventoryItemsList]: + """Implements GET inventoryItems in a vCenter. + + Returns the list of inventoryItems of the given vCenter. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param vcenter_name: Name of the vCenter. + :type vcenter_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either InventoryItemsList or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.InventoryItemsList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.InventoryItemsList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_v_center_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vcenter_name=vcenter_name, + api_version=api_version, + template_url=self.list_by_v_center.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_v_center_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vcenter_name=vcenter_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("InventoryItemsList", 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_v_center.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}/inventoryItems"} # type: ignore diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_machine_extensions_operations.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_machine_extensions_operations.py new file mode 100644 index 00000000000..4a04d9f88ac --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_machine_extensions_operations.py @@ -0,0 +1,633 @@ +# pylint: disable=too-many-lines +# 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, Optional, TypeVar, Union, cast + +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 +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._machine_extensions_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class MachineExtensionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.connectedvmware.aio.AzureArcVMwareManagementServiceAPI`'s + :attr:`machine_extensions` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + async def _create_or_update_initial( + self, + resource_group_name: str, + name: str, + extension_name: str, + extension_parameters: _models.MachineExtension, + **kwargs: Any + ) -> _models.MachineExtension: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.MachineExtension] + + _json = self._serialize.body(extension_parameters, 'MachineExtension') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + extension_name=extension_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('MachineExtension', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('MachineExtension', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}"} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + name: str, + extension_name: str, + extension_parameters: _models.MachineExtension, + **kwargs: Any + ) -> AsyncLROPoller[_models.MachineExtension]: + """The operation to create or update the extension. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param name: The name of the machine where the extension should be created or updated. + :type name: str + :param extension_name: The name of the machine extension. + :type extension_name: str + :param extension_parameters: Parameters supplied to the Create Machine Extension operation. + :type extension_parameters: ~azure.mgmt.connectedvmware.models.MachineExtension + :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: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MachineExtension or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.MachineExtension] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.MachineExtension] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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( # type: ignore + resource_group_name=resource_group_name, + name=name, + extension_name=extension_name, + extension_parameters=extension_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('MachineExtension', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}"} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + name: str, + extension_name: str, + extension_parameters: _models.MachineExtensionUpdate, + **kwargs: Any + ) -> _models.MachineExtension: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.MachineExtension] + + _json = self._serialize.body(extension_parameters, 'MachineExtensionUpdate') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + extension_name=extension_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('MachineExtension', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('MachineExtension', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}"} # type: ignore + + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + name: str, + extension_name: str, + extension_parameters: _models.MachineExtensionUpdate, + **kwargs: Any + ) -> AsyncLROPoller[_models.MachineExtension]: + """The operation to update the extension. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param name: The name of the machine where the extension should be created or updated. + :type name: str + :param extension_name: The name of the machine extension. + :type extension_name: str + :param extension_parameters: Parameters supplied to the Create Machine Extension operation. + :type extension_parameters: ~azure.mgmt.connectedvmware.models.MachineExtensionUpdate + :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: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either MachineExtension or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.MachineExtension] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.MachineExtension] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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( # type: ignore + resource_group_name=resource_group_name, + name=name, + extension_name=extension_name, + extension_parameters=extension_parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('MachineExtension', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + name: str, + extension_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + extension_name=extension_name, + api_version=api_version, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}"} # type: ignore + + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + name: str, + extension_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """The operation to delete the extension. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param name: The name of the machine where the extension should be deleted. + :type name: str + :param extension_name: The name of the machine extension. + :type extension_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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._delete_initial( # type: ignore + resource_group_name=resource_group_name, + name=name, + extension_name=extension_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}"} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + name: str, + extension_name: str, + **kwargs: Any + ) -> _models.MachineExtension: + """The operation to get the extension. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param name: The name of the machine containing the extension. + :type name: str + :param extension_name: The name of the machine extension. + :type extension_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: MachineExtension, or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.MachineExtension + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.MachineExtension] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + extension_name=extension_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('MachineExtension', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}"} # type: ignore + + + @distributed_trace + def list( + self, + resource_group_name: str, + name: str, + expand: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable[_models.MachineExtensionsListResult]: + """The operation to get all extensions of a non-Azure machine. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param name: The name of the machine containing the extension. + :type name: str + :param expand: The expand expression to apply on the operation. Default value is None. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either MachineExtensionsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.MachineExtensionsListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.MachineExtensionsListResult] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + api_version=api_version, + expand=expand, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + api_version=api_version, + expand=expand, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("MachineExtensionsListResult", 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions"} # type: ignore diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_operations.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_operations.py new file mode 100644 index 00000000000..93099c75710 --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_operations.py @@ -0,0 +1,122 @@ +# pylint: disable=too-many-lines +# 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, Optional, TypeVar + +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 +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._operations import build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.connectedvmware.aio.AzureArcVMwareManagementServiceAPI`'s + :attr:`operations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable[_models.OperationsList]: + """Returns list of all operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationsList or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.OperationsList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationsList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("OperationsList", 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/providers/Microsoft.ConnectedVMwarevSphere/operations"} # type: ignore diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_patch.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_patch.py new file mode 100644 index 00000000000..0ad201a8c58 --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_resource_pools_operations.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_resource_pools_operations.py new file mode 100644 index 00000000000..c7941c2cdc7 --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_resource_pools_operations.py @@ -0,0 +1,633 @@ +# pylint: disable=too-many-lines +# 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, Optional, TypeVar, Union, cast + +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 +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._resource_pools_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_request, build_update_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ResourcePoolsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.connectedvmware.aio.AzureArcVMwareManagementServiceAPI`'s + :attr:`resource_pools` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + async def _create_initial( + self, + resource_group_name: str, + resource_pool_name: str, + body: Optional[_models.ResourcePool] = None, + **kwargs: Any + ) -> _models.ResourcePool: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourcePool] + + if body is not None: + _json = self._serialize.body(body, 'ResourcePool') + else: + _json = None + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_pool_name=resource_pool_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('ResourcePool', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ResourcePool', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}"} # type: ignore + + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + resource_pool_name: str, + body: Optional[_models.ResourcePool] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.ResourcePool]: + """Implements resourcePool PUT method. + + Create Or Update resourcePool. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param resource_pool_name: Name of the resourcePool. + :type resource_pool_name: str + :param body: Request payload. Default value is None. + :type body: ~azure.mgmt.connectedvmware.models.ResourcePool + :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: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ResourcePool or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.ResourcePool] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourcePool] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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_initial( # type: ignore + resource_group_name=resource_group_name, + resource_pool_name=resource_pool_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ResourcePool', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}"} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + resource_pool_name: str, + **kwargs: Any + ) -> _models.ResourcePool: + """Gets a resourcePool. + + Implements resourcePool GET method. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param resource_pool_name: Name of the resourcePool. + :type resource_pool_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourcePool, or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.ResourcePool + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourcePool] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_pool_name=resource_pool_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ResourcePool', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}"} # type: ignore + + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + resource_pool_name: str, + body: Optional[_models.ResourcePatch] = None, + **kwargs: Any + ) -> _models.ResourcePool: + """Updates a resourcePool. + + API to update certain properties of the resourcePool resource. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param resource_pool_name: Name of the resourcePool. + :type resource_pool_name: str + :param body: Resource properties to update. Default value is None. + :type body: ~azure.mgmt.connectedvmware.models.ResourcePatch + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ResourcePool, or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.ResourcePool + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourcePool] + + if body is not None: + _json = self._serialize.body(body, 'ResourcePatch') + else: + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_pool_name=resource_pool_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ResourcePool', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}"} # type: ignore + + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + resource_pool_name: str, + force: Optional[bool] = None, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_pool_name=resource_pool_name, + api_version=api_version, + force=force, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}"} # type: ignore + + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + resource_pool_name: str, + force: Optional[bool] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes an resourcePool. + + Implements resourcePool DELETE method. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param resource_pool_name: Name of the resourcePool. + :type resource_pool_name: str + :param force: Whether force delete was specified. Default value is None. + :type force: bool + :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: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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._delete_initial( # type: ignore + resource_group_name=resource_group_name, + resource_pool_name=resource_pool_name, + force=force, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}"} # type: ignore + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable[_models.ResourcePoolsList]: + """Implements GET resourcePools in a subscription. + + List of resourcePools in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ResourcePoolsList or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.ResourcePoolsList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourcePoolsList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ResourcePoolsList", 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.ResourcePoolsList]: + """Implements GET resourcePools in a resource group. + + List of resourcePools in a resource group. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ResourcePoolsList or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.ResourcePoolsList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourcePoolsList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ResourcePoolsList", 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools"} # type: ignore diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_vcenters_operations.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_vcenters_operations.py new file mode 100644 index 00000000000..daaafef52f5 --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_vcenters_operations.py @@ -0,0 +1,633 @@ +# pylint: disable=too-many-lines +# 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, Optional, TypeVar, Union, cast + +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 +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._vcenters_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_request, build_update_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class VCentersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.connectedvmware.aio.AzureArcVMwareManagementServiceAPI`'s + :attr:`vcenters` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + async def _create_initial( + self, + resource_group_name: str, + vcenter_name: str, + body: Optional[_models.VCenter] = None, + **kwargs: Any + ) -> _models.VCenter: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VCenter] + + if body is not None: + _json = self._serialize.body(body, 'VCenter') + else: + _json = None + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vcenter_name=vcenter_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('VCenter', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('VCenter', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}"} # type: ignore + + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + vcenter_name: str, + body: Optional[_models.VCenter] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.VCenter]: + """Implements vCenter PUT method. + + Create Or Update vCenter. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param vcenter_name: Name of the vCenter. + :type vcenter_name: str + :param body: Request payload. Default value is None. + :type body: ~azure.mgmt.connectedvmware.models.VCenter + :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: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either VCenter or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.VCenter] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VCenter] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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_initial( # type: ignore + resource_group_name=resource_group_name, + vcenter_name=vcenter_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('VCenter', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}"} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + vcenter_name: str, + **kwargs: Any + ) -> _models.VCenter: + """Gets a vCenter. + + Implements vCenter GET method. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param vcenter_name: Name of the vCenter. + :type vcenter_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VCenter, or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.VCenter + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VCenter] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vcenter_name=vcenter_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('VCenter', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}"} # type: ignore + + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + vcenter_name: str, + body: Optional[_models.ResourcePatch] = None, + **kwargs: Any + ) -> _models.VCenter: + """Updates a vCenter. + + API to update certain properties of the vCenter resource. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param vcenter_name: Name of the vCenter. + :type vcenter_name: str + :param body: Resource properties to update. Default value is None. + :type body: ~azure.mgmt.connectedvmware.models.ResourcePatch + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VCenter, or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.VCenter + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VCenter] + + if body is not None: + _json = self._serialize.body(body, 'ResourcePatch') + else: + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vcenter_name=vcenter_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('VCenter', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}"} # type: ignore + + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + vcenter_name: str, + force: Optional[bool] = None, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + vcenter_name=vcenter_name, + api_version=api_version, + force=force, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}"} # type: ignore + + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + vcenter_name: str, + force: Optional[bool] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes an vCenter. + + Implements vCenter DELETE method. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param vcenter_name: Name of the vCenter. + :type vcenter_name: str + :param force: Whether force delete was specified. Default value is None. + :type force: bool + :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: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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._delete_initial( # type: ignore + resource_group_name=resource_group_name, + vcenter_name=vcenter_name, + force=force, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}"} # type: ignore + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable[_models.VCentersList]: + """Implements GET vCenters in a subscription. + + List of vCenters in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either VCentersList or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.VCentersList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VCentersList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("VCentersList", 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/vcenters"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.VCentersList]: + """Implements GET vCenters in a resource group. + + List of vCenters in a resource group. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either VCentersList or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.VCentersList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VCentersList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("VCentersList", 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters"} # type: ignore diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_virtual_machine_templates_operations.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_virtual_machine_templates_operations.py new file mode 100644 index 00000000000..8d5fef85e36 --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_virtual_machine_templates_operations.py @@ -0,0 +1,636 @@ +# pylint: disable=too-many-lines +# 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, Optional, TypeVar, Union, cast + +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 +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._virtual_machine_templates_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_request, build_update_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class VirtualMachineTemplatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.connectedvmware.aio.AzureArcVMwareManagementServiceAPI`'s + :attr:`virtual_machine_templates` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + async def _create_initial( + self, + resource_group_name: str, + virtual_machine_template_name: str, + body: Optional[_models.VirtualMachineTemplate] = None, + **kwargs: Any + ) -> _models.VirtualMachineTemplate: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineTemplate] + + if body is not None: + _json = self._serialize.body(body, 'VirtualMachineTemplate') + else: + _json = None + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_template_name=virtual_machine_template_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('VirtualMachineTemplate', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('VirtualMachineTemplate', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}"} # type: ignore + + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + virtual_machine_template_name: str, + body: Optional[_models.VirtualMachineTemplate] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachineTemplate]: + """Implements virtual machine template PUT method. + + Create Or Update virtual machine template. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param virtual_machine_template_name: Name of the virtual machine template resource. + :type virtual_machine_template_name: str + :param body: Request payload. Default value is None. + :type body: ~azure.mgmt.connectedvmware.models.VirtualMachineTemplate + :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: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either VirtualMachineTemplate or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.VirtualMachineTemplate] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineTemplate] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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_initial( # type: ignore + resource_group_name=resource_group_name, + virtual_machine_template_name=virtual_machine_template_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('VirtualMachineTemplate', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}"} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + virtual_machine_template_name: str, + **kwargs: Any + ) -> _models.VirtualMachineTemplate: + """Gets a virtual machine template. + + Implements virtual machine template GET method. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param virtual_machine_template_name: Name of the virtual machine template resource. + :type virtual_machine_template_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VirtualMachineTemplate, or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.VirtualMachineTemplate + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineTemplate] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_template_name=virtual_machine_template_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('VirtualMachineTemplate', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}"} # type: ignore + + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + virtual_machine_template_name: str, + body: Optional[_models.ResourcePatch] = None, + **kwargs: Any + ) -> _models.VirtualMachineTemplate: + """Updates a virtual machine template. + + API to update certain properties of the virtual machine template resource. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param virtual_machine_template_name: Name of the virtual machine template resource. + :type virtual_machine_template_name: str + :param body: Resource properties to update. Default value is None. + :type body: ~azure.mgmt.connectedvmware.models.ResourcePatch + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VirtualMachineTemplate, or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.VirtualMachineTemplate + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineTemplate] + + if body is not None: + _json = self._serialize.body(body, 'ResourcePatch') + else: + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_template_name=virtual_machine_template_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('VirtualMachineTemplate', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}"} # type: ignore + + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_machine_template_name: str, + force: Optional[bool] = None, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_template_name=virtual_machine_template_name, + api_version=api_version, + force=force, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}"} # type: ignore + + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_machine_template_name: str, + force: Optional[bool] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes an virtual machine template. + + Implements virtual machine template DELETE method. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param virtual_machine_template_name: Name of the virtual machine template resource. + :type virtual_machine_template_name: str + :param force: Whether force delete was specified. Default value is None. + :type force: bool + :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: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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._delete_initial( # type: ignore + resource_group_name=resource_group_name, + virtual_machine_template_name=virtual_machine_template_name, + force=force, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}"} # type: ignore + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable[_models.VirtualMachineTemplatesList]: + """Implements GET virtualMachineTemplates in a subscription. + + List of virtualMachineTemplates in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either VirtualMachineTemplatesList or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.VirtualMachineTemplatesList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineTemplatesList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualMachineTemplatesList", 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.VirtualMachineTemplatesList]: + """Implements GET virtualMachineTemplates in a resource group. + + List of virtualMachineTemplates in a resource group. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either VirtualMachineTemplatesList or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.VirtualMachineTemplatesList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineTemplatesList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualMachineTemplatesList", 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates"} # type: ignore diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_virtual_machines_operations.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_virtual_machines_operations.py new file mode 100644 index 00000000000..56432841bcc --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_virtual_machines_operations.py @@ -0,0 +1,1364 @@ +# pylint: disable=too-many-lines +# 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, Optional, TypeVar, Union, cast + +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 +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._virtual_machines_operations import build_assess_patches_request_initial, build_create_request_initial, build_delete_request_initial, build_get_request, build_install_patches_request_initial, build_list_by_resource_group_request, build_list_request, build_restart_request_initial, build_start_request_initial, build_stop_request_initial, build_update_request_initial +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class VirtualMachinesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.connectedvmware.aio.AzureArcVMwareManagementServiceAPI`'s + :attr:`virtual_machines` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + async def _assess_patches_initial( + self, + resource_group_name: str, + name: str, + **kwargs: Any + ) -> Optional[_models.VirtualMachineAssessPatchesResult]: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.VirtualMachineAssessPatchesResult]] + + + request = build_assess_patches_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + api_version=api_version, + template_url=self._assess_patches_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('VirtualMachineAssessPatchesResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _assess_patches_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/assessPatches"} # type: ignore + + + @distributed_trace_async + async def begin_assess_patches( + self, + resource_group_name: str, + name: str, + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachineAssessPatchesResult]: + """The operation to assess patches on a vSphere VMware machine identity in Azure. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param name: The name of the vSphere VMware machine. + :type name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either VirtualMachineAssessPatchesResult or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.VirtualMachineAssessPatchesResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineAssessPatchesResult] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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._assess_patches_initial( # type: ignore + resource_group_name=resource_group_name, + name=name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('VirtualMachineAssessPatchesResult', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_assess_patches.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/assessPatches"} # type: ignore + + async def _install_patches_initial( + self, + resource_group_name: str, + name: str, + install_patches_input: _models.VirtualMachineInstallPatchesParameters, + **kwargs: Any + ) -> Optional[_models.VirtualMachineInstallPatchesResult]: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.VirtualMachineInstallPatchesResult]] + + _json = self._serialize.body(install_patches_input, 'VirtualMachineInstallPatchesParameters') + + request = build_install_patches_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + name=name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._install_patches_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('VirtualMachineInstallPatchesResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _install_patches_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/installPatches"} # type: ignore + + + @distributed_trace_async + async def begin_install_patches( + self, + resource_group_name: str, + name: str, + install_patches_input: _models.VirtualMachineInstallPatchesParameters, + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachineInstallPatchesResult]: + """The operation to install patches on a vSphere VMware machine identity in Azure. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param name: The name of the vSphere VMware machine. + :type name: str + :param install_patches_input: Input for InstallPatches as directly received by the API. + :type install_patches_input: + ~azure.mgmt.connectedvmware.models.VirtualMachineInstallPatchesParameters + :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: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either VirtualMachineInstallPatchesResult + or the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.VirtualMachineInstallPatchesResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineInstallPatchesResult] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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._install_patches_initial( # type: ignore + resource_group_name=resource_group_name, + name=name, + install_patches_input=install_patches_input, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('VirtualMachineInstallPatchesResult', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'location'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_install_patches.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/installPatches"} # type: ignore + + async def _create_initial( + self, + resource_group_name: str, + virtual_machine_name: str, + body: Optional[_models.VirtualMachine] = None, + **kwargs: Any + ) -> _models.VirtualMachine: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] + + if body is not None: + _json = self._serialize.body(body, 'VirtualMachine') + else: + _json = None + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('VirtualMachine', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('VirtualMachine', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}"} # type: ignore + + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + virtual_machine_name: str, + body: Optional[_models.VirtualMachine] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachine]: + """Implements virtual machine PUT method. + + Create Or Update virtual machine. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param virtual_machine_name: Name of the virtual machine resource. + :type virtual_machine_name: str + :param body: Request payload. Default value is None. + :type body: ~azure.mgmt.connectedvmware.models.VirtualMachine + :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: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either VirtualMachine or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.VirtualMachine] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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_initial( # type: ignore + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('VirtualMachine', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}"} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + virtual_machine_name: str, + **kwargs: Any + ) -> _models.VirtualMachine: + """Gets a virtual machine. + + Implements virtual machine GET method. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param virtual_machine_name: Name of the virtual machine resource. + :type virtual_machine_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VirtualMachine, or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.VirtualMachine + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('VirtualMachine', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}"} # type: ignore + + + async def _update_initial( + self, + resource_group_name: str, + virtual_machine_name: str, + body: Optional[_models.VirtualMachineUpdate] = None, + **kwargs: Any + ) -> Optional[_models.VirtualMachine]: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.VirtualMachine]] + + if body is not None: + _json = self._serialize.body(body, 'VirtualMachineUpdate') + else: + _json = None + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('VirtualMachine', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('VirtualMachine', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}"} # type: ignore + + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + virtual_machine_name: str, + body: Optional[_models.VirtualMachineUpdate] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualMachine]: + """Updates a virtual machine. + + API to update certain properties of the virtual machine resource. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param virtual_machine_name: Name of the virtual machine resource. + :type virtual_machine_name: str + :param body: Resource properties to update. Default value is None. + :type body: ~azure.mgmt.connectedvmware.models.VirtualMachineUpdate + :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: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either VirtualMachine or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.VirtualMachine] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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( # type: ignore + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('VirtualMachine', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_machine_name: str, + force: Optional[bool] = None, + retain: Optional[bool] = None, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + api_version=api_version, + force=force, + retain=retain, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}"} # type: ignore + + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_machine_name: str, + force: Optional[bool] = None, + retain: Optional[bool] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes an virtual machine. + + Implements virtual machine DELETE method. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param virtual_machine_name: Name of the virtual machine resource. + :type virtual_machine_name: str + :param force: Whether force delete was specified. Default value is None. + :type force: bool + :param retain: Whether to just disable the VM from azure and retain the VM in the VMM. Default + value is None. + :type retain: bool + :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: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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._delete_initial( # type: ignore + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + force=force, + retain=retain, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}"} # type: ignore + + async def _stop_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_machine_name: str, + body: Optional[_models.StopVirtualMachineOptions] = None, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] + + if body is not None: + _json = self._serialize.body(body, 'StopVirtualMachineOptions') + else: + _json = None + + request = build_stop_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._stop_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _stop_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/stop"} # type: ignore + + + @distributed_trace_async + async def begin_stop( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_machine_name: str, + body: Optional[_models.StopVirtualMachineOptions] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Implements the operation to stop a virtual machine. + + Stop virtual machine. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param virtual_machine_name: Name of the virtual machine resource. + :type virtual_machine_name: str + :param body: Virtualmachine stop action payload. Default value is None. + :type body: ~azure.mgmt.connectedvmware.models.StopVirtualMachineOptions + :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: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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._stop_initial( # type: ignore + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/stop"} # type: ignore + + async def _start_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_machine_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_start_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + api_version=api_version, + template_url=self._start_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _start_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/start"} # type: ignore + + + @distributed_trace_async + async def begin_start( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_machine_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Implements the operation to start a virtual machine. + + Start virtual machine. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param virtual_machine_name: Name of the virtual machine resource. + :type virtual_machine_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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._start_initial( # type: ignore + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_start.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/start"} # type: ignore + + async def _restart_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_machine_name: str, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_restart_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + api_version=api_version, + template_url=self._restart_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _restart_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/restart"} # type: ignore + + + @distributed_trace_async + async def begin_restart( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_machine_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Implements the operation to restart a virtual machine. + + Restart virtual machine. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param virtual_machine_name: Name of the virtual machine resource. + :type virtual_machine_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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._restart_initial( # type: ignore + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_restart.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/restart"} # type: ignore + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable[_models.VirtualMachinesList]: + """Implements GET virtualMachines in a subscription. + + List of virtualMachines in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either VirtualMachinesList or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.VirtualMachinesList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachinesList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualMachinesList", 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.VirtualMachinesList]: + """Implements GET virtualMachines in a resource group. + + List of virtualMachines in a resource group. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either VirtualMachinesList or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.VirtualMachinesList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachinesList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualMachinesList", 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines"} # type: ignore diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_virtual_networks_operations.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_virtual_networks_operations.py new file mode 100644 index 00000000000..5fd4e997199 --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_virtual_networks_operations.py @@ -0,0 +1,633 @@ +# pylint: disable=too-many-lines +# 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, Optional, TypeVar, Union, cast + +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 +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._virtual_networks_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_request, build_update_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class VirtualNetworksOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.connectedvmware.aio.AzureArcVMwareManagementServiceAPI`'s + :attr:`virtual_networks` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + async def _create_initial( + self, + resource_group_name: str, + virtual_network_name: str, + body: Optional[_models.VirtualNetwork] = None, + **kwargs: Any + ) -> _models.VirtualNetwork: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualNetwork] + + if body is not None: + _json = self._serialize.body(body, 'VirtualNetwork') + else: + _json = None + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_network_name=virtual_network_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize('VirtualNetwork', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('VirtualNetwork', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}"} # type: ignore + + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + virtual_network_name: str, + body: Optional[_models.VirtualNetwork] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.VirtualNetwork]: + """Implements virtual network PUT method. + + Create Or Update virtual network. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param virtual_network_name: Name of the virtual network resource. + :type virtual_network_name: str + :param body: Request payload. Default value is None. + :type body: ~azure.mgmt.connectedvmware.models.VirtualNetwork + :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: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either VirtualNetwork or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.VirtualNetwork] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualNetwork] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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_initial( # type: ignore + resource_group_name=resource_group_name, + virtual_network_name=virtual_network_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('VirtualNetwork', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + lro_options={'final-state-via': 'azure-async-operation'}, + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}"} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + virtual_network_name: str, + **kwargs: Any + ) -> _models.VirtualNetwork: + """Gets a virtual network. + + Implements virtual network GET method. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param virtual_network_name: Name of the virtual network resource. + :type virtual_network_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VirtualNetwork, or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.VirtualNetwork + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualNetwork] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_network_name=virtual_network_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('VirtualNetwork', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}"} # type: ignore + + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + virtual_network_name: str, + body: Optional[_models.ResourcePatch] = None, + **kwargs: Any + ) -> _models.VirtualNetwork: + """Updates a virtual network. + + API to update certain properties of the virtual network resource. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param virtual_network_name: Name of the virtual network resource. + :type virtual_network_name: str + :param body: Resource properties to update. Default value is None. + :type body: ~azure.mgmt.connectedvmware.models.ResourcePatch + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VirtualNetwork, or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.VirtualNetwork + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualNetwork] + + if body is not None: + _json = self._serialize.body(body, 'ResourcePatch') + else: + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_network_name=virtual_network_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('VirtualNetwork', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}"} # type: ignore + + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_network_name: str, + force: Optional[bool] = None, + **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_network_name=virtual_network_name, + api_version=api_version, + force=force, + template_url=self._delete_initial.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}"} # type: ignore + + + @distributed_trace_async + async def begin_delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + virtual_network_name: str, + force: Optional[bool] = None, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes an virtual network. + + Implements virtual network DELETE method. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param virtual_network_name: Name of the virtual network resource. + :type virtual_network_name: str + :param force: Whether force delete was specified. Default value is None. + :type force: bool + :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: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[None] + polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + 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._delete_initial( # type: ignore + resource_group_name=resource_group_name, + virtual_network_name=virtual_network_name, + force=force, + api_version=api_version, + cls=lambda x,y,z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling( + lro_delay, + + + **kwargs + )) # type: AsyncPollingMethod + elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}"} # type: ignore + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable[_models.VirtualNetworksList]: + """Implements GET virtualNetworks in a subscription. + + List of virtualNetworks in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either VirtualNetworksList or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.VirtualNetworksList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualNetworksList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualNetworksList", 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable[_models.VirtualNetworksList]: + """Implements GET virtualNetworks in a resource group. + + List of virtualNetworks in a resource group. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either VirtualNetworksList or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.VirtualNetworksList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualNetworksList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=self.list_by_resource_group.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("VirtualNetworksList", 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks"} # type: ignore diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/models/__init__.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/models/__init__.py new file mode 100644 index 00000000000..89491cbd810 --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/models/__init__.py @@ -0,0 +1,235 @@ +# 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 ._models_py3 import AvailablePatchCountByClassification +from ._models_py3 import Cluster +from ._models_py3 import ClusterInventoryItem +from ._models_py3 import ClustersList +from ._models_py3 import Condition +from ._models_py3 import Datastore +from ._models_py3 import DatastoreInventoryItem +from ._models_py3 import DatastoresList +from ._models_py3 import ErrorDefinition +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse +from ._models_py3 import ExtendedLocation +from ._models_py3 import GuestAgent +from ._models_py3 import GuestAgentList +from ._models_py3 import GuestAgentProfile +from ._models_py3 import GuestCredential +from ._models_py3 import HardwareProfile +from ._models_py3 import Host +from ._models_py3 import HostInventoryItem +from ._models_py3 import HostsList +from ._models_py3 import HttpProxyConfiguration +from ._models_py3 import HybridIdentityMetadata +from ._models_py3 import HybridIdentityMetadataList +from ._models_py3 import Identity +from ._models_py3 import InventoryItem +from ._models_py3 import InventoryItemDetails +from ._models_py3 import InventoryItemProperties +from ._models_py3 import InventoryItemsList +from ._models_py3 import LinuxParameters +from ._models_py3 import MachineExtension +from ._models_py3 import MachineExtensionInstanceView +from ._models_py3 import MachineExtensionInstanceViewStatus +from ._models_py3 import MachineExtensionPropertiesInstanceView +from ._models_py3 import MachineExtensionUpdate +from ._models_py3 import MachineExtensionsListResult +from ._models_py3 import NetworkInterface +from ._models_py3 import NetworkInterfaceUpdate +from ._models_py3 import NetworkProfile +from ._models_py3 import NetworkProfileUpdate +from ._models_py3 import NicIPAddressSettings +from ._models_py3 import NicIPSettings +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationsList +from ._models_py3 import OsProfile +from ._models_py3 import OsProfileLinuxConfiguration +from ._models_py3 import OsProfileUpdate +from ._models_py3 import OsProfileUpdateLinuxConfiguration +from ._models_py3 import OsProfileUpdateWindowsConfiguration +from ._models_py3 import OsProfileWindowsConfiguration +from ._models_py3 import PlacementProfile +from ._models_py3 import ProxyResource +from ._models_py3 import Resource +from ._models_py3 import ResourcePatch +from ._models_py3 import ResourcePool +from ._models_py3 import ResourcePoolInventoryItem +from ._models_py3 import ResourcePoolsList +from ._models_py3 import ResourceStatus +from ._models_py3 import SecurityProfile +from ._models_py3 import StopVirtualMachineOptions +from ._models_py3 import StorageProfile +from ._models_py3 import StorageProfileUpdate +from ._models_py3 import SystemData +from ._models_py3 import UefiSettings +from ._models_py3 import VCenter +from ._models_py3 import VCentersList +from ._models_py3 import VICredential +from ._models_py3 import VirtualDisk +from ._models_py3 import VirtualDiskUpdate +from ._models_py3 import VirtualMachine +from ._models_py3 import VirtualMachineAssessPatchesResult +from ._models_py3 import VirtualMachineInstallPatchesParameters +from ._models_py3 import VirtualMachineInstallPatchesResult +from ._models_py3 import VirtualMachineInventoryItem +from ._models_py3 import VirtualMachineTemplate +from ._models_py3 import VirtualMachineTemplateInventoryItem +from ._models_py3 import VirtualMachineTemplatesList +from ._models_py3 import VirtualMachineUpdate +from ._models_py3 import VirtualMachinesList +from ._models_py3 import VirtualNetwork +from ._models_py3 import VirtualNetworkInventoryItem +from ._models_py3 import VirtualNetworksList +from ._models_py3 import VirtualSCSIController +from ._models_py3 import WindowsParameters + + +from ._azure_arc_vmware_management_service_api_enums import ( + CreatedByType, + DiskMode, + DiskType, + FirmwareType, + IPAddressAllocationMethod, + IdentityType, + InventoryType, + NICType, + OsType, + OsTypeUM, + PatchOperationStartedBy, + PatchOperationStatus, + PatchServiceUsed, + PowerOnBootOption, + ProvisioningAction, + ProvisioningState, + SCSIControllerType, + StatusLevelTypes, + StatusTypes, + VMGuestPatchClassificationLinux, + VMGuestPatchClassificationWindows, + VMGuestPatchRebootSetting, + VMGuestPatchRebootStatus, + VirtualSCSISharing, +) +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'AvailablePatchCountByClassification', + 'Cluster', + 'ClusterInventoryItem', + 'ClustersList', + 'Condition', + 'Datastore', + 'DatastoreInventoryItem', + 'DatastoresList', + 'ErrorDefinition', + 'ErrorDetail', + 'ErrorResponse', + 'ExtendedLocation', + 'GuestAgent', + 'GuestAgentList', + 'GuestAgentProfile', + 'GuestCredential', + 'HardwareProfile', + 'Host', + 'HostInventoryItem', + 'HostsList', + 'HttpProxyConfiguration', + 'HybridIdentityMetadata', + 'HybridIdentityMetadataList', + 'Identity', + 'InventoryItem', + 'InventoryItemDetails', + 'InventoryItemProperties', + 'InventoryItemsList', + 'LinuxParameters', + 'MachineExtension', + 'MachineExtensionInstanceView', + 'MachineExtensionInstanceViewStatus', + 'MachineExtensionPropertiesInstanceView', + 'MachineExtensionUpdate', + 'MachineExtensionsListResult', + 'NetworkInterface', + 'NetworkInterfaceUpdate', + 'NetworkProfile', + 'NetworkProfileUpdate', + 'NicIPAddressSettings', + 'NicIPSettings', + 'Operation', + 'OperationDisplay', + 'OperationsList', + 'OsProfile', + 'OsProfileLinuxConfiguration', + 'OsProfileUpdate', + 'OsProfileUpdateLinuxConfiguration', + 'OsProfileUpdateWindowsConfiguration', + 'OsProfileWindowsConfiguration', + 'PlacementProfile', + 'ProxyResource', + 'Resource', + 'ResourcePatch', + 'ResourcePool', + 'ResourcePoolInventoryItem', + 'ResourcePoolsList', + 'ResourceStatus', + 'SecurityProfile', + 'StopVirtualMachineOptions', + 'StorageProfile', + 'StorageProfileUpdate', + 'SystemData', + 'UefiSettings', + 'VCenter', + 'VCentersList', + 'VICredential', + 'VirtualDisk', + 'VirtualDiskUpdate', + 'VirtualMachine', + 'VirtualMachineAssessPatchesResult', + 'VirtualMachineInstallPatchesParameters', + 'VirtualMachineInstallPatchesResult', + 'VirtualMachineInventoryItem', + 'VirtualMachineTemplate', + 'VirtualMachineTemplateInventoryItem', + 'VirtualMachineTemplatesList', + 'VirtualMachineUpdate', + 'VirtualMachinesList', + 'VirtualNetwork', + 'VirtualNetworkInventoryItem', + 'VirtualNetworksList', + 'VirtualSCSIController', + 'WindowsParameters', + 'CreatedByType', + 'DiskMode', + 'DiskType', + 'FirmwareType', + 'IPAddressAllocationMethod', + 'IdentityType', + 'InventoryType', + 'NICType', + 'OsType', + 'OsTypeUM', + 'PatchOperationStartedBy', + 'PatchOperationStatus', + 'PatchServiceUsed', + 'PowerOnBootOption', + 'ProvisioningAction', + 'ProvisioningState', + 'SCSIControllerType', + 'StatusLevelTypes', + 'StatusTypes', + 'VMGuestPatchClassificationLinux', + 'VMGuestPatchClassificationWindows', + 'VMGuestPatchRebootSetting', + 'VMGuestPatchRebootStatus', + 'VirtualSCSISharing', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/models/_azure_arc_vmware_management_service_api_enums.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/models/_azure_arc_vmware_management_service_api_enums.py new file mode 100644 index 00000000000..56ca49a3352 --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/models/_azure_arc_vmware_management_service_api_enums.py @@ -0,0 +1,230 @@ +# 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 +from azure.core import CaseInsensitiveEnumMeta + + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource. + """ + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + +class DiskMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines the different types of disk modes. + """ + + PERSISTENT = "persistent" + INDEPENDENT_PERSISTENT = "independent_persistent" + INDEPENDENT_NONPERSISTENT = "independent_nonpersistent" + +class DiskType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines the different types of disks. + """ + + FLAT = "flat" + PMEM = "pmem" + RAWPHYSICAL = "rawphysical" + RAWVIRTUAL = "rawvirtual" + SPARSE = "sparse" + SESPARSE = "sesparse" + UNKNOWN = "unknown" + +class FirmwareType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Firmware type + """ + + BIOS = "bios" + EFI = "efi" + +class IdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of managed service identity. + """ + + NONE = "None" + SYSTEM_ASSIGNED = "SystemAssigned" + +class InventoryType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The inventory type. + """ + + RESOURCE_POOL = "ResourcePool" + VIRTUAL_MACHINE = "VirtualMachine" + VIRTUAL_MACHINE_TEMPLATE = "VirtualMachineTemplate" + VIRTUAL_NETWORK = "VirtualNetwork" + CLUSTER = "Cluster" + DATASTORE = "Datastore" + HOST = "Host" + +class IPAddressAllocationMethod(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """IP address allocation method. + """ + + UNSET = "unset" + DYNAMIC = "dynamic" + STATIC = "static" + LINKLAYER = "linklayer" + RANDOM = "random" + OTHER = "other" + +class NICType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """NIC type + """ + + VMXNET3 = "vmxnet3" + VMXNET2 = "vmxnet2" + VMXNET = "vmxnet" + E1000 = "e1000" + E1000_E = "e1000e" + PCNET32 = "pcnet32" + +class OsType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines the different types of VM guest operating systems. + """ + + WINDOWS = "Windows" + LINUX = "Linux" + OTHER = "Other" + +class OsTypeUM(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The operating system type of the machine. + """ + + WINDOWS = "Windows" + LINUX = "Linux" + +class PatchOperationStartedBy(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates if operation was triggered by user or by platform. + """ + + USER = "User" + PLATFORM = "Platform" + +class PatchOperationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The overall success or failure status of the operation. It remains "InProgress" until the + operation completes. At that point it will become "Unknown", "Failed", "Succeeded", or + "CompletedWithWarnings." + """ + + UNKNOWN = "Unknown" + IN_PROGRESS = "InProgress" + FAILED = "Failed" + SUCCEEDED = "Succeeded" + COMPLETED_WITH_WARNINGS = "CompletedWithWarnings" + +class PatchServiceUsed(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies the patch service used for the operation. + """ + + UNKNOWN = "Unknown" + WU = "WU" + WU_WSUS = "WU_WSUS" + YUM = "YUM" + APT = "APT" + ZYPPER = "Zypper" + +class PowerOnBootOption(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines the options for power on boot. + """ + + ENABLED = "enabled" + DISABLED = "disabled" + +class ProvisioningAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines the different types of operations for guest agent. + """ + + INSTALL = "install" + UNINSTALL = "uninstall" + REPAIR = "repair" + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current deployment state of resource. + """ + + SUCCEEDED = "Succeeded" + FAILED = "Failed" + CANCELED = "Canceled" + PROVISIONING = "Provisioning" + UPDATING = "Updating" + DELETING = "Deleting" + ACCEPTED = "Accepted" + CREATED = "Created" + +class SCSIControllerType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines the different types of SCSI controllers. + """ + + LSILOGIC = "lsilogic" + BUSLOGIC = "buslogic" + PVSCSI = "pvscsi" + LSILOGICSAS = "lsilogicsas" + +class StatusLevelTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The level code. + """ + + INFO = "Info" + WARNING = "Warning" + ERROR = "Error" + +class StatusTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the hybrid machine agent. + """ + + CONNECTED = "Connected" + DISCONNECTED = "Disconnected" + ERROR = "Error" + +class VirtualSCSISharing(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines the sharing mode for sharing the SCSI bus. + """ + + NO_SHARING = "noSharing" + PHYSICAL_SHARING = "physicalSharing" + VIRTUAL_SHARING = "virtualSharing" + +class VMGuestPatchClassificationLinux(str, Enum, metaclass=CaseInsensitiveEnumMeta): + + CRITICAL = "Critical" + SECURITY = "Security" + OTHER = "Other" + +class VMGuestPatchClassificationWindows(str, Enum, metaclass=CaseInsensitiveEnumMeta): + + CRITICAL = "Critical" + SECURITY = "Security" + UPDATE_ROLL_UP = "UpdateRollUp" + FEATURE_PACK = "FeaturePack" + SERVICE_PACK = "ServicePack" + DEFINITION = "Definition" + TOOLS = "Tools" + UPDATES = "Updates" + +class VMGuestPatchRebootSetting(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines when it is acceptable to reboot a VM during a software update operation. + """ + + IF_REQUIRED = "IfRequired" + NEVER = "Never" + ALWAYS = "Always" + +class VMGuestPatchRebootStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The reboot state of the VM following completion of the operation. + """ + + UNKNOWN = "Unknown" + NOT_NEEDED = "NotNeeded" + REQUIRED = "Required" + STARTED = "Started" + FAILED = "Failed" + COMPLETED = "Completed" diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/models/_models_py3.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/models/_models_py3.py new file mode 100644 index 00000000000..ef58bbce0cc --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/models/_models_py3.py @@ -0,0 +1,5263 @@ +# 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 Any, Dict, List, Optional, TYPE_CHECKING, Union + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models + + +class AvailablePatchCountByClassification(msrest.serialization.Model): + """Summarization of patches available for installation on the machine by classification. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar security: Number of security patches available for installation. + :vartype security: int + :ivar critical: Number of critical patches available for installation. + :vartype critical: int + :ivar definition: Number of definition patches available for installation. + :vartype definition: int + :ivar update_rollup: Number of update Rollup patches available for installation. + :vartype update_rollup: int + :ivar feature_pack: Number of feature pack patches available for installation. + :vartype feature_pack: int + :ivar service_pack: Number of service pack patches available for installation. + :vartype service_pack: int + :ivar tools: Number of tools patches available for installation. + :vartype tools: int + :ivar updates: Number of updates category patches available for installation. + :vartype updates: int + :ivar other: Number of other patches available for installation. + :vartype other: int + """ + + _validation = { + 'security': {'readonly': True}, + 'critical': {'readonly': True}, + 'definition': {'readonly': True}, + 'update_rollup': {'readonly': True}, + 'feature_pack': {'readonly': True}, + 'service_pack': {'readonly': True}, + 'tools': {'readonly': True}, + 'updates': {'readonly': True}, + 'other': {'readonly': True}, + } + + _attribute_map = { + 'security': {'key': 'security', 'type': 'int'}, + 'critical': {'key': 'critical', 'type': 'int'}, + 'definition': {'key': 'definition', 'type': 'int'}, + 'update_rollup': {'key': 'updateRollup', 'type': 'int'}, + 'feature_pack': {'key': 'featurePack', 'type': 'int'}, + 'service_pack': {'key': 'servicePack', 'type': 'int'}, + 'tools': {'key': 'tools', 'type': 'int'}, + 'updates': {'key': 'updates', 'type': 'int'}, + 'other': {'key': 'other', 'type': 'int'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(AvailablePatchCountByClassification, self).__init__(**kwargs) + self.security = None + self.critical = None + self.definition = None + self.update_rollup = None + self.feature_pack = None + self.service_pack = None + self.tools = None + self.updates = None + self.other = None + + +class Cluster(msrest.serialization.Model): + """Define the cluster. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar location: Required. Gets or sets the location. + :vartype location: str + :ivar extended_location: Gets or sets the extended location. + :vartype extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation + :ivar system_data: The system data. + :vartype system_data: ~azure.mgmt.connectedvmware.models.SystemData + :ivar tags: A set of tags. Gets or sets the Resource tags. + :vartype tags: dict[str, str] + :ivar name: Gets or sets the name. + :vartype name: str + :ivar id: Gets or sets the Id. + :vartype id: str + :ivar type: Gets or sets the type of the resource. + :vartype type: str + :ivar kind: Metadata used by portal/tooling/etc to render different UX experiences for + resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, + the resource provider must validate and persist this value. + :vartype kind: str + :ivar uuid: Gets or sets a unique identifier for this resource. + :vartype uuid: str + :ivar v_center_id: Gets or sets the ARM Id of the vCenter resource in which this cluster + resides. + :vartype v_center_id: str + :ivar mo_ref_id: Gets or sets the vCenter MoRef (Managed Object Reference) ID for the cluster. + :vartype mo_ref_id: str + :ivar inventory_item_id: Gets or sets the inventory Item ID for the cluster. + :vartype inventory_item_id: str + :ivar mo_name: Gets or sets the vCenter Managed Object name for the cluster. + :vartype mo_name: str + :ivar statuses: The resource status information. + :vartype statuses: list[~azure.mgmt.connectedvmware.models.ResourceStatus] + :ivar custom_resource_name: Gets the name of the corresponding resource in Kubernetes. + :vartype custom_resource_name: str + :ivar datastore_ids: Gets or sets the datastore ARM ids. + :vartype datastore_ids: list[str] + :ivar network_ids: Gets or sets the network ARM ids. + :vartype network_ids: list[str] + :ivar provisioning_state: Gets or sets the provisioning state. + :vartype provisioning_state: str + """ + + _validation = { + 'location': {'required': True}, + 'system_data': {'readonly': True}, + 'name': {'readonly': True}, + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'uuid': {'readonly': True}, + 'mo_name': {'readonly': True}, + 'statuses': {'readonly': True}, + 'custom_resource_name': {'readonly': True}, + 'datastore_ids': {'readonly': True}, + 'network_ids': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'location': {'key': 'location', 'type': 'str'}, + 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'name': {'key': 'name', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'uuid': {'key': 'properties.uuid', 'type': 'str'}, + 'v_center_id': {'key': 'properties.vCenterId', 'type': 'str'}, + 'mo_ref_id': {'key': 'properties.moRefId', 'type': 'str'}, + 'inventory_item_id': {'key': 'properties.inventoryItemId', 'type': 'str'}, + 'mo_name': {'key': 'properties.moName', 'type': 'str'}, + 'statuses': {'key': 'properties.statuses', 'type': '[ResourceStatus]'}, + 'custom_resource_name': {'key': 'properties.customResourceName', 'type': 'str'}, + 'datastore_ids': {'key': 'properties.datastoreIds', 'type': '[str]'}, + 'network_ids': {'key': 'properties.networkIds', 'type': '[str]'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + } + + def __init__( + self, + *, + location: str, + extended_location: Optional["_models.ExtendedLocation"] = None, + tags: Optional[Dict[str, str]] = None, + kind: Optional[str] = None, + v_center_id: Optional[str] = None, + mo_ref_id: Optional[str] = None, + inventory_item_id: Optional[str] = None, + **kwargs + ): + """ + :keyword location: Required. Gets or sets the location. + :paramtype location: str + :keyword extended_location: Gets or sets the extended location. + :paramtype extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation + :keyword tags: A set of tags. Gets or sets the Resource tags. + :paramtype tags: dict[str, str] + :keyword kind: Metadata used by portal/tooling/etc to render different UX experiences for + resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, + the resource provider must validate and persist this value. + :paramtype kind: str + :keyword v_center_id: Gets or sets the ARM Id of the vCenter resource in which this cluster + resides. + :paramtype v_center_id: str + :keyword mo_ref_id: Gets or sets the vCenter MoRef (Managed Object Reference) ID for the + cluster. + :paramtype mo_ref_id: str + :keyword inventory_item_id: Gets or sets the inventory Item ID for the cluster. + :paramtype inventory_item_id: str + """ + super(Cluster, self).__init__(**kwargs) + self.location = location + self.extended_location = extended_location + self.system_data = None + self.tags = tags + self.name = None + self.id = None + self.type = None + self.kind = kind + self.uuid = None + self.v_center_id = v_center_id + self.mo_ref_id = mo_ref_id + self.inventory_item_id = inventory_item_id + self.mo_name = None + self.statuses = None + self.custom_resource_name = None + self.datastore_ids = None + self.network_ids = None + self.provisioning_state = None + + +class InventoryItemProperties(msrest.serialization.Model): + """Defines the resource properties. + + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: ClusterInventoryItem, DatastoreInventoryItem, HostInventoryItem, ResourcePoolInventoryItem, VirtualMachineInventoryItem, VirtualMachineTemplateInventoryItem, VirtualNetworkInventoryItem. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar inventory_type: Required. They inventory type.Constant filled by server. Known values + are: "ResourcePool", "VirtualMachine", "VirtualMachineTemplate", "VirtualNetwork", "Cluster", + "Datastore", "Host". + :vartype inventory_type: str or ~azure.mgmt.connectedvmware.models.InventoryType + :ivar managed_resource_id: Gets or sets the tracked resource id corresponding to the inventory + resource. + :vartype managed_resource_id: str + :ivar mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory item. + :vartype mo_ref_id: str + :ivar mo_name: Gets or sets the vCenter Managed Object name for the inventory item. + :vartype mo_name: str + :ivar provisioning_state: Gets or sets the provisioning state. + :vartype provisioning_state: str + """ + + _validation = { + 'inventory_type': {'required': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'inventory_type': {'key': 'inventoryType', 'type': 'str'}, + 'managed_resource_id': {'key': 'managedResourceId', 'type': 'str'}, + 'mo_ref_id': {'key': 'moRefId', 'type': 'str'}, + 'mo_name': {'key': 'moName', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + } + + _subtype_map = { + 'inventory_type': {'Cluster': 'ClusterInventoryItem', 'Datastore': 'DatastoreInventoryItem', 'Host': 'HostInventoryItem', 'ResourcePool': 'ResourcePoolInventoryItem', 'VirtualMachine': 'VirtualMachineInventoryItem', 'VirtualMachineTemplate': 'VirtualMachineTemplateInventoryItem', 'VirtualNetwork': 'VirtualNetworkInventoryItem'} + } + + def __init__( + self, + *, + managed_resource_id: Optional[str] = None, + mo_ref_id: Optional[str] = None, + mo_name: Optional[str] = None, + **kwargs + ): + """ + :keyword managed_resource_id: Gets or sets the tracked resource id corresponding to the + inventory resource. + :paramtype managed_resource_id: str + :keyword mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory + item. + :paramtype mo_ref_id: str + :keyword mo_name: Gets or sets the vCenter Managed Object name for the inventory item. + :paramtype mo_name: str + """ + super(InventoryItemProperties, self).__init__(**kwargs) + self.inventory_type = None # type: Optional[str] + self.managed_resource_id = managed_resource_id + self.mo_ref_id = mo_ref_id + self.mo_name = mo_name + self.provisioning_state = None + + +class ClusterInventoryItem(InventoryItemProperties): + """The cluster inventory item. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar inventory_type: Required. They inventory type.Constant filled by server. Known values + are: "ResourcePool", "VirtualMachine", "VirtualMachineTemplate", "VirtualNetwork", "Cluster", + "Datastore", "Host". + :vartype inventory_type: str or ~azure.mgmt.connectedvmware.models.InventoryType + :ivar managed_resource_id: Gets or sets the tracked resource id corresponding to the inventory + resource. + :vartype managed_resource_id: str + :ivar mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory item. + :vartype mo_ref_id: str + :ivar mo_name: Gets or sets the vCenter Managed Object name for the inventory item. + :vartype mo_name: str + :ivar provisioning_state: Gets or sets the provisioning state. + :vartype provisioning_state: str + """ + + _validation = { + 'inventory_type': {'required': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'inventory_type': {'key': 'inventoryType', 'type': 'str'}, + 'managed_resource_id': {'key': 'managedResourceId', 'type': 'str'}, + 'mo_ref_id': {'key': 'moRefId', 'type': 'str'}, + 'mo_name': {'key': 'moName', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + } + + def __init__( + self, + *, + managed_resource_id: Optional[str] = None, + mo_ref_id: Optional[str] = None, + mo_name: Optional[str] = None, + **kwargs + ): + """ + :keyword managed_resource_id: Gets or sets the tracked resource id corresponding to the + inventory resource. + :paramtype managed_resource_id: str + :keyword mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory + item. + :paramtype mo_ref_id: str + :keyword mo_name: Gets or sets the vCenter Managed Object name for the inventory item. + :paramtype mo_name: str + """ + super(ClusterInventoryItem, self).__init__(managed_resource_id=managed_resource_id, mo_ref_id=mo_ref_id, mo_name=mo_name, **kwargs) + self.inventory_type = 'Cluster' # type: str + + +class ClustersList(msrest.serialization.Model): + """List of Clusters. + + All required parameters must be populated in order to send to Azure. + + :ivar next_link: Url to follow for getting next page of Clusters. + :vartype next_link: str + :ivar value: Required. Array of Clusters. + :vartype value: list[~azure.mgmt.connectedvmware.models.Cluster] + """ + + _validation = { + 'value': {'required': True}, + } + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[Cluster]'}, + } + + def __init__( + self, + *, + value: List["_models.Cluster"], + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword next_link: Url to follow for getting next page of Clusters. + :paramtype next_link: str + :keyword value: Required. Array of Clusters. + :paramtype value: list[~azure.mgmt.connectedvmware.models.Cluster] + """ + super(ClustersList, self).__init__(**kwargs) + self.next_link = next_link + self.value = value + + +class Condition(msrest.serialization.Model): + """Condition defines an extension to status. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar status: Status of the condition. + :vartype status: str + :ivar reason: The reason for the condition's status. + :vartype reason: str + :ivar message: A human readable message indicating details about the status. + :vartype message: str + :ivar severity: Severity with which to treat failures of this type of condition. + :vartype severity: str + """ + + _validation = { + 'status': {'readonly': True}, + 'reason': {'readonly': True}, + 'message': {'readonly': True}, + 'severity': {'readonly': True}, + } + + _attribute_map = { + 'status': {'key': 'status', 'type': 'str'}, + 'reason': {'key': 'reason', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'severity': {'key': 'severity', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(Condition, self).__init__(**kwargs) + self.status = None + self.reason = None + self.message = None + self.severity = None + + +class Datastore(msrest.serialization.Model): + """Define the datastore. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar location: Required. Gets or sets the location. + :vartype location: str + :ivar extended_location: Gets or sets the extended location. + :vartype extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation + :ivar system_data: The system data. + :vartype system_data: ~azure.mgmt.connectedvmware.models.SystemData + :ivar tags: A set of tags. Gets or sets the Resource tags. + :vartype tags: dict[str, str] + :ivar name: Gets or sets the name. + :vartype name: str + :ivar id: Gets or sets the Id. + :vartype id: str + :ivar type: Gets or sets the type of the resource. + :vartype type: str + :ivar kind: Metadata used by portal/tooling/etc to render different UX experiences for + resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, + the resource provider must validate and persist this value. + :vartype kind: str + :ivar uuid: Gets or sets a unique identifier for this resource. + :vartype uuid: str + :ivar v_center_id: Gets or sets the ARM Id of the vCenter resource in which this datastore + resides. + :vartype v_center_id: str + :ivar mo_ref_id: Gets or sets the vCenter MoRef (Managed Object Reference) ID for the + datastore. + :vartype mo_ref_id: str + :ivar inventory_item_id: Gets or sets the inventory Item ID for the datastore. + :vartype inventory_item_id: str + :ivar mo_name: Gets or sets the vCenter Managed Object name for the datastore. + :vartype mo_name: str + :ivar statuses: The resource status information. + :vartype statuses: list[~azure.mgmt.connectedvmware.models.ResourceStatus] + :ivar custom_resource_name: Gets the name of the corresponding resource in Kubernetes. + :vartype custom_resource_name: str + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Succeeded", + "Failed", "Canceled", "Provisioning", "Updating", "Deleting", "Accepted", "Created". + :vartype provisioning_state: str or ~azure.mgmt.connectedvmware.models.ProvisioningState + """ + + _validation = { + 'location': {'required': True}, + 'system_data': {'readonly': True}, + 'name': {'readonly': True}, + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'uuid': {'readonly': True}, + 'mo_name': {'readonly': True}, + 'statuses': {'readonly': True}, + 'custom_resource_name': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'location': {'key': 'location', 'type': 'str'}, + 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'name': {'key': 'name', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'uuid': {'key': 'properties.uuid', 'type': 'str'}, + 'v_center_id': {'key': 'properties.vCenterId', 'type': 'str'}, + 'mo_ref_id': {'key': 'properties.moRefId', 'type': 'str'}, + 'inventory_item_id': {'key': 'properties.inventoryItemId', 'type': 'str'}, + 'mo_name': {'key': 'properties.moName', 'type': 'str'}, + 'statuses': {'key': 'properties.statuses', 'type': '[ResourceStatus]'}, + 'custom_resource_name': {'key': 'properties.customResourceName', 'type': 'str'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + } + + def __init__( + self, + *, + location: str, + extended_location: Optional["_models.ExtendedLocation"] = None, + tags: Optional[Dict[str, str]] = None, + kind: Optional[str] = None, + v_center_id: Optional[str] = None, + mo_ref_id: Optional[str] = None, + inventory_item_id: Optional[str] = None, + **kwargs + ): + """ + :keyword location: Required. Gets or sets the location. + :paramtype location: str + :keyword extended_location: Gets or sets the extended location. + :paramtype extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation + :keyword tags: A set of tags. Gets or sets the Resource tags. + :paramtype tags: dict[str, str] + :keyword kind: Metadata used by portal/tooling/etc to render different UX experiences for + resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, + the resource provider must validate and persist this value. + :paramtype kind: str + :keyword v_center_id: Gets or sets the ARM Id of the vCenter resource in which this datastore + resides. + :paramtype v_center_id: str + :keyword mo_ref_id: Gets or sets the vCenter MoRef (Managed Object Reference) ID for the + datastore. + :paramtype mo_ref_id: str + :keyword inventory_item_id: Gets or sets the inventory Item ID for the datastore. + :paramtype inventory_item_id: str + """ + super(Datastore, self).__init__(**kwargs) + self.location = location + self.extended_location = extended_location + self.system_data = None + self.tags = tags + self.name = None + self.id = None + self.type = None + self.kind = kind + self.uuid = None + self.v_center_id = v_center_id + self.mo_ref_id = mo_ref_id + self.inventory_item_id = inventory_item_id + self.mo_name = None + self.statuses = None + self.custom_resource_name = None + self.provisioning_state = None + + +class DatastoreInventoryItem(InventoryItemProperties): + """The datastore inventory item. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar inventory_type: Required. They inventory type.Constant filled by server. Known values + are: "ResourcePool", "VirtualMachine", "VirtualMachineTemplate", "VirtualNetwork", "Cluster", + "Datastore", "Host". + :vartype inventory_type: str or ~azure.mgmt.connectedvmware.models.InventoryType + :ivar managed_resource_id: Gets or sets the tracked resource id corresponding to the inventory + resource. + :vartype managed_resource_id: str + :ivar mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory item. + :vartype mo_ref_id: str + :ivar mo_name: Gets or sets the vCenter Managed Object name for the inventory item. + :vartype mo_name: str + :ivar provisioning_state: Gets or sets the provisioning state. + :vartype provisioning_state: str + :ivar capacity_gb: Gets or sets Maximum capacity of this datastore, in GBs. + :vartype capacity_gb: long + :ivar free_space_gb: Gets or sets Available space of this datastore, in GBs. + :vartype free_space_gb: long + """ + + _validation = { + 'inventory_type': {'required': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'inventory_type': {'key': 'inventoryType', 'type': 'str'}, + 'managed_resource_id': {'key': 'managedResourceId', 'type': 'str'}, + 'mo_ref_id': {'key': 'moRefId', 'type': 'str'}, + 'mo_name': {'key': 'moName', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'capacity_gb': {'key': 'capacityGB', 'type': 'long'}, + 'free_space_gb': {'key': 'freeSpaceGB', 'type': 'long'}, + } + + def __init__( + self, + *, + managed_resource_id: Optional[str] = None, + mo_ref_id: Optional[str] = None, + mo_name: Optional[str] = None, + capacity_gb: Optional[int] = None, + free_space_gb: Optional[int] = None, + **kwargs + ): + """ + :keyword managed_resource_id: Gets or sets the tracked resource id corresponding to the + inventory resource. + :paramtype managed_resource_id: str + :keyword mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory + item. + :paramtype mo_ref_id: str + :keyword mo_name: Gets or sets the vCenter Managed Object name for the inventory item. + :paramtype mo_name: str + :keyword capacity_gb: Gets or sets Maximum capacity of this datastore, in GBs. + :paramtype capacity_gb: long + :keyword free_space_gb: Gets or sets Available space of this datastore, in GBs. + :paramtype free_space_gb: long + """ + super(DatastoreInventoryItem, self).__init__(managed_resource_id=managed_resource_id, mo_ref_id=mo_ref_id, mo_name=mo_name, **kwargs) + self.inventory_type = 'Datastore' # type: str + self.capacity_gb = capacity_gb + self.free_space_gb = free_space_gb + + +class DatastoresList(msrest.serialization.Model): + """List of Datastores. + + All required parameters must be populated in order to send to Azure. + + :ivar next_link: Url to follow for getting next page of Datastores. + :vartype next_link: str + :ivar value: Required. Array of Datastores. + :vartype value: list[~azure.mgmt.connectedvmware.models.Datastore] + """ + + _validation = { + 'value': {'required': True}, + } + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[Datastore]'}, + } + + def __init__( + self, + *, + value: List["_models.Datastore"], + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword next_link: Url to follow for getting next page of Datastores. + :paramtype next_link: str + :keyword value: Required. Array of Datastores. + :paramtype value: list[~azure.mgmt.connectedvmware.models.Datastore] + """ + super(DatastoresList, self).__init__(**kwargs) + self.next_link = next_link + self.value = value + + +class ErrorDefinition(msrest.serialization.Model): + """Error definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: Service specific error code which serves as the substatus for the HTTP error code. + :vartype code: str + :ivar message: Description of the error. + :vartype message: str + :ivar details: Internal error details. + :vartype details: list[~azure.mgmt.connectedvmware.models.ErrorDefinition] + """ + + _validation = { + 'code': {'readonly': True}, + 'message': {'readonly': True}, + 'details': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[ErrorDefinition]'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ErrorDefinition, self).__init__(**kwargs) + self.code = None + self.message = None + self.details = None + + +class ErrorDetail(msrest.serialization.Model): + """Error details. + + All required parameters must be populated in order to send to Azure. + + :ivar code: Required. The error's code. + :vartype code: str + :ivar message: Required. A human readable error message. + :vartype message: str + :ivar target: Indicates which property in the request is responsible for the error. + :vartype target: str + :ivar details: Additional error details. + :vartype details: list[~azure.mgmt.connectedvmware.models.ErrorDetail] + """ + + _validation = { + 'code': {'required': True}, + 'message': {'required': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[ErrorDetail]'}, + } + + def __init__( + self, + *, + code: str, + message: str, + target: Optional[str] = None, + details: Optional[List["_models.ErrorDetail"]] = None, + **kwargs + ): + """ + :keyword code: Required. The error's code. + :paramtype code: str + :keyword message: Required. A human readable error message. + :paramtype message: str + :keyword target: Indicates which property in the request is responsible for the error. + :paramtype target: str + :keyword details: Additional error details. + :paramtype details: list[~azure.mgmt.connectedvmware.models.ErrorDetail] + """ + super(ErrorDetail, self).__init__(**kwargs) + self.code = code + self.message = message + self.target = target + self.details = details + + +class ErrorResponse(msrest.serialization.Model): + """Error response. + + :ivar error: The error details. + :vartype error: ~azure.mgmt.connectedvmware.models.ErrorDefinition + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDefinition'}, + } + + def __init__( + self, + *, + error: Optional["_models.ErrorDefinition"] = None, + **kwargs + ): + """ + :keyword error: The error details. + :paramtype error: ~azure.mgmt.connectedvmware.models.ErrorDefinition + """ + super(ErrorResponse, self).__init__(**kwargs) + self.error = error + + +class ExtendedLocation(msrest.serialization.Model): + """The extended location. + + :ivar type: The extended location type. + :vartype type: str + :ivar name: The extended location name. + :vartype name: str + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__( + self, + *, + type: Optional[str] = None, + name: Optional[str] = None, + **kwargs + ): + """ + :keyword type: The extended location type. + :paramtype type: str + :keyword name: The extended location name. + :paramtype name: str + """ + super(ExtendedLocation, self).__init__(**kwargs) + self.type = type + self.name = name + + +class Resource(msrest.serialization.Model): + """Common fields that are returned in the response for all Azure Resource Manager resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class ProxyResource(Resource): + """The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ProxyResource, self).__init__(**kwargs) + + +class GuestAgent(ProxyResource): + """Defines the GuestAgent. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: The system data. + :vartype system_data: ~azure.mgmt.connectedvmware.models.SystemData + :ivar uuid: Gets or sets a unique identifier for this resource. + :vartype uuid: str + :ivar credentials: Username / Password Credentials to provision guest agent. + :vartype credentials: ~azure.mgmt.connectedvmware.models.GuestCredential + :ivar http_proxy_config: HTTP Proxy configuration for the VM. + :vartype http_proxy_config: ~azure.mgmt.connectedvmware.models.HttpProxyConfiguration + :ivar provisioning_action: Gets or sets the guest agent provisioning action. Known values are: + "install", "uninstall", "repair". + :vartype provisioning_action: str or ~azure.mgmt.connectedvmware.models.ProvisioningAction + :ivar status: Gets or sets the guest agent status. + :vartype status: str + :ivar custom_resource_name: Gets the name of the corresponding resource in Kubernetes. + :vartype custom_resource_name: str + :ivar statuses: The resource status information. + :vartype statuses: list[~azure.mgmt.connectedvmware.models.ResourceStatus] + :ivar provisioning_state: Gets or sets the provisioning state. + :vartype provisioning_state: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'uuid': {'readonly': True}, + 'status': {'readonly': True}, + 'custom_resource_name': {'readonly': True}, + 'statuses': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'uuid': {'key': 'properties.uuid', 'type': 'str'}, + 'credentials': {'key': 'properties.credentials', 'type': 'GuestCredential'}, + 'http_proxy_config': {'key': 'properties.httpProxyConfig', 'type': 'HttpProxyConfiguration'}, + 'provisioning_action': {'key': 'properties.provisioningAction', 'type': 'str'}, + 'status': {'key': 'properties.status', 'type': 'str'}, + 'custom_resource_name': {'key': 'properties.customResourceName', 'type': 'str'}, + 'statuses': {'key': 'properties.statuses', 'type': '[ResourceStatus]'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + } + + def __init__( + self, + *, + credentials: Optional["_models.GuestCredential"] = None, + http_proxy_config: Optional["_models.HttpProxyConfiguration"] = None, + provisioning_action: Optional[Union[str, "_models.ProvisioningAction"]] = None, + **kwargs + ): + """ + :keyword credentials: Username / Password Credentials to provision guest agent. + :paramtype credentials: ~azure.mgmt.connectedvmware.models.GuestCredential + :keyword http_proxy_config: HTTP Proxy configuration for the VM. + :paramtype http_proxy_config: ~azure.mgmt.connectedvmware.models.HttpProxyConfiguration + :keyword provisioning_action: Gets or sets the guest agent provisioning action. Known values + are: "install", "uninstall", "repair". + :paramtype provisioning_action: str or ~azure.mgmt.connectedvmware.models.ProvisioningAction + """ + super(GuestAgent, self).__init__(**kwargs) + self.system_data = None + self.uuid = None + self.credentials = credentials + self.http_proxy_config = http_proxy_config + self.provisioning_action = provisioning_action + self.status = None + self.custom_resource_name = None + self.statuses = None + self.provisioning_state = None + + +class GuestAgentList(msrest.serialization.Model): + """List of GuestAgent. + + All required parameters must be populated in order to send to Azure. + + :ivar next_link: Url to follow for getting next page of GuestAgent. + :vartype next_link: str + :ivar value: Required. Array of GuestAgent. + :vartype value: list[~azure.mgmt.connectedvmware.models.GuestAgent] + """ + + _validation = { + 'value': {'required': True}, + } + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[GuestAgent]'}, + } + + def __init__( + self, + *, + value: List["_models.GuestAgent"], + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword next_link: Url to follow for getting next page of GuestAgent. + :paramtype next_link: str + :keyword value: Required. Array of GuestAgent. + :paramtype value: list[~azure.mgmt.connectedvmware.models.GuestAgent] + """ + super(GuestAgentList, self).__init__(**kwargs) + self.next_link = next_link + self.value = value + + +class GuestAgentProfile(msrest.serialization.Model): + """Defines the resource properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar vm_uuid: Specifies the VM's unique SMBIOS ID. + :vartype vm_uuid: str + :ivar status: The status of the hybrid machine agent. Known values are: "Connected", + "Disconnected", "Error". + :vartype status: str or ~azure.mgmt.connectedvmware.models.StatusTypes + :ivar last_status_change: The time of the last status change. + :vartype last_status_change: ~datetime.datetime + :ivar agent_version: The hybrid machine agent full version. + :vartype agent_version: str + :ivar error_details: Details about the error state. + :vartype error_details: list[~azure.mgmt.connectedvmware.models.ErrorDetail] + """ + + _validation = { + 'vm_uuid': {'readonly': True}, + 'status': {'readonly': True}, + 'last_status_change': {'readonly': True}, + 'agent_version': {'readonly': True}, + 'error_details': {'readonly': True}, + } + + _attribute_map = { + 'vm_uuid': {'key': 'vmUuid', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'last_status_change': {'key': 'lastStatusChange', 'type': 'iso-8601'}, + 'agent_version': {'key': 'agentVersion', 'type': 'str'}, + 'error_details': {'key': 'errorDetails', 'type': '[ErrorDetail]'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(GuestAgentProfile, self).__init__(**kwargs) + self.vm_uuid = None + self.status = None + self.last_status_change = None + self.agent_version = None + self.error_details = None + + +class GuestCredential(msrest.serialization.Model): + """Username / Password Credentials to connect to guest. + + :ivar username: Gets or sets username to connect with the guest. + :vartype username: str + :ivar password: Gets or sets the password to connect with the guest. + :vartype password: str + """ + + _attribute_map = { + 'username': {'key': 'username', 'type': 'str'}, + 'password': {'key': 'password', 'type': 'str'}, + } + + def __init__( + self, + *, + username: Optional[str] = None, + password: Optional[str] = None, + **kwargs + ): + """ + :keyword username: Gets or sets username to connect with the guest. + :paramtype username: str + :keyword password: Gets or sets the password to connect with the guest. + :paramtype password: str + """ + super(GuestCredential, self).__init__(**kwargs) + self.username = username + self.password = password + + +class HardwareProfile(msrest.serialization.Model): + """Defines the resource properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar memory_size_mb: Gets or sets memory size in MBs for the vm. + :vartype memory_size_mb: int + :ivar num_cp_us: Gets or sets the number of vCPUs for the vm. + :vartype num_cp_us: int + :ivar num_cores_per_socket: Gets or sets the number of cores per socket for the vm. Defaults to + 1 if unspecified. + :vartype num_cores_per_socket: int + :ivar cpu_hot_add_enabled: Gets or sets a value indicating whether virtual processors can be + added while this virtual machine is running. + :vartype cpu_hot_add_enabled: bool + :ivar cpu_hot_remove_enabled: Gets or sets a value indicating whether virtual processors can be + removed while this virtual machine is running. + :vartype cpu_hot_remove_enabled: bool + :ivar memory_hot_add_enabled: Gets or sets a value indicating whether memory can be added while + this virtual machine is running. + :vartype memory_hot_add_enabled: bool + """ + + _validation = { + 'cpu_hot_add_enabled': {'readonly': True}, + 'cpu_hot_remove_enabled': {'readonly': True}, + 'memory_hot_add_enabled': {'readonly': True}, + } + + _attribute_map = { + 'memory_size_mb': {'key': 'memorySizeMB', 'type': 'int'}, + 'num_cp_us': {'key': 'numCPUs', 'type': 'int'}, + 'num_cores_per_socket': {'key': 'numCoresPerSocket', 'type': 'int'}, + 'cpu_hot_add_enabled': {'key': 'cpuHotAddEnabled', 'type': 'bool'}, + 'cpu_hot_remove_enabled': {'key': 'cpuHotRemoveEnabled', 'type': 'bool'}, + 'memory_hot_add_enabled': {'key': 'memoryHotAddEnabled', 'type': 'bool'}, + } + + def __init__( + self, + *, + memory_size_mb: Optional[int] = None, + num_cp_us: Optional[int] = None, + num_cores_per_socket: Optional[int] = None, + **kwargs + ): + """ + :keyword memory_size_mb: Gets or sets memory size in MBs for the vm. + :paramtype memory_size_mb: int + :keyword num_cp_us: Gets or sets the number of vCPUs for the vm. + :paramtype num_cp_us: int + :keyword num_cores_per_socket: Gets or sets the number of cores per socket for the vm. Defaults + to 1 if unspecified. + :paramtype num_cores_per_socket: int + """ + super(HardwareProfile, self).__init__(**kwargs) + self.memory_size_mb = memory_size_mb + self.num_cp_us = num_cp_us + self.num_cores_per_socket = num_cores_per_socket + self.cpu_hot_add_enabled = None + self.cpu_hot_remove_enabled = None + self.memory_hot_add_enabled = None + + +class Host(msrest.serialization.Model): + """Define the host. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar location: Required. Gets or sets the location. + :vartype location: str + :ivar extended_location: Gets or sets the extended location. + :vartype extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation + :ivar system_data: The system data. + :vartype system_data: ~azure.mgmt.connectedvmware.models.SystemData + :ivar tags: A set of tags. Gets or sets the Resource tags. + :vartype tags: dict[str, str] + :ivar name: Gets or sets the name. + :vartype name: str + :ivar id: Gets or sets the Id. + :vartype id: str + :ivar type: Gets or sets the type of the resource. + :vartype type: str + :ivar kind: Metadata used by portal/tooling/etc to render different UX experiences for + resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, + the resource provider must validate and persist this value. + :vartype kind: str + :ivar uuid: Gets or sets a unique identifier for this resource. + :vartype uuid: str + :ivar v_center_id: Gets or sets the ARM Id of the vCenter resource in which this host resides. + :vartype v_center_id: str + :ivar mo_ref_id: Gets or sets the vCenter MoRef (Managed Object Reference) ID for the host. + :vartype mo_ref_id: str + :ivar inventory_item_id: Gets or sets the inventory Item ID for the host. + :vartype inventory_item_id: str + :ivar mo_name: Gets or sets the vCenter Managed Object name for the host. + :vartype mo_name: str + :ivar statuses: The resource status information. + :vartype statuses: list[~azure.mgmt.connectedvmware.models.ResourceStatus] + :ivar custom_resource_name: Gets the name of the corresponding resource in Kubernetes. + :vartype custom_resource_name: str + :ivar provisioning_state: Gets or sets the provisioning state. + :vartype provisioning_state: str + """ + + _validation = { + 'location': {'required': True}, + 'system_data': {'readonly': True}, + 'name': {'readonly': True}, + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'uuid': {'readonly': True}, + 'mo_name': {'readonly': True}, + 'statuses': {'readonly': True}, + 'custom_resource_name': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'location': {'key': 'location', 'type': 'str'}, + 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'name': {'key': 'name', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'uuid': {'key': 'properties.uuid', 'type': 'str'}, + 'v_center_id': {'key': 'properties.vCenterId', 'type': 'str'}, + 'mo_ref_id': {'key': 'properties.moRefId', 'type': 'str'}, + 'inventory_item_id': {'key': 'properties.inventoryItemId', 'type': 'str'}, + 'mo_name': {'key': 'properties.moName', 'type': 'str'}, + 'statuses': {'key': 'properties.statuses', 'type': '[ResourceStatus]'}, + 'custom_resource_name': {'key': 'properties.customResourceName', 'type': 'str'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + } + + def __init__( + self, + *, + location: str, + extended_location: Optional["_models.ExtendedLocation"] = None, + tags: Optional[Dict[str, str]] = None, + kind: Optional[str] = None, + v_center_id: Optional[str] = None, + mo_ref_id: Optional[str] = None, + inventory_item_id: Optional[str] = None, + **kwargs + ): + """ + :keyword location: Required. Gets or sets the location. + :paramtype location: str + :keyword extended_location: Gets or sets the extended location. + :paramtype extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation + :keyword tags: A set of tags. Gets or sets the Resource tags. + :paramtype tags: dict[str, str] + :keyword kind: Metadata used by portal/tooling/etc to render different UX experiences for + resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, + the resource provider must validate and persist this value. + :paramtype kind: str + :keyword v_center_id: Gets or sets the ARM Id of the vCenter resource in which this host + resides. + :paramtype v_center_id: str + :keyword mo_ref_id: Gets or sets the vCenter MoRef (Managed Object Reference) ID for the host. + :paramtype mo_ref_id: str + :keyword inventory_item_id: Gets or sets the inventory Item ID for the host. + :paramtype inventory_item_id: str + """ + super(Host, self).__init__(**kwargs) + self.location = location + self.extended_location = extended_location + self.system_data = None + self.tags = tags + self.name = None + self.id = None + self.type = None + self.kind = kind + self.uuid = None + self.v_center_id = v_center_id + self.mo_ref_id = mo_ref_id + self.inventory_item_id = inventory_item_id + self.mo_name = None + self.statuses = None + self.custom_resource_name = None + self.provisioning_state = None + + +class HostInventoryItem(InventoryItemProperties): + """The host inventory item. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar inventory_type: Required. They inventory type.Constant filled by server. Known values + are: "ResourcePool", "VirtualMachine", "VirtualMachineTemplate", "VirtualNetwork", "Cluster", + "Datastore", "Host". + :vartype inventory_type: str or ~azure.mgmt.connectedvmware.models.InventoryType + :ivar managed_resource_id: Gets or sets the tracked resource id corresponding to the inventory + resource. + :vartype managed_resource_id: str + :ivar mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory item. + :vartype mo_ref_id: str + :ivar mo_name: Gets or sets the vCenter Managed Object name for the inventory item. + :vartype mo_name: str + :ivar provisioning_state: Gets or sets the provisioning state. + :vartype provisioning_state: str + :ivar parent: Parent host inventory resource details. + :vartype parent: ~azure.mgmt.connectedvmware.models.InventoryItemDetails + """ + + _validation = { + 'inventory_type': {'required': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'inventory_type': {'key': 'inventoryType', 'type': 'str'}, + 'managed_resource_id': {'key': 'managedResourceId', 'type': 'str'}, + 'mo_ref_id': {'key': 'moRefId', 'type': 'str'}, + 'mo_name': {'key': 'moName', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'parent': {'key': 'parent', 'type': 'InventoryItemDetails'}, + } + + def __init__( + self, + *, + managed_resource_id: Optional[str] = None, + mo_ref_id: Optional[str] = None, + mo_name: Optional[str] = None, + parent: Optional["_models.InventoryItemDetails"] = None, + **kwargs + ): + """ + :keyword managed_resource_id: Gets or sets the tracked resource id corresponding to the + inventory resource. + :paramtype managed_resource_id: str + :keyword mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory + item. + :paramtype mo_ref_id: str + :keyword mo_name: Gets or sets the vCenter Managed Object name for the inventory item. + :paramtype mo_name: str + :keyword parent: Parent host inventory resource details. + :paramtype parent: ~azure.mgmt.connectedvmware.models.InventoryItemDetails + """ + super(HostInventoryItem, self).__init__(managed_resource_id=managed_resource_id, mo_ref_id=mo_ref_id, mo_name=mo_name, **kwargs) + self.inventory_type = 'Host' # type: str + self.parent = parent + + +class HostsList(msrest.serialization.Model): + """List of Hosts. + + All required parameters must be populated in order to send to Azure. + + :ivar next_link: Url to follow for getting next page of Hosts. + :vartype next_link: str + :ivar value: Required. Array of Hosts. + :vartype value: list[~azure.mgmt.connectedvmware.models.Host] + """ + + _validation = { + 'value': {'required': True}, + } + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[Host]'}, + } + + def __init__( + self, + *, + value: List["_models.Host"], + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword next_link: Url to follow for getting next page of Hosts. + :paramtype next_link: str + :keyword value: Required. Array of Hosts. + :paramtype value: list[~azure.mgmt.connectedvmware.models.Host] + """ + super(HostsList, self).__init__(**kwargs) + self.next_link = next_link + self.value = value + + +class HttpProxyConfiguration(msrest.serialization.Model): + """HTTP Proxy configuration for the VM. + + :ivar https_proxy: Gets or sets httpsProxy url. + :vartype https_proxy: str + """ + + _attribute_map = { + 'https_proxy': {'key': 'httpsProxy', 'type': 'str'}, + } + + def __init__( + self, + *, + https_proxy: Optional[str] = None, + **kwargs + ): + """ + :keyword https_proxy: Gets or sets httpsProxy url. + :paramtype https_proxy: str + """ + super(HttpProxyConfiguration, self).__init__(**kwargs) + self.https_proxy = https_proxy + + +class HybridIdentityMetadata(ProxyResource): + """Defines the HybridIdentityMetadata. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: The system data. + :vartype system_data: ~azure.mgmt.connectedvmware.models.SystemData + :ivar vm_id: Gets or sets the Vm Id. + :vartype vm_id: str + :ivar public_key: Gets or sets the Public Key. + :vartype public_key: str + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.connectedvmware.models.Identity + :ivar provisioning_state: Gets or sets the provisioning state. + :vartype provisioning_state: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'identity': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'vm_id': {'key': 'properties.vmId', 'type': 'str'}, + 'public_key': {'key': 'properties.publicKey', 'type': 'str'}, + 'identity': {'key': 'properties.identity', 'type': 'Identity'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + } + + def __init__( + self, + *, + vm_id: Optional[str] = None, + public_key: Optional[str] = None, + **kwargs + ): + """ + :keyword vm_id: Gets or sets the Vm Id. + :paramtype vm_id: str + :keyword public_key: Gets or sets the Public Key. + :paramtype public_key: str + """ + super(HybridIdentityMetadata, self).__init__(**kwargs) + self.system_data = None + self.vm_id = vm_id + self.public_key = public_key + self.identity = None + self.provisioning_state = None + + +class HybridIdentityMetadataList(msrest.serialization.Model): + """List of HybridIdentityMetadata. + + All required parameters must be populated in order to send to Azure. + + :ivar next_link: Url to follow for getting next page of HybridIdentityMetadata. + :vartype next_link: str + :ivar value: Required. Array of HybridIdentityMetadata. + :vartype value: list[~azure.mgmt.connectedvmware.models.HybridIdentityMetadata] + """ + + _validation = { + 'value': {'required': True}, + } + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[HybridIdentityMetadata]'}, + } + + def __init__( + self, + *, + value: List["_models.HybridIdentityMetadata"], + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword next_link: Url to follow for getting next page of HybridIdentityMetadata. + :paramtype next_link: str + :keyword value: Required. Array of HybridIdentityMetadata. + :paramtype value: list[~azure.mgmt.connectedvmware.models.HybridIdentityMetadata] + """ + super(HybridIdentityMetadataList, self).__init__(**kwargs) + self.next_link = next_link + self.value = value + + +class Identity(msrest.serialization.Model): + """Managed service identity. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar principal_id: The principal id of managed service identity. + :vartype principal_id: str + :ivar tenant_id: The tenant of managed service identity. + :vartype tenant_id: str + :ivar type: Required. The type of managed service identity. Known values are: "None", + "SystemAssigned". + :vartype type: str or ~azure.mgmt.connectedvmware.models.IdentityType + """ + + _validation = { + 'principal_id': {'readonly': True}, + 'tenant_id': {'readonly': True}, + 'type': {'required': True}, + } + + _attribute_map = { + 'principal_id': {'key': 'principalId', 'type': 'str'}, + 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + *, + type: Union[str, "_models.IdentityType"], + **kwargs + ): + """ + :keyword type: Required. The type of managed service identity. Known values are: "None", + "SystemAssigned". + :paramtype type: str or ~azure.mgmt.connectedvmware.models.IdentityType + """ + super(Identity, self).__init__(**kwargs) + self.principal_id = None + self.tenant_id = None + self.type = type + + +class InventoryItem(ProxyResource): + """Defines the inventory item. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: The system data. + :vartype system_data: ~azure.mgmt.connectedvmware.models.SystemData + :ivar kind: Metadata used by portal/tooling/etc to render different UX experiences for + resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, + the resource provider must validate and persist this value. + :vartype kind: str + :ivar inventory_type: Required. They inventory type.Constant filled by server. Known values + are: "ResourcePool", "VirtualMachine", "VirtualMachineTemplate", "VirtualNetwork", "Cluster", + "Datastore", "Host". + :vartype inventory_type: str or ~azure.mgmt.connectedvmware.models.InventoryType + :ivar managed_resource_id: Gets or sets the tracked resource id corresponding to the inventory + resource. + :vartype managed_resource_id: str + :ivar mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory item. + :vartype mo_ref_id: str + :ivar mo_name: Gets or sets the vCenter Managed Object name for the inventory item. + :vartype mo_name: str + :ivar provisioning_state: Gets or sets the provisioning state. + :vartype provisioning_state: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'inventory_type': {'required': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'inventory_type': {'key': 'properties.inventoryType', 'type': 'str'}, + 'managed_resource_id': {'key': 'properties.managedResourceId', 'type': 'str'}, + 'mo_ref_id': {'key': 'properties.moRefId', 'type': 'str'}, + 'mo_name': {'key': 'properties.moName', 'type': 'str'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + } + + def __init__( + self, + *, + kind: Optional[str] = None, + managed_resource_id: Optional[str] = None, + mo_ref_id: Optional[str] = None, + mo_name: Optional[str] = None, + **kwargs + ): + """ + :keyword kind: Metadata used by portal/tooling/etc to render different UX experiences for + resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, + the resource provider must validate and persist this value. + :paramtype kind: str + :keyword managed_resource_id: Gets or sets the tracked resource id corresponding to the + inventory resource. + :paramtype managed_resource_id: str + :keyword mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory + item. + :paramtype mo_ref_id: str + :keyword mo_name: Gets or sets the vCenter Managed Object name for the inventory item. + :paramtype mo_name: str + """ + super(InventoryItem, self).__init__(**kwargs) + self.system_data = None + self.kind = kind + self.inventory_type = None # type: Optional[str] + self.managed_resource_id = managed_resource_id + self.mo_ref_id = mo_ref_id + self.mo_name = mo_name + self.provisioning_state = None + + +class InventoryItemDetails(msrest.serialization.Model): + """Defines the resource properties. + + :ivar inventory_item_id: Gets or sets the inventory Item ID for the resource. + :vartype inventory_item_id: str + :ivar mo_name: Gets or sets the vCenter Managed Object name for the resource. + :vartype mo_name: str + """ + + _attribute_map = { + 'inventory_item_id': {'key': 'inventoryItemId', 'type': 'str'}, + 'mo_name': {'key': 'moName', 'type': 'str'}, + } + + def __init__( + self, + *, + inventory_item_id: Optional[str] = None, + mo_name: Optional[str] = None, + **kwargs + ): + """ + :keyword inventory_item_id: Gets or sets the inventory Item ID for the resource. + :paramtype inventory_item_id: str + :keyword mo_name: Gets or sets the vCenter Managed Object name for the resource. + :paramtype mo_name: str + """ + super(InventoryItemDetails, self).__init__(**kwargs) + self.inventory_item_id = inventory_item_id + self.mo_name = mo_name + + +class InventoryItemsList(msrest.serialization.Model): + """List of InventoryItems. + + All required parameters must be populated in order to send to Azure. + + :ivar next_link: Url to follow for getting next page of InventoryItems. + :vartype next_link: str + :ivar value: Required. Array of InventoryItems. + :vartype value: list[~azure.mgmt.connectedvmware.models.InventoryItem] + """ + + _validation = { + 'value': {'required': True}, + } + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[InventoryItem]'}, + } + + def __init__( + self, + *, + value: List["_models.InventoryItem"], + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword next_link: Url to follow for getting next page of InventoryItems. + :paramtype next_link: str + :keyword value: Required. Array of InventoryItems. + :paramtype value: list[~azure.mgmt.connectedvmware.models.InventoryItem] + """ + super(InventoryItemsList, self).__init__(**kwargs) + self.next_link = next_link + self.value = value + + +class LinuxParameters(msrest.serialization.Model): + """Input for InstallPatches on a Linux VM, as directly received by the API. + + :ivar classifications_to_include: The update classifications to select when installing patches + for Linux. + :vartype classifications_to_include: list[str or + ~azure.mgmt.connectedvmware.models.VMGuestPatchClassificationLinux] + :ivar package_name_masks_to_include: packages to include in the patch operation. Format: + packageName_packageVersion. + :vartype package_name_masks_to_include: list[str] + :ivar package_name_masks_to_exclude: packages to exclude in the patch operation. Format: + packageName_packageVersion. + :vartype package_name_masks_to_exclude: list[str] + """ + + _attribute_map = { + 'classifications_to_include': {'key': 'classificationsToInclude', 'type': '[str]'}, + 'package_name_masks_to_include': {'key': 'packageNameMasksToInclude', 'type': '[str]'}, + 'package_name_masks_to_exclude': {'key': 'packageNameMasksToExclude', 'type': '[str]'}, + } + + def __init__( + self, + *, + classifications_to_include: Optional[List[Union[str, "_models.VMGuestPatchClassificationLinux"]]] = None, + package_name_masks_to_include: Optional[List[str]] = None, + package_name_masks_to_exclude: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword classifications_to_include: The update classifications to select when installing + patches for Linux. + :paramtype classifications_to_include: list[str or + ~azure.mgmt.connectedvmware.models.VMGuestPatchClassificationLinux] + :keyword package_name_masks_to_include: packages to include in the patch operation. Format: + packageName_packageVersion. + :paramtype package_name_masks_to_include: list[str] + :keyword package_name_masks_to_exclude: packages to exclude in the patch operation. Format: + packageName_packageVersion. + :paramtype package_name_masks_to_exclude: list[str] + """ + super(LinuxParameters, self).__init__(**kwargs) + self.classifications_to_include = classifications_to_include + self.package_name_masks_to_include = package_name_masks_to_include + self.package_name_masks_to_exclude = package_name_masks_to_exclude + + +class MachineExtension(msrest.serialization.Model): + """Describes a Machine Extension. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar location: Gets or sets the location. + :vartype location: str + :ivar system_data: The system data. + :vartype system_data: ~azure.mgmt.connectedvmware.models.SystemData + :ivar tags: A set of tags. Gets or sets the Resource tags. + :vartype tags: dict[str, str] + :ivar name: Gets or sets the name. + :vartype name: str + :ivar id: Gets or sets the Id. + :vartype id: str + :ivar type: Gets or sets the type of the resource. + :vartype type: str + :ivar force_update_tag: How the extension handler should be forced to update even if the + extension configuration has not changed. + :vartype force_update_tag: str + :ivar publisher: The name of the extension handler publisher. + :vartype publisher: str + :ivar type_properties_type: Specifies the type of the extension; an example is + "CustomScriptExtension". + :vartype type_properties_type: str + :ivar type_handler_version: Specifies the version of the script handler. + :vartype type_handler_version: str + :ivar enable_automatic_upgrade: Indicates whether the extension should be automatically + upgraded by the platform if there is a newer version available. + :vartype enable_automatic_upgrade: bool + :ivar auto_upgrade_minor_version: Indicates whether the extension should use a newer minor + version if one is available at deployment time. Once deployed, however, the extension will not + upgrade minor versions unless redeployed, even with this property set to true. + :vartype auto_upgrade_minor_version: bool + :ivar settings: Json formatted public settings for the extension. + :vartype settings: any + :ivar protected_settings: The extension can contain either protectedSettings or + protectedSettingsFromKeyVault or no protected settings at all. + :vartype protected_settings: any + :ivar provisioning_state: The provisioning state, which only appears in the response. + :vartype provisioning_state: str + :ivar instance_view: The machine extension instance view. + :vartype instance_view: + ~azure.mgmt.connectedvmware.models.MachineExtensionPropertiesInstanceView + """ + + _validation = { + 'system_data': {'readonly': True}, + 'name': {'readonly': True}, + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'location': {'key': 'location', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'name': {'key': 'name', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'force_update_tag': {'key': 'properties.forceUpdateTag', 'type': 'str'}, + 'publisher': {'key': 'properties.publisher', 'type': 'str'}, + 'type_properties_type': {'key': 'properties.type', 'type': 'str'}, + 'type_handler_version': {'key': 'properties.typeHandlerVersion', 'type': 'str'}, + 'enable_automatic_upgrade': {'key': 'properties.enableAutomaticUpgrade', 'type': 'bool'}, + 'auto_upgrade_minor_version': {'key': 'properties.autoUpgradeMinorVersion', 'type': 'bool'}, + 'settings': {'key': 'properties.settings', 'type': 'object'}, + 'protected_settings': {'key': 'properties.protectedSettings', 'type': 'object'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'instance_view': {'key': 'properties.instanceView', 'type': 'MachineExtensionPropertiesInstanceView'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + force_update_tag: Optional[str] = None, + publisher: Optional[str] = None, + type_properties_type: Optional[str] = None, + type_handler_version: Optional[str] = None, + enable_automatic_upgrade: Optional[bool] = None, + auto_upgrade_minor_version: Optional[bool] = None, + settings: Optional[Any] = None, + protected_settings: Optional[Any] = None, + instance_view: Optional["_models.MachineExtensionPropertiesInstanceView"] = None, + **kwargs + ): + """ + :keyword location: Gets or sets the location. + :paramtype location: str + :keyword tags: A set of tags. Gets or sets the Resource tags. + :paramtype tags: dict[str, str] + :keyword force_update_tag: How the extension handler should be forced to update even if the + extension configuration has not changed. + :paramtype force_update_tag: str + :keyword publisher: The name of the extension handler publisher. + :paramtype publisher: str + :keyword type_properties_type: Specifies the type of the extension; an example is + "CustomScriptExtension". + :paramtype type_properties_type: str + :keyword type_handler_version: Specifies the version of the script handler. + :paramtype type_handler_version: str + :keyword enable_automatic_upgrade: Indicates whether the extension should be automatically + upgraded by the platform if there is a newer version available. + :paramtype enable_automatic_upgrade: bool + :keyword auto_upgrade_minor_version: Indicates whether the extension should use a newer minor + version if one is available at deployment time. Once deployed, however, the extension will not + upgrade minor versions unless redeployed, even with this property set to true. + :paramtype auto_upgrade_minor_version: bool + :keyword settings: Json formatted public settings for the extension. + :paramtype settings: any + :keyword protected_settings: The extension can contain either protectedSettings or + protectedSettingsFromKeyVault or no protected settings at all. + :paramtype protected_settings: any + :keyword instance_view: The machine extension instance view. + :paramtype instance_view: + ~azure.mgmt.connectedvmware.models.MachineExtensionPropertiesInstanceView + """ + super(MachineExtension, self).__init__(**kwargs) + self.location = location + self.system_data = None + self.tags = tags + self.name = None + self.id = None + self.type = None + self.force_update_tag = force_update_tag + self.publisher = publisher + self.type_properties_type = type_properties_type + self.type_handler_version = type_handler_version + self.enable_automatic_upgrade = enable_automatic_upgrade + self.auto_upgrade_minor_version = auto_upgrade_minor_version + self.settings = settings + self.protected_settings = protected_settings + self.provisioning_state = None + self.instance_view = instance_view + + +class MachineExtensionInstanceView(msrest.serialization.Model): + """Describes the Machine Extension Instance View. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The machine extension name. + :vartype name: str + :ivar type: Specifies the type of the extension; an example is "CustomScriptExtension". + :vartype type: str + :ivar type_handler_version: Specifies the version of the script handler. + :vartype type_handler_version: str + :ivar status: Instance view status. + :vartype status: ~azure.mgmt.connectedvmware.models.MachineExtensionInstanceViewStatus + """ + + _validation = { + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'type_handler_version': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'type_handler_version': {'key': 'typeHandlerVersion', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'MachineExtensionInstanceViewStatus'}, + } + + def __init__( + self, + *, + status: Optional["_models.MachineExtensionInstanceViewStatus"] = None, + **kwargs + ): + """ + :keyword status: Instance view status. + :paramtype status: ~azure.mgmt.connectedvmware.models.MachineExtensionInstanceViewStatus + """ + super(MachineExtensionInstanceView, self).__init__(**kwargs) + self.name = None + self.type = None + self.type_handler_version = None + self.status = status + + +class MachineExtensionInstanceViewStatus(msrest.serialization.Model): + """Instance view status. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The status code. + :vartype code: str + :ivar level: The level code. Known values are: "Info", "Warning", "Error". + :vartype level: str or ~azure.mgmt.connectedvmware.models.StatusLevelTypes + :ivar display_status: The short localizable label for the status. + :vartype display_status: str + :ivar message: The detailed status message, including for alerts and error messages. + :vartype message: str + :ivar time: The time of the status. + :vartype time: ~datetime.datetime + """ + + _validation = { + 'code': {'readonly': True}, + 'level': {'readonly': True}, + 'display_status': {'readonly': True}, + 'message': {'readonly': True}, + 'time': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'level': {'key': 'level', 'type': 'str'}, + 'display_status': {'key': 'displayStatus', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'time': {'key': 'time', 'type': 'iso-8601'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(MachineExtensionInstanceViewStatus, self).__init__(**kwargs) + self.code = None + self.level = None + self.display_status = None + self.message = None + self.time = None + + +class MachineExtensionPropertiesInstanceView(MachineExtensionInstanceView): + """The machine extension instance view. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The machine extension name. + :vartype name: str + :ivar type: Specifies the type of the extension; an example is "CustomScriptExtension". + :vartype type: str + :ivar type_handler_version: Specifies the version of the script handler. + :vartype type_handler_version: str + :ivar status: Instance view status. + :vartype status: ~azure.mgmt.connectedvmware.models.MachineExtensionInstanceViewStatus + """ + + _validation = { + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'type_handler_version': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'type_handler_version': {'key': 'typeHandlerVersion', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'MachineExtensionInstanceViewStatus'}, + } + + def __init__( + self, + *, + status: Optional["_models.MachineExtensionInstanceViewStatus"] = None, + **kwargs + ): + """ + :keyword status: Instance view status. + :paramtype status: ~azure.mgmt.connectedvmware.models.MachineExtensionInstanceViewStatus + """ + super(MachineExtensionPropertiesInstanceView, self).__init__(status=status, **kwargs) + + +class MachineExtensionsListResult(msrest.serialization.Model): + """Describes the Machine Extensions List Result. + + :ivar value: The list of extensions. + :vartype value: list[~azure.mgmt.connectedvmware.models.MachineExtension] + :ivar next_link: The uri to fetch the next page of machine extensions. Call ListNext() with + this to fetch the next page of extensions. + :vartype next_link: str + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[MachineExtension]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["_models.MachineExtension"]] = None, + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword value: The list of extensions. + :paramtype value: list[~azure.mgmt.connectedvmware.models.MachineExtension] + :keyword next_link: The uri to fetch the next page of machine extensions. Call ListNext() with + this to fetch the next page of extensions. + :paramtype next_link: str + """ + super(MachineExtensionsListResult, self).__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class ResourcePatch(msrest.serialization.Model): + """Object containing updates for patch operations. + + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ + super(ResourcePatch, self).__init__(**kwargs) + self.tags = tags + + +class MachineExtensionUpdate(ResourcePatch): + """Describes a Machine Extension Update. + + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar force_update_tag: How the extension handler should be forced to update even if the + extension configuration has not changed. + :vartype force_update_tag: str + :ivar publisher: The name of the extension handler publisher. + :vartype publisher: str + :ivar type: Specifies the type of the extension; an example is "CustomScriptExtension". + :vartype type: str + :ivar type_handler_version: Specifies the version of the script handler. + :vartype type_handler_version: str + :ivar enable_automatic_upgrade: Indicates whether the extension should be automatically + upgraded by the platform if there is a newer version available. + :vartype enable_automatic_upgrade: bool + :ivar auto_upgrade_minor_version: Indicates whether the extension should use a newer minor + version if one is available at deployment time. Once deployed, however, the extension will not + upgrade minor versions unless redeployed, even with this property set to true. + :vartype auto_upgrade_minor_version: bool + :ivar settings: Json formatted public settings for the extension. + :vartype settings: any + :ivar protected_settings: The extension can contain either protectedSettings or + protectedSettingsFromKeyVault or no protected settings at all. + :vartype protected_settings: any + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + 'force_update_tag': {'key': 'properties.forceUpdateTag', 'type': 'str'}, + 'publisher': {'key': 'properties.publisher', 'type': 'str'}, + 'type': {'key': 'properties.type', 'type': 'str'}, + 'type_handler_version': {'key': 'properties.typeHandlerVersion', 'type': 'str'}, + 'enable_automatic_upgrade': {'key': 'properties.enableAutomaticUpgrade', 'type': 'bool'}, + 'auto_upgrade_minor_version': {'key': 'properties.autoUpgradeMinorVersion', 'type': 'bool'}, + 'settings': {'key': 'properties.settings', 'type': 'object'}, + 'protected_settings': {'key': 'properties.protectedSettings', 'type': 'object'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + force_update_tag: Optional[str] = None, + publisher: Optional[str] = None, + type: Optional[str] = None, + type_handler_version: Optional[str] = None, + enable_automatic_upgrade: Optional[bool] = None, + auto_upgrade_minor_version: Optional[bool] = None, + settings: Optional[Any] = None, + protected_settings: Optional[Any] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword force_update_tag: How the extension handler should be forced to update even if the + extension configuration has not changed. + :paramtype force_update_tag: str + :keyword publisher: The name of the extension handler publisher. + :paramtype publisher: str + :keyword type: Specifies the type of the extension; an example is "CustomScriptExtension". + :paramtype type: str + :keyword type_handler_version: Specifies the version of the script handler. + :paramtype type_handler_version: str + :keyword enable_automatic_upgrade: Indicates whether the extension should be automatically + upgraded by the platform if there is a newer version available. + :paramtype enable_automatic_upgrade: bool + :keyword auto_upgrade_minor_version: Indicates whether the extension should use a newer minor + version if one is available at deployment time. Once deployed, however, the extension will not + upgrade minor versions unless redeployed, even with this property set to true. + :paramtype auto_upgrade_minor_version: bool + :keyword settings: Json formatted public settings for the extension. + :paramtype settings: any + :keyword protected_settings: The extension can contain either protectedSettings or + protectedSettingsFromKeyVault or no protected settings at all. + :paramtype protected_settings: any + """ + super(MachineExtensionUpdate, self).__init__(tags=tags, **kwargs) + self.force_update_tag = force_update_tag + self.publisher = publisher + self.type = type + self.type_handler_version = type_handler_version + self.enable_automatic_upgrade = enable_automatic_upgrade + self.auto_upgrade_minor_version = auto_upgrade_minor_version + self.settings = settings + self.protected_settings = protected_settings + + +class NetworkInterface(msrest.serialization.Model): + """Network Interface model. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Gets or sets the name of the network interface. + :vartype name: str + :ivar label: Gets or sets the label of the virtual network in vCenter that the nic is connected + to. + :vartype label: str + :ivar ip_addresses: Gets or sets the nic ip addresses. + :vartype ip_addresses: list[str] + :ivar mac_address: Gets or sets the NIC MAC address. + :vartype mac_address: str + :ivar network_id: Gets or sets the ARM Id of the network resource to connect the virtual + machine. + :vartype network_id: str + :ivar nic_type: NIC type. Known values are: "vmxnet3", "vmxnet2", "vmxnet", "e1000", "e1000e", + "pcnet32". + :vartype nic_type: str or ~azure.mgmt.connectedvmware.models.NICType + :ivar power_on_boot: Gets or sets the power on boot. Known values are: "enabled", "disabled". + :vartype power_on_boot: str or ~azure.mgmt.connectedvmware.models.PowerOnBootOption + :ivar network_mo_ref_id: Gets or sets the vCenter MoRef (Managed Object Reference) ID of the + virtual network + that the nic is connected to. + :vartype network_mo_ref_id: str + :ivar network_mo_name: Gets or sets the name of the virtual network in vCenter that the nic is + connected to. + :vartype network_mo_name: str + :ivar device_key: Gets or sets the device key value. + :vartype device_key: int + :ivar ip_settings: Gets or sets the ipsettings. + :vartype ip_settings: ~azure.mgmt.connectedvmware.models.NicIPSettings + """ + + _validation = { + 'label': {'readonly': True}, + 'ip_addresses': {'readonly': True}, + 'mac_address': {'readonly': True}, + 'network_mo_ref_id': {'readonly': True}, + 'network_mo_name': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'label': {'key': 'label', 'type': 'str'}, + 'ip_addresses': {'key': 'ipAddresses', 'type': '[str]'}, + 'mac_address': {'key': 'macAddress', 'type': 'str'}, + 'network_id': {'key': 'networkId', 'type': 'str'}, + 'nic_type': {'key': 'nicType', 'type': 'str'}, + 'power_on_boot': {'key': 'powerOnBoot', 'type': 'str'}, + 'network_mo_ref_id': {'key': 'networkMoRefId', 'type': 'str'}, + 'network_mo_name': {'key': 'networkMoName', 'type': 'str'}, + 'device_key': {'key': 'deviceKey', 'type': 'int'}, + 'ip_settings': {'key': 'ipSettings', 'type': 'NicIPSettings'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + network_id: Optional[str] = None, + nic_type: Optional[Union[str, "_models.NICType"]] = None, + power_on_boot: Optional[Union[str, "_models.PowerOnBootOption"]] = None, + device_key: Optional[int] = None, + ip_settings: Optional["_models.NicIPSettings"] = None, + **kwargs + ): + """ + :keyword name: Gets or sets the name of the network interface. + :paramtype name: str + :keyword network_id: Gets or sets the ARM Id of the network resource to connect the virtual + machine. + :paramtype network_id: str + :keyword nic_type: NIC type. Known values are: "vmxnet3", "vmxnet2", "vmxnet", "e1000", + "e1000e", "pcnet32". + :paramtype nic_type: str or ~azure.mgmt.connectedvmware.models.NICType + :keyword power_on_boot: Gets or sets the power on boot. Known values are: "enabled", + "disabled". + :paramtype power_on_boot: str or ~azure.mgmt.connectedvmware.models.PowerOnBootOption + :keyword device_key: Gets or sets the device key value. + :paramtype device_key: int + :keyword ip_settings: Gets or sets the ipsettings. + :paramtype ip_settings: ~azure.mgmt.connectedvmware.models.NicIPSettings + """ + super(NetworkInterface, self).__init__(**kwargs) + self.name = name + self.label = None + self.ip_addresses = None + self.mac_address = None + self.network_id = network_id + self.nic_type = nic_type + self.power_on_boot = power_on_boot + self.network_mo_ref_id = None + self.network_mo_name = None + self.device_key = device_key + self.ip_settings = ip_settings + + +class NetworkInterfaceUpdate(msrest.serialization.Model): + """Defines the network interface update. + + :ivar name: Gets or sets the name of the network interface. + :vartype name: str + :ivar network_id: Gets or sets the ARM Id of the network resource to connect the virtual + machine. + :vartype network_id: str + :ivar nic_type: NIC type. Known values are: "vmxnet3", "vmxnet2", "vmxnet", "e1000", "e1000e", + "pcnet32". + :vartype nic_type: str or ~azure.mgmt.connectedvmware.models.NICType + :ivar power_on_boot: Gets or sets the power on boot. Known values are: "enabled", "disabled". + :vartype power_on_boot: str or ~azure.mgmt.connectedvmware.models.PowerOnBootOption + :ivar device_key: Gets or sets the device key value. + :vartype device_key: int + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'network_id': {'key': 'networkId', 'type': 'str'}, + 'nic_type': {'key': 'nicType', 'type': 'str'}, + 'power_on_boot': {'key': 'powerOnBoot', 'type': 'str'}, + 'device_key': {'key': 'deviceKey', 'type': 'int'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + network_id: Optional[str] = None, + nic_type: Optional[Union[str, "_models.NICType"]] = None, + power_on_boot: Optional[Union[str, "_models.PowerOnBootOption"]] = None, + device_key: Optional[int] = None, + **kwargs + ): + """ + :keyword name: Gets or sets the name of the network interface. + :paramtype name: str + :keyword network_id: Gets or sets the ARM Id of the network resource to connect the virtual + machine. + :paramtype network_id: str + :keyword nic_type: NIC type. Known values are: "vmxnet3", "vmxnet2", "vmxnet", "e1000", + "e1000e", "pcnet32". + :paramtype nic_type: str or ~azure.mgmt.connectedvmware.models.NICType + :keyword power_on_boot: Gets or sets the power on boot. Known values are: "enabled", + "disabled". + :paramtype power_on_boot: str or ~azure.mgmt.connectedvmware.models.PowerOnBootOption + :keyword device_key: Gets or sets the device key value. + :paramtype device_key: int + """ + super(NetworkInterfaceUpdate, self).__init__(**kwargs) + self.name = name + self.network_id = network_id + self.nic_type = nic_type + self.power_on_boot = power_on_boot + self.device_key = device_key + + +class NetworkProfile(msrest.serialization.Model): + """Defines the resource properties. + + :ivar network_interfaces: Gets or sets the list of network interfaces associated with the + virtual machine. + :vartype network_interfaces: list[~azure.mgmt.connectedvmware.models.NetworkInterface] + """ + + _attribute_map = { + 'network_interfaces': {'key': 'networkInterfaces', 'type': '[NetworkInterface]'}, + } + + def __init__( + self, + *, + network_interfaces: Optional[List["_models.NetworkInterface"]] = None, + **kwargs + ): + """ + :keyword network_interfaces: Gets or sets the list of network interfaces associated with the + virtual machine. + :paramtype network_interfaces: list[~azure.mgmt.connectedvmware.models.NetworkInterface] + """ + super(NetworkProfile, self).__init__(**kwargs) + self.network_interfaces = network_interfaces + + +class NetworkProfileUpdate(msrest.serialization.Model): + """Defines the update resource properties. + + :ivar network_interfaces: Gets or sets the list of network interfaces associated with the + virtual machine. + :vartype network_interfaces: list[~azure.mgmt.connectedvmware.models.NetworkInterfaceUpdate] + """ + + _attribute_map = { + 'network_interfaces': {'key': 'networkInterfaces', 'type': '[NetworkInterfaceUpdate]'}, + } + + def __init__( + self, + *, + network_interfaces: Optional[List["_models.NetworkInterfaceUpdate"]] = None, + **kwargs + ): + """ + :keyword network_interfaces: Gets or sets the list of network interfaces associated with the + virtual machine. + :paramtype network_interfaces: list[~azure.mgmt.connectedvmware.models.NetworkInterfaceUpdate] + """ + super(NetworkProfileUpdate, self).__init__(**kwargs) + self.network_interfaces = network_interfaces + + +class NicIPAddressSettings(msrest.serialization.Model): + """IP address information for a virtual network adapter reported by the fabric. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar allocation_method: Gets the ip address allocation method. + :vartype allocation_method: str + :ivar ip_address: Gets the ip address for the nic. + :vartype ip_address: str + :ivar subnet_mask: Gets the mask. + :vartype subnet_mask: str + """ + + _validation = { + 'allocation_method': {'readonly': True}, + 'ip_address': {'readonly': True}, + 'subnet_mask': {'readonly': True}, + } + + _attribute_map = { + 'allocation_method': {'key': 'allocationMethod', 'type': 'str'}, + 'ip_address': {'key': 'ipAddress', 'type': 'str'}, + 'subnet_mask': {'key': 'subnetMask', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(NicIPAddressSettings, self).__init__(**kwargs) + self.allocation_method = None + self.ip_address = None + self.subnet_mask = None + + +class NicIPSettings(msrest.serialization.Model): + """Defines the network interface ip settings. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar allocation_method: Gets or sets the nic allocation method. Known values are: "unset", + "dynamic", "static", "linklayer", "random", "other". + :vartype allocation_method: str or ~azure.mgmt.connectedvmware.models.IPAddressAllocationMethod + :ivar dns_servers: Gets or sets the dns servers. + :vartype dns_servers: list[str] + :ivar gateway: Gets or sets the gateway. + :vartype gateway: list[str] + :ivar ip_address: Gets or sets the ip address for the nic. + :vartype ip_address: str + :ivar subnet_mask: Gets or sets the mask. + :vartype subnet_mask: str + :ivar primary_wins_server: Gets or sets the primary server. + :vartype primary_wins_server: str + :ivar secondary_wins_server: Gets or sets the secondary server. + :vartype secondary_wins_server: str + :ivar ip_address_info: Gets or sets the IP address information being reported for this NIC. + This contains the same IPv4 information above plus IPV6 information. + :vartype ip_address_info: list[~azure.mgmt.connectedvmware.models.NicIPAddressSettings] + """ + + _validation = { + 'primary_wins_server': {'readonly': True}, + 'secondary_wins_server': {'readonly': True}, + 'ip_address_info': {'readonly': True}, + } + + _attribute_map = { + 'allocation_method': {'key': 'allocationMethod', 'type': 'str'}, + 'dns_servers': {'key': 'dnsServers', 'type': '[str]'}, + 'gateway': {'key': 'gateway', 'type': '[str]'}, + 'ip_address': {'key': 'ipAddress', 'type': 'str'}, + 'subnet_mask': {'key': 'subnetMask', 'type': 'str'}, + 'primary_wins_server': {'key': 'primaryWinsServer', 'type': 'str'}, + 'secondary_wins_server': {'key': 'secondaryWinsServer', 'type': 'str'}, + 'ip_address_info': {'key': 'ipAddressInfo', 'type': '[NicIPAddressSettings]'}, + } + + def __init__( + self, + *, + allocation_method: Optional[Union[str, "_models.IPAddressAllocationMethod"]] = None, + dns_servers: Optional[List[str]] = None, + gateway: Optional[List[str]] = None, + ip_address: Optional[str] = None, + subnet_mask: Optional[str] = None, + **kwargs + ): + """ + :keyword allocation_method: Gets or sets the nic allocation method. Known values are: "unset", + "dynamic", "static", "linklayer", "random", "other". + :paramtype allocation_method: str or + ~azure.mgmt.connectedvmware.models.IPAddressAllocationMethod + :keyword dns_servers: Gets or sets the dns servers. + :paramtype dns_servers: list[str] + :keyword gateway: Gets or sets the gateway. + :paramtype gateway: list[str] + :keyword ip_address: Gets or sets the ip address for the nic. + :paramtype ip_address: str + :keyword subnet_mask: Gets or sets the mask. + :paramtype subnet_mask: str + """ + super(NicIPSettings, self).__init__(**kwargs) + self.allocation_method = allocation_method + self.dns_servers = dns_servers + self.gateway = gateway + self.ip_address = ip_address + self.subnet_mask = subnet_mask + self.primary_wins_server = None + self.secondary_wins_server = None + self.ip_address_info = None + + +class Operation(msrest.serialization.Model): + """Operation provided by provider. + + :ivar name: Name of the operation. + :vartype name: str + :ivar is_data_action: Indicates whether the operation is data action or not. + :vartype is_data_action: bool + :ivar display: Properties of the operation. + :vartype display: ~azure.mgmt.connectedvmware.models.OperationDisplay + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + is_data_action: Optional[bool] = None, + display: Optional["_models.OperationDisplay"] = None, + **kwargs + ): + """ + :keyword name: Name of the operation. + :paramtype name: str + :keyword is_data_action: Indicates whether the operation is data action or not. + :paramtype is_data_action: bool + :keyword display: Properties of the operation. + :paramtype display: ~azure.mgmt.connectedvmware.models.OperationDisplay + """ + super(Operation, self).__init__(**kwargs) + self.name = name + self.is_data_action = is_data_action + self.display = display + + +class OperationDisplay(msrest.serialization.Model): + """Properties of the operation. + + :ivar provider: Provider name. + :vartype provider: str + :ivar resource: Resource name. + :vartype resource: str + :ivar operation: Operation name. + :vartype operation: str + :ivar description: Description of the operation. + :vartype 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 + ): + """ + :keyword provider: Provider name. + :paramtype provider: str + :keyword resource: Resource name. + :paramtype resource: str + :keyword operation: Operation name. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ + super(OperationDisplay, self).__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + self.description = description + + +class OperationsList(msrest.serialization.Model): + """Lists the operations available. + + All required parameters must be populated in order to send to Azure. + + :ivar next_link: Url to follow for getting next page of operations. + :vartype next_link: str + :ivar value: Required. Array of operations. + :vartype value: list[~azure.mgmt.connectedvmware.models.Operation] + """ + + _validation = { + 'value': {'required': True}, + } + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[Operation]'}, + } + + def __init__( + self, + *, + value: List["_models.Operation"], + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword next_link: Url to follow for getting next page of operations. + :paramtype next_link: str + :keyword value: Required. Array of operations. + :paramtype value: list[~azure.mgmt.connectedvmware.models.Operation] + """ + super(OperationsList, self).__init__(**kwargs) + self.next_link = next_link + self.value = value + + +class OsProfile(msrest.serialization.Model): + """Defines the resource properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar computer_name: Gets or sets computer name. + :vartype computer_name: str + :ivar admin_username: Gets or sets administrator username. + :vartype admin_username: str + :ivar admin_password: Gets or sets administrator password. + :vartype admin_password: str + :ivar guest_id: Gets or sets the guestId. + :vartype guest_id: str + :ivar allow_extension_operations: Gets or sets a value indicating whether the VM is ready for + extension operations. + :vartype allow_extension_operations: bool + :ivar os_type: Gets or sets the type of the os. Known values are: "Windows", "Linux", "Other". + :vartype os_type: str or ~azure.mgmt.connectedvmware.models.OsType + :ivar os_name: Gets or sets os name. + :vartype os_name: str + :ivar tools_running_status: Gets or sets the current running status of VMware Tools running in + the guest operating system. + :vartype tools_running_status: str + :ivar tools_version_status: Gets or sets the current version status of VMware Tools installed + in the guest operating system. + :vartype tools_version_status: str + :ivar tools_version: Gets or sets the current version of VMware Tools. + :vartype tools_version: str + :ivar windows_configuration: Specifies the windows configuration for update management. + :vartype windows_configuration: + ~azure.mgmt.connectedvmware.models.OsProfileWindowsConfiguration + :ivar linux_configuration: Specifies the linux configuration for update management. + :vartype linux_configuration: ~azure.mgmt.connectedvmware.models.OsProfileLinuxConfiguration + """ + + _validation = { + 'allow_extension_operations': {'readonly': True}, + 'os_name': {'readonly': True}, + 'tools_running_status': {'readonly': True}, + 'tools_version_status': {'readonly': True}, + 'tools_version': {'readonly': True}, + } + + _attribute_map = { + 'computer_name': {'key': 'computerName', 'type': 'str'}, + 'admin_username': {'key': 'adminUsername', 'type': 'str'}, + 'admin_password': {'key': 'adminPassword', 'type': 'str'}, + 'guest_id': {'key': 'guestId', 'type': 'str'}, + 'allow_extension_operations': {'key': 'allowExtensionOperations', 'type': 'bool'}, + 'os_type': {'key': 'osType', 'type': 'str'}, + 'os_name': {'key': 'osName', 'type': 'str'}, + 'tools_running_status': {'key': 'toolsRunningStatus', 'type': 'str'}, + 'tools_version_status': {'key': 'toolsVersionStatus', 'type': 'str'}, + 'tools_version': {'key': 'toolsVersion', 'type': 'str'}, + 'windows_configuration': {'key': 'windowsConfiguration', 'type': 'OsProfileWindowsConfiguration'}, + 'linux_configuration': {'key': 'linuxConfiguration', 'type': 'OsProfileLinuxConfiguration'}, + } + + def __init__( + self, + *, + computer_name: Optional[str] = None, + admin_username: Optional[str] = None, + admin_password: Optional[str] = None, + guest_id: Optional[str] = None, + os_type: Optional[Union[str, "_models.OsType"]] = None, + windows_configuration: Optional["_models.OsProfileWindowsConfiguration"] = None, + linux_configuration: Optional["_models.OsProfileLinuxConfiguration"] = None, + **kwargs + ): + """ + :keyword computer_name: Gets or sets computer name. + :paramtype computer_name: str + :keyword admin_username: Gets or sets administrator username. + :paramtype admin_username: str + :keyword admin_password: Gets or sets administrator password. + :paramtype admin_password: str + :keyword guest_id: Gets or sets the guestId. + :paramtype guest_id: str + :keyword os_type: Gets or sets the type of the os. Known values are: "Windows", "Linux", + "Other". + :paramtype os_type: str or ~azure.mgmt.connectedvmware.models.OsType + :keyword windows_configuration: Specifies the windows configuration for update management. + :paramtype windows_configuration: + ~azure.mgmt.connectedvmware.models.OsProfileWindowsConfiguration + :keyword linux_configuration: Specifies the linux configuration for update management. + :paramtype linux_configuration: ~azure.mgmt.connectedvmware.models.OsProfileLinuxConfiguration + """ + super(OsProfile, self).__init__(**kwargs) + self.computer_name = computer_name + self.admin_username = admin_username + self.admin_password = admin_password + self.guest_id = guest_id + self.allow_extension_operations = None + self.os_type = os_type + self.os_name = None + self.tools_running_status = None + self.tools_version_status = None + self.tools_version = None + self.windows_configuration = windows_configuration + self.linux_configuration = linux_configuration + + +class OsProfileLinuxConfiguration(msrest.serialization.Model): + """Specifies the linux configuration for update management. + + :ivar assessment_mode: Specifies the assessment mode. + :vartype assessment_mode: str + :ivar patch_mode: Specifies the patch mode. + :vartype patch_mode: str + """ + + _attribute_map = { + 'assessment_mode': {'key': 'patchSettings.assessmentMode', 'type': 'str'}, + 'patch_mode': {'key': 'patchSettings.patchMode', 'type': 'str'}, + } + + def __init__( + self, + *, + assessment_mode: Optional[str] = None, + patch_mode: Optional[str] = None, + **kwargs + ): + """ + :keyword assessment_mode: Specifies the assessment mode. + :paramtype assessment_mode: str + :keyword patch_mode: Specifies the patch mode. + :paramtype patch_mode: str + """ + super(OsProfileLinuxConfiguration, self).__init__(**kwargs) + self.assessment_mode = assessment_mode + self.patch_mode = patch_mode + + +class OsProfileUpdate(msrest.serialization.Model): + """Defines the os update properties. + + :ivar windows_configuration: Specifies the windows configuration for update management. + :vartype windows_configuration: + ~azure.mgmt.connectedvmware.models.OsProfileUpdateWindowsConfiguration + :ivar linux_configuration: Specifies the linux configuration for update management. + :vartype linux_configuration: + ~azure.mgmt.connectedvmware.models.OsProfileUpdateLinuxConfiguration + """ + + _attribute_map = { + 'windows_configuration': {'key': 'windowsConfiguration', 'type': 'OsProfileUpdateWindowsConfiguration'}, + 'linux_configuration': {'key': 'linuxConfiguration', 'type': 'OsProfileUpdateLinuxConfiguration'}, + } + + def __init__( + self, + *, + windows_configuration: Optional["_models.OsProfileUpdateWindowsConfiguration"] = None, + linux_configuration: Optional["_models.OsProfileUpdateLinuxConfiguration"] = None, + **kwargs + ): + """ + :keyword windows_configuration: Specifies the windows configuration for update management. + :paramtype windows_configuration: + ~azure.mgmt.connectedvmware.models.OsProfileUpdateWindowsConfiguration + :keyword linux_configuration: Specifies the linux configuration for update management. + :paramtype linux_configuration: + ~azure.mgmt.connectedvmware.models.OsProfileUpdateLinuxConfiguration + """ + super(OsProfileUpdate, self).__init__(**kwargs) + self.windows_configuration = windows_configuration + self.linux_configuration = linux_configuration + + +class OsProfileUpdateLinuxConfiguration(msrest.serialization.Model): + """Specifies the linux configuration for update management. + + :ivar assessment_mode: Specifies the assessment mode. + :vartype assessment_mode: str + :ivar patch_mode: Specifies the patch mode. + :vartype patch_mode: str + """ + + _attribute_map = { + 'assessment_mode': {'key': 'patchSettings.assessmentMode', 'type': 'str'}, + 'patch_mode': {'key': 'patchSettings.patchMode', 'type': 'str'}, + } + + def __init__( + self, + *, + assessment_mode: Optional[str] = None, + patch_mode: Optional[str] = None, + **kwargs + ): + """ + :keyword assessment_mode: Specifies the assessment mode. + :paramtype assessment_mode: str + :keyword patch_mode: Specifies the patch mode. + :paramtype patch_mode: str + """ + super(OsProfileUpdateLinuxConfiguration, self).__init__(**kwargs) + self.assessment_mode = assessment_mode + self.patch_mode = patch_mode + + +class OsProfileUpdateWindowsConfiguration(msrest.serialization.Model): + """Specifies the windows configuration for update management. + + :ivar assessment_mode: Specifies the assessment mode. + :vartype assessment_mode: str + :ivar patch_mode: Specifies the patch mode. + :vartype patch_mode: str + """ + + _attribute_map = { + 'assessment_mode': {'key': 'patchSettings.assessmentMode', 'type': 'str'}, + 'patch_mode': {'key': 'patchSettings.patchMode', 'type': 'str'}, + } + + def __init__( + self, + *, + assessment_mode: Optional[str] = None, + patch_mode: Optional[str] = None, + **kwargs + ): + """ + :keyword assessment_mode: Specifies the assessment mode. + :paramtype assessment_mode: str + :keyword patch_mode: Specifies the patch mode. + :paramtype patch_mode: str + """ + super(OsProfileUpdateWindowsConfiguration, self).__init__(**kwargs) + self.assessment_mode = assessment_mode + self.patch_mode = patch_mode + + +class OsProfileWindowsConfiguration(msrest.serialization.Model): + """Specifies the windows configuration for update management. + + :ivar assessment_mode: Specifies the assessment mode. + :vartype assessment_mode: str + :ivar patch_mode: Specifies the patch mode. + :vartype patch_mode: str + """ + + _attribute_map = { + 'assessment_mode': {'key': 'patchSettings.assessmentMode', 'type': 'str'}, + 'patch_mode': {'key': 'patchSettings.patchMode', 'type': 'str'}, + } + + def __init__( + self, + *, + assessment_mode: Optional[str] = None, + patch_mode: Optional[str] = None, + **kwargs + ): + """ + :keyword assessment_mode: Specifies the assessment mode. + :paramtype assessment_mode: str + :keyword patch_mode: Specifies the patch mode. + :paramtype patch_mode: str + """ + super(OsProfileWindowsConfiguration, self).__init__(**kwargs) + self.assessment_mode = assessment_mode + self.patch_mode = patch_mode + + +class PlacementProfile(msrest.serialization.Model): + """Defines the resource properties. + + :ivar resource_pool_id: Gets or sets the ARM Id of the resourcePool resource on which this + virtual machine will deploy. + :vartype resource_pool_id: str + :ivar cluster_id: Gets or sets the ARM Id of the cluster resource on which this virtual machine + will deploy. + :vartype cluster_id: str + :ivar host_id: Gets or sets the ARM Id of the host resource on which this virtual machine will + deploy. + :vartype host_id: str + :ivar datastore_id: Gets or sets the ARM Id of the datastore resource on which the data for the + virtual machine will be kept. + :vartype datastore_id: str + """ + + _attribute_map = { + 'resource_pool_id': {'key': 'resourcePoolId', 'type': 'str'}, + 'cluster_id': {'key': 'clusterId', 'type': 'str'}, + 'host_id': {'key': 'hostId', 'type': 'str'}, + 'datastore_id': {'key': 'datastoreId', 'type': 'str'}, + } + + def __init__( + self, + *, + resource_pool_id: Optional[str] = None, + cluster_id: Optional[str] = None, + host_id: Optional[str] = None, + datastore_id: Optional[str] = None, + **kwargs + ): + """ + :keyword resource_pool_id: Gets or sets the ARM Id of the resourcePool resource on which this + virtual machine will deploy. + :paramtype resource_pool_id: str + :keyword cluster_id: Gets or sets the ARM Id of the cluster resource on which this virtual + machine will deploy. + :paramtype cluster_id: str + :keyword host_id: Gets or sets the ARM Id of the host resource on which this virtual machine + will deploy. + :paramtype host_id: str + :keyword datastore_id: Gets or sets the ARM Id of the datastore resource on which the data for + the virtual machine will be kept. + :paramtype datastore_id: str + """ + super(PlacementProfile, self).__init__(**kwargs) + self.resource_pool_id = resource_pool_id + self.cluster_id = cluster_id + self.host_id = host_id + self.datastore_id = datastore_id + + +class ResourcePool(msrest.serialization.Model): + """Define the resourcePool. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar location: Required. Gets or sets the location. + :vartype location: str + :ivar extended_location: Gets or sets the extended location. + :vartype extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation + :ivar system_data: The system data. + :vartype system_data: ~azure.mgmt.connectedvmware.models.SystemData + :ivar tags: A set of tags. Gets or sets the Resource tags. + :vartype tags: dict[str, str] + :ivar name: Gets or sets the name. + :vartype name: str + :ivar id: Gets or sets the Id. + :vartype id: str + :ivar type: Gets or sets the type of the resource. + :vartype type: str + :ivar kind: Metadata used by portal/tooling/etc to render different UX experiences for + resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, + the resource provider must validate and persist this value. + :vartype kind: str + :ivar uuid: Gets or sets a unique identifier for this resource. + :vartype uuid: str + :ivar v_center_id: Gets or sets the ARM Id of the vCenter resource in which this resource pool + resides. + :vartype v_center_id: str + :ivar mo_ref_id: Gets or sets the vCenter MoRef (Managed Object Reference) ID for the resource + pool. + :vartype mo_ref_id: str + :ivar inventory_item_id: Gets or sets the inventory Item ID for the resource pool. + :vartype inventory_item_id: str + :ivar mo_name: Gets or sets the vCenter Managed Object name for the resource pool. + :vartype mo_name: str + :ivar cpu_shares_level: Gets or sets CPUSharesLevel which specifies the CPU allocation level + for this pool. + This property is used in relative allocation between resource consumers. + :vartype cpu_shares_level: str + :ivar cpu_reservation_m_hz: Gets or sets CPUReservationMHz which specifies the CPU size in MHz + that is guaranteed + to be available. + :vartype cpu_reservation_m_hz: long + :ivar cpu_limit_m_hz: Gets or sets CPULimitMHz which specifies a CPU usage limit in MHz. + Utilization will not exceed this limit even if there are available resources. + :vartype cpu_limit_m_hz: long + :ivar mem_shares_level: Gets or sets CPUSharesLevel which specifies the memory allocation level + for this pool. + This property is used in relative allocation between resource consumers. + :vartype mem_shares_level: str + :ivar mem_reservation_mb: Gets or sets MemReservationMB which specifies the guaranteed + available memory in + megabytes. + :vartype mem_reservation_mb: long + :ivar mem_limit_mb: Gets or sets MemLimitMB specifies a memory usage limit in megabytes. + Utilization will not exceed the specified limit even if there are available resources. + :vartype mem_limit_mb: long + :ivar custom_resource_name: Gets the name of the corresponding resource in Kubernetes. + :vartype custom_resource_name: str + :ivar statuses: The resource status information. + :vartype statuses: list[~azure.mgmt.connectedvmware.models.ResourceStatus] + :ivar provisioning_state: Gets or sets the provisioning state. + :vartype provisioning_state: str + """ + + _validation = { + 'location': {'required': True}, + 'system_data': {'readonly': True}, + 'name': {'readonly': True}, + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'uuid': {'readonly': True}, + 'mo_name': {'readonly': True}, + 'cpu_shares_level': {'readonly': True}, + 'cpu_reservation_m_hz': {'readonly': True}, + 'cpu_limit_m_hz': {'readonly': True}, + 'mem_shares_level': {'readonly': True}, + 'mem_reservation_mb': {'readonly': True}, + 'mem_limit_mb': {'readonly': True}, + 'custom_resource_name': {'readonly': True}, + 'statuses': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'location': {'key': 'location', 'type': 'str'}, + 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'name': {'key': 'name', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'uuid': {'key': 'properties.uuid', 'type': 'str'}, + 'v_center_id': {'key': 'properties.vCenterId', 'type': 'str'}, + 'mo_ref_id': {'key': 'properties.moRefId', 'type': 'str'}, + 'inventory_item_id': {'key': 'properties.inventoryItemId', 'type': 'str'}, + 'mo_name': {'key': 'properties.moName', 'type': 'str'}, + 'cpu_shares_level': {'key': 'properties.cpuSharesLevel', 'type': 'str'}, + 'cpu_reservation_m_hz': {'key': 'properties.cpuReservationMHz', 'type': 'long'}, + 'cpu_limit_m_hz': {'key': 'properties.cpuLimitMHz', 'type': 'long'}, + 'mem_shares_level': {'key': 'properties.memSharesLevel', 'type': 'str'}, + 'mem_reservation_mb': {'key': 'properties.memReservationMB', 'type': 'long'}, + 'mem_limit_mb': {'key': 'properties.memLimitMB', 'type': 'long'}, + 'custom_resource_name': {'key': 'properties.customResourceName', 'type': 'str'}, + 'statuses': {'key': 'properties.statuses', 'type': '[ResourceStatus]'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + } + + def __init__( + self, + *, + location: str, + extended_location: Optional["_models.ExtendedLocation"] = None, + tags: Optional[Dict[str, str]] = None, + kind: Optional[str] = None, + v_center_id: Optional[str] = None, + mo_ref_id: Optional[str] = None, + inventory_item_id: Optional[str] = None, + **kwargs + ): + """ + :keyword location: Required. Gets or sets the location. + :paramtype location: str + :keyword extended_location: Gets or sets the extended location. + :paramtype extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation + :keyword tags: A set of tags. Gets or sets the Resource tags. + :paramtype tags: dict[str, str] + :keyword kind: Metadata used by portal/tooling/etc to render different UX experiences for + resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, + the resource provider must validate and persist this value. + :paramtype kind: str + :keyword v_center_id: Gets or sets the ARM Id of the vCenter resource in which this resource + pool resides. + :paramtype v_center_id: str + :keyword mo_ref_id: Gets or sets the vCenter MoRef (Managed Object Reference) ID for the + resource pool. + :paramtype mo_ref_id: str + :keyword inventory_item_id: Gets or sets the inventory Item ID for the resource pool. + :paramtype inventory_item_id: str + """ + super(ResourcePool, self).__init__(**kwargs) + self.location = location + self.extended_location = extended_location + self.system_data = None + self.tags = tags + self.name = None + self.id = None + self.type = None + self.kind = kind + self.uuid = None + self.v_center_id = v_center_id + self.mo_ref_id = mo_ref_id + self.inventory_item_id = inventory_item_id + self.mo_name = None + self.cpu_shares_level = None + self.cpu_reservation_m_hz = None + self.cpu_limit_m_hz = None + self.mem_shares_level = None + self.mem_reservation_mb = None + self.mem_limit_mb = None + self.custom_resource_name = None + self.statuses = None + self.provisioning_state = None + + +class ResourcePoolInventoryItem(InventoryItemProperties): + """The resource pool inventory item. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar inventory_type: Required. They inventory type.Constant filled by server. Known values + are: "ResourcePool", "VirtualMachine", "VirtualMachineTemplate", "VirtualNetwork", "Cluster", + "Datastore", "Host". + :vartype inventory_type: str or ~azure.mgmt.connectedvmware.models.InventoryType + :ivar managed_resource_id: Gets or sets the tracked resource id corresponding to the inventory + resource. + :vartype managed_resource_id: str + :ivar mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory item. + :vartype mo_ref_id: str + :ivar mo_name: Gets or sets the vCenter Managed Object name for the inventory item. + :vartype mo_name: str + :ivar provisioning_state: Gets or sets the provisioning state. + :vartype provisioning_state: str + :ivar parent: Parent resourcePool inventory resource details. + :vartype parent: ~azure.mgmt.connectedvmware.models.InventoryItemDetails + """ + + _validation = { + 'inventory_type': {'required': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'inventory_type': {'key': 'inventoryType', 'type': 'str'}, + 'managed_resource_id': {'key': 'managedResourceId', 'type': 'str'}, + 'mo_ref_id': {'key': 'moRefId', 'type': 'str'}, + 'mo_name': {'key': 'moName', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'parent': {'key': 'parent', 'type': 'InventoryItemDetails'}, + } + + def __init__( + self, + *, + managed_resource_id: Optional[str] = None, + mo_ref_id: Optional[str] = None, + mo_name: Optional[str] = None, + parent: Optional["_models.InventoryItemDetails"] = None, + **kwargs + ): + """ + :keyword managed_resource_id: Gets or sets the tracked resource id corresponding to the + inventory resource. + :paramtype managed_resource_id: str + :keyword mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory + item. + :paramtype mo_ref_id: str + :keyword mo_name: Gets or sets the vCenter Managed Object name for the inventory item. + :paramtype mo_name: str + :keyword parent: Parent resourcePool inventory resource details. + :paramtype parent: ~azure.mgmt.connectedvmware.models.InventoryItemDetails + """ + super(ResourcePoolInventoryItem, self).__init__(managed_resource_id=managed_resource_id, mo_ref_id=mo_ref_id, mo_name=mo_name, **kwargs) + self.inventory_type = 'ResourcePool' # type: str + self.parent = parent + + +class ResourcePoolsList(msrest.serialization.Model): + """List of ResourcePools. + + All required parameters must be populated in order to send to Azure. + + :ivar next_link: Url to follow for getting next page of ResourcePools. + :vartype next_link: str + :ivar value: Required. Array of ResourcePools. + :vartype value: list[~azure.mgmt.connectedvmware.models.ResourcePool] + """ + + _validation = { + 'value': {'required': True}, + } + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[ResourcePool]'}, + } + + def __init__( + self, + *, + value: List["_models.ResourcePool"], + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword next_link: Url to follow for getting next page of ResourcePools. + :paramtype next_link: str + :keyword value: Required. Array of ResourcePools. + :paramtype value: list[~azure.mgmt.connectedvmware.models.ResourcePool] + """ + super(ResourcePoolsList, self).__init__(**kwargs) + self.next_link = next_link + self.value = value + + +class ResourceStatus(msrest.serialization.Model): + """The resource status information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The type of the condition. + :vartype type: str + :ivar status: Status of the condition. + :vartype status: str + :ivar reason: The reason for the condition's status. + :vartype reason: str + :ivar message: A human readable message indicating details about the status. + :vartype message: str + :ivar severity: Severity with which to treat failures of this type of condition. + :vartype severity: str + :ivar last_updated_at: The last update time for this condition. + :vartype last_updated_at: ~datetime.datetime + """ + + _validation = { + 'type': {'readonly': True}, + 'status': {'readonly': True}, + 'reason': {'readonly': True}, + 'message': {'readonly': True}, + 'severity': {'readonly': True}, + 'last_updated_at': {'readonly': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'reason': {'key': 'reason', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'severity': {'key': 'severity', 'type': 'str'}, + 'last_updated_at': {'key': 'lastUpdatedAt', 'type': 'iso-8601'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ResourceStatus, self).__init__(**kwargs) + self.type = None + self.status = None + self.reason = None + self.message = None + self.severity = None + self.last_updated_at = None + + +class SecurityProfile(msrest.serialization.Model): + """Specifies the Security profile settings for the virtual machine. + + :ivar uefi_settings: Specifies the security settings like secure boot used while creating the + virtual machine. + :vartype uefi_settings: ~azure.mgmt.connectedvmware.models.UefiSettings + """ + + _attribute_map = { + 'uefi_settings': {'key': 'uefiSettings', 'type': 'UefiSettings'}, + } + + def __init__( + self, + *, + uefi_settings: Optional["_models.UefiSettings"] = None, + **kwargs + ): + """ + :keyword uefi_settings: Specifies the security settings like secure boot used while creating + the virtual machine. + :paramtype uefi_settings: ~azure.mgmt.connectedvmware.models.UefiSettings + """ + super(SecurityProfile, self).__init__(**kwargs) + self.uefi_settings = uefi_settings + + +class StopVirtualMachineOptions(msrest.serialization.Model): + """Defines the stop action properties. + + :ivar skip_shutdown: Gets or sets a value indicating whether to request non-graceful VM + shutdown. True value for this flag indicates non-graceful shutdown whereas false indicates + otherwise. Defaults to false. + :vartype skip_shutdown: bool + """ + + _attribute_map = { + 'skip_shutdown': {'key': 'skipShutdown', 'type': 'bool'}, + } + + def __init__( + self, + *, + skip_shutdown: Optional[bool] = False, + **kwargs + ): + """ + :keyword skip_shutdown: Gets or sets a value indicating whether to request non-graceful VM + shutdown. True value for this flag indicates non-graceful shutdown whereas false indicates + otherwise. Defaults to false. + :paramtype skip_shutdown: bool + """ + super(StopVirtualMachineOptions, self).__init__(**kwargs) + self.skip_shutdown = skip_shutdown + + +class StorageProfile(msrest.serialization.Model): + """Defines the resource properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar disks: Gets or sets the list of virtual disks associated with the virtual machine. + :vartype disks: list[~azure.mgmt.connectedvmware.models.VirtualDisk] + :ivar scsi_controllers: Gets or sets the list of virtual SCSI controllers associated with the + virtual machine. + :vartype scsi_controllers: list[~azure.mgmt.connectedvmware.models.VirtualSCSIController] + """ + + _validation = { + 'scsi_controllers': {'readonly': True}, + } + + _attribute_map = { + 'disks': {'key': 'disks', 'type': '[VirtualDisk]'}, + 'scsi_controllers': {'key': 'scsiControllers', 'type': '[VirtualSCSIController]'}, + } + + def __init__( + self, + *, + disks: Optional[List["_models.VirtualDisk"]] = None, + **kwargs + ): + """ + :keyword disks: Gets or sets the list of virtual disks associated with the virtual machine. + :paramtype disks: list[~azure.mgmt.connectedvmware.models.VirtualDisk] + """ + super(StorageProfile, self).__init__(**kwargs) + self.disks = disks + self.scsi_controllers = None + + +class StorageProfileUpdate(msrest.serialization.Model): + """Defines the resource update properties. + + :ivar disks: Gets or sets the list of virtual disks associated with the virtual machine. + :vartype disks: list[~azure.mgmt.connectedvmware.models.VirtualDiskUpdate] + """ + + _attribute_map = { + 'disks': {'key': 'disks', 'type': '[VirtualDiskUpdate]'}, + } + + def __init__( + self, + *, + disks: Optional[List["_models.VirtualDiskUpdate"]] = None, + **kwargs + ): + """ + :keyword disks: Gets or sets the list of virtual disks associated with the virtual machine. + :paramtype disks: list[~azure.mgmt.connectedvmware.models.VirtualDiskUpdate] + """ + super(StorageProfileUpdate, self).__init__(**kwargs) + self.disks = disks + + +class SystemData(msrest.serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or ~azure.mgmt.connectedvmware.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.connectedvmware.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'createdByType', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~azure.mgmt.connectedvmware.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or ~azure.mgmt.connectedvmware.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + super(SystemData, self).__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + + +class UefiSettings(msrest.serialization.Model): + """Specifies the security settings like secure boot used while creating the virtual machine. + + :ivar secure_boot_enabled: Specifies whether secure boot should be enabled on the virtual + machine. + :vartype secure_boot_enabled: bool + """ + + _attribute_map = { + 'secure_boot_enabled': {'key': 'secureBootEnabled', 'type': 'bool'}, + } + + def __init__( + self, + *, + secure_boot_enabled: Optional[bool] = None, + **kwargs + ): + """ + :keyword secure_boot_enabled: Specifies whether secure boot should be enabled on the virtual + machine. + :paramtype secure_boot_enabled: bool + """ + super(UefiSettings, self).__init__(**kwargs) + self.secure_boot_enabled = secure_boot_enabled + + +class VCenter(msrest.serialization.Model): + """Defines the vCenter. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar location: Required. Gets or sets the location. + :vartype location: str + :ivar extended_location: Gets or sets the extended location. + :vartype extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation + :ivar system_data: The system data. + :vartype system_data: ~azure.mgmt.connectedvmware.models.SystemData + :ivar tags: A set of tags. Gets or sets the Resource tags. + :vartype tags: dict[str, str] + :ivar name: Gets or sets the name. + :vartype name: str + :ivar id: Gets or sets the Id. + :vartype id: str + :ivar type: Gets or sets the type of the resource. + :vartype type: str + :ivar kind: Metadata used by portal/tooling/etc to render different UX experiences for + resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, + the resource provider must validate and persist this value. + :vartype kind: str + :ivar uuid: Gets or sets a unique identifier for this resource. + :vartype uuid: str + :ivar fqdn: Required. Gets or sets the FQDN/IPAddress of the vCenter. + :vartype fqdn: str + :ivar port: Gets or sets the port of the vCenter. + :vartype port: int + :ivar version: Gets or sets the version of the vCenter. + :vartype version: str + :ivar instance_uuid: Gets or sets the instance UUID of the vCenter. + :vartype instance_uuid: str + :ivar connection_status: Gets or sets the connection status to the vCenter. + :vartype connection_status: str + :ivar custom_resource_name: Gets the name of the corresponding resource in Kubernetes. + :vartype custom_resource_name: str + :ivar credentials: Username / Password Credentials to connect to vcenter. + :vartype credentials: ~azure.mgmt.connectedvmware.models.VICredential + :ivar statuses: The resource status information. + :vartype statuses: list[~azure.mgmt.connectedvmware.models.ResourceStatus] + :ivar provisioning_state: Gets or sets the provisioning state. + :vartype provisioning_state: str + """ + + _validation = { + 'location': {'required': True}, + 'system_data': {'readonly': True}, + 'name': {'readonly': True}, + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'uuid': {'readonly': True}, + 'fqdn': {'required': True}, + 'port': {'maximum': 65535, 'minimum': 1}, + 'version': {'readonly': True}, + 'instance_uuid': {'readonly': True}, + 'connection_status': {'readonly': True}, + 'custom_resource_name': {'readonly': True}, + 'statuses': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'location': {'key': 'location', 'type': 'str'}, + 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'name': {'key': 'name', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'uuid': {'key': 'properties.uuid', 'type': 'str'}, + 'fqdn': {'key': 'properties.fqdn', 'type': 'str'}, + 'port': {'key': 'properties.port', 'type': 'int'}, + 'version': {'key': 'properties.version', 'type': 'str'}, + 'instance_uuid': {'key': 'properties.instanceUuid', 'type': 'str'}, + 'connection_status': {'key': 'properties.connectionStatus', 'type': 'str'}, + 'custom_resource_name': {'key': 'properties.customResourceName', 'type': 'str'}, + 'credentials': {'key': 'properties.credentials', 'type': 'VICredential'}, + 'statuses': {'key': 'properties.statuses', 'type': '[ResourceStatus]'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + } + + def __init__( + self, + *, + location: str, + fqdn: str, + extended_location: Optional["_models.ExtendedLocation"] = None, + tags: Optional[Dict[str, str]] = None, + kind: Optional[str] = None, + port: Optional[int] = None, + credentials: Optional["_models.VICredential"] = None, + **kwargs + ): + """ + :keyword location: Required. Gets or sets the location. + :paramtype location: str + :keyword extended_location: Gets or sets the extended location. + :paramtype extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation + :keyword tags: A set of tags. Gets or sets the Resource tags. + :paramtype tags: dict[str, str] + :keyword kind: Metadata used by portal/tooling/etc to render different UX experiences for + resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, + the resource provider must validate and persist this value. + :paramtype kind: str + :keyword fqdn: Required. Gets or sets the FQDN/IPAddress of the vCenter. + :paramtype fqdn: str + :keyword port: Gets or sets the port of the vCenter. + :paramtype port: int + :keyword credentials: Username / Password Credentials to connect to vcenter. + :paramtype credentials: ~azure.mgmt.connectedvmware.models.VICredential + """ + super(VCenter, self).__init__(**kwargs) + self.location = location + self.extended_location = extended_location + self.system_data = None + self.tags = tags + self.name = None + self.id = None + self.type = None + self.kind = kind + self.uuid = None + self.fqdn = fqdn + self.port = port + self.version = None + self.instance_uuid = None + self.connection_status = None + self.custom_resource_name = None + self.credentials = credentials + self.statuses = None + self.provisioning_state = None + + +class VCentersList(msrest.serialization.Model): + """List of VCenters. + + All required parameters must be populated in order to send to Azure. + + :ivar next_link: Url to follow for getting next page of VCenters. + :vartype next_link: str + :ivar value: Required. Array of VCenters. + :vartype value: list[~azure.mgmt.connectedvmware.models.VCenter] + """ + + _validation = { + 'value': {'required': True}, + } + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[VCenter]'}, + } + + def __init__( + self, + *, + value: List["_models.VCenter"], + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword next_link: Url to follow for getting next page of VCenters. + :paramtype next_link: str + :keyword value: Required. Array of VCenters. + :paramtype value: list[~azure.mgmt.connectedvmware.models.VCenter] + """ + super(VCentersList, self).__init__(**kwargs) + self.next_link = next_link + self.value = value + + +class VICredential(msrest.serialization.Model): + """Username / Password Credentials to connect to vcenter. + + :ivar username: Gets or sets username to connect with the vCenter. + :vartype username: str + :ivar password: Gets or sets the password to connect with the vCenter. + :vartype password: str + """ + + _attribute_map = { + 'username': {'key': 'username', 'type': 'str'}, + 'password': {'key': 'password', 'type': 'str'}, + } + + def __init__( + self, + *, + username: Optional[str] = None, + password: Optional[str] = None, + **kwargs + ): + """ + :keyword username: Gets or sets username to connect with the vCenter. + :paramtype username: str + :keyword password: Gets or sets the password to connect with the vCenter. + :paramtype password: str + """ + super(VICredential, self).__init__(**kwargs) + self.username = username + self.password = password + + +class VirtualDisk(msrest.serialization.Model): + """Virtual disk model. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Gets or sets the name of the virtual disk. + :vartype name: str + :ivar label: Gets or sets the label of the virtual disk in vCenter. + :vartype label: str + :ivar disk_object_id: Gets or sets the disk object id. + :vartype disk_object_id: str + :ivar disk_size_gb: Gets or sets the disk total size. + :vartype disk_size_gb: int + :ivar device_key: Gets or sets the device key value. + :vartype device_key: int + :ivar disk_mode: Gets or sets the disk mode. Known values are: "persistent", + "independent_persistent", "independent_nonpersistent". + :vartype disk_mode: str or ~azure.mgmt.connectedvmware.models.DiskMode + :ivar controller_key: Gets or sets the controller id. + :vartype controller_key: int + :ivar unit_number: Gets or sets the unit number of the disk on the controller. + :vartype unit_number: int + :ivar device_name: Gets or sets the device name. + :vartype device_name: str + :ivar disk_type: Gets or sets the disk backing type. Known values are: "flat", "pmem", + "rawphysical", "rawvirtual", "sparse", "sesparse", "unknown". + :vartype disk_type: str or ~azure.mgmt.connectedvmware.models.DiskType + """ + + _validation = { + 'label': {'readonly': True}, + 'disk_object_id': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'label': {'key': 'label', 'type': 'str'}, + 'disk_object_id': {'key': 'diskObjectId', 'type': 'str'}, + 'disk_size_gb': {'key': 'diskSizeGB', 'type': 'int'}, + 'device_key': {'key': 'deviceKey', 'type': 'int'}, + 'disk_mode': {'key': 'diskMode', 'type': 'str'}, + 'controller_key': {'key': 'controllerKey', 'type': 'int'}, + 'unit_number': {'key': 'unitNumber', 'type': 'int'}, + 'device_name': {'key': 'deviceName', 'type': 'str'}, + 'disk_type': {'key': 'diskType', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + disk_size_gb: Optional[int] = None, + device_key: Optional[int] = None, + disk_mode: Optional[Union[str, "_models.DiskMode"]] = None, + controller_key: Optional[int] = None, + unit_number: Optional[int] = None, + device_name: Optional[str] = None, + disk_type: Optional[Union[str, "_models.DiskType"]] = None, + **kwargs + ): + """ + :keyword name: Gets or sets the name of the virtual disk. + :paramtype name: str + :keyword disk_size_gb: Gets or sets the disk total size. + :paramtype disk_size_gb: int + :keyword device_key: Gets or sets the device key value. + :paramtype device_key: int + :keyword disk_mode: Gets or sets the disk mode. Known values are: "persistent", + "independent_persistent", "independent_nonpersistent". + :paramtype disk_mode: str or ~azure.mgmt.connectedvmware.models.DiskMode + :keyword controller_key: Gets or sets the controller id. + :paramtype controller_key: int + :keyword unit_number: Gets or sets the unit number of the disk on the controller. + :paramtype unit_number: int + :keyword device_name: Gets or sets the device name. + :paramtype device_name: str + :keyword disk_type: Gets or sets the disk backing type. Known values are: "flat", "pmem", + "rawphysical", "rawvirtual", "sparse", "sesparse", "unknown". + :paramtype disk_type: str or ~azure.mgmt.connectedvmware.models.DiskType + """ + super(VirtualDisk, self).__init__(**kwargs) + self.name = name + self.label = None + self.disk_object_id = None + self.disk_size_gb = disk_size_gb + self.device_key = device_key + self.disk_mode = disk_mode + self.controller_key = controller_key + self.unit_number = unit_number + self.device_name = device_name + self.disk_type = disk_type + + +class VirtualDiskUpdate(msrest.serialization.Model): + """Defines the virtual disk update. + + :ivar name: Gets or sets the name of the virtual disk. + :vartype name: str + :ivar disk_size_gb: Gets or sets the disk total size. + :vartype disk_size_gb: int + :ivar device_key: Gets or sets the device key value. + :vartype device_key: int + :ivar disk_mode: Gets or sets the disk mode. Known values are: "persistent", + "independent_persistent", "independent_nonpersistent". + :vartype disk_mode: str or ~azure.mgmt.connectedvmware.models.DiskMode + :ivar controller_key: Gets or sets the controller id. + :vartype controller_key: int + :ivar unit_number: Gets or sets the unit number of the disk on the controller. + :vartype unit_number: int + :ivar device_name: Gets or sets the device name. + :vartype device_name: str + :ivar disk_type: Gets or sets the disk backing type. Known values are: "flat", "pmem", + "rawphysical", "rawvirtual", "sparse", "sesparse", "unknown". + :vartype disk_type: str or ~azure.mgmt.connectedvmware.models.DiskType + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'disk_size_gb': {'key': 'diskSizeGB', 'type': 'int'}, + 'device_key': {'key': 'deviceKey', 'type': 'int'}, + 'disk_mode': {'key': 'diskMode', 'type': 'str'}, + 'controller_key': {'key': 'controllerKey', 'type': 'int'}, + 'unit_number': {'key': 'unitNumber', 'type': 'int'}, + 'device_name': {'key': 'deviceName', 'type': 'str'}, + 'disk_type': {'key': 'diskType', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + disk_size_gb: Optional[int] = None, + device_key: Optional[int] = None, + disk_mode: Optional[Union[str, "_models.DiskMode"]] = None, + controller_key: Optional[int] = None, + unit_number: Optional[int] = None, + device_name: Optional[str] = None, + disk_type: Optional[Union[str, "_models.DiskType"]] = None, + **kwargs + ): + """ + :keyword name: Gets or sets the name of the virtual disk. + :paramtype name: str + :keyword disk_size_gb: Gets or sets the disk total size. + :paramtype disk_size_gb: int + :keyword device_key: Gets or sets the device key value. + :paramtype device_key: int + :keyword disk_mode: Gets or sets the disk mode. Known values are: "persistent", + "independent_persistent", "independent_nonpersistent". + :paramtype disk_mode: str or ~azure.mgmt.connectedvmware.models.DiskMode + :keyword controller_key: Gets or sets the controller id. + :paramtype controller_key: int + :keyword unit_number: Gets or sets the unit number of the disk on the controller. + :paramtype unit_number: int + :keyword device_name: Gets or sets the device name. + :paramtype device_name: str + :keyword disk_type: Gets or sets the disk backing type. Known values are: "flat", "pmem", + "rawphysical", "rawvirtual", "sparse", "sesparse", "unknown". + :paramtype disk_type: str or ~azure.mgmt.connectedvmware.models.DiskType + """ + super(VirtualDiskUpdate, self).__init__(**kwargs) + self.name = name + self.disk_size_gb = disk_size_gb + self.device_key = device_key + self.disk_mode = disk_mode + self.controller_key = controller_key + self.unit_number = unit_number + self.device_name = device_name + self.disk_type = disk_type + + +class VirtualMachine(msrest.serialization.Model): + """Define the virtualMachine. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar location: Required. Gets or sets the location. + :vartype location: str + :ivar extended_location: Gets or sets the extended location. + :vartype extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation + :ivar system_data: The system data. + :vartype system_data: ~azure.mgmt.connectedvmware.models.SystemData + :ivar tags: A set of tags. Gets or sets the Resource tags. + :vartype tags: dict[str, str] + :ivar name: Gets or sets the name. + :vartype name: str + :ivar id: Gets or sets the Id. + :vartype id: str + :ivar type: Gets or sets the type of the resource. + :vartype type: str + :ivar kind: Metadata used by portal/tooling/etc to render different UX experiences for + resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, + the resource provider must validate and persist this value. + :vartype kind: str + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.connectedvmware.models.Identity + :ivar resource_pool_id: Gets or sets the ARM Id of the resourcePool resource on which this + virtual machine will + deploy. + :vartype resource_pool_id: str + :ivar template_id: Gets or sets the ARM Id of the template resource to deploy the virtual + machine. + :vartype template_id: str + :ivar v_center_id: Gets or sets the ARM Id of the vCenter resource in which this resource pool + resides. + :vartype v_center_id: str + :ivar placement_profile: Placement properties. + :vartype placement_profile: ~azure.mgmt.connectedvmware.models.PlacementProfile + :ivar os_profile: OS properties. + :vartype os_profile: ~azure.mgmt.connectedvmware.models.OsProfile + :ivar hardware_profile: Hardware properties. + :vartype hardware_profile: ~azure.mgmt.connectedvmware.models.HardwareProfile + :ivar network_profile: Network properties. + :vartype network_profile: ~azure.mgmt.connectedvmware.models.NetworkProfile + :ivar storage_profile: Storage properties. + :vartype storage_profile: ~azure.mgmt.connectedvmware.models.StorageProfile + :ivar guest_agent_profile: Guest agent status properties. + :vartype guest_agent_profile: ~azure.mgmt.connectedvmware.models.GuestAgentProfile + :ivar security_profile: Gets the security profile. + :vartype security_profile: ~azure.mgmt.connectedvmware.models.SecurityProfile + :ivar mo_ref_id: Gets or sets the vCenter MoRef (Managed Object Reference) ID for the virtual + machine. + :vartype mo_ref_id: str + :ivar inventory_item_id: Gets or sets the inventory Item ID for the virtual machine. + :vartype inventory_item_id: str + :ivar mo_name: Gets or sets the vCenter Managed Object name for the virtual machine. + :vartype mo_name: str + :ivar folder_path: Gets or sets the folder path of the vm. + :vartype folder_path: str + :ivar instance_uuid: Gets or sets the instance uuid of the vm. + :vartype instance_uuid: str + :ivar smbios_uuid: Gets or sets the SMBIOS UUID of the vm. + :vartype smbios_uuid: str + :ivar firmware_type: Firmware type. Known values are: "bios", "efi". + :vartype firmware_type: str or ~azure.mgmt.connectedvmware.models.FirmwareType + :ivar power_state: Gets the power state of the virtual machine. + :vartype power_state: str + :ivar custom_resource_name: Gets the name of the corresponding resource in Kubernetes. + :vartype custom_resource_name: str + :ivar uuid: Gets or sets a unique identifier for this resource. + :vartype uuid: str + :ivar statuses: The resource status information. + :vartype statuses: list[~azure.mgmt.connectedvmware.models.ResourceStatus] + :ivar provisioning_state: Gets or sets the provisioning state. + :vartype provisioning_state: str + :ivar vm_id: Gets or sets a unique identifier for the vm resource. + :vartype vm_id: str + """ + + _validation = { + 'location': {'required': True}, + 'system_data': {'readonly': True}, + 'name': {'readonly': True}, + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'mo_name': {'readonly': True}, + 'folder_path': {'readonly': True}, + 'instance_uuid': {'readonly': True}, + 'power_state': {'readonly': True}, + 'custom_resource_name': {'readonly': True}, + 'uuid': {'readonly': True}, + 'statuses': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'vm_id': {'readonly': True}, + } + + _attribute_map = { + 'location': {'key': 'location', 'type': 'str'}, + 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'name': {'key': 'name', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, + 'resource_pool_id': {'key': 'properties.resourcePoolId', 'type': 'str'}, + 'template_id': {'key': 'properties.templateId', 'type': 'str'}, + 'v_center_id': {'key': 'properties.vCenterId', 'type': 'str'}, + 'placement_profile': {'key': 'properties.placementProfile', 'type': 'PlacementProfile'}, + 'os_profile': {'key': 'properties.osProfile', 'type': 'OsProfile'}, + 'hardware_profile': {'key': 'properties.hardwareProfile', 'type': 'HardwareProfile'}, + 'network_profile': {'key': 'properties.networkProfile', 'type': 'NetworkProfile'}, + 'storage_profile': {'key': 'properties.storageProfile', 'type': 'StorageProfile'}, + 'guest_agent_profile': {'key': 'properties.guestAgentProfile', 'type': 'GuestAgentProfile'}, + 'security_profile': {'key': 'properties.securityProfile', 'type': 'SecurityProfile'}, + 'mo_ref_id': {'key': 'properties.moRefId', 'type': 'str'}, + 'inventory_item_id': {'key': 'properties.inventoryItemId', 'type': 'str'}, + 'mo_name': {'key': 'properties.moName', 'type': 'str'}, + 'folder_path': {'key': 'properties.folderPath', 'type': 'str'}, + 'instance_uuid': {'key': 'properties.instanceUuid', 'type': 'str'}, + 'smbios_uuid': {'key': 'properties.smbiosUuid', 'type': 'str'}, + 'firmware_type': {'key': 'properties.firmwareType', 'type': 'str'}, + 'power_state': {'key': 'properties.powerState', 'type': 'str'}, + 'custom_resource_name': {'key': 'properties.customResourceName', 'type': 'str'}, + 'uuid': {'key': 'properties.uuid', 'type': 'str'}, + 'statuses': {'key': 'properties.statuses', 'type': '[ResourceStatus]'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'vm_id': {'key': 'properties.vmId', 'type': 'str'}, + } + + def __init__( + self, + *, + location: str, + extended_location: Optional["_models.ExtendedLocation"] = None, + tags: Optional[Dict[str, str]] = None, + kind: Optional[str] = None, + identity: Optional["_models.Identity"] = None, + resource_pool_id: Optional[str] = None, + template_id: Optional[str] = None, + v_center_id: Optional[str] = None, + placement_profile: Optional["_models.PlacementProfile"] = None, + os_profile: Optional["_models.OsProfile"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + guest_agent_profile: Optional["_models.GuestAgentProfile"] = None, + security_profile: Optional["_models.SecurityProfile"] = None, + mo_ref_id: Optional[str] = None, + inventory_item_id: Optional[str] = None, + smbios_uuid: Optional[str] = None, + firmware_type: Optional[Union[str, "_models.FirmwareType"]] = None, + **kwargs + ): + """ + :keyword location: Required. Gets or sets the location. + :paramtype location: str + :keyword extended_location: Gets or sets the extended location. + :paramtype extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation + :keyword tags: A set of tags. Gets or sets the Resource tags. + :paramtype tags: dict[str, str] + :keyword kind: Metadata used by portal/tooling/etc to render different UX experiences for + resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, + the resource provider must validate and persist this value. + :paramtype kind: str + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.connectedvmware.models.Identity + :keyword resource_pool_id: Gets or sets the ARM Id of the resourcePool resource on which this + virtual machine will + deploy. + :paramtype resource_pool_id: str + :keyword template_id: Gets or sets the ARM Id of the template resource to deploy the virtual + machine. + :paramtype template_id: str + :keyword v_center_id: Gets or sets the ARM Id of the vCenter resource in which this resource + pool resides. + :paramtype v_center_id: str + :keyword placement_profile: Placement properties. + :paramtype placement_profile: ~azure.mgmt.connectedvmware.models.PlacementProfile + :keyword os_profile: OS properties. + :paramtype os_profile: ~azure.mgmt.connectedvmware.models.OsProfile + :keyword hardware_profile: Hardware properties. + :paramtype hardware_profile: ~azure.mgmt.connectedvmware.models.HardwareProfile + :keyword network_profile: Network properties. + :paramtype network_profile: ~azure.mgmt.connectedvmware.models.NetworkProfile + :keyword storage_profile: Storage properties. + :paramtype storage_profile: ~azure.mgmt.connectedvmware.models.StorageProfile + :keyword guest_agent_profile: Guest agent status properties. + :paramtype guest_agent_profile: ~azure.mgmt.connectedvmware.models.GuestAgentProfile + :keyword security_profile: Gets the security profile. + :paramtype security_profile: ~azure.mgmt.connectedvmware.models.SecurityProfile + :keyword mo_ref_id: Gets or sets the vCenter MoRef (Managed Object Reference) ID for the + virtual machine. + :paramtype mo_ref_id: str + :keyword inventory_item_id: Gets or sets the inventory Item ID for the virtual machine. + :paramtype inventory_item_id: str + :keyword smbios_uuid: Gets or sets the SMBIOS UUID of the vm. + :paramtype smbios_uuid: str + :keyword firmware_type: Firmware type. Known values are: "bios", "efi". + :paramtype firmware_type: str or ~azure.mgmt.connectedvmware.models.FirmwareType + """ + super(VirtualMachine, self).__init__(**kwargs) + self.location = location + self.extended_location = extended_location + self.system_data = None + self.tags = tags + self.name = None + self.id = None + self.type = None + self.kind = kind + self.identity = identity + self.resource_pool_id = resource_pool_id + self.template_id = template_id + self.v_center_id = v_center_id + self.placement_profile = placement_profile + self.os_profile = os_profile + self.hardware_profile = hardware_profile + self.network_profile = network_profile + self.storage_profile = storage_profile + self.guest_agent_profile = guest_agent_profile + self.security_profile = security_profile + self.mo_ref_id = mo_ref_id + self.inventory_item_id = inventory_item_id + self.mo_name = None + self.folder_path = None + self.instance_uuid = None + self.smbios_uuid = smbios_uuid + self.firmware_type = firmware_type + self.power_state = None + self.custom_resource_name = None + self.uuid = None + self.statuses = None + self.provisioning_state = None + self.vm_id = None + + +class VirtualMachineAssessPatchesResult(msrest.serialization.Model): + """Describes the properties of an AssessPatches result. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar status: The overall success or failure status of the operation. It remains "InProgress" + until the operation completes. At that point it will become "Unknown", "Failed", "Succeeded", + or "CompletedWithWarnings.". Known values are: "Unknown", "InProgress", "Failed", "Succeeded", + "CompletedWithWarnings". + :vartype status: str or ~azure.mgmt.connectedvmware.models.PatchOperationStatus + :ivar assessment_activity_id: The activity ID of the operation that produced this result. + :vartype assessment_activity_id: str + :ivar reboot_pending: The overall reboot status of the VM. It will be true when partially + installed patches require a reboot to complete installation but the reboot has not yet + occurred. + :vartype reboot_pending: bool + :ivar available_patch_count_by_classification: Summarization of patches available for + installation on the machine by classification. + :vartype available_patch_count_by_classification: + ~azure.mgmt.connectedvmware.models.AvailablePatchCountByClassification + :ivar start_date_time: The UTC timestamp when the operation began. + :vartype start_date_time: ~datetime.datetime + :ivar last_modified_date_time: The UTC timestamp when the operation finished. + :vartype last_modified_date_time: ~datetime.datetime + :ivar started_by: Indicates if operation was triggered by user or by platform. Known values + are: "User", "Platform". + :vartype started_by: str or ~azure.mgmt.connectedvmware.models.PatchOperationStartedBy + :ivar patch_service_used: Specifies the patch service used for the operation. Known values are: + "Unknown", "WU", "WU_WSUS", "YUM", "APT", "Zypper". + :vartype patch_service_used: str or ~azure.mgmt.connectedvmware.models.PatchServiceUsed + :ivar os_type: The operating system type of the machine. Known values are: "Windows", "Linux". + :vartype os_type: str or ~azure.mgmt.connectedvmware.models.OsTypeUM + :ivar error_details: The errors that were encountered during execution of the operation. The + details array contains the list of them. + :vartype error_details: ~azure.mgmt.connectedvmware.models.ErrorDetail + """ + + _validation = { + 'status': {'readonly': True}, + 'assessment_activity_id': {'readonly': True}, + 'reboot_pending': {'readonly': True}, + 'start_date_time': {'readonly': True}, + 'last_modified_date_time': {'readonly': True}, + 'started_by': {'readonly': True}, + 'patch_service_used': {'readonly': True}, + 'os_type': {'readonly': True}, + 'error_details': {'readonly': True}, + } + + _attribute_map = { + 'status': {'key': 'status', 'type': 'str'}, + 'assessment_activity_id': {'key': 'assessmentActivityId', 'type': 'str'}, + 'reboot_pending': {'key': 'rebootPending', 'type': 'bool'}, + 'available_patch_count_by_classification': {'key': 'availablePatchCountByClassification', 'type': 'AvailablePatchCountByClassification'}, + 'start_date_time': {'key': 'startDateTime', 'type': 'iso-8601'}, + 'last_modified_date_time': {'key': 'lastModifiedDateTime', 'type': 'iso-8601'}, + 'started_by': {'key': 'startedBy', 'type': 'str'}, + 'patch_service_used': {'key': 'patchServiceUsed', 'type': 'str'}, + 'os_type': {'key': 'osType', 'type': 'str'}, + 'error_details': {'key': 'errorDetails', 'type': 'ErrorDetail'}, + } + + def __init__( + self, + *, + available_patch_count_by_classification: Optional["_models.AvailablePatchCountByClassification"] = None, + **kwargs + ): + """ + :keyword available_patch_count_by_classification: Summarization of patches available for + installation on the machine by classification. + :paramtype available_patch_count_by_classification: + ~azure.mgmt.connectedvmware.models.AvailablePatchCountByClassification + """ + super(VirtualMachineAssessPatchesResult, self).__init__(**kwargs) + self.status = None + self.assessment_activity_id = None + self.reboot_pending = None + self.available_patch_count_by_classification = available_patch_count_by_classification + self.start_date_time = None + self.last_modified_date_time = None + self.started_by = None + self.patch_service_used = None + self.os_type = None + self.error_details = None + + +class VirtualMachineInstallPatchesParameters(msrest.serialization.Model): + """Input for InstallPatches as directly received by the API. + + All required parameters must be populated in order to send to Azure. + + :ivar maximum_duration: Required. Specifies the maximum amount of time that the operation will + run. It must be an ISO 8601-compliant duration string such as PT4H (4 hours). + :vartype maximum_duration: str + :ivar reboot_setting: Required. Defines when it is acceptable to reboot a VM during a software + update operation. Known values are: "IfRequired", "Never", "Always". + :vartype reboot_setting: str or ~azure.mgmt.connectedvmware.models.VMGuestPatchRebootSetting + :ivar windows_parameters: Input for InstallPatches on a Windows VM, as directly received by the + API. + :vartype windows_parameters: ~azure.mgmt.connectedvmware.models.WindowsParameters + :ivar linux_parameters: Input for InstallPatches on a Linux VM, as directly received by the + API. + :vartype linux_parameters: ~azure.mgmt.connectedvmware.models.LinuxParameters + """ + + _validation = { + 'maximum_duration': {'required': True}, + 'reboot_setting': {'required': True}, + } + + _attribute_map = { + 'maximum_duration': {'key': 'maximumDuration', 'type': 'str'}, + 'reboot_setting': {'key': 'rebootSetting', 'type': 'str'}, + 'windows_parameters': {'key': 'windowsParameters', 'type': 'WindowsParameters'}, + 'linux_parameters': {'key': 'linuxParameters', 'type': 'LinuxParameters'}, + } + + def __init__( + self, + *, + maximum_duration: str, + reboot_setting: Union[str, "_models.VMGuestPatchRebootSetting"], + windows_parameters: Optional["_models.WindowsParameters"] = None, + linux_parameters: Optional["_models.LinuxParameters"] = None, + **kwargs + ): + """ + :keyword maximum_duration: Required. Specifies the maximum amount of time that the operation + will run. It must be an ISO 8601-compliant duration string such as PT4H (4 hours). + :paramtype maximum_duration: str + :keyword reboot_setting: Required. Defines when it is acceptable to reboot a VM during a + software update operation. Known values are: "IfRequired", "Never", "Always". + :paramtype reboot_setting: str or ~azure.mgmt.connectedvmware.models.VMGuestPatchRebootSetting + :keyword windows_parameters: Input for InstallPatches on a Windows VM, as directly received by + the API. + :paramtype windows_parameters: ~azure.mgmt.connectedvmware.models.WindowsParameters + :keyword linux_parameters: Input for InstallPatches on a Linux VM, as directly received by the + API. + :paramtype linux_parameters: ~azure.mgmt.connectedvmware.models.LinuxParameters + """ + super(VirtualMachineInstallPatchesParameters, self).__init__(**kwargs) + self.maximum_duration = maximum_duration + self.reboot_setting = reboot_setting + self.windows_parameters = windows_parameters + self.linux_parameters = linux_parameters + + +class VirtualMachineInstallPatchesResult(msrest.serialization.Model): + """The result summary of an installation operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar status: The overall success or failure status of the operation. It remains "InProgress" + until the operation completes. At that point it will become "Failed", "Succeeded", "Unknown" or + "CompletedWithWarnings.". Known values are: "Unknown", "InProgress", "Failed", "Succeeded", + "CompletedWithWarnings". + :vartype status: str or ~azure.mgmt.connectedvmware.models.PatchOperationStatus + :ivar installation_activity_id: The activity ID of the operation that produced this result. + :vartype installation_activity_id: str + :ivar reboot_status: The reboot state of the VM following completion of the operation. Known + values are: "Unknown", "NotNeeded", "Required", "Started", "Failed", "Completed". + :vartype reboot_status: str or ~azure.mgmt.connectedvmware.models.VMGuestPatchRebootStatus + :ivar maintenance_window_exceeded: Whether the operation ran out of time before it completed + all its intended actions. + :vartype maintenance_window_exceeded: bool + :ivar excluded_patch_count: The number of patches that were not installed due to the user + blocking their installation. + :vartype excluded_patch_count: int + :ivar not_selected_patch_count: The number of patches that were detected as available for + install, but did not meet the operation's criteria. + :vartype not_selected_patch_count: int + :ivar pending_patch_count: The number of patches that were identified as meeting the + installation criteria, but were not able to be installed. Typically this happens when + maintenanceWindowExceeded == true. + :vartype pending_patch_count: int + :ivar installed_patch_count: The number of patches successfully installed. + :vartype installed_patch_count: int + :ivar failed_patch_count: The number of patches that could not be installed due to some issue. + See errors for details. + :vartype failed_patch_count: int + :ivar start_date_time: The UTC timestamp when the operation began. + :vartype start_date_time: ~datetime.datetime + :ivar last_modified_date_time: The UTC timestamp when the operation finished. + :vartype last_modified_date_time: ~datetime.datetime + :ivar started_by: Indicates if operation was triggered by user or by platform. Known values + are: "User", "Platform". + :vartype started_by: str or ~azure.mgmt.connectedvmware.models.PatchOperationStartedBy + :ivar patch_service_used: Specifies the patch service used for the operation. Known values are: + "Unknown", "WU", "WU_WSUS", "YUM", "APT", "Zypper". + :vartype patch_service_used: str or ~azure.mgmt.connectedvmware.models.PatchServiceUsed + :ivar os_type: The operating system type of the machine. Known values are: "Windows", "Linux". + :vartype os_type: str or ~azure.mgmt.connectedvmware.models.OsTypeUM + :ivar error_details: The errors that were encountered during execution of the operation. The + details array contains the list of them. + :vartype error_details: ~azure.mgmt.connectedvmware.models.ErrorDetail + """ + + _validation = { + 'status': {'readonly': True}, + 'installation_activity_id': {'readonly': True}, + 'reboot_status': {'readonly': True}, + 'maintenance_window_exceeded': {'readonly': True}, + 'excluded_patch_count': {'readonly': True}, + 'not_selected_patch_count': {'readonly': True}, + 'pending_patch_count': {'readonly': True}, + 'installed_patch_count': {'readonly': True}, + 'failed_patch_count': {'readonly': True}, + 'start_date_time': {'readonly': True}, + 'last_modified_date_time': {'readonly': True}, + 'started_by': {'readonly': True}, + 'patch_service_used': {'readonly': True}, + 'os_type': {'readonly': True}, + 'error_details': {'readonly': True}, + } + + _attribute_map = { + 'status': {'key': 'status', 'type': 'str'}, + 'installation_activity_id': {'key': 'installationActivityId', 'type': 'str'}, + 'reboot_status': {'key': 'rebootStatus', 'type': 'str'}, + 'maintenance_window_exceeded': {'key': 'maintenanceWindowExceeded', 'type': 'bool'}, + 'excluded_patch_count': {'key': 'excludedPatchCount', 'type': 'int'}, + 'not_selected_patch_count': {'key': 'notSelectedPatchCount', 'type': 'int'}, + 'pending_patch_count': {'key': 'pendingPatchCount', 'type': 'int'}, + 'installed_patch_count': {'key': 'installedPatchCount', 'type': 'int'}, + 'failed_patch_count': {'key': 'failedPatchCount', 'type': 'int'}, + 'start_date_time': {'key': 'startDateTime', 'type': 'iso-8601'}, + 'last_modified_date_time': {'key': 'lastModifiedDateTime', 'type': 'iso-8601'}, + 'started_by': {'key': 'startedBy', 'type': 'str'}, + 'patch_service_used': {'key': 'patchServiceUsed', 'type': 'str'}, + 'os_type': {'key': 'osType', 'type': 'str'}, + 'error_details': {'key': 'errorDetails', 'type': 'ErrorDetail'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(VirtualMachineInstallPatchesResult, self).__init__(**kwargs) + self.status = None + self.installation_activity_id = None + self.reboot_status = None + self.maintenance_window_exceeded = None + self.excluded_patch_count = None + self.not_selected_patch_count = None + self.pending_patch_count = None + self.installed_patch_count = None + self.failed_patch_count = None + self.start_date_time = None + self.last_modified_date_time = None + self.started_by = None + self.patch_service_used = None + self.os_type = None + self.error_details = None + + +class VirtualMachineInventoryItem(InventoryItemProperties): + """The VM inventory item. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar inventory_type: Required. They inventory type.Constant filled by server. Known values + are: "ResourcePool", "VirtualMachine", "VirtualMachineTemplate", "VirtualNetwork", "Cluster", + "Datastore", "Host". + :vartype inventory_type: str or ~azure.mgmt.connectedvmware.models.InventoryType + :ivar managed_resource_id: Gets or sets the tracked resource id corresponding to the inventory + resource. + :vartype managed_resource_id: str + :ivar mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory item. + :vartype mo_ref_id: str + :ivar mo_name: Gets or sets the vCenter Managed Object name for the inventory item. + :vartype mo_name: str + :ivar provisioning_state: Gets or sets the provisioning state. + :vartype provisioning_state: str + :ivar os_type: Gets or sets the type of the os. Known values are: "Windows", "Linux", "Other". + :vartype os_type: str or ~azure.mgmt.connectedvmware.models.OsType + :ivar os_name: Gets or sets os name. + :vartype os_name: str + :ivar ip_addresses: Gets or sets the nic ip addresses. + :vartype ip_addresses: list[str] + :ivar folder_path: Gets or sets the folder path of the vm. + :vartype folder_path: str + :ivar host: Host inventory resource details. + :vartype host: ~azure.mgmt.connectedvmware.models.InventoryItemDetails + :ivar resource_pool: ResourcePool inventory resource details. + :vartype resource_pool: ~azure.mgmt.connectedvmware.models.InventoryItemDetails + :ivar instance_uuid: Gets or sets the instance uuid of the vm. + :vartype instance_uuid: str + :ivar smbios_uuid: Gets or sets the SMBIOS UUID of the vm. + :vartype smbios_uuid: str + :ivar power_state: Gets the power state of the virtual machine. + :vartype power_state: str + :ivar tools_running_status: Gets or sets the current running status of VMware Tools running in + the guest operating system. + :vartype tools_running_status: str + :ivar tools_version_status: Gets or sets the current version status of VMware Tools installed + in the guest operating system. + :vartype tools_version_status: str + :ivar tools_version: Gets or sets the current version of VMware Tools. + :vartype tools_version: str + """ + + _validation = { + 'inventory_type': {'required': True}, + 'provisioning_state': {'readonly': True}, + 'power_state': {'readonly': True}, + 'tools_running_status': {'readonly': True}, + 'tools_version_status': {'readonly': True}, + 'tools_version': {'readonly': True}, + } + + _attribute_map = { + 'inventory_type': {'key': 'inventoryType', 'type': 'str'}, + 'managed_resource_id': {'key': 'managedResourceId', 'type': 'str'}, + 'mo_ref_id': {'key': 'moRefId', 'type': 'str'}, + 'mo_name': {'key': 'moName', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'os_type': {'key': 'osType', 'type': 'str'}, + 'os_name': {'key': 'osName', 'type': 'str'}, + 'ip_addresses': {'key': 'ipAddresses', 'type': '[str]'}, + 'folder_path': {'key': 'folderPath', 'type': 'str'}, + 'host': {'key': 'host', 'type': 'InventoryItemDetails'}, + 'resource_pool': {'key': 'resourcePool', 'type': 'InventoryItemDetails'}, + 'instance_uuid': {'key': 'instanceUuid', 'type': 'str'}, + 'smbios_uuid': {'key': 'smbiosUuid', 'type': 'str'}, + 'power_state': {'key': 'powerState', 'type': 'str'}, + 'tools_running_status': {'key': 'toolsRunningStatus', 'type': 'str'}, + 'tools_version_status': {'key': 'toolsVersionStatus', 'type': 'str'}, + 'tools_version': {'key': 'toolsVersion', 'type': 'str'}, + } + + def __init__( + self, + *, + managed_resource_id: Optional[str] = None, + mo_ref_id: Optional[str] = None, + mo_name: Optional[str] = None, + os_type: Optional[Union[str, "_models.OsType"]] = None, + os_name: Optional[str] = None, + ip_addresses: Optional[List[str]] = None, + folder_path: Optional[str] = None, + host: Optional["_models.InventoryItemDetails"] = None, + resource_pool: Optional["_models.InventoryItemDetails"] = None, + instance_uuid: Optional[str] = None, + smbios_uuid: Optional[str] = None, + **kwargs + ): + """ + :keyword managed_resource_id: Gets or sets the tracked resource id corresponding to the + inventory resource. + :paramtype managed_resource_id: str + :keyword mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory + item. + :paramtype mo_ref_id: str + :keyword mo_name: Gets or sets the vCenter Managed Object name for the inventory item. + :paramtype mo_name: str + :keyword os_type: Gets or sets the type of the os. Known values are: "Windows", "Linux", + "Other". + :paramtype os_type: str or ~azure.mgmt.connectedvmware.models.OsType + :keyword os_name: Gets or sets os name. + :paramtype os_name: str + :keyword ip_addresses: Gets or sets the nic ip addresses. + :paramtype ip_addresses: list[str] + :keyword folder_path: Gets or sets the folder path of the vm. + :paramtype folder_path: str + :keyword host: Host inventory resource details. + :paramtype host: ~azure.mgmt.connectedvmware.models.InventoryItemDetails + :keyword resource_pool: ResourcePool inventory resource details. + :paramtype resource_pool: ~azure.mgmt.connectedvmware.models.InventoryItemDetails + :keyword instance_uuid: Gets or sets the instance uuid of the vm. + :paramtype instance_uuid: str + :keyword smbios_uuid: Gets or sets the SMBIOS UUID of the vm. + :paramtype smbios_uuid: str + """ + super(VirtualMachineInventoryItem, self).__init__(managed_resource_id=managed_resource_id, mo_ref_id=mo_ref_id, mo_name=mo_name, **kwargs) + self.inventory_type = 'VirtualMachine' # type: str + self.os_type = os_type + self.os_name = os_name + self.ip_addresses = ip_addresses + self.folder_path = folder_path + self.host = host + self.resource_pool = resource_pool + self.instance_uuid = instance_uuid + self.smbios_uuid = smbios_uuid + self.power_state = None + self.tools_running_status = None + self.tools_version_status = None + self.tools_version = None + + +class VirtualMachinesList(msrest.serialization.Model): + """List of VirtualMachines. + + All required parameters must be populated in order to send to Azure. + + :ivar next_link: Url to follow for getting next page of VirtualMachines. + :vartype next_link: str + :ivar value: Required. Array of VirtualMachines. + :vartype value: list[~azure.mgmt.connectedvmware.models.VirtualMachine] + """ + + _validation = { + 'value': {'required': True}, + } + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[VirtualMachine]'}, + } + + def __init__( + self, + *, + value: List["_models.VirtualMachine"], + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword next_link: Url to follow for getting next page of VirtualMachines. + :paramtype next_link: str + :keyword value: Required. Array of VirtualMachines. + :paramtype value: list[~azure.mgmt.connectedvmware.models.VirtualMachine] + """ + super(VirtualMachinesList, self).__init__(**kwargs) + self.next_link = next_link + self.value = value + + +class VirtualMachineTemplate(msrest.serialization.Model): + """Define the virtualMachineTemplate. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar location: Required. Gets or sets the location. + :vartype location: str + :ivar extended_location: Gets or sets the extended location. + :vartype extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation + :ivar system_data: The system data. + :vartype system_data: ~azure.mgmt.connectedvmware.models.SystemData + :ivar tags: A set of tags. Gets or sets the Resource tags. + :vartype tags: dict[str, str] + :ivar name: Gets or sets the name. + :vartype name: str + :ivar id: Gets or sets the Id. + :vartype id: str + :ivar type: Gets or sets the type of the resource. + :vartype type: str + :ivar kind: Metadata used by portal/tooling/etc to render different UX experiences for + resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, + the resource provider must validate and persist this value. + :vartype kind: str + :ivar uuid: Gets or sets a unique identifier for this resource. + :vartype uuid: str + :ivar v_center_id: Gets or sets the ARM Id of the vCenter resource in which this template + resides. + :vartype v_center_id: str + :ivar mo_ref_id: Gets or sets the vCenter MoRef (Managed Object Reference) ID for the virtual + machine + template. + :vartype mo_ref_id: str + :ivar inventory_item_id: Gets or sets the inventory Item ID for the virtual machine template. + :vartype inventory_item_id: str + :ivar mo_name: Gets or sets the vCenter Managed Object name for the virtual machine template. + :vartype mo_name: str + :ivar memory_size_mb: Gets or sets memory size in MBs for the template. + :vartype memory_size_mb: int + :ivar num_cp_us: Gets or sets the number of vCPUs for the template. + :vartype num_cp_us: int + :ivar num_cores_per_socket: Gets or sets the number of cores per socket for the template. + Defaults to 1 if unspecified. + :vartype num_cores_per_socket: int + :ivar os_type: Gets or sets the type of the os. Known values are: "Windows", "Linux", "Other". + :vartype os_type: str or ~azure.mgmt.connectedvmware.models.OsType + :ivar os_name: Gets or sets os name. + :vartype os_name: str + :ivar folder_path: Gets or sets the folder path of the template. + :vartype folder_path: str + :ivar network_interfaces: Gets or sets the network interfaces of the template. + :vartype network_interfaces: list[~azure.mgmt.connectedvmware.models.NetworkInterface] + :ivar disks: Gets or sets the disks the template. + :vartype disks: list[~azure.mgmt.connectedvmware.models.VirtualDisk] + :ivar custom_resource_name: Gets the name of the corresponding resource in Kubernetes. + :vartype custom_resource_name: str + :ivar tools_version_status: Gets or sets the current version status of VMware Tools installed + in the guest operating system. + :vartype tools_version_status: str + :ivar tools_version: Gets or sets the current version of VMware Tools. + :vartype tools_version: str + :ivar firmware_type: Firmware type. Known values are: "bios", "efi". + :vartype firmware_type: str or ~azure.mgmt.connectedvmware.models.FirmwareType + :ivar statuses: The resource status information. + :vartype statuses: list[~azure.mgmt.connectedvmware.models.ResourceStatus] + :ivar provisioning_state: Gets or sets the provisioning state. + :vartype provisioning_state: str + """ + + _validation = { + 'location': {'required': True}, + 'system_data': {'readonly': True}, + 'name': {'readonly': True}, + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'uuid': {'readonly': True}, + 'mo_name': {'readonly': True}, + 'memory_size_mb': {'readonly': True}, + 'num_cp_us': {'readonly': True}, + 'num_cores_per_socket': {'readonly': True}, + 'os_type': {'readonly': True}, + 'os_name': {'readonly': True}, + 'folder_path': {'readonly': True}, + 'network_interfaces': {'readonly': True}, + 'disks': {'readonly': True}, + 'custom_resource_name': {'readonly': True}, + 'tools_version_status': {'readonly': True}, + 'tools_version': {'readonly': True}, + 'firmware_type': {'readonly': True}, + 'statuses': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'location': {'key': 'location', 'type': 'str'}, + 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'name': {'key': 'name', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'uuid': {'key': 'properties.uuid', 'type': 'str'}, + 'v_center_id': {'key': 'properties.vCenterId', 'type': 'str'}, + 'mo_ref_id': {'key': 'properties.moRefId', 'type': 'str'}, + 'inventory_item_id': {'key': 'properties.inventoryItemId', 'type': 'str'}, + 'mo_name': {'key': 'properties.moName', 'type': 'str'}, + 'memory_size_mb': {'key': 'properties.memorySizeMB', 'type': 'int'}, + 'num_cp_us': {'key': 'properties.numCPUs', 'type': 'int'}, + 'num_cores_per_socket': {'key': 'properties.numCoresPerSocket', 'type': 'int'}, + 'os_type': {'key': 'properties.osType', 'type': 'str'}, + 'os_name': {'key': 'properties.osName', 'type': 'str'}, + 'folder_path': {'key': 'properties.folderPath', 'type': 'str'}, + 'network_interfaces': {'key': 'properties.networkInterfaces', 'type': '[NetworkInterface]'}, + 'disks': {'key': 'properties.disks', 'type': '[VirtualDisk]'}, + 'custom_resource_name': {'key': 'properties.customResourceName', 'type': 'str'}, + 'tools_version_status': {'key': 'properties.toolsVersionStatus', 'type': 'str'}, + 'tools_version': {'key': 'properties.toolsVersion', 'type': 'str'}, + 'firmware_type': {'key': 'properties.firmwareType', 'type': 'str'}, + 'statuses': {'key': 'properties.statuses', 'type': '[ResourceStatus]'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + } + + def __init__( + self, + *, + location: str, + extended_location: Optional["_models.ExtendedLocation"] = None, + tags: Optional[Dict[str, str]] = None, + kind: Optional[str] = None, + v_center_id: Optional[str] = None, + mo_ref_id: Optional[str] = None, + inventory_item_id: Optional[str] = None, + **kwargs + ): + """ + :keyword location: Required. Gets or sets the location. + :paramtype location: str + :keyword extended_location: Gets or sets the extended location. + :paramtype extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation + :keyword tags: A set of tags. Gets or sets the Resource tags. + :paramtype tags: dict[str, str] + :keyword kind: Metadata used by portal/tooling/etc to render different UX experiences for + resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, + the resource provider must validate and persist this value. + :paramtype kind: str + :keyword v_center_id: Gets or sets the ARM Id of the vCenter resource in which this template + resides. + :paramtype v_center_id: str + :keyword mo_ref_id: Gets or sets the vCenter MoRef (Managed Object Reference) ID for the + virtual machine + template. + :paramtype mo_ref_id: str + :keyword inventory_item_id: Gets or sets the inventory Item ID for the virtual machine + template. + :paramtype inventory_item_id: str + """ + super(VirtualMachineTemplate, self).__init__(**kwargs) + self.location = location + self.extended_location = extended_location + self.system_data = None + self.tags = tags + self.name = None + self.id = None + self.type = None + self.kind = kind + self.uuid = None + self.v_center_id = v_center_id + self.mo_ref_id = mo_ref_id + self.inventory_item_id = inventory_item_id + self.mo_name = None + self.memory_size_mb = None + self.num_cp_us = None + self.num_cores_per_socket = None + self.os_type = None + self.os_name = None + self.folder_path = None + self.network_interfaces = None + self.disks = None + self.custom_resource_name = None + self.tools_version_status = None + self.tools_version = None + self.firmware_type = None + self.statuses = None + self.provisioning_state = None + + +class VirtualMachineTemplateInventoryItem(InventoryItemProperties): + """The VM Template inventory item. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar inventory_type: Required. They inventory type.Constant filled by server. Known values + are: "ResourcePool", "VirtualMachine", "VirtualMachineTemplate", "VirtualNetwork", "Cluster", + "Datastore", "Host". + :vartype inventory_type: str or ~azure.mgmt.connectedvmware.models.InventoryType + :ivar managed_resource_id: Gets or sets the tracked resource id corresponding to the inventory + resource. + :vartype managed_resource_id: str + :ivar mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory item. + :vartype mo_ref_id: str + :ivar mo_name: Gets or sets the vCenter Managed Object name for the inventory item. + :vartype mo_name: str + :ivar provisioning_state: Gets or sets the provisioning state. + :vartype provisioning_state: str + :ivar memory_size_mb: Gets or sets memory size in MBs for the template. + :vartype memory_size_mb: int + :ivar num_cp_us: Gets or sets the number of vCPUs for the template. + :vartype num_cp_us: int + :ivar num_cores_per_socket: Gets or sets the number of cores per socket for the template. + Defaults to 1 if unspecified. + :vartype num_cores_per_socket: int + :ivar os_type: Gets or sets the type of the os. Known values are: "Windows", "Linux", "Other". + :vartype os_type: str or ~azure.mgmt.connectedvmware.models.OsType + :ivar os_name: Gets or sets os name. + :vartype os_name: str + :ivar folder_path: Gets or sets the folder path of the template. + :vartype folder_path: str + """ + + _validation = { + 'inventory_type': {'required': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'inventory_type': {'key': 'inventoryType', 'type': 'str'}, + 'managed_resource_id': {'key': 'managedResourceId', 'type': 'str'}, + 'mo_ref_id': {'key': 'moRefId', 'type': 'str'}, + 'mo_name': {'key': 'moName', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + 'memory_size_mb': {'key': 'memorySizeMB', 'type': 'int'}, + 'num_cp_us': {'key': 'numCPUs', 'type': 'int'}, + 'num_cores_per_socket': {'key': 'numCoresPerSocket', 'type': 'int'}, + 'os_type': {'key': 'osType', 'type': 'str'}, + 'os_name': {'key': 'osName', 'type': 'str'}, + 'folder_path': {'key': 'folderPath', 'type': 'str'}, + } + + def __init__( + self, + *, + managed_resource_id: Optional[str] = None, + mo_ref_id: Optional[str] = None, + mo_name: Optional[str] = None, + memory_size_mb: Optional[int] = None, + num_cp_us: Optional[int] = None, + num_cores_per_socket: Optional[int] = None, + os_type: Optional[Union[str, "_models.OsType"]] = None, + os_name: Optional[str] = None, + folder_path: Optional[str] = None, + **kwargs + ): + """ + :keyword managed_resource_id: Gets or sets the tracked resource id corresponding to the + inventory resource. + :paramtype managed_resource_id: str + :keyword mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory + item. + :paramtype mo_ref_id: str + :keyword mo_name: Gets or sets the vCenter Managed Object name for the inventory item. + :paramtype mo_name: str + :keyword memory_size_mb: Gets or sets memory size in MBs for the template. + :paramtype memory_size_mb: int + :keyword num_cp_us: Gets or sets the number of vCPUs for the template. + :paramtype num_cp_us: int + :keyword num_cores_per_socket: Gets or sets the number of cores per socket for the template. + Defaults to 1 if unspecified. + :paramtype num_cores_per_socket: int + :keyword os_type: Gets or sets the type of the os. Known values are: "Windows", "Linux", + "Other". + :paramtype os_type: str or ~azure.mgmt.connectedvmware.models.OsType + :keyword os_name: Gets or sets os name. + :paramtype os_name: str + :keyword folder_path: Gets or sets the folder path of the template. + :paramtype folder_path: str + """ + super(VirtualMachineTemplateInventoryItem, self).__init__(managed_resource_id=managed_resource_id, mo_ref_id=mo_ref_id, mo_name=mo_name, **kwargs) + self.inventory_type = 'VirtualMachineTemplate' # type: str + self.memory_size_mb = memory_size_mb + self.num_cp_us = num_cp_us + self.num_cores_per_socket = num_cores_per_socket + self.os_type = os_type + self.os_name = os_name + self.folder_path = folder_path + + +class VirtualMachineTemplatesList(msrest.serialization.Model): + """List of VirtualMachineTemplates. + + All required parameters must be populated in order to send to Azure. + + :ivar next_link: Url to follow for getting next page of VirtualMachineTemplates. + :vartype next_link: str + :ivar value: Required. Array of VirtualMachineTemplates. + :vartype value: list[~azure.mgmt.connectedvmware.models.VirtualMachineTemplate] + """ + + _validation = { + 'value': {'required': True}, + } + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[VirtualMachineTemplate]'}, + } + + def __init__( + self, + *, + value: List["_models.VirtualMachineTemplate"], + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword next_link: Url to follow for getting next page of VirtualMachineTemplates. + :paramtype next_link: str + :keyword value: Required. Array of VirtualMachineTemplates. + :paramtype value: list[~azure.mgmt.connectedvmware.models.VirtualMachineTemplate] + """ + super(VirtualMachineTemplatesList, self).__init__(**kwargs) + self.next_link = next_link + self.value = value + + +class VirtualMachineUpdate(msrest.serialization.Model): + """Defines the virtualMachineUpdate. + + :ivar tags: A set of tags. Gets or sets the Resource tags. + :vartype tags: dict[str, str] + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.connectedvmware.models.Identity + :ivar hardware_profile: Defines the resource properties. + :vartype hardware_profile: ~azure.mgmt.connectedvmware.models.HardwareProfile + :ivar os_profile: OS properties. + :vartype os_profile: ~azure.mgmt.connectedvmware.models.OsProfileUpdate + :ivar storage_profile: Defines the resource update properties. + :vartype storage_profile: ~azure.mgmt.connectedvmware.models.StorageProfileUpdate + :ivar network_profile: Defines the update resource properties. + :vartype network_profile: ~azure.mgmt.connectedvmware.models.NetworkProfileUpdate + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + 'identity': {'key': 'identity', 'type': 'Identity'}, + 'hardware_profile': {'key': 'properties.hardwareProfile', 'type': 'HardwareProfile'}, + 'os_profile': {'key': 'properties.osProfile', 'type': 'OsProfileUpdate'}, + 'storage_profile': {'key': 'properties.storageProfile', 'type': 'StorageProfileUpdate'}, + 'network_profile': {'key': 'properties.networkProfile', 'type': 'NetworkProfileUpdate'}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + identity: Optional["_models.Identity"] = None, + hardware_profile: Optional["_models.HardwareProfile"] = None, + os_profile: Optional["_models.OsProfileUpdate"] = None, + storage_profile: Optional["_models.StorageProfileUpdate"] = None, + network_profile: Optional["_models.NetworkProfileUpdate"] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Gets or sets the Resource tags. + :paramtype tags: dict[str, str] + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.connectedvmware.models.Identity + :keyword hardware_profile: Defines the resource properties. + :paramtype hardware_profile: ~azure.mgmt.connectedvmware.models.HardwareProfile + :keyword os_profile: OS properties. + :paramtype os_profile: ~azure.mgmt.connectedvmware.models.OsProfileUpdate + :keyword storage_profile: Defines the resource update properties. + :paramtype storage_profile: ~azure.mgmt.connectedvmware.models.StorageProfileUpdate + :keyword network_profile: Defines the update resource properties. + :paramtype network_profile: ~azure.mgmt.connectedvmware.models.NetworkProfileUpdate + """ + super(VirtualMachineUpdate, self).__init__(**kwargs) + self.tags = tags + self.identity = identity + self.hardware_profile = hardware_profile + self.os_profile = os_profile + self.storage_profile = storage_profile + self.network_profile = network_profile + + +class VirtualNetwork(msrest.serialization.Model): + """Define the virtualNetwork. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar location: Required. Gets or sets the location. + :vartype location: str + :ivar extended_location: Gets or sets the extended location. + :vartype extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation + :ivar system_data: The system data. + :vartype system_data: ~azure.mgmt.connectedvmware.models.SystemData + :ivar tags: A set of tags. Gets or sets the Resource tags. + :vartype tags: dict[str, str] + :ivar name: Gets or sets the name. + :vartype name: str + :ivar id: Gets or sets the Id. + :vartype id: str + :ivar type: Gets or sets the type of the resource. + :vartype type: str + :ivar kind: Metadata used by portal/tooling/etc to render different UX experiences for + resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, + the resource provider must validate and persist this value. + :vartype kind: str + :ivar uuid: Gets or sets a unique identifier for this resource. + :vartype uuid: str + :ivar v_center_id: Gets or sets the ARM Id of the vCenter resource in which this template + resides. + :vartype v_center_id: str + :ivar mo_ref_id: Gets or sets the vCenter MoRef (Managed Object Reference) ID for the virtual + network. + :vartype mo_ref_id: str + :ivar inventory_item_id: Gets or sets the inventory Item ID for the virtual network. + :vartype inventory_item_id: str + :ivar mo_name: Gets or sets the vCenter Managed Object name for the virtual network. + :vartype mo_name: str + :ivar custom_resource_name: Gets the name of the corresponding resource in Kubernetes. + :vartype custom_resource_name: str + :ivar statuses: The resource status information. + :vartype statuses: list[~azure.mgmt.connectedvmware.models.ResourceStatus] + :ivar provisioning_state: Gets or sets the provisioning state. + :vartype provisioning_state: str + """ + + _validation = { + 'location': {'required': True}, + 'system_data': {'readonly': True}, + 'name': {'readonly': True}, + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'uuid': {'readonly': True}, + 'mo_name': {'readonly': True}, + 'custom_resource_name': {'readonly': True}, + 'statuses': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'location': {'key': 'location', 'type': 'str'}, + 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'name': {'key': 'name', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'uuid': {'key': 'properties.uuid', 'type': 'str'}, + 'v_center_id': {'key': 'properties.vCenterId', 'type': 'str'}, + 'mo_ref_id': {'key': 'properties.moRefId', 'type': 'str'}, + 'inventory_item_id': {'key': 'properties.inventoryItemId', 'type': 'str'}, + 'mo_name': {'key': 'properties.moName', 'type': 'str'}, + 'custom_resource_name': {'key': 'properties.customResourceName', 'type': 'str'}, + 'statuses': {'key': 'properties.statuses', 'type': '[ResourceStatus]'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + } + + def __init__( + self, + *, + location: str, + extended_location: Optional["_models.ExtendedLocation"] = None, + tags: Optional[Dict[str, str]] = None, + kind: Optional[str] = None, + v_center_id: Optional[str] = None, + mo_ref_id: Optional[str] = None, + inventory_item_id: Optional[str] = None, + **kwargs + ): + """ + :keyword location: Required. Gets or sets the location. + :paramtype location: str + :keyword extended_location: Gets or sets the extended location. + :paramtype extended_location: ~azure.mgmt.connectedvmware.models.ExtendedLocation + :keyword tags: A set of tags. Gets or sets the Resource tags. + :paramtype tags: dict[str, str] + :keyword kind: Metadata used by portal/tooling/etc to render different UX experiences for + resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, + the resource provider must validate and persist this value. + :paramtype kind: str + :keyword v_center_id: Gets or sets the ARM Id of the vCenter resource in which this template + resides. + :paramtype v_center_id: str + :keyword mo_ref_id: Gets or sets the vCenter MoRef (Managed Object Reference) ID for the + virtual network. + :paramtype mo_ref_id: str + :keyword inventory_item_id: Gets or sets the inventory Item ID for the virtual network. + :paramtype inventory_item_id: str + """ + super(VirtualNetwork, self).__init__(**kwargs) + self.location = location + self.extended_location = extended_location + self.system_data = None + self.tags = tags + self.name = None + self.id = None + self.type = None + self.kind = kind + self.uuid = None + self.v_center_id = v_center_id + self.mo_ref_id = mo_ref_id + self.inventory_item_id = inventory_item_id + self.mo_name = None + self.custom_resource_name = None + self.statuses = None + self.provisioning_state = None + + +class VirtualNetworkInventoryItem(InventoryItemProperties): + """The Virtual network inventory item. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar inventory_type: Required. They inventory type.Constant filled by server. Known values + are: "ResourcePool", "VirtualMachine", "VirtualMachineTemplate", "VirtualNetwork", "Cluster", + "Datastore", "Host". + :vartype inventory_type: str or ~azure.mgmt.connectedvmware.models.InventoryType + :ivar managed_resource_id: Gets or sets the tracked resource id corresponding to the inventory + resource. + :vartype managed_resource_id: str + :ivar mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory item. + :vartype mo_ref_id: str + :ivar mo_name: Gets or sets the vCenter Managed Object name for the inventory item. + :vartype mo_name: str + :ivar provisioning_state: Gets or sets the provisioning state. + :vartype provisioning_state: str + """ + + _validation = { + 'inventory_type': {'required': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'inventory_type': {'key': 'inventoryType', 'type': 'str'}, + 'managed_resource_id': {'key': 'managedResourceId', 'type': 'str'}, + 'mo_ref_id': {'key': 'moRefId', 'type': 'str'}, + 'mo_name': {'key': 'moName', 'type': 'str'}, + 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, + } + + def __init__( + self, + *, + managed_resource_id: Optional[str] = None, + mo_ref_id: Optional[str] = None, + mo_name: Optional[str] = None, + **kwargs + ): + """ + :keyword managed_resource_id: Gets or sets the tracked resource id corresponding to the + inventory resource. + :paramtype managed_resource_id: str + :keyword mo_ref_id: Gets or sets the MoRef (Managed Object Reference) ID for the inventory + item. + :paramtype mo_ref_id: str + :keyword mo_name: Gets or sets the vCenter Managed Object name for the inventory item. + :paramtype mo_name: str + """ + super(VirtualNetworkInventoryItem, self).__init__(managed_resource_id=managed_resource_id, mo_ref_id=mo_ref_id, mo_name=mo_name, **kwargs) + self.inventory_type = 'VirtualNetwork' # type: str + + +class VirtualNetworksList(msrest.serialization.Model): + """List of VirtualNetworks. + + All required parameters must be populated in order to send to Azure. + + :ivar next_link: Url to follow for getting next page of VirtualNetworks. + :vartype next_link: str + :ivar value: Required. Array of VirtualNetworks. + :vartype value: list[~azure.mgmt.connectedvmware.models.VirtualNetwork] + """ + + _validation = { + 'value': {'required': True}, + } + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[VirtualNetwork]'}, + } + + def __init__( + self, + *, + value: List["_models.VirtualNetwork"], + next_link: Optional[str] = None, + **kwargs + ): + """ + :keyword next_link: Url to follow for getting next page of VirtualNetworks. + :paramtype next_link: str + :keyword value: Required. Array of VirtualNetworks. + :paramtype value: list[~azure.mgmt.connectedvmware.models.VirtualNetwork] + """ + super(VirtualNetworksList, self).__init__(**kwargs) + self.next_link = next_link + self.value = value + + +class VirtualSCSIController(msrest.serialization.Model): + """This data object type contains the properties of a SCSI controller device attached to a virtual machine that is reported by the controller. + + :ivar type: Gets or sets the controller type. Known values are: "lsilogic", "buslogic", + "pvscsi", "lsilogicsas". + :vartype type: str or ~azure.mgmt.connectedvmware.models.SCSIControllerType + :ivar controller_key: Gets or sets the key of the controller. + :vartype controller_key: int + :ivar bus_number: Gets or sets the bus number of the controller. + :vartype bus_number: int + :ivar scsi_ctlr_unit_number: Gets or sets the SCSI controller unit number. + :vartype scsi_ctlr_unit_number: int + :ivar sharing: Gets or sets the sharing mode. Known values are: "noSharing", "physicalSharing", + "virtualSharing". + :vartype sharing: str or ~azure.mgmt.connectedvmware.models.VirtualSCSISharing + """ + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'controller_key': {'key': 'controllerKey', 'type': 'int'}, + 'bus_number': {'key': 'busNumber', 'type': 'int'}, + 'scsi_ctlr_unit_number': {'key': 'scsiCtlrUnitNumber', 'type': 'int'}, + 'sharing': {'key': 'sharing', 'type': 'str'}, + } + + def __init__( + self, + *, + type: Optional[Union[str, "_models.SCSIControllerType"]] = None, + controller_key: Optional[int] = None, + bus_number: Optional[int] = None, + scsi_ctlr_unit_number: Optional[int] = None, + sharing: Optional[Union[str, "_models.VirtualSCSISharing"]] = None, + **kwargs + ): + """ + :keyword type: Gets or sets the controller type. Known values are: "lsilogic", "buslogic", + "pvscsi", "lsilogicsas". + :paramtype type: str or ~azure.mgmt.connectedvmware.models.SCSIControllerType + :keyword controller_key: Gets or sets the key of the controller. + :paramtype controller_key: int + :keyword bus_number: Gets or sets the bus number of the controller. + :paramtype bus_number: int + :keyword scsi_ctlr_unit_number: Gets or sets the SCSI controller unit number. + :paramtype scsi_ctlr_unit_number: int + :keyword sharing: Gets or sets the sharing mode. Known values are: "noSharing", + "physicalSharing", "virtualSharing". + :paramtype sharing: str or ~azure.mgmt.connectedvmware.models.VirtualSCSISharing + """ + super(VirtualSCSIController, self).__init__(**kwargs) + self.type = type + self.controller_key = controller_key + self.bus_number = bus_number + self.scsi_ctlr_unit_number = scsi_ctlr_unit_number + self.sharing = sharing + + +class WindowsParameters(msrest.serialization.Model): + """Input for InstallPatches on a Windows VM, as directly received by the API. + + :ivar classifications_to_include: The update classifications to select when installing patches + for Windows. + :vartype classifications_to_include: list[str or + ~azure.mgmt.connectedvmware.models.VMGuestPatchClassificationWindows] + :ivar kb_numbers_to_include: Kbs to include in the patch operation. + :vartype kb_numbers_to_include: list[str] + :ivar kb_numbers_to_exclude: Kbs to exclude in the patch operation. + :vartype kb_numbers_to_exclude: list[str] + :ivar exclude_kbs_requiring_reboot: Filters out Kbs that don't have an + InstallationRebootBehavior of 'NeverReboots' when this is set to true. + :vartype exclude_kbs_requiring_reboot: bool + :ivar max_patch_publish_date: This is used to install patches that were published on or before + this given max published date. + :vartype max_patch_publish_date: ~datetime.datetime + """ + + _attribute_map = { + 'classifications_to_include': {'key': 'classificationsToInclude', 'type': '[str]'}, + 'kb_numbers_to_include': {'key': 'kbNumbersToInclude', 'type': '[str]'}, + 'kb_numbers_to_exclude': {'key': 'kbNumbersToExclude', 'type': '[str]'}, + 'exclude_kbs_requiring_reboot': {'key': 'excludeKbsRequiringReboot', 'type': 'bool'}, + 'max_patch_publish_date': {'key': 'maxPatchPublishDate', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + classifications_to_include: Optional[List[Union[str, "_models.VMGuestPatchClassificationWindows"]]] = None, + kb_numbers_to_include: Optional[List[str]] = None, + kb_numbers_to_exclude: Optional[List[str]] = None, + exclude_kbs_requiring_reboot: Optional[bool] = None, + max_patch_publish_date: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword classifications_to_include: The update classifications to select when installing + patches for Windows. + :paramtype classifications_to_include: list[str or + ~azure.mgmt.connectedvmware.models.VMGuestPatchClassificationWindows] + :keyword kb_numbers_to_include: Kbs to include in the patch operation. + :paramtype kb_numbers_to_include: list[str] + :keyword kb_numbers_to_exclude: Kbs to exclude in the patch operation. + :paramtype kb_numbers_to_exclude: list[str] + :keyword exclude_kbs_requiring_reboot: Filters out Kbs that don't have an + InstallationRebootBehavior of 'NeverReboots' when this is set to true. + :paramtype exclude_kbs_requiring_reboot: bool + :keyword max_patch_publish_date: This is used to install patches that were published on or + before this given max published date. + :paramtype max_patch_publish_date: ~datetime.datetime + """ + super(WindowsParameters, self).__init__(**kwargs) + self.classifications_to_include = classifications_to_include + self.kb_numbers_to_include = kb_numbers_to_include + self.kb_numbers_to_exclude = kb_numbers_to_exclude + self.exclude_kbs_requiring_reboot = exclude_kbs_requiring_reboot + self.max_patch_publish_date = max_patch_publish_date diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/models/_patch.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/models/_patch.py new file mode 100644 index 00000000000..0ad201a8c58 --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/operations/__init__.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/operations/__init__.py new file mode 100644 index 00000000000..295107adb1c --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/operations/__init__.py @@ -0,0 +1,20 @@ +# 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 ._operations import Operations +from ._virtual_machines_operations import VirtualMachinesOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk +__all__ = [ + 'Operations', + 'VirtualMachinesOperations', +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/operations/_operations.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/operations/_operations.py new file mode 100644 index 00000000000..2f6f2cb3cb7 --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/operations/_operations.py @@ -0,0 +1,151 @@ +# pylint: disable=too-many-lines +# 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, Iterable, Optional, TypeVar + +from msrest import Serializer + +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 HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.ConnectedVMwarevSphere/operations") + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.connectedvmware.AzureArcVMwareManagementServiceAPI`'s + :attr:`operations` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> Iterable[_models.OperationsList]: + """Returns list of all operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationsList or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.connectedvmware.models.OperationsList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationsList] + + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + + request = build_list_request( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("OperationsList", 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( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': "/providers/Microsoft.ConnectedVMwarevSphere/operations"} # type: ignore diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/operations/_patch.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/operations/_patch.py new file mode 100644 index 00000000000..0ad201a8c58 --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/operations/_virtual_machines_operations.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/operations/_virtual_machines_operations.py new file mode 100644 index 00000000000..4a13f663fe6 --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/operations/_virtual_machines_operations.py @@ -0,0 +1,154 @@ +# pylint: disable=too-many-lines +# 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, Iterable, Optional, TypeVar, Union, cast + +from msrest import Serializer + +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 HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + resource_group_name: str, + virtual_machine_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "virtualMachineName": _SERIALIZER.url("virtual_machine_name", virtual_machine_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +class VirtualMachinesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.connectedvmware.AzureArcVMwareManagementServiceAPI`'s + :attr:`virtual_machines` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + + @distributed_trace + def get( + self, + resource_group_name: str, + virtual_machine_name: str, + **kwargs: Any + ) -> _models.VirtualMachine: + """Gets a virtual machine. + + Implements virtual machine GET method. + + :param resource_group_name: The Resource Group Name. + :type resource_group_name: str + :param virtual_machine_name: Name of the virtual machine resource. + :type virtual_machine_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: VirtualMachine, or the result of cls(response) + :rtype: ~azure.mgmt.connectedvmware.models.VirtualMachine + :raises: ~azure.core.exceptions.HttpResponseError + """ + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + virtual_machine_name=virtual_machine_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('VirtualMachine', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}"} # type: ignore + + diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/py.typed b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file From 798b3a1329c4342558f4e95a1f7c5d88c520ca95 Mon Sep 17 00:00:00 2001 From: Vivian Thiebaut Date: Wed, 14 Sep 2022 13:57:18 -0400 Subject: [PATCH 03/15] Correct parameter help --- src/ssh/azext_ssh/_params.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/ssh/azext_ssh/_params.py b/src/ssh/azext_ssh/_params.py index a2a50f4ef6c..1bf44cb81d1 100644 --- a/src/ssh/azext_ssh/_params.py +++ b/src/ssh/azext_ssh/_params.py @@ -20,8 +20,10 @@ def load_arguments(self, _): help='Path to a certificate file used for authentication when using local user credentials.') c.argument('port', options_list=['--port'], help='SSH port') c.argument('resource_type', options_list=['--resource-type'], - help='Resource type should be either Microsoft.Compute/virtualMachines, Microsoft.HybridCompute/machines, or Microsoft.ConnectedVMwareSphere.', - completer=["Microsoft.HybridCompute", "Microsoft.Compute"]) + help=('Resource type should be either Microsoft.Compute/virtualMachines, Microsoft.HybridCompute/machines, ' + 'or Microsoft.ConnectedVMwareSphere/virtualMachines.'), + completer=['Microsoft.Compute/virtualMachines', 'Microsoft.HybridCompute/machines', + 'Microsoft.ConnectedVMwareSphere/virtualMachines']) c.argument('ssh_client_folder', options_list=['--ssh-client-folder'], help='Folder path that contains ssh executables (ssh.exe, ssh-keygen.exe, etc). ' 'Default to ssh pre-installed if not provided.') @@ -52,7 +54,10 @@ def load_arguments(self, _): help='Folder where new generated keys will be stored.') c.argument('port', options_list=['--port'], help='SSH Port') c.argument('resource_type', options_list=['--resource-type'], - help='Resource type should be either Microsoft.Compute or Microsoft.HybridCompute') + help=('Resource type should be either Microsoft.Compute/virtualMachines, Microsoft.HybridCompute/machines, ' + 'or Microsoft.ConnectedVMwareSphere/virtualMachines.'), + completer=['Microsoft.Compute/virtualMachines', 'Microsoft.HybridCompute/machines', + 'Microsoft.ConnectedVMwareSphere/virtualMachines']) c.argument('cert_file', options_list=['--certificate-file', '-c'], help='Path to certificate file') c.argument('ssh_proxy_folder', options_list=['--ssh-proxy-folder'], help=('Path to the folder where the ssh proxy should be saved. ' @@ -80,8 +85,10 @@ def load_arguments(self, _): c.argument('cert_file', options_list=['--certificate-file', '-c'], help='Path to certificate file') c.argument('port', options_list=['--port'], help='Port to connect to on the remote host.') c.argument('resource_type', options_list=['--resource-type'], - help='Resource type should be either Microsoft.Compute/virtualMachines, Microsoft.HybridCompute/machines, or Microsoft.ConnectedVMwareSphere.', - completer=["Microsoft.HybridCompute", "Microsoft.Compute"]) + help=('Resource type should be either Microsoft.HybridCompute/machines ' + 'or Microsoft.ConnectedVMwareSphere/virtualMachines.'), + completer=['Microsoft.HybridCompute/machines', + 'Microsoft.ConnectedVMwareSphere/virtualMachines']) c.argument('ssh_client_folder', options_list=['--ssh-client-folder'], help='Folder path that contains ssh executables (ssh.exe, ssh-keygen.exe, etc). ' 'Default to ssh pre-installed if not provided.') From 76570512ca3e8e31cceb5446b0249aa398330472 Mon Sep 17 00:00:00 2001 From: Vivian Thiebaut Date: Wed, 14 Sep 2022 14:23:29 -0400 Subject: [PATCH 04/15] Fix style errors --- src/ssh/azext_ssh/_client_factory.py | 4 +--- src/ssh/azext_ssh/_params.py | 12 +++++----- src/ssh/azext_ssh/custom.py | 8 +++---- src/ssh/azext_ssh/resource_type_utils.py | 28 +++++++++++------------- src/ssh/azext_ssh/ssh_info.py | 8 +++---- src/ssh/azext_ssh/target_os_utils.py | 28 ++++++++++++++---------- 6 files changed, 44 insertions(+), 44 deletions(-) diff --git a/src/ssh/azext_ssh/_client_factory.py b/src/ssh/azext_ssh/_client_factory.py index d6afedf250c..8c33c6f3ccb 100644 --- a/src/ssh/azext_ssh/_client_factory.py +++ b/src/ssh/azext_ssh/_client_factory.py @@ -33,11 +33,9 @@ def cf_machine(cli_ctx, *_): def cf_connectedvmware_cl(cli_ctx, *_): from azext_ssh.vendored_sdks.connectedvmware import AzureArcVMwareManagementServiceAPI - return get_mgmt_service_client(cli_ctx, + return get_mgmt_service_client(cli_ctx, AzureArcVMwareManagementServiceAPI) def cf_vmware(cli_ctx, *_): return cf_connectedvmware_cl(cli_ctx).virtual_machines - - diff --git a/src/ssh/azext_ssh/_params.py b/src/ssh/azext_ssh/_params.py index 1bf44cb81d1..b4d65666328 100644 --- a/src/ssh/azext_ssh/_params.py +++ b/src/ssh/azext_ssh/_params.py @@ -20,8 +20,9 @@ def load_arguments(self, _): help='Path to a certificate file used for authentication when using local user credentials.') c.argument('port', options_list=['--port'], help='SSH port') c.argument('resource_type', options_list=['--resource-type'], - help=('Resource type should be either Microsoft.Compute/virtualMachines, Microsoft.HybridCompute/machines, ' - 'or Microsoft.ConnectedVMwareSphere/virtualMachines.'), + help=('Resource type should be either Microsoft.Compute/virtualMachines, ' + 'Microsoft.HybridCompute/machines, ' + 'or Microsoft.ConnectedVMwareSphere/virtualMachines.'), completer=['Microsoft.Compute/virtualMachines', 'Microsoft.HybridCompute/machines', 'Microsoft.ConnectedVMwareSphere/virtualMachines']) c.argument('ssh_client_folder', options_list=['--ssh-client-folder'], @@ -54,8 +55,9 @@ def load_arguments(self, _): help='Folder where new generated keys will be stored.') c.argument('port', options_list=['--port'], help='SSH Port') c.argument('resource_type', options_list=['--resource-type'], - help=('Resource type should be either Microsoft.Compute/virtualMachines, Microsoft.HybridCompute/machines, ' - 'or Microsoft.ConnectedVMwareSphere/virtualMachines.'), + help=('Resource type should be either Microsoft.Compute/virtualMachines, ' + 'Microsoft.HybridCompute/machines, ' + 'or Microsoft.ConnectedVMwareSphere/virtualMachines.'), completer=['Microsoft.Compute/virtualMachines', 'Microsoft.HybridCompute/machines', 'Microsoft.ConnectedVMwareSphere/virtualMachines']) c.argument('cert_file', options_list=['--certificate-file', '-c'], help='Path to certificate file') @@ -86,7 +88,7 @@ def load_arguments(self, _): c.argument('port', options_list=['--port'], help='Port to connect to on the remote host.') c.argument('resource_type', options_list=['--resource-type'], help=('Resource type should be either Microsoft.HybridCompute/machines ' - 'or Microsoft.ConnectedVMwareSphere/virtualMachines.'), + 'or Microsoft.ConnectedVMwareSphere/virtualMachines.'), completer=['Microsoft.HybridCompute/machines', 'Microsoft.ConnectedVMwareSphere/virtualMachines']) c.argument('ssh_client_folder', options_list=['--ssh-client-folder'], diff --git a/src/ssh/azext_ssh/custom.py b/src/ssh/azext_ssh/custom.py index caccbbc2a52..68446b36468 100644 --- a/src/ssh/azext_ssh/custom.py +++ b/src/ssh/azext_ssh/custom.py @@ -11,8 +11,6 @@ import platform import oschmod -import colorama - from knack import log from azure.cli.core import azclierror from azure.cli.core import telemetry @@ -143,12 +141,12 @@ def ssh_cert(cmd, cert_path=None, public_key_file=None, ssh_client_folder=None): def ssh_arc(cmd, resource_group_name=None, vm_name=None, public_key_file=None, private_key_file=None, - local_user=None, cert_file=None, port=None, resource_type=None, ssh_client_folder=None, + local_user=None, cert_file=None, port=None, resource_type=None, ssh_client_folder=None, delete_credentials=False, ssh_proxy_folder=None, winrdp=False, ssh_args=None): if not resource_type: resource_type = const.ARC_RESOURCE_TYPE_PLACEHOLDER - + ssh_vm(cmd, resource_group_name, vm_name, None, public_key_file, private_key_file, False, local_user, cert_file, port, ssh_client_folder, delete_credentials, resource_type, ssh_proxy_folder, winrdp, ssh_args) @@ -267,7 +265,7 @@ def _prepare_jwk_data(public_key_file): def _assert_args(resource_group, vm_name, ssh_ip, resource_type, cert_file, username): - + if resource_type and \ resource_type.lower() not in const.SUPPORTED_RESOURCE_TYPES and \ resource_type.lower() not in const.LEGACY_SUPPORTED_RESOURCE_TYPES: diff --git a/src/ssh/azext_ssh/resource_type_utils.py b/src/ssh/azext_ssh/resource_type_utils.py index 36594fb8a43..7407a38083a 100644 --- a/src/ssh/azext_ssh/resource_type_utils.py +++ b/src/ssh/azext_ssh/resource_type_utils.py @@ -5,9 +5,8 @@ import colorama -from azure.cli.core import telemetry -from azure.cli.core import azclierror from knack import log +from azure.cli.core import telemetry, azclierror from azure.mgmt.resource import ResourceManagementClient from azure.cli.core.commands.client_factory import get_mgmt_service_client @@ -18,7 +17,9 @@ def _list_types_of_resources_with_provided_name(cmd, op_info): resource_client = get_mgmt_service_client(cmd.cli_ctx, ResourceManagementClient) - resources = resource_client.resources.list_by_resource_group(op_info.resource_group_name, filter=f"name eq '{op_info.vm_name}'") + resources = resource_client.resources.list_by_resource_group( + op_info.resource_group_name, + filter=f"name eq '{op_info.vm_name}'") resource_types_present = set() while True: @@ -28,7 +29,7 @@ def _list_types_of_resources_with_provided_name(cmd, op_info): resource_types_present.add(resource.type.lower()) except StopIteration: break - + return resource_types_present @@ -38,7 +39,7 @@ def decide_resource_type(cmd, op_info): # Arc Server. Which just means that the Connectivity Proxy won't be used to establish connection. if op_info.ip: return "Microsoft.Compute/virtualMachines" - + # Set of resource types in target resource group of resources that match vm_name types_in_rg = _list_types_of_resources_with_provided_name(cmd, op_info) target_resource_type = None @@ -49,15 +50,16 @@ def decide_resource_type(cmd, op_info): if op_info.resource_type.lower() in types_in_rg: target_resource_type = consts.RESOURCE_TYPE_LOWER_CASE_TO_CORRECT_CASE[op_info.resource_type.lower()] else: - raise azclierror.ResourceNotFoundError(f"Unable to find resource {op_info.vm_name} of type " - f"{consts.RESOURCE_TYPE_LOWER_CASE_TO_CORRECT_CASE[op_info.resource_type.lower()]} " - f"under the resource group {op_info.resource_group}", - consts.RECOMMENDATION_RESOURCE_NOT_FOUND) + raise azclierror.ResourceNotFoundError( + f"Unable to find resource {op_info.vm_name} of type " + f"{consts.RESOURCE_TYPE_LOWER_CASE_TO_CORRECT_CASE[op_info.resource_type.lower()]} " + f"under the resource group {op_info.resource_group}", + consts.RECOMMENDATION_RESOURCE_NOT_FOUND) else: if op_info.resource_type == consts.ARC_RESOURCE_TYPE_PLACEHOLDER: types_in_rg.discard("microsoft.compute/virtualmachines") - + if len(types_in_rg) > 1: raise azclierror.BadRequestError(f"{op_info.resource_group_name} has more than one valid target with the " f"same name: {op_info.vm_name}.", @@ -70,11 +72,7 @@ def decide_resource_type(cmd, op_info): consts.RECOMMENDATION_RESOURCE_NOT_FOUND) target_resource_type = consts.RESOURCE_TYPE_LOWER_CASE_TO_CORRECT_CASE[types_in_rg.pop().lower()] - + telemetry.add_extension_event('ssh', {'Context.Default.AzureCLI.TargetResourceType': target_resource_type}) print(target_resource_type) return target_resource_type - - - - diff --git a/src/ssh/azext_ssh/ssh_info.py b/src/ssh/azext_ssh/ssh_info.py index ea42a809fbe..07a09f9f916 100644 --- a/src/ssh/azext_ssh/ssh_info.py +++ b/src/ssh/azext_ssh/ssh_info.py @@ -41,8 +41,8 @@ def __init__(self, resource_group_name, vm_name, ssh_ip, public_key_file, privat self.credentials_folder = os.path.abspath(credentials_folder) if credentials_folder else None def is_arc(self): - if self.resource_type == "Microsoft.HybridCompute/machines" or\ - self.resource_type == "Microsoft.ConnectedVMwarevSphere/virtualMachines": + if self.resource_type in ["Microsoft.HybridCompute/machines", + "Microsoft.ConnectedVMwarevSphere/virtualMachines"]: return True return False @@ -101,8 +101,8 @@ def __init__(self, config_path, resource_group_name, vm_name, ssh_ip, public_key self.credentials_folder = os.path.abspath(credentials_folder) if credentials_folder else None def is_arc(self): - if self.resource_type == "Microsoft.HybridCompute/machines" or\ - self.resource_type == "Microsoft.ConnectedVMwarevSphere/virtualMachines": + if self.resource_type in ["Microsoft.HybridCompute/machines", + "Microsoft.ConnectedVMwarevSphere/virtualMachines"]: return True return False diff --git a/src/ssh/azext_ssh/target_os_utils.py b/src/ssh/azext_ssh/target_os_utils.py index 3fef5c58684..7fb46a1bbca 100644 --- a/src/ssh/azext_ssh/target_os_utils.py +++ b/src/ssh/azext_ssh/target_os_utils.py @@ -9,23 +9,22 @@ from azure.cli.core import azclierror from knack import log -from . import constants as consts - logger = log.get_logger(__name__) + def send_target_os_telemetry(cmd, op_info): os_type = None - + if op_info.resource_type.lower() == "microsoft.compute": os_type = _get_azure_vm_os(cmd, op_info.resource_group_name, op_info.vm_name) elif op_info.resource_type.lower() == "microsoft.hybridcompute": os_type = _get_arc_server_os(cmd, op_info.resource_group_name, op_info.vm_name) elif op_info.resource_type.lower() == "microsoft.connectedvmwarevsphere/virtualmachines": os_type = _get_connected_vmware_os(cmd, op_info.resource_group_name, op_info.vm_name) - + if os_type: - logger.debug(f"Target OS Type: {os_type}") + logger.debug("Target OS Type: %s", os_type) telemetry.add_extension_event('ssh', {'Context.Default.AzureCLI.TargetOSType': os_type}) # Note 2: This is a temporary check while AAD login is not enabled for Windows. @@ -34,50 +33,55 @@ def send_target_os_telemetry(cmd, op_info): error_message = "SSH Login using AAD credentials is not currently supported for Windows." recommendation = colorama.Fore.YELLOW + "Please provide --local-user." + colorama.Style.RESET_ALL raise azclierror.RequiredArgumentMissingError(error_message, recommendation) - + def _get_azure_vm_os(cmd, resource_group_name, vm_name): from azure.cli.core.commands import client_factory from azure.cli.core import profiles vm = None os_type = None + # pylint: disable=broad-except try: compute_client = client_factory.get_mgmt_service_client(cmd.cli_ctx, profiles.ResourceType.MGMT_COMPUTE) vm = compute_client.virtual_machines.get(resource_group_name, vm_name) - - except Exception as e: + except Exception: return None if vm and vm.storage_profile and vm.storage_profile.os_disk and vm.storage_profile.os_disk.os_type: os_type = vm.storage_profile.os_disk.os_type + return os_type + def _get_arc_server_os(cmd, resource_group_name, vm_name): from azext_ssh._client_factory import cf_machine client = cf_machine(cmd.cli_ctx) arc = None os_type = None + # pylint: disable=broad-except try: arc = client.get(resource_group_name=resource_group_name, machine_name=vm_name) - except: + except Exception: return None if arc and arc.properties and arc.properties and arc.properties.os_name: os_type = arc.properties.os_name + return os_type + def _get_connected_vmware_os(cmd, resource_group_name, vm_name): from azext_ssh._client_factory import cf_vmware client = cf_vmware(cmd.cli_ctx) vmware = None os_type = None + # pylint: disable=broad-except try: vmware = client.get(resource_group_name=resource_group_name, virtual_machine_name=vm_name) - except: + except Exception: return None - + if vmware and vmware.os_profile and vmware.os_profile.os_type: os_type = vmware.os_profile.os_type return os_type - From a1f625b16d027bf255390f2ec4112dd40de17c1d Mon Sep 17 00:00:00 2001 From: Vivian Thiebaut Date: Wed, 14 Sep 2022 16:04:44 -0400 Subject: [PATCH 05/15] fix tests --- src/ssh/azext_ssh/resource_type_utils.py | 2 +- src/ssh/azext_ssh/tests/latest/test_custom.py | 46 ++++---- .../azext_ssh/tests/latest/test_rdp_utils.py | 4 +- .../tests/latest/test_resource_type_utils.py | 110 ++++++++++++++++++ .../azext_ssh/tests/latest/test_ssh_info.py | 10 +- .../azext_ssh/tests/latest/test_ssh_utils.py | 6 +- 6 files changed, 144 insertions(+), 34 deletions(-) create mode 100644 src/ssh/azext_ssh/tests/latest/test_resource_type_utils.py diff --git a/src/ssh/azext_ssh/resource_type_utils.py b/src/ssh/azext_ssh/resource_type_utils.py index 7407a38083a..ad0416483ce 100644 --- a/src/ssh/azext_ssh/resource_type_utils.py +++ b/src/ssh/azext_ssh/resource_type_utils.py @@ -53,7 +53,7 @@ def decide_resource_type(cmd, op_info): raise azclierror.ResourceNotFoundError( f"Unable to find resource {op_info.vm_name} of type " f"{consts.RESOURCE_TYPE_LOWER_CASE_TO_CORRECT_CASE[op_info.resource_type.lower()]} " - f"under the resource group {op_info.resource_group}", + f"under the resource group {op_info.resource_group_name}", consts.RECOMMENDATION_RESOURCE_NOT_FOUND) else: diff --git a/src/ssh/azext_ssh/tests/latest/test_custom.py b/src/ssh/azext_ssh/tests/latest/test_custom.py index 69e1b6f3c2c..bc5f03effc2 100644 --- a/src/ssh/azext_ssh/tests/latest/test_custom.py +++ b/src/ssh/azext_ssh/tests/latest/test_custom.py @@ -11,7 +11,6 @@ from azext_ssh import ssh_info from azure.cli.core import azclierror -from azure.core.exceptions import ResourceNotFoundError class SshCustomCommandTest(unittest.TestCase): @@ -19,7 +18,7 @@ class SshCustomCommandTest(unittest.TestCase): @mock.patch('azext_ssh.custom._do_ssh_op') @mock.patch('azext_ssh.custom._assert_args') @mock.patch('azext_ssh.ssh_info.SSHSession') - @mock.patch('azext_ssh.custom._decide_resource_type') + @mock.patch('azext_ssh.resource_type_utils.decide_resource_type') def test_ssh_vm(self, mock_type, mock_info, mock_assert, mock_do_op): cmd = mock.Mock() ssh_info = mock.Mock() @@ -37,7 +36,7 @@ def test_ssh_vm(self, mock_type, mock_info, mock_assert, mock_do_op): @mock.patch('azext_ssh.custom._do_ssh_op') @mock.patch('azext_ssh.custom._assert_args') @mock.patch('azext_ssh.ssh_info.SSHSession') - @mock.patch('azext_ssh.custom._decide_resource_type') + @mock.patch('azext_ssh.resource_type_utils.decide_resource_type') @mock.patch('platform.system') def test_ssh_vm_rdp(self, mock_sys, mock_type, mock_info, mock_assert, mock_do_op): cmd = mock.Mock() @@ -57,7 +56,7 @@ def test_ssh_vm_rdp(self, mock_sys, mock_type, mock_info, mock_assert, mock_do_o @mock.patch('azext_ssh.custom._do_ssh_op') @mock.patch('azext_ssh.custom._assert_args') @mock.patch('azext_ssh.ssh_info.SSHSession') - @mock.patch('azext_ssh.custom._decide_resource_type') + @mock.patch('azext_ssh.resource_type_utils.decide_resource_type') def test_ssh_vm_debug(self, mock_type, mock_info, mock_assert, mock_do_op): cmd = mock.Mock() ssh_info = mock.Mock() @@ -73,7 +72,7 @@ def test_ssh_vm_debug(self, mock_type, mock_info, mock_assert, mock_do_op): mock_do_op.assert_called_once_with(cmd, ssh_info, ssh_utils.start_ssh_connection) @mock.patch('azext_ssh.custom._do_ssh_op') - @mock.patch('azext_ssh.custom._decide_resource_type') + @mock.patch('azext_ssh.resource_type_utils.decide_resource_type') @mock.patch('os.environ.get') @mock.patch('azext_ssh.custom._assert_args') @mock.patch('azext_ssh.ssh_info.SSHSession') @@ -100,7 +99,7 @@ def test_delete_credentials_not_cloudshell(self, mock_getenv): @mock.patch('azext_ssh.custom._assert_args') @mock.patch('azext_ssh.custom._do_ssh_op') - @mock.patch('azext_ssh.custom._decide_resource_type') + @mock.patch('azext_ssh.resource_type_utils.decide_resource_type') @mock.patch('os.path.dirname') @mock.patch('os.path.isdir') @mock.patch('azext_ssh.ssh_info.ConfigSession') @@ -131,10 +130,10 @@ def test_ssh_config_no_cred_folder(self, mock_join, mock_info, mock_isdir, mock_ mock_type.assert_called_once_with(cmd, config_info) mock_assert.assert_called_once_with("rg", "vm", "ip", "type", "cert", "user") mock_do_op.assert_called_once_with(cmd, config_info, ssh_utils.write_ssh_config) - + @mock.patch('azext_ssh.custom._assert_args') @mock.patch('azext_ssh.custom._do_ssh_op') - @mock.patch('azext_ssh.custom._decide_resource_type') + @mock.patch('azext_ssh.resource_type_utils.decide_resource_type') @mock.patch('azext_ssh.ssh_info.ConfigSession') @mock.patch('os.path.isdir') @mock.patch('os.path.dirname') @@ -158,13 +157,13 @@ def test_ssh_config_credentials_folder_and_key(self): self.assertRaises( azclierror.ArgumentUsageError, custom.ssh_config, cmd, 'path', 'rg', 'vm', 'ip', 'pub', 'priv', True, False, 'user', 'cert', 'port', 'type', 'cred', 'proxy', 'client' ) - + @mock.patch('azext_ssh.custom.ssh_vm') def test_ssh_arc(self, mock_vm): cmd = mock.Mock() - custom.ssh_arc(cmd, "rg", "vm", "pub", "priv", "user", "cert", "port", "client", False, "proxy", False, []) + custom.ssh_arc(cmd, "rg", "vm", "pub", "priv", "user", "cert", "port", None, "client", False, "proxy", False, []) - mock_vm.assert_called_once_with(cmd, "rg", "vm", None, "pub", "priv", False, "user", "cert", "port", "client", False, "Microsoft.HybridCompute", "proxy", False, []) + mock_vm.assert_called_once_with(cmd, "rg", "vm", None, "pub", "priv", False, "user", "cert", "port", "client", False, "arc", "proxy", False, []) def test_ssh_cert_no_args(self): cmd = mock.Mock() @@ -193,10 +192,10 @@ def test_ssh_cert(self, mock_write_cert, mock_get_keys, mock_abspath, mock_isdir mock_get_keys.assert_called_once_with('/pubkey/path', None, None, '/client/path') mock_write_cert.assert_called_once_with(cmd, 'pubkey', '/cert/path', '/client/path') - + def test_assert_args_invalid_resource_type(self): self.assertRaises(azclierror.InvalidArgumentValueError, custom._assert_args, 'rg', 'vm', 'ip', "Microsoft.Network", 'cert', 'user') - + def test_assert_args_no_ip_or_vm(self): self.assertRaises(azclierror.RequiredArgumentMissingError, custom._assert_args, None, None, None, None, None, None) @@ -215,8 +214,9 @@ def test_assert_args_cert_with_no_user(self): @mock.patch('os.path.isfile') def test_assert_args_invalid_cert_filepath(self, mock_is_file): mock_is_file.return_value = False + # Legacy Resource Type shouldn't raise error. self.assertRaises(azclierror.FileOperationError, custom._assert_args, 'rg', 'vm', None, 'Microsoft.HybridCompute', 'cert_path', 'username') - + @mock.patch('azext_ssh.ssh_utils.create_ssh_keyfile') @mock.patch('tempfile.mkdtemp') @mock.patch('os.path.isfile') @@ -360,7 +360,7 @@ def test_do_ssh_op_aad_user_compute(self, mock_write_cert, mock_ssh_creds, mock_ cmd.cli_ctx.cloud = mock.Mock() cmd.cli_ctx.cloud.name = "azurecloud" - op_info = ssh_info.SSHSession(None, None, "1.2.3.4", None, None, False, None, None, None, None, None, None, "Microsoft.Compute", None, None, False) + op_info = ssh_info.SSHSession(None, None, "1.2.3.4", None, None, False, None, None, None, None, None, None, "Microsoft.Compute/virtualMachines", None, None, False) op_info.public_key_file = "publicfile" op_info.private_key_file = "privatefile" op_info.ssh_client_folder = "/client/folder" @@ -389,7 +389,7 @@ def test_do_ssh_op_local_user_compute(self, mock_ip, mock_check_files): mock_op = mock.Mock() mock_ip.return_value = "1.2.3.4" - op_info = ssh_info.ConfigSession("config", "rg", "vm", None, None, None, False, False, "username", None, None, "Microsoft.Compute", None, None, None) + op_info = ssh_info.ConfigSession("config", "rg", "vm", None, None, None, False, False, "username", None, None, "Microsoft.Compute/virtualMachines", None, None, None) op_info.public_key_file = "publicfile" op_info.private_key_file = "privatefile" op_info.cert_file = "cert" @@ -408,7 +408,7 @@ def test_do_ssh_op_no_public_ip(self, mock_ip, mock_check_files): mock_op = mock.Mock() mock_ip.return_value = None - op_info = ssh_info.SSHSession("rg", "vm", None, None, None, False, None, None, None, None, None, None, "Microsoft.Compute", None, None, False) + op_info = ssh_info.SSHSession("rg", "vm", None, None, None, False, None, None, None, None, None, None, "Microsoft.Compute/virtualMachines", None, None, False) self.assertRaises( azclierror.ResourceNotFoundError, custom._do_ssh_op, cmd, op_info, mock_op) @@ -426,7 +426,7 @@ def test_do_ssh_op_arc_local_user(self, mock_get_cert, mock_check_keys, mock_sta cmd = mock.Mock() mock_op = mock.Mock() - op_info = ssh_info.SSHSession("rg", "vm", None, None, None, False, "user", None, "port", None, [], False, "Microsoft.HybridCompute", None, None, False) + op_info = ssh_info.SSHSession("rg", "vm", None, None, None, False, "user", None, "port", None, [], False, "Microsoft.HybridCompute/machines", None, None, False) op_info.private_key_file = "priv" op_info.cert_file = "cert" op_info.ssh_client_folder = "client" @@ -471,7 +471,7 @@ def test_do_ssh_arc_op_aad_user(self, mock_cert_exp, mock_start_ssh, mock_write_ mock_op = mock.Mock() - op_info = ssh_info.SSHSession("rg", "vm", None, None, None, False, None, None, "port", None, [], False, "Microsoft.HybridCompute", None, None, False) + op_info = ssh_info.SSHSession("rg", "vm", None, None, None, False, None, None, "port", None, [], False, "Microsoft.HybridCompute/machines", None, None, False) op_info.public_key_file = "publicfile" op_info.private_key_file = "privatefile" op_info.ssh_client_folder = "client" @@ -488,7 +488,7 @@ def test_do_ssh_arc_op_aad_user(self, mock_cert_exp, mock_start_ssh, mock_write_ mock_get_proxy.assert_called_once_with('proxy') mock_get_relay_info.assert_called_once_with(cmd, 'rg', 'vm', 3600) mock_op.assert_called_once_with(op_info, False, True) - + ''' def test_decide_resource_type_ip(self): cmd = mock.Mock() op_info = ssh_info.SSHSession(None, None, "ip", None, None, False, None, None, None, None, [], False, None, None, None, False) @@ -498,14 +498,14 @@ def test_decide_resource_type_ip(self): def test_decide_resource_type_resourcetype_arc(self, mock_is_arc): cmd = mock.Mock() mock_is_arc.return_value = None, None, True - op_info = ssh_info.SSHSession("rg", "vm", None, None, None, False, None, None, None, None, [], False, "Microsoft.HybridCompute", None, None, False) + op_info = ssh_info.SSHSession("rg", "vm", None, None, None, False, None, None, None, None, [], False, "Microsoft.HybridCompute/machines", None, None, False) self.assertEqual(custom._decide_resource_type(cmd, op_info), "Microsoft.HybridCompute") @mock.patch('azext_ssh.custom._check_if_azure_vm') def test_decide_resource_type_resourcetype_arc(self, mock_is_vm): cmd = mock.Mock() mock_is_vm.return_value = None, None, True - op_info = ssh_info.SSHSession("rg", "vm", None, None, None, False, None, None, None, None, [], False, "Microsoft.Compute", None, None, False) + op_info = ssh_info.SSHSession("rg", "vm", None, None, None, False, None, None, None, None, [], False, "Microsoft.Compute/virtualMachines", None, None, False) self.assertEqual(custom._decide_resource_type(cmd, op_info), "Microsoft.Compute") @mock.patch('azext_ssh.custom._check_if_azure_vm') @@ -545,7 +545,7 @@ def test_decide_resource_type_rg_vm_arc(self, mock_is_arc, mock_is_vm): mock_is_arc.return_value = None, ResourceNotFoundError(), False op_info = ssh_info.SSHSession("rg", "vm", None, None, None, False, None, None, None, None, [], False, None, None, None, False) self.assertEqual(custom._decide_resource_type(cmd, op_info), "Microsoft.Compute") - + ''' if __name__ == '__main__': unittest.main() diff --git a/src/ssh/azext_ssh/tests/latest/test_rdp_utils.py b/src/ssh/azext_ssh/tests/latest/test_rdp_utils.py index 74489140d52..da0db68bc45 100644 --- a/src/ssh/azext_ssh/tests/latest/test_rdp_utils.py +++ b/src/ssh/azext_ssh/tests/latest/test_rdp_utils.py @@ -16,7 +16,7 @@ class RDPUtilsTest(unittest.TestCase): @mock.patch('azext_ssh.custom.connectivity_utils.format_relay_info_string') @mock.patch("subprocess.Popen") def test_start_ssh_tunnel(self, mock_popen, mock_relay, mock_path, mock_env): - op_info = ssh_info.SSHSession("rg", "vm", None, None, None, False, "user", None, "port", None, ['arg1', 'arg2', '-v'], False, "Microsoft.HybridCompute", None, None, True) + op_info = ssh_info.SSHSession("rg", "vm", None, None, None, False, "user", None, "port", None, ['arg1', 'arg2', '-v'], False, "Microsoft.HybridCompute/machines", None, None, True) op_info.public_key_file = "pub" op_info.private_key_file = "priv" op_info.cert_file = "cert" @@ -70,7 +70,7 @@ def test_get_rdp_path(self, mock_isfile, mock_join, mock_env, mock_arch, mock_sy @mock.patch.object(rdp_utils, 'call_rdp') @mock.patch.object(rdp_utils, 'terminate_ssh') def test_start_rdp_connection(self, mock_terminate, mock_rdp, mock_wait, mock_tunnel, mock_isopen, mock_getport): - op_info = ssh_info.SSHSession("rg", "vm", None, None, None, False, "user", None, "port", None, ['arg1', 'arg2'], False, "Microsoft.HybridCompute", None, None, True) + op_info = ssh_info.SSHSession("rg", "vm", None, None, None, False, "user", None, "port", None, ['arg1', 'arg2'], False, "Microsoft.HybridCompute/machines", None, None, True) op_info.public_key_file = "pub" op_info.private_key_file = "priv" op_info.cert_file = "cert" diff --git a/src/ssh/azext_ssh/tests/latest/test_resource_type_utils.py b/src/ssh/azext_ssh/tests/latest/test_resource_type_utils.py new file mode 100644 index 00000000000..a73df6e8915 --- /dev/null +++ b/src/ssh/azext_ssh/tests/latest/test_resource_type_utils.py @@ -0,0 +1,110 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- +import io +import unittest +from unittest import mock +from azext_ssh import resource_type_utils +from azext_ssh import rdp_utils +from azext_ssh import ssh_utils +from azext_ssh import ssh_info + +from azure.cli.core import azclierror + +class SshResourceTypeUtilsCommandTest(unittest.TestCase): + + @mock.patch('azext_ssh.resource_type_utils._list_types_of_resources_with_provided_name') + def test_decide_resource_type_ip(self, mock_list_types): + cmd = mock.Mock() + op_info = ssh_info.SSHSession(None, None, "ip", None, None, False, None, None, None, None, [], False, None, None, None, False) + self.assertEqual(resource_type_utils.decide_resource_type(cmd, op_info), "Microsoft.Compute/virtualMachines") + mock_list_types.assert_not_called() + + ################################ Test Resource Type Provided ############################## + + @mock.patch('azext_ssh.resource_type_utils._list_types_of_resources_with_provided_name') + def test_decide_resource_type_resourcetype_arc(self, mock_list_types): + cmd = mock.Mock() + mock_list_types.return_value = {'microsoft.hybridcompute/machines', 'microsoft.compute/virtualmachines'} + op_info = ssh_info.SSHSession("rg", "vm", None, None, None, False, None, None, None, None, [], False, "Microsoft.HybridCompute/machines", None, None, False) + self.assertEqual(resource_type_utils.decide_resource_type(cmd, op_info), "Microsoft.HybridCompute/machines") + + @mock.patch('azext_ssh.resource_type_utils._list_types_of_resources_with_provided_name') + def test_decide_resource_type_resourcetype_compute(self, mock_list_types): + cmd = mock.Mock() + mock_list_types.return_value = {'microsoft.hybridcompute/machines', 'microsoft.compute/virtualmachines', 'microsoft.connectedvmwarevsphere/virtualmachines'} + op_info = ssh_info.SSHSession("rg", "vm", None, None, None, False, None, None, None, None, [], False, "Microsoft.Compute/virtualMachines", None, None, False) + self.assertEqual(resource_type_utils.decide_resource_type(cmd, op_info), "Microsoft.Compute/virtualMachines") + + @mock.patch('azext_ssh.resource_type_utils._list_types_of_resources_with_provided_name') + def test_decide_resource_type_resourcetype_vmware(self, mock_list_types): + cmd = mock.Mock() + mock_list_types.return_value = {'microsoft.hybridcompute/machines', 'microsoft.compute/virtualmachines', 'microsoft.connectedvmwarevsphere/virtualmachines'} + op_info = ssh_info.SSHSession("rg", "vm", None, None, None, False, None, None, None, None, [], False, "Microsoft.connectedvmwarevsphere/virtualMachines", None, None, False) + self.assertEqual(resource_type_utils.decide_resource_type(cmd, op_info), "Microsoft.ConnectedVMwarevSphere/virtualMachines") + + + ############################ Test Legacy Resource Type (Resource Provider) ########################## + @mock.patch('azext_ssh.resource_type_utils._list_types_of_resources_with_provided_name') + def test_decide_resource_type_resourcetype_arc_legacy(self, mock_list_types): + cmd = mock.Mock() + mock_list_types.return_value = {'microsoft.hybridcompute/machines', 'microsoft.compute/virtualmachines'} + op_info = ssh_info.SSHSession("rg", "vm", None, None, None, False, None, None, None, None, [], False, "Microsoft.HybridCompute", None, None, False) + self.assertEqual(resource_type_utils.decide_resource_type(cmd, op_info), "Microsoft.HybridCompute/machines") + + @mock.patch('azext_ssh.resource_type_utils._list_types_of_resources_with_provided_name') + def test_decide_resource_type_resourcetype_compute_legacy(self, mock_list_types): + cmd = mock.Mock() + mock_list_types.return_value = {'microsoft.hybridcompute/machines', 'microsoft.compute/virtualmachines', 'microsoft.connectedvmwarevsphere/virtualmachines'} + op_info = ssh_info.SSHSession("rg", "vm", None, None, None, False, None, None, None, None, [], False, "Microsoft.Compute", None, None, False) + self.assertEqual(resource_type_utils.decide_resource_type(cmd, op_info), "Microsoft.Compute/virtualMachines") + + @mock.patch('azext_ssh.resource_type_utils._list_types_of_resources_with_provided_name') + def test_decide_resource_type_resourcetype_vmware_legacy(self, mock_list_types): + cmd = mock.Mock() + mock_list_types.return_value = {'microsoft.hybridcompute/machines', 'microsoft.compute/virtualmachines', 'microsoft.connectedvmwarevsphere/virtualmachines'} + op_info = ssh_info.SSHSession("rg", "vm", None, None, None, False, None, None, None, None, [], False, "Microsoft.connectedvmwarevsphere", None, None, False) + self.assertEqual(resource_type_utils.decide_resource_type(cmd, op_info), "Microsoft.ConnectedVMwarevSphere/virtualMachines") + + ############################# Test No Resource Type Provided ################################### + @mock.patch('azext_ssh.resource_type_utils._list_types_of_resources_with_provided_name') + def test_decide_resource_type_more_than_one(self, mock_list_types): + cmd = mock.Mock() + mock_list_types.return_value = {'microsoft.hybridcompute/machines', 'microsoft.compute/virtualmachines', 'microsoft.connectedvmwarevsphere/virtualmachines'} + op_info = ssh_info.SSHSession("rg", "vm", None, None, None, False, None, None, None, None, [], False, None, None, None, False) + self.assertRaises( + azclierror.BadRequestError, resource_type_utils.decide_resource_type, cmd, op_info) + + @mock.patch('azext_ssh.resource_type_utils._list_types_of_resources_with_provided_name') + def test_decide_resource_type_rg_vm_neither(self, mock_list_types): + cmd = mock.Mock() + mock_list_types.return_value = {} + op_info = ssh_info.SSHSession("rg", "vm", None, None, None, False, None, None, None, None, [], False, None, None, None, False) + self.assertRaises( + azclierror.ResourceNotFoundError, resource_type_utils.decide_resource_type, cmd, op_info) + + @mock.patch('azext_ssh.resource_type_utils._list_types_of_resources_with_provided_name') + def test_decide_resource_type_rg_arc(self, mock_list_types): + cmd = mock.Mock() + mock_list_types.return_value = {"microsoft.hybridcompute/machines"} + op_info = ssh_info.SSHSession("rg", "vm", None, None, None, False, None, None, None, None, [], False, None, None, None, False) + self.assertEqual(resource_type_utils.decide_resource_type(cmd, op_info), "Microsoft.HybridCompute/machines") + + @mock.patch('azext_ssh.resource_type_utils._list_types_of_resources_with_provided_name') + def test_decide_resource_type_rg_vm(self, mock_list_types): + cmd = mock.Mock() + mock_list_types.return_value = {"microsoft.compute/virtualmachines"} + op_info = ssh_info.SSHSession("rg", "vm", None, None, None, False, None, None, None, None, [], False, None, None, None, False) + self.assertEqual(resource_type_utils.decide_resource_type(cmd, op_info), "Microsoft.Compute/virtualMachines") + + @mock.patch('azext_ssh.resource_type_utils._list_types_of_resources_with_provided_name') + def test_decide_resource_type_rg_vmware(self, mock_list_types): + cmd = mock.Mock() + mock_list_types.return_value = {'microsoft.connectedvmwarevsphere/virtualmachines'} + op_info = ssh_info.SSHSession("rg", "vm", None, None, None, False, None, None, None, None, [], False, None, None, None, False) + self.assertEqual(resource_type_utils.decide_resource_type(cmd, op_info), "Microsoft.ConnectedVMwarevSphere/virtualMachines") + + + if __name__ == '__main__': + unittest.main() \ No newline at end of file diff --git a/src/ssh/azext_ssh/tests/latest/test_ssh_info.py b/src/ssh/azext_ssh/tests/latest/test_ssh_info.py index 517b554f1d3..c40921b2c2f 100644 --- a/src/ssh/azext_ssh/tests/latest/test_ssh_info.py +++ b/src/ssh/azext_ssh/tests/latest/test_ssh_info.py @@ -44,21 +44,21 @@ def test_ssh_session(self, mock_abspath): def test_ssh_session_get_host(self): - session = ssh_info.SSHSession(None, None, "ip", None, None, False, "user", None, None, None, [], False, "Microsoft.Compute", None, None, False) + session = ssh_info.SSHSession(None, None, "ip", None, None, False, "user", None, None, None, [], False, "Microsoft.Compute/virtualMachines", None, None, False) self.assertEqual("user@ip", session.get_host()) - session = ssh_info.SSHSession("rg", "vm", None, None, None, False, "user", None, None, None, [], False, "Microsoft.HybridCompute", None, None, True) + session = ssh_info.SSHSession("rg", "vm", None, None, None, False, "user", None, None, None, [], False, "Microsoft.HybridCompute/machines", None, None, True) self.assertEqual("user@vm", session.get_host()) @mock.patch('os.path.abspath') def test_ssh_session_build_args_compute(self, mock_abspath): mock_abspath.side_effect = ["pub_path", "priv_path", "cert_path", "client_path"] - session = ssh_info.SSHSession("rg", "vm", "ip", "pub", "priv", False, "user", "cert", "port", "client/folder", [], None, "Microsoft.Compute", None, None, False) + session = ssh_info.SSHSession("rg", "vm", "ip", "pub", "priv", False, "user", "cert", "port", "client/folder", [], None, "Microsoft.Compute/virtualMachines", None, None, False) self.assertEqual(["-i", "priv_path", "-o", "CertificateFile=\"cert_path\"", "-p", "port"], session.build_args()) @mock.patch('os.path.abspath') def test_ssh_session_build_args_hyvridcompute(self, mock_abspath): mock_abspath.side_effect = ["pub_path", "priv_path", "cert_path", "client_path"] - session = ssh_info.SSHSession("rg", "vm", "ip", "pub", "priv", False, "user", "cert", "port", "client/folder", [], None, "Microsoft.HybridCompute", None, None, True) + session = ssh_info.SSHSession("rg", "vm", "ip", "pub", "priv", False, "user", "cert", "port", "client/folder", [], None, "Microsoft.HybridCompute/machines", None, None, True) session.proxy_path = "proxy_path" self.assertEqual(["-o", "ProxyCommand=\"proxy_path\" -p port", "-i", "priv_path", "-o", "CertificateFile=\"cert_path\""], session.build_args()) @@ -233,7 +233,7 @@ def test_get_config_text_arc(self, create_file, mock_abspath): ] mock_abspath.side_effect = ["config_path", "pub_path", "priv_path", "cert_path", "client_path", "cred_path"] - session = ssh_info.ConfigSession("config", "rg", "vm", None, "pub", "priv", False, False, "user", "cert", None, "Microsoft.HybridCompute", "cred", None, "client/folder") + session = ssh_info.ConfigSession("config", "rg", "vm", None, "pub", "priv", False, False, "user", "cert", None, "Microsoft.HybridCompute/machines", "cred", None, "client/folder") session.proxy_path = "proxy_path" self.assertEqual(session.get_config_text(True), expected_lines_aad) self.assertEqual(session.get_config_text(False), expected_lines_local_user) diff --git a/src/ssh/azext_ssh/tests/latest/test_ssh_utils.py b/src/ssh/azext_ssh/tests/latest/test_ssh_utils.py index 26877814d08..76826373a05 100644 --- a/src/ssh/azext_ssh/tests/latest/test_ssh_utils.py +++ b/src/ssh/azext_ssh/tests/latest/test_ssh_utils.py @@ -50,7 +50,7 @@ def test_start_ssh_connection_compute(self, mock_system, mock_copy_env, mock_cal @mock.patch('platform.system') def test_start_ssh_connection_arc(self, mock_system, mock_relay_str, mock_call, mock_path, mock_copy_env, mock_terminatecleanup): - op_info = ssh_info.SSHSession("rg", "vm", None, None, None, False, "user", None, "port", None, ['arg1'], False, "Microsoft.HybridCompute", None, None, False) + op_info = ssh_info.SSHSession("rg", "vm", None, None, None, False, "user", None, "port", None, ['arg1'], False, "Microsoft.HybridCompute/machines", None, None, False) op_info.public_key_file = "pub" op_info.private_key_file = "priv" op_info.cert_file = "cert" @@ -77,7 +77,7 @@ def test_start_ssh_connection_arc(self, mock_system, mock_relay_str, mock_call, @mock.patch.object(ssh_utils, '_issue_config_cleanup_warning') @mock.patch('os.path.abspath') def test_write_ssh_config_ip_and_vm_compute_append(self, mock_abspath, mock_warning): - op_info = ssh_info.ConfigSession("config", "rg", "vm", "ip", None, None, False, False, "user", None, "port", "Microsoft.Compute", None, None, "client") + op_info = ssh_info.ConfigSession("config", "rg", "vm", "ip", None, None, False, False, "user", None, "port", "Microsoft.Compute/virtualMachines", None, None, "client") op_info.config_path = "config" op_info.ssh_client_folder = "client" op_info.private_key_file = "priv" @@ -112,7 +112,7 @@ def test_write_ssh_config_ip_and_vm_compute_append(self, mock_abspath, mock_warn @mock.patch('os.path.abspath') @mock.patch.object(ssh_info.ConfigSession, '_create_relay_info_file') def test_write_ssh_config_arc_overwrite(self, mock_create_file, mock_abspath, mock_warning): - op_info = ssh_info.ConfigSession("config", "rg", "vm", None, None, None, True, False, "user", None, "port", "Microsoft.HybridCompute", None, None, "client") + op_info = ssh_info.ConfigSession("config", "rg", "vm", None, None, None, True, False, "user", None, "port", "Microsoft.HybridCompute/machines", None, None, "client") op_info.config_path = "config" op_info.ssh_client_folder = "client" op_info.private_key_file = "priv" From 649ce2c1f0a956f9f219c44c2f6fc04fe2175565 Mon Sep 17 00:00:00 2001 From: Vivian Thiebaut Date: Thu, 15 Sep 2022 11:29:54 -0400 Subject: [PATCH 06/15] Remove hard-coded resource type from hybridconnectivity sdk --- src/ssh/azext_ssh/connectivity_utils.py | 18 +++--- src/ssh/azext_ssh/custom.py | 3 +- src/ssh/azext_ssh/tests/latest/test_custom.py | 62 +------------------ .../operations/_endpoints_operations.py | 8 ++- 4 files changed, 21 insertions(+), 70 deletions(-) diff --git a/src/ssh/azext_ssh/connectivity_utils.py b/src/ssh/azext_ssh/connectivity_utils.py index fd38dab6281..9e99a026f46 100644 --- a/src/ssh/azext_ssh/connectivity_utils.py +++ b/src/ssh/azext_ssh/connectivity_utils.py @@ -28,7 +28,7 @@ # Get the Access Details to connect to Arc Connectivity platform from the HybridConnectivity RP -def get_relay_information(cmd, resource_group, vm_name, certificate_validity_in_seconds): +def get_relay_information(cmd, resource_group, vm_name, resource_type, certificate_validity_in_seconds): from azext_ssh._client_factory import cf_endpoint client = cf_endpoint(cmd.cli_ctx) @@ -39,16 +39,18 @@ def get_relay_information(cmd, resource_group, vm_name, certificate_validity_in_ try: t0 = time.time() result = client.list_credentials(resource_group_name=resource_group, machine_name=vm_name, - endpoint_name="default", expiresin=certificate_validity_in_seconds) + resource_type=resource_type, endpoint_name="default", + expiresin=certificate_validity_in_seconds) time_elapsed = time.time() - t0 telemetry.add_extension_event('ssh', {'Context.Default.AzureCLI.SSHListCredentialsTime': time_elapsed}) except ResourceNotFoundError: logger.debug("Default Endpoint couldn't be found. Trying to create Default Endpoint.") - _create_default_endpoint(cmd, resource_group, vm_name, client) + _create_default_endpoint(cmd, resource_group, vm_name, resource_type, client) try: t0 = time.time() result = client.list_credentials(resource_group_name=resource_group, machine_name=vm_name, - endpoint_name="default", expiresin=certificate_validity_in_seconds) + resource_type=resource_type, endpoint_name="default", + expiresin=certificate_validity_in_seconds) time_elapsed = time.time() - t0 telemetry.add_extension_event('ssh', {'Context.Default.AzureCLI.SSHListCredentialsTime': time_elapsed}) except Exception as e: @@ -58,12 +60,14 @@ def get_relay_information(cmd, resource_group, vm_name, certificate_validity_in_ return result -def _create_default_endpoint(cmd, resource_group, vm_name, client): +def _create_default_endpoint(cmd, resource_group, vm_name, resource_type, client): + namespace = resource_type.split('/', 1)[0] + arc_type = resource_type.split('/', 1)[1] az_resource_id = resource_id(subscription=get_subscription_id(cmd.cli_ctx), resource_group=resource_group, - namespace="Microsoft.HybridCompute", type="machines", name=vm_name) + namespace=namespace, type=arc_type, name=vm_name) endpoint_resource = {"id": az_resource_id, "type_properties_type": "default"} try: - client.create_or_update(resource_group, vm_name, "default", endpoint_resource) + client.create_or_update(resource_group, vm_name, resource_type, "default", endpoint_resource) except Exception as e: colorama.init() raise azclierror.UnauthorizedError(f"Unable to create Default Endpoint for {vm_name} in {resource_group}." diff --git a/src/ssh/azext_ssh/custom.py b/src/ssh/azext_ssh/custom.py index 68446b36468..2badd399097 100644 --- a/src/ssh/azext_ssh/custom.py +++ b/src/ssh/azext_ssh/custom.py @@ -188,7 +188,8 @@ def _do_ssh_op(cmd, op_info, op_call): if op_info.is_arc(): op_info.proxy_path = connectivity_utils.get_client_side_proxy(op_info.ssh_proxy_folder) op_info.relay_info = connectivity_utils.get_relay_information(cmd, op_info.resource_group_name, - op_info.vm_name, cert_lifetime) + op_info.vm_name, op_info.resource_type, + cert_lifetime) except Exception as e: if delete_keys or delete_cert: logger.debug("An error occured before operation concluded. Deleting generated keys: %s %s %s", diff --git a/src/ssh/azext_ssh/tests/latest/test_custom.py b/src/ssh/azext_ssh/tests/latest/test_custom.py index bc5f03effc2..e74dec5dd15 100644 --- a/src/ssh/azext_ssh/tests/latest/test_custom.py +++ b/src/ssh/azext_ssh/tests/latest/test_custom.py @@ -435,7 +435,7 @@ def test_do_ssh_op_arc_local_user(self, mock_get_cert, mock_check_keys, mock_sta custom._do_ssh_op(cmd, op_info, mock_op) mock_get_proxy.assert_called_once_with('proxy') - mock_get_relay_info.assert_called_once_with(cmd, 'rg', 'vm', None) + mock_get_relay_info.assert_called_once_with(cmd, 'rg', 'vm', 'Microsoft.HybridCompute/machines', None) mock_op.assert_called_once_with(op_info, False, False) mock_get_cert.assert_not_called() mock_check_keys.assert_not_called() @@ -486,66 +486,8 @@ def test_do_ssh_arc_op_aad_user(self, mock_cert_exp, mock_start_ssh, mock_write_ mock_get_mod_exp.assert_called_once_with("public") mock_write_cert.assert_called_once_with("certificate", "public-aadcert.pub") mock_get_proxy.assert_called_once_with('proxy') - mock_get_relay_info.assert_called_once_with(cmd, 'rg', 'vm', 3600) + mock_get_relay_info.assert_called_once_with(cmd, 'rg', 'vm', 'Microsoft.HybridCompute/machines', 3600) mock_op.assert_called_once_with(op_info, False, True) - ''' - def test_decide_resource_type_ip(self): - cmd = mock.Mock() - op_info = ssh_info.SSHSession(None, None, "ip", None, None, False, None, None, None, None, [], False, None, None, None, False) - self.assertEqual(custom._decide_resource_type(cmd, op_info), "Microsoft.Compute") - - @mock.patch('azext_ssh.custom._check_if_arc_server') - def test_decide_resource_type_resourcetype_arc(self, mock_is_arc): - cmd = mock.Mock() - mock_is_arc.return_value = None, None, True - op_info = ssh_info.SSHSession("rg", "vm", None, None, None, False, None, None, None, None, [], False, "Microsoft.HybridCompute/machines", None, None, False) - self.assertEqual(custom._decide_resource_type(cmd, op_info), "Microsoft.HybridCompute") - - @mock.patch('azext_ssh.custom._check_if_azure_vm') - def test_decide_resource_type_resourcetype_arc(self, mock_is_vm): - cmd = mock.Mock() - mock_is_vm.return_value = None, None, True - op_info = ssh_info.SSHSession("rg", "vm", None, None, None, False, None, None, None, None, [], False, "Microsoft.Compute/virtualMachines", None, None, False) - self.assertEqual(custom._decide_resource_type(cmd, op_info), "Microsoft.Compute") - - @mock.patch('azext_ssh.custom._check_if_azure_vm') - @mock.patch('azext_ssh.custom._check_if_arc_server') - def test_decide_resource_type_rg_vm_both(self, mock_is_arc, mock_is_vm): - cmd = mock.Mock() - mock_is_vm.return_value = None, None, True - mock_is_arc.return_value = None, None, True - op_info = ssh_info.SSHSession("rg", "vm", None, None, None, False, None, None, None, None, [], False, None, None, None, False) - self.assertRaises( - azclierror.BadRequestError, custom._decide_resource_type, cmd, op_info) - - @mock.patch('azext_ssh.custom._check_if_azure_vm') - @mock.patch('azext_ssh.custom._check_if_arc_server') - def test_decide_resource_type_rg_vm_neither(self, mock_is_arc, mock_is_vm): - cmd = mock.Mock() - mock_is_vm.return_value = None, ResourceNotFoundError(), False - mock_is_arc.return_value = None, ResourceNotFoundError(), False - op_info = ssh_info.SSHSession("rg", "vm", None, None, None, False, None, None, None, None, [], False, None, None, None, False) - self.assertRaises( - azclierror.ResourceNotFoundError, custom._decide_resource_type, cmd, op_info) - - @mock.patch('azext_ssh.custom._check_if_azure_vm') - @mock.patch('azext_ssh.custom._check_if_arc_server') - def test_decide_resource_type_rg_vm_arc(self, mock_is_arc, mock_is_vm): - cmd = mock.Mock() - mock_is_vm.return_value = None, ResourceNotFoundError(), False - mock_is_arc.return_value = None, None, True - op_info = ssh_info.SSHSession("rg", "vm", None, None, None, False, None, None, None, None, [], False, None, None, None, False) - self.assertEqual(custom._decide_resource_type(cmd, op_info), "Microsoft.HybridCompute") - - @mock.patch('azext_ssh.custom._check_if_azure_vm') - @mock.patch('azext_ssh.custom._check_if_arc_server') - def test_decide_resource_type_rg_vm_arc(self, mock_is_arc, mock_is_vm): - cmd = mock.Mock() - mock_is_vm.return_value = None, None, True - mock_is_arc.return_value = None, ResourceNotFoundError(), False - op_info = ssh_info.SSHSession("rg", "vm", None, None, None, False, None, None, None, None, [], False, None, None, None, False) - self.assertEqual(custom._decide_resource_type(cmd, op_info), "Microsoft.Compute") - ''' if __name__ == '__main__': unittest.main() diff --git a/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/operations/_endpoints_operations.py b/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/operations/_endpoints_operations.py index d591c41d544..e49a08fe5a9 100644 --- a/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/operations/_endpoints_operations.py +++ b/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/operations/_endpoints_operations.py @@ -49,6 +49,7 @@ def create_or_update( self, resource_group_name, # type: str machine_name, # type: str + resource_type, #type: str endpoint_name, # type: str endpoint_resource, # type: "models.EndpointResource" **kwargs # type: Any @@ -83,6 +84,7 @@ def create_or_update( 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), 'machineName': self._serialize.url("machine_name", machine_name, 'str'), + 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), 'endpointName': self._serialize.url("endpoint_name", endpoint_name, 'str', skip_quote=True), } url = self._client.format_url(url, **path_format_arguments) @@ -114,12 +116,13 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.HybridConnectivity/endpoints/{endpointName}'} # type: ignore + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceType}/{machineName}/providers/Microsoft.HybridConnectivity/endpoints/{endpointName}'} # type: ignore def list_credentials( self, resource_group_name, # type: str machine_name, # type: str + resource_type, # type: str endpoint_name, # type: str expiresin=10800, # type: Optional[int] **kwargs # type: Any @@ -153,6 +156,7 @@ def list_credentials( 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), 'machineName': self._serialize.url("machine_name", machine_name, 'str'), + 'resourceType': self._serialize.url("resource_type", resource_type, 'str', min_length=1), 'endpointName': self._serialize.url("endpoint_name", endpoint_name, 'str', skip_quote=True), } url = self._client.format_url(url, **path_format_arguments) @@ -182,4 +186,4 @@ def list_credentials( return cls(pipeline_response, deserialized, {}) return deserialized - list_credentials.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/providers/Microsoft.HybridConnectivity/endpoints/{endpointName}/listCredentials'} # type: ignore + list_credentials.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceType}/{machineName}/providers/Microsoft.HybridConnectivity/endpoints/{endpointName}/listCredentials'} # type: ignore From 4136c64bfe39e17b3f9abbb6ab248995eecfbc0a Mon Sep 17 00:00:00 2001 From: Vivian Thiebaut Date: Thu, 15 Sep 2022 13:47:07 -0400 Subject: [PATCH 07/15] fix az ssh arc command --- src/ssh/azext_ssh/constants.py | 2 +- src/ssh/azext_ssh/custom.py | 3 ++- src/ssh/azext_ssh/resource_type_utils.py | 2 +- src/ssh/azext_ssh/target_os_utils.py | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/ssh/azext_ssh/constants.py b/src/ssh/azext_ssh/constants.py index 3acf108d35e..638c824b445 100644 --- a/src/ssh/azext_ssh/constants.py +++ b/src/ssh/azext_ssh/constants.py @@ -19,7 +19,7 @@ "and resource exists." + Style.RESET_ALL) RDP_TERMINATE_SSH_WAIT_TIME_IN_SECONDS = 30 -ARC_RESOURCE_TYPE_PLACEHOLDER = "arc" +ARC_RESOURCE_TYPE_PLACEHOLDER = "arc_resource_type_placeholder" SUPPORTED_RESOURCE_TYPES = ["microsoft.hybridcompute/machines", "microsoft.compute/virtualmachines", diff --git a/src/ssh/azext_ssh/custom.py b/src/ssh/azext_ssh/custom.py index 2badd399097..c366a942efe 100644 --- a/src/ssh/azext_ssh/custom.py +++ b/src/ssh/azext_ssh/custom.py @@ -269,7 +269,8 @@ def _assert_args(resource_group, vm_name, ssh_ip, resource_type, cert_file, user if resource_type and \ resource_type.lower() not in const.SUPPORTED_RESOURCE_TYPES and \ - resource_type.lower() not in const.LEGACY_SUPPORTED_RESOURCE_TYPES: + resource_type.lower() not in const.LEGACY_SUPPORTED_RESOURCE_TYPES and \ + resource_type != const.ARC_RESOURCE_TYPE_PLACEHOLDER: raise azclierror.InvalidArgumentValueError("--resource-type must be either " "\"Microsoft.Compute/virtualMachines\", " "\"Microsoft.HybridCompute/machines\", " diff --git a/src/ssh/azext_ssh/resource_type_utils.py b/src/ssh/azext_ssh/resource_type_utils.py index ad0416483ce..498e6b0759a 100644 --- a/src/ssh/azext_ssh/resource_type_utils.py +++ b/src/ssh/azext_ssh/resource_type_utils.py @@ -74,5 +74,5 @@ def decide_resource_type(cmd, op_info): target_resource_type = consts.RESOURCE_TYPE_LOWER_CASE_TO_CORRECT_CASE[types_in_rg.pop().lower()] telemetry.add_extension_event('ssh', {'Context.Default.AzureCLI.TargetResourceType': target_resource_type}) - print(target_resource_type) + return target_resource_type diff --git a/src/ssh/azext_ssh/target_os_utils.py b/src/ssh/azext_ssh/target_os_utils.py index 7fb46a1bbca..b351de47df2 100644 --- a/src/ssh/azext_ssh/target_os_utils.py +++ b/src/ssh/azext_ssh/target_os_utils.py @@ -16,9 +16,9 @@ def send_target_os_telemetry(cmd, op_info): os_type = None - if op_info.resource_type.lower() == "microsoft.compute": + if op_info.resource_type.lower() == "microsoft.compute/virtualmachines": os_type = _get_azure_vm_os(cmd, op_info.resource_group_name, op_info.vm_name) - elif op_info.resource_type.lower() == "microsoft.hybridcompute": + elif op_info.resource_type.lower() == "microsoft.hybridcompute/machines": os_type = _get_arc_server_os(cmd, op_info.resource_group_name, op_info.vm_name) elif op_info.resource_type.lower() == "microsoft.connectedvmwarevsphere/virtualmachines": os_type = _get_connected_vmware_os(cmd, op_info.resource_group_name, op_info.vm_name) From 2745cb6034f3dd4a7c4127a4ce788f242d880309 Mon Sep 17 00:00:00 2001 From: Vivian Thiebaut Date: Thu, 15 Sep 2022 14:44:01 -0400 Subject: [PATCH 08/15] small changes? --- src/ssh/azext_ssh/resource_type_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ssh/azext_ssh/resource_type_utils.py b/src/ssh/azext_ssh/resource_type_utils.py index 498e6b0759a..b4038c9aca1 100644 --- a/src/ssh/azext_ssh/resource_type_utils.py +++ b/src/ssh/azext_ssh/resource_type_utils.py @@ -74,5 +74,5 @@ def decide_resource_type(cmd, op_info): target_resource_type = consts.RESOURCE_TYPE_LOWER_CASE_TO_CORRECT_CASE[types_in_rg.pop().lower()] telemetry.add_extension_event('ssh', {'Context.Default.AzureCLI.TargetResourceType': target_resource_type}) - + logger.debug("Target Resource Type: %s", target_resource_type) return target_resource_type From 8a2208eafd46ea03d74cfc4c326fbf38b9e7dc18 Mon Sep 17 00:00:00 2001 From: Vivian Thiebaut Date: Mon, 19 Sep 2022 19:11:57 -0400 Subject: [PATCH 09/15] Fix test --- src/ssh/azext_ssh/tests/latest/test_custom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ssh/azext_ssh/tests/latest/test_custom.py b/src/ssh/azext_ssh/tests/latest/test_custom.py index e74dec5dd15..7c99a1cfd18 100644 --- a/src/ssh/azext_ssh/tests/latest/test_custom.py +++ b/src/ssh/azext_ssh/tests/latest/test_custom.py @@ -163,7 +163,7 @@ def test_ssh_arc(self, mock_vm): cmd = mock.Mock() custom.ssh_arc(cmd, "rg", "vm", "pub", "priv", "user", "cert", "port", None, "client", False, "proxy", False, []) - mock_vm.assert_called_once_with(cmd, "rg", "vm", None, "pub", "priv", False, "user", "cert", "port", "client", False, "arc", "proxy", False, []) + mock_vm.assert_called_once_with(cmd, "rg", "vm", None, "pub", "priv", False, "user", "cert", "port", "client", False, 'arc_resource_type_placeholder', "proxy", False, []) def test_ssh_cert_no_args(self): cmd = mock.Mock() From c4df9c2291ddc11b095ac1cd8b930049605cc6b2 Mon Sep 17 00:00:00 2001 From: Vivian Thiebaut Date: Tue, 20 Sep 2022 10:29:58 -0400 Subject: [PATCH 10/15] Fix errors on aio for connectedvmware caused by the changes I made to the non async operations --- ...azure_arc_vmware_management_service_api.py | 36 +- .../aio/operations/__init__.py | 22 - .../aio/operations/_clusters_operations.py | 633 --------- .../aio/operations/_datastores_operations.py | 633 --------- .../operations/_guest_agents_operations.py | 490 ------- .../aio/operations/_hosts_operations.py | 630 --------- .../_hybrid_identity_metadata_operations.py | 354 ----- .../operations/_inventory_items_operations.py | 353 ----- .../_machine_extensions_operations.py | 633 --------- .../operations/_resource_pools_operations.py | 633 --------- .../aio/operations/_vcenters_operations.py | 633 --------- .../_virtual_machine_templates_operations.py | 636 --------- .../_virtual_machines_operations.py | 1255 +---------------- .../_virtual_networks_operations.py | 633 --------- 14 files changed, 2 insertions(+), 7572 deletions(-) delete mode 100644 src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_clusters_operations.py delete mode 100644 src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_datastores_operations.py delete mode 100644 src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_guest_agents_operations.py delete mode 100644 src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_hosts_operations.py delete mode 100644 src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_hybrid_identity_metadata_operations.py delete mode 100644 src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_inventory_items_operations.py delete mode 100644 src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_machine_extensions_operations.py delete mode 100644 src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_resource_pools_operations.py delete mode 100644 src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_vcenters_operations.py delete mode 100644 src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_virtual_machine_templates_operations.py delete mode 100644 src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_virtual_networks_operations.py diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/_azure_arc_vmware_management_service_api.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/_azure_arc_vmware_management_service_api.py index 09359454d77..c959f20fc28 100644 --- a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/_azure_arc_vmware_management_service_api.py +++ b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/_azure_arc_vmware_management_service_api.py @@ -16,7 +16,7 @@ from .. import models from ._configuration import AzureArcVMwareManagementServiceAPIConfiguration -from .operations import ClustersOperations, DatastoresOperations, GuestAgentsOperations, HostsOperations, HybridIdentityMetadataOperations, InventoryItemsOperations, MachineExtensionsOperations, Operations, ResourcePoolsOperations, VCentersOperations, VirtualMachineTemplatesOperations, VirtualMachinesOperations, VirtualNetworksOperations +from .operations import VirtualMachinesOperations, Operations if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports @@ -87,40 +87,6 @@ def __init__( self.virtual_machines = VirtualMachinesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.resource_pools = ResourcePoolsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.clusters = ClustersOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.hosts = HostsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.datastores = DatastoresOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.vcenters = VCentersOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.virtual_machine_templates = VirtualMachineTemplatesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.virtual_networks = VirtualNetworksOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.inventory_items = InventoryItemsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.hybrid_identity_metadata = HybridIdentityMetadataOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.machine_extensions = MachineExtensionsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.guest_agents = GuestAgentsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - def _send_request( self, diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/__init__.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/__init__.py index 21604bbdbe2..295107adb1c 100644 --- a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/__init__.py +++ b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/__init__.py @@ -8,17 +8,6 @@ from ._operations import Operations from ._virtual_machines_operations import VirtualMachinesOperations -from ._resource_pools_operations import ResourcePoolsOperations -from ._clusters_operations import ClustersOperations -from ._hosts_operations import HostsOperations -from ._datastores_operations import DatastoresOperations -from ._vcenters_operations import VCentersOperations -from ._virtual_machine_templates_operations import VirtualMachineTemplatesOperations -from ._virtual_networks_operations import VirtualNetworksOperations -from ._inventory_items_operations import InventoryItemsOperations -from ._hybrid_identity_metadata_operations import HybridIdentityMetadataOperations -from ._machine_extensions_operations import MachineExtensionsOperations -from ._guest_agents_operations import GuestAgentsOperations from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import @@ -26,17 +15,6 @@ __all__ = [ 'Operations', 'VirtualMachinesOperations', - 'ResourcePoolsOperations', - 'ClustersOperations', - 'HostsOperations', - 'DatastoresOperations', - 'VCentersOperations', - 'VirtualMachineTemplatesOperations', - 'VirtualNetworksOperations', - 'InventoryItemsOperations', - 'HybridIdentityMetadataOperations', - 'MachineExtensionsOperations', - 'GuestAgentsOperations', ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() \ No newline at end of file diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_clusters_operations.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_clusters_operations.py deleted file mode 100644 index ed42c74da29..00000000000 --- a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_clusters_operations.py +++ /dev/null @@ -1,633 +0,0 @@ -# pylint: disable=too-many-lines -# 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, Optional, TypeVar, Union, cast - -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 -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._clusters_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_request, build_update_request -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class ClustersOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.connectedvmware.aio.AzureArcVMwareManagementServiceAPI`'s - :attr:`clusters` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - - async def _create_initial( - self, - resource_group_name: str, - cluster_name: str, - body: Optional[_models.Cluster] = None, - **kwargs: Any - ) -> _models.Cluster: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Cluster] - - if body is not None: - _json = self._serialize.body(body, 'Cluster') - else: - _json = None - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_name=cluster_name, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self._create_initial.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize('Cluster', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('Cluster', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}"} # type: ignore - - - @distributed_trace_async - async def begin_create( - self, - resource_group_name: str, - cluster_name: str, - body: Optional[_models.Cluster] = None, - **kwargs: Any - ) -> AsyncLROPoller[_models.Cluster]: - """Implements cluster PUT method. - - Create Or Update cluster. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param cluster_name: Name of the cluster. - :type cluster_name: str - :param body: Request payload. Default value is None. - :type body: ~azure.mgmt.connectedvmware.models.Cluster - :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: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Cluster or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.Cluster] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Cluster] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - 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_initial( # type: ignore - resource_group_name=resource_group_name, - cluster_name=cluster_name, - body=body, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Cluster', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'azure-async-operation'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}"} # type: ignore - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - cluster_name: str, - **kwargs: Any - ) -> _models.Cluster: - """Gets a cluster. - - Implements cluster GET method. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param cluster_name: Name of the cluster. - :type cluster_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Cluster, or the result of cls(response) - :rtype: ~azure.mgmt.connectedvmware.models.Cluster - :raises: ~azure.core.exceptions.HttpResponseError - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Cluster] - - - request = build_get_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_name=cluster_name, - api_version=api_version, - template_url=self.get.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('Cluster', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}"} # type: ignore - - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - cluster_name: str, - body: Optional[_models.ResourcePatch] = None, - **kwargs: Any - ) -> _models.Cluster: - """Updates a cluster. - - API to update certain properties of the cluster resource. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param cluster_name: Name of the cluster. - :type cluster_name: str - :param body: Resource properties to update. Default value is None. - :type body: ~azure.mgmt.connectedvmware.models.ResourcePatch - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Cluster, or the result of cls(response) - :rtype: ~azure.mgmt.connectedvmware.models.Cluster - :raises: ~azure.core.exceptions.HttpResponseError - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Cluster] - - if body is not None: - _json = self._serialize.body(body, 'ResourcePatch') - else: - _json = None - - request = build_update_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_name=cluster_name, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self.update.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('Cluster', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}"} # type: ignore - - - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - cluster_name: str, - force: Optional[bool] = None, - **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - cluster_name=cluster_name, - api_version=api_version, - force=force, - template_url=self._delete_initial.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}"} # type: ignore - - - @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - cluster_name: str, - force: Optional[bool] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes an cluster. - - Implements cluster DELETE method. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param cluster_name: Name of the cluster. - :type cluster_name: str - :param force: Whether force delete was specified. Default value is None. - :type force: bool - :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: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - 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._delete_initial( # type: ignore - resource_group_name=resource_group_name, - cluster_name=cluster_name, - force=force, - api_version=api_version, - cls=lambda x,y,z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters/{clusterName}"} # type: ignore - - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.ClustersList]: - """Implements GET clusters in a subscription. - - List of clusters in a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ClustersList or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.ClustersList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ClustersList] - - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ClustersList", 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/clusters"} # type: ignore - - @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ClustersList]: - """Implements GET clusters in a resource group. - - List of clusters in a resource group. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ClustersList or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.ClustersList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ClustersList] - - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ClustersList", 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/clusters"} # type: ignore diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_datastores_operations.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_datastores_operations.py deleted file mode 100644 index 88f72ed0920..00000000000 --- a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_datastores_operations.py +++ /dev/null @@ -1,633 +0,0 @@ -# pylint: disable=too-many-lines -# 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, Optional, TypeVar, Union, cast - -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 -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._datastores_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_request, build_update_request -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class DatastoresOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.connectedvmware.aio.AzureArcVMwareManagementServiceAPI`'s - :attr:`datastores` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - - async def _create_initial( - self, - resource_group_name: str, - datastore_name: str, - body: Optional[_models.Datastore] = None, - **kwargs: Any - ) -> _models.Datastore: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Datastore] - - if body is not None: - _json = self._serialize.body(body, 'Datastore') - else: - _json = None - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - datastore_name=datastore_name, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self._create_initial.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize('Datastore', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('Datastore', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}"} # type: ignore - - - @distributed_trace_async - async def begin_create( - self, - resource_group_name: str, - datastore_name: str, - body: Optional[_models.Datastore] = None, - **kwargs: Any - ) -> AsyncLROPoller[_models.Datastore]: - """Implements datastore PUT method. - - Create Or Update datastore. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param datastore_name: Name of the datastore. - :type datastore_name: str - :param body: Request payload. Default value is None. - :type body: ~azure.mgmt.connectedvmware.models.Datastore - :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: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Datastore or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.Datastore] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Datastore] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - 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_initial( # type: ignore - resource_group_name=resource_group_name, - datastore_name=datastore_name, - body=body, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Datastore', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'azure-async-operation'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}"} # type: ignore - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - datastore_name: str, - **kwargs: Any - ) -> _models.Datastore: - """Gets a datastore. - - Implements datastore GET method. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param datastore_name: Name of the datastore. - :type datastore_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Datastore, or the result of cls(response) - :rtype: ~azure.mgmt.connectedvmware.models.Datastore - :raises: ~azure.core.exceptions.HttpResponseError - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Datastore] - - - request = build_get_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - datastore_name=datastore_name, - api_version=api_version, - template_url=self.get.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('Datastore', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}"} # type: ignore - - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - datastore_name: str, - body: Optional[_models.ResourcePatch] = None, - **kwargs: Any - ) -> _models.Datastore: - """Updates a datastore. - - API to update certain properties of the datastore resource. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param datastore_name: Name of the datastore. - :type datastore_name: str - :param body: Resource properties to update. Default value is None. - :type body: ~azure.mgmt.connectedvmware.models.ResourcePatch - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Datastore, or the result of cls(response) - :rtype: ~azure.mgmt.connectedvmware.models.Datastore - :raises: ~azure.core.exceptions.HttpResponseError - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Datastore] - - if body is not None: - _json = self._serialize.body(body, 'ResourcePatch') - else: - _json = None - - request = build_update_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - datastore_name=datastore_name, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self.update.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('Datastore', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}"} # type: ignore - - - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - datastore_name: str, - force: Optional[bool] = None, - **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - datastore_name=datastore_name, - api_version=api_version, - force=force, - template_url=self._delete_initial.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}"} # type: ignore - - - @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - datastore_name: str, - force: Optional[bool] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes an datastore. - - Implements datastore DELETE method. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param datastore_name: Name of the datastore. - :type datastore_name: str - :param force: Whether force delete was specified. Default value is None. - :type force: bool - :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: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - 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._delete_initial( # type: ignore - resource_group_name=resource_group_name, - datastore_name=datastore_name, - force=force, - api_version=api_version, - cls=lambda x,y,z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores/{datastoreName}"} # type: ignore - - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.DatastoresList]: - """Implements GET datastores in a subscription. - - List of datastores in a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatastoresList or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.DatastoresList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DatastoresList] - - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DatastoresList", 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/datastores"} # type: ignore - - @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.DatastoresList]: - """Implements GET datastores in a resource group. - - List of datastores in a resource group. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DatastoresList or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.DatastoresList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DatastoresList] - - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("DatastoresList", 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/datastores"} # type: ignore diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_guest_agents_operations.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_guest_agents_operations.py deleted file mode 100644 index ef995f14e0b..00000000000 --- a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_guest_agents_operations.py +++ /dev/null @@ -1,490 +0,0 @@ -# pylint: disable=too-many-lines -# 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, Optional, TypeVar, Union, cast - -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 -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._guest_agents_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_by_vm_request -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class GuestAgentsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.connectedvmware.aio.AzureArcVMwareManagementServiceAPI`'s - :attr:`guest_agents` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - - async def _create_initial( - self, - resource_group_name: str, - virtual_machine_name: str, - name: str, - body: Optional[_models.GuestAgent] = None, - **kwargs: Any - ) -> _models.GuestAgent: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestAgent] - - if body is not None: - _json = self._serialize.body(body, 'GuestAgent') - else: - _json = None - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - virtual_machine_name=virtual_machine_name, - name=name, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self._create_initial.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize('GuestAgent', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('GuestAgent', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents/{name}"} # type: ignore - - - @distributed_trace_async - async def begin_create( - self, - resource_group_name: str, - virtual_machine_name: str, - name: str, - body: Optional[_models.GuestAgent] = None, - **kwargs: Any - ) -> AsyncLROPoller[_models.GuestAgent]: - """Implements GuestAgent PUT method. - - Create Or Update GuestAgent. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param virtual_machine_name: Name of the vm. - :type virtual_machine_name: str - :param name: Name of the guestAgents. - :type name: str - :param body: Request payload. Default value is None. - :type body: ~azure.mgmt.connectedvmware.models.GuestAgent - :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: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either GuestAgent or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.GuestAgent] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestAgent] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - 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_initial( # type: ignore - resource_group_name=resource_group_name, - virtual_machine_name=virtual_machine_name, - name=name, - body=body, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize('GuestAgent', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'azure-async-operation'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents/{name}"} # type: ignore - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - virtual_machine_name: str, - name: str, - **kwargs: Any - ) -> _models.GuestAgent: - """Gets GuestAgent. - - Implements GuestAgent GET method. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param virtual_machine_name: Name of the vm. - :type virtual_machine_name: str - :param name: Name of the GuestAgent. - :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: GuestAgent, or the result of cls(response) - :rtype: ~azure.mgmt.connectedvmware.models.GuestAgent - :raises: ~azure.core.exceptions.HttpResponseError - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestAgent] - - - request = build_get_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - virtual_machine_name=virtual_machine_name, - name=name, - api_version=api_version, - template_url=self.get.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('GuestAgent', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents/{name}"} # type: ignore - - - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - virtual_machine_name: str, - name: str, - **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - virtual_machine_name=virtual_machine_name, - name=name, - api_version=api_version, - template_url=self._delete_initial.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents/{name}"} # type: ignore - - - @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - virtual_machine_name: str, - name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes an GuestAgent. - - Implements GuestAgent DELETE method. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param virtual_machine_name: Name of the vm. - :type virtual_machine_name: str - :param name: Name of the GuestAgent. - :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - 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._delete_initial( # type: ignore - resource_group_name=resource_group_name, - virtual_machine_name=virtual_machine_name, - name=name, - api_version=api_version, - cls=lambda x,y,z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents/{name}"} # type: ignore - - @distributed_trace - def list_by_vm( - self, - resource_group_name: str, - virtual_machine_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.GuestAgentList]: - """Implements GET GuestAgent in a vm. - - Returns the list of GuestAgent of the given vm. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param virtual_machine_name: Name of the vm. - :type virtual_machine_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either GuestAgentList or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.GuestAgentList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.GuestAgentList] - - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_vm_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - virtual_machine_name=virtual_machine_name, - api_version=api_version, - template_url=self.list_by_vm.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - else: - - request = build_list_by_vm_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - virtual_machine_name=virtual_machine_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("GuestAgentList", 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list_by_vm.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/guestAgents"} # type: ignore diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_hosts_operations.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_hosts_operations.py deleted file mode 100644 index 3c14f97a77a..00000000000 --- a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_hosts_operations.py +++ /dev/null @@ -1,630 +0,0 @@ -# pylint: disable=too-many-lines -# 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, Optional, TypeVar, Union, cast - -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 -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._hosts_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_request, build_update_request -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class HostsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.connectedvmware.aio.AzureArcVMwareManagementServiceAPI`'s - :attr:`hosts` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - - async def _create_initial( - self, - resource_group_name: str, - host_name: str, - body: Optional[_models.Host] = None, - **kwargs: Any - ) -> _models.Host: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Host] - - if body is not None: - _json = self._serialize.body(body, 'Host') - else: - _json = None - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - host_name=host_name, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self._create_initial.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize('Host', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('Host', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}"} # type: ignore - - - @distributed_trace_async - async def begin_create( - self, - resource_group_name: str, - host_name: str, - body: Optional[_models.Host] = None, - **kwargs: Any - ) -> AsyncLROPoller[_models.Host]: - """Implements host PUT method. - - Create Or Update host. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param host_name: Name of the host. - :type host_name: str - :param body: Request payload. Default value is None. - :type body: ~azure.mgmt.connectedvmware.models.Host - :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: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either Host or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.Host] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Host] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - 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_initial( # type: ignore - resource_group_name=resource_group_name, - host_name=host_name, - body=body, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize('Host', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'azure-async-operation'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}"} # type: ignore - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - host_name: str, - **kwargs: Any - ) -> _models.Host: - """Gets a host. - - Implements host GET method. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param host_name: Name of the host. - :type host_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Host, or the result of cls(response) - :rtype: ~azure.mgmt.connectedvmware.models.Host - :raises: ~azure.core.exceptions.HttpResponseError - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Host] - - - request = build_get_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - host_name=host_name, - api_version=api_version, - template_url=self.get.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('Host', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}"} # type: ignore - - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - host_name: str, - body: Optional[_models.ResourcePatch] = None, - **kwargs: Any - ) -> _models.Host: - """Updates a host. - - API to update certain properties of the host resource. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param host_name: Name of the host. - :type host_name: str - :param body: Resource properties to update. Default value is None. - :type body: ~azure.mgmt.connectedvmware.models.ResourcePatch - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Host, or the result of cls(response) - :rtype: ~azure.mgmt.connectedvmware.models.Host - :raises: ~azure.core.exceptions.HttpResponseError - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Host] - - if body is not None: - _json = self._serialize.body(body, 'ResourcePatch') - else: - _json = None - - request = build_update_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - host_name=host_name, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self.update.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('Host', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}"} # type: ignore - - - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - host_name: str, - force: Optional[bool] = None, - **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - host_name=host_name, - api_version=api_version, - force=force, - template_url=self._delete_initial.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}"} # type: ignore - - - @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - host_name: str, - force: Optional[bool] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes an host. - - Implements host DELETE method. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param host_name: Name of the host. - :type host_name: str - :param force: Whether force delete was specified. Default value is None. - :type force: bool - :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: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - 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._delete_initial( # type: ignore - resource_group_name=resource_group_name, - host_name=host_name, - force=force, - api_version=api_version, - cls=lambda x,y,z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts/{hostName}"} # type: ignore - - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.HostsList]: - """Implements GET hosts in a subscription. - - List of hosts in a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either HostsList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.HostsList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.HostsList] - - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("HostsList", 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/hosts"} # type: ignore - - @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.HostsList]: - """Implements GET hosts in a resource group. - - List of hosts in a resource group. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either HostsList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.HostsList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.HostsList] - - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("HostsList", 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/hosts"} # type: ignore diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_hybrid_identity_metadata_operations.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_hybrid_identity_metadata_operations.py deleted file mode 100644 index f3cab1c2c55..00000000000 --- a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_hybrid_identity_metadata_operations.py +++ /dev/null @@ -1,354 +0,0 @@ -# pylint: disable=too-many-lines -# 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, Optional, TypeVar - -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 -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._hybrid_identity_metadata_operations import build_create_request, build_delete_request, build_get_request, build_list_by_vm_request -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class HybridIdentityMetadataOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.connectedvmware.aio.AzureArcVMwareManagementServiceAPI`'s - :attr:`hybrid_identity_metadata` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - - @distributed_trace_async - async def create( - self, - resource_group_name: str, - virtual_machine_name: str, - metadata_name: str, - body: Optional[_models.HybridIdentityMetadata] = None, - **kwargs: Any - ) -> _models.HybridIdentityMetadata: - """Implements HybridIdentityMetadata PUT method. - - Create Or Update HybridIdentityMetadata. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param virtual_machine_name: Name of the vm. - :type virtual_machine_name: str - :param metadata_name: Name of the hybridIdentityMetadata. - :type metadata_name: str - :param body: Request payload. Default value is None. - :type body: ~azure.mgmt.connectedvmware.models.HybridIdentityMetadata - :keyword callable cls: A custom type or function that will be passed the direct response - :return: HybridIdentityMetadata, or the result of cls(response) - :rtype: ~azure.mgmt.connectedvmware.models.HybridIdentityMetadata - :raises: ~azure.core.exceptions.HttpResponseError - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.HybridIdentityMetadata] - - if body is not None: - _json = self._serialize.body(body, 'HybridIdentityMetadata') - else: - _json = None - - request = build_create_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - virtual_machine_name=virtual_machine_name, - metadata_name=metadata_name, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self.create.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('HybridIdentityMetadata', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}"} # type: ignore - - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - virtual_machine_name: str, - metadata_name: str, - **kwargs: Any - ) -> _models.HybridIdentityMetadata: - """Gets HybridIdentityMetadata. - - Implements HybridIdentityMetadata GET method. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param virtual_machine_name: Name of the vm. - :type virtual_machine_name: str - :param metadata_name: Name of the HybridIdentityMetadata. - :type metadata_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: HybridIdentityMetadata, or the result of cls(response) - :rtype: ~azure.mgmt.connectedvmware.models.HybridIdentityMetadata - :raises: ~azure.core.exceptions.HttpResponseError - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.HybridIdentityMetadata] - - - request = build_get_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - virtual_machine_name=virtual_machine_name, - metadata_name=metadata_name, - api_version=api_version, - template_url=self.get.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('HybridIdentityMetadata', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}"} # type: ignore - - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - virtual_machine_name: str, - metadata_name: str, - **kwargs: Any - ) -> None: - """Deletes an HybridIdentityMetadata. - - Implements HybridIdentityMetadata DELETE method. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param virtual_machine_name: Name of the vm. - :type virtual_machine_name: str - :param metadata_name: Name of the HybridIdentityMetadata. - :type metadata_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_delete_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - virtual_machine_name=virtual_machine_name, - metadata_name=metadata_name, - api_version=api_version, - template_url=self.delete.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/hybridIdentityMetadata/{metadataName}"} # type: ignore - - - @distributed_trace - def list_by_vm( - self, - resource_group_name: str, - virtual_machine_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.HybridIdentityMetadataList]: - """Implements GET HybridIdentityMetadata in a vm. - - Returns the list of HybridIdentityMetadata of the given vm. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param virtual_machine_name: Name of the vm. - :type virtual_machine_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either HybridIdentityMetadataList or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.HybridIdentityMetadataList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.HybridIdentityMetadataList] - - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_vm_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - virtual_machine_name=virtual_machine_name, - api_version=api_version, - template_url=self.list_by_vm.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - else: - - request = build_list_by_vm_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - virtual_machine_name=virtual_machine_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("HybridIdentityMetadataList", 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list_by_vm.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/hybridIdentityMetadata"} # type: ignore diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_inventory_items_operations.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_inventory_items_operations.py deleted file mode 100644 index 88ed9743339..00000000000 --- a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_inventory_items_operations.py +++ /dev/null @@ -1,353 +0,0 @@ -# pylint: disable=too-many-lines -# 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, Optional, TypeVar - -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 -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._inventory_items_operations import build_create_request, build_delete_request, build_get_request, build_list_by_v_center_request -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class InventoryItemsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.connectedvmware.aio.AzureArcVMwareManagementServiceAPI`'s - :attr:`inventory_items` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - - @distributed_trace_async - async def create( - self, - resource_group_name: str, - vcenter_name: str, - inventory_item_name: str, - body: Optional[_models.InventoryItem] = None, - **kwargs: Any - ) -> _models.InventoryItem: - """Implements InventoryItem PUT method. - - Create Or Update InventoryItem. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param vcenter_name: Name of the vCenter. - :type vcenter_name: str - :param inventory_item_name: Name of the inventoryItem. - :type inventory_item_name: str - :param body: Request payload. Default value is None. - :type body: ~azure.mgmt.connectedvmware.models.InventoryItem - :keyword callable cls: A custom type or function that will be passed the direct response - :return: InventoryItem, or the result of cls(response) - :rtype: ~azure.mgmt.connectedvmware.models.InventoryItem - :raises: ~azure.core.exceptions.HttpResponseError - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.InventoryItem] - - if body is not None: - _json = self._serialize.body(body, 'InventoryItem') - else: - _json = None - - request = build_create_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - vcenter_name=vcenter_name, - inventory_item_name=inventory_item_name, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self.create.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('InventoryItem', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}/inventoryItems/{inventoryItemName}"} # type: ignore - - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - vcenter_name: str, - inventory_item_name: str, - **kwargs: Any - ) -> _models.InventoryItem: - """Gets InventoryItem. - - Implements InventoryItem GET method. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param vcenter_name: Name of the vCenter. - :type vcenter_name: str - :param inventory_item_name: Name of the inventoryItem. - :type inventory_item_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: InventoryItem, or the result of cls(response) - :rtype: ~azure.mgmt.connectedvmware.models.InventoryItem - :raises: ~azure.core.exceptions.HttpResponseError - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.InventoryItem] - - - request = build_get_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - vcenter_name=vcenter_name, - inventory_item_name=inventory_item_name, - api_version=api_version, - template_url=self.get.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('InventoryItem', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}/inventoryItems/{inventoryItemName}"} # type: ignore - - - @distributed_trace_async - async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - vcenter_name: str, - inventory_item_name: str, - **kwargs: Any - ) -> None: - """Deletes an inventoryItem. - - Implements inventoryItem DELETE method. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param vcenter_name: Name of the vCenter. - :type vcenter_name: str - :param inventory_item_name: Name of the inventoryItem. - :type inventory_item_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_delete_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - vcenter_name=vcenter_name, - inventory_item_name=inventory_item_name, - api_version=api_version, - template_url=self.delete.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}/inventoryItems/{inventoryItemName}"} # type: ignore - - - @distributed_trace - def list_by_v_center( - self, - resource_group_name: str, - vcenter_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.InventoryItemsList]: - """Implements GET inventoryItems in a vCenter. - - Returns the list of inventoryItems of the given vCenter. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param vcenter_name: Name of the vCenter. - :type vcenter_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either InventoryItemsList or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.InventoryItemsList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.InventoryItemsList] - - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_v_center_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - vcenter_name=vcenter_name, - api_version=api_version, - template_url=self.list_by_v_center.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - else: - - request = build_list_by_v_center_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - vcenter_name=vcenter_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("InventoryItemsList", 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list_by_v_center.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}/inventoryItems"} # type: ignore diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_machine_extensions_operations.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_machine_extensions_operations.py deleted file mode 100644 index 4a04d9f88ac..00000000000 --- a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_machine_extensions_operations.py +++ /dev/null @@ -1,633 +0,0 @@ -# pylint: disable=too-many-lines -# 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, Optional, TypeVar, Union, cast - -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 -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._machine_extensions_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class MachineExtensionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.connectedvmware.aio.AzureArcVMwareManagementServiceAPI`'s - :attr:`machine_extensions` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - - async def _create_or_update_initial( - self, - resource_group_name: str, - name: str, - extension_name: str, - extension_parameters: _models.MachineExtension, - **kwargs: Any - ) -> _models.MachineExtension: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MachineExtension] - - _json = self._serialize.body(extension_parameters, 'MachineExtension') - - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - name=name, - extension_name=extension_name, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self._create_or_update_initial.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize('MachineExtension', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('MachineExtension', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}"} # type: ignore - - - @distributed_trace_async - async def begin_create_or_update( - self, - resource_group_name: str, - name: str, - extension_name: str, - extension_parameters: _models.MachineExtension, - **kwargs: Any - ) -> AsyncLROPoller[_models.MachineExtension]: - """The operation to create or update the extension. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param name: The name of the machine where the extension should be created or updated. - :type name: str - :param extension_name: The name of the machine extension. - :type extension_name: str - :param extension_parameters: Parameters supplied to the Create Machine Extension operation. - :type extension_parameters: ~azure.mgmt.connectedvmware.models.MachineExtension - :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: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either MachineExtension or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.MachineExtension] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MachineExtension] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - 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( # type: ignore - resource_group_name=resource_group_name, - name=name, - extension_name=extension_name, - extension_parameters=extension_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize('MachineExtension', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'azure-async-operation'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}"} # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - name: str, - extension_name: str, - extension_parameters: _models.MachineExtensionUpdate, - **kwargs: Any - ) -> _models.MachineExtension: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MachineExtension] - - _json = self._serialize.body(extension_parameters, 'MachineExtensionUpdate') - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - name=name, - extension_name=extension_name, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self._update_initial.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize('MachineExtension', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('MachineExtension', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}"} # type: ignore - - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - name: str, - extension_name: str, - extension_parameters: _models.MachineExtensionUpdate, - **kwargs: Any - ) -> AsyncLROPoller[_models.MachineExtension]: - """The operation to update the extension. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param name: The name of the machine where the extension should be created or updated. - :type name: str - :param extension_name: The name of the machine extension. - :type extension_name: str - :param extension_parameters: Parameters supplied to the Create Machine Extension operation. - :type extension_parameters: ~azure.mgmt.connectedvmware.models.MachineExtensionUpdate - :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: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either MachineExtension or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.MachineExtension] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.MachineExtension] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - 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( # type: ignore - resource_group_name=resource_group_name, - name=name, - extension_name=extension_name, - extension_parameters=extension_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize('MachineExtension', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}"} # type: ignore - - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - name: str, - extension_name: str, - **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - name=name, - extension_name=extension_name, - api_version=api_version, - template_url=self._delete_initial.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}"} # type: ignore - - - @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - name: str, - extension_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """The operation to delete the extension. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param name: The name of the machine where the extension should be deleted. - :type name: str - :param extension_name: The name of the machine extension. - :type extension_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - 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._delete_initial( # type: ignore - resource_group_name=resource_group_name, - name=name, - extension_name=extension_name, - api_version=api_version, - cls=lambda x,y,z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}"} # type: ignore - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - name: str, - extension_name: str, - **kwargs: Any - ) -> _models.MachineExtension: - """The operation to get the extension. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param name: The name of the machine containing the extension. - :type name: str - :param extension_name: The name of the machine extension. - :type extension_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: MachineExtension, or the result of cls(response) - :rtype: ~azure.mgmt.connectedvmware.models.MachineExtension - :raises: ~azure.core.exceptions.HttpResponseError - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MachineExtension] - - - request = build_get_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - name=name, - extension_name=extension_name, - api_version=api_version, - template_url=self.get.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('MachineExtension', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions/{extensionName}"} # type: ignore - - - @distributed_trace - def list( - self, - resource_group_name: str, - name: str, - expand: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable[_models.MachineExtensionsListResult]: - """The operation to get all extensions of a non-Azure machine. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param name: The name of the machine containing the extension. - :type name: str - :param expand: The expand expression to apply on the operation. Default value is None. - :type expand: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MachineExtensionsListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.MachineExtensionsListResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.MachineExtensionsListResult] - - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - name=name, - api_version=api_version, - expand=expand, - template_url=self.list.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - name=name, - api_version=api_version, - expand=expand, - template_url=next_link, - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("MachineExtensionsListResult", 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/extensions"} # type: ignore diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_resource_pools_operations.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_resource_pools_operations.py deleted file mode 100644 index c7941c2cdc7..00000000000 --- a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_resource_pools_operations.py +++ /dev/null @@ -1,633 +0,0 @@ -# pylint: disable=too-many-lines -# 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, Optional, TypeVar, Union, cast - -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 -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._resource_pools_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_request, build_update_request -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class ResourcePoolsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.connectedvmware.aio.AzureArcVMwareManagementServiceAPI`'s - :attr:`resource_pools` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - - async def _create_initial( - self, - resource_group_name: str, - resource_pool_name: str, - body: Optional[_models.ResourcePool] = None, - **kwargs: Any - ) -> _models.ResourcePool: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourcePool] - - if body is not None: - _json = self._serialize.body(body, 'ResourcePool') - else: - _json = None - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_pool_name=resource_pool_name, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self._create_initial.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize('ResourcePool', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('ResourcePool', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}"} # type: ignore - - - @distributed_trace_async - async def begin_create( - self, - resource_group_name: str, - resource_pool_name: str, - body: Optional[_models.ResourcePool] = None, - **kwargs: Any - ) -> AsyncLROPoller[_models.ResourcePool]: - """Implements resourcePool PUT method. - - Create Or Update resourcePool. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param resource_pool_name: Name of the resourcePool. - :type resource_pool_name: str - :param body: Request payload. Default value is None. - :type body: ~azure.mgmt.connectedvmware.models.ResourcePool - :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: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either ResourcePool or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.ResourcePool] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourcePool] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - 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_initial( # type: ignore - resource_group_name=resource_group_name, - resource_pool_name=resource_pool_name, - body=body, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize('ResourcePool', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'azure-async-operation'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}"} # type: ignore - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - resource_pool_name: str, - **kwargs: Any - ) -> _models.ResourcePool: - """Gets a resourcePool. - - Implements resourcePool GET method. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param resource_pool_name: Name of the resourcePool. - :type resource_pool_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourcePool, or the result of cls(response) - :rtype: ~azure.mgmt.connectedvmware.models.ResourcePool - :raises: ~azure.core.exceptions.HttpResponseError - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourcePool] - - - request = build_get_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_pool_name=resource_pool_name, - api_version=api_version, - template_url=self.get.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('ResourcePool', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}"} # type: ignore - - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - resource_pool_name: str, - body: Optional[_models.ResourcePatch] = None, - **kwargs: Any - ) -> _models.ResourcePool: - """Updates a resourcePool. - - API to update certain properties of the resourcePool resource. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param resource_pool_name: Name of the resourcePool. - :type resource_pool_name: str - :param body: Resource properties to update. Default value is None. - :type body: ~azure.mgmt.connectedvmware.models.ResourcePatch - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ResourcePool, or the result of cls(response) - :rtype: ~azure.mgmt.connectedvmware.models.ResourcePool - :raises: ~azure.core.exceptions.HttpResponseError - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourcePool] - - if body is not None: - _json = self._serialize.body(body, 'ResourcePatch') - else: - _json = None - - request = build_update_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_pool_name=resource_pool_name, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self.update.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('ResourcePool', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}"} # type: ignore - - - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - resource_pool_name: str, - force: Optional[bool] = None, - **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_pool_name=resource_pool_name, - api_version=api_version, - force=force, - template_url=self._delete_initial.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}"} # type: ignore - - - @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - resource_pool_name: str, - force: Optional[bool] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes an resourcePool. - - Implements resourcePool DELETE method. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param resource_pool_name: Name of the resourcePool. - :type resource_pool_name: str - :param force: Whether force delete was specified. Default value is None. - :type force: bool - :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: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - 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._delete_initial( # type: ignore - resource_group_name=resource_group_name, - resource_pool_name=resource_pool_name, - force=force, - api_version=api_version, - cls=lambda x,y,z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools/{resourcePoolName}"} # type: ignore - - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.ResourcePoolsList]: - """Implements GET resourcePools in a subscription. - - List of resourcePools in a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourcePoolsList or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.ResourcePoolsList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourcePoolsList] - - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ResourcePoolsList", 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools"} # type: ignore - - @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ResourcePoolsList]: - """Implements GET resourcePools in a resource group. - - List of resourcePools in a resource group. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ResourcePoolsList or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.ResourcePoolsList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ResourcePoolsList] - - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ResourcePoolsList", 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/resourcePools"} # type: ignore diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_vcenters_operations.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_vcenters_operations.py deleted file mode 100644 index daaafef52f5..00000000000 --- a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_vcenters_operations.py +++ /dev/null @@ -1,633 +0,0 @@ -# pylint: disable=too-many-lines -# 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, Optional, TypeVar, Union, cast - -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 -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._vcenters_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_request, build_update_request -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class VCentersOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.connectedvmware.aio.AzureArcVMwareManagementServiceAPI`'s - :attr:`vcenters` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - - async def _create_initial( - self, - resource_group_name: str, - vcenter_name: str, - body: Optional[_models.VCenter] = None, - **kwargs: Any - ) -> _models.VCenter: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.VCenter] - - if body is not None: - _json = self._serialize.body(body, 'VCenter') - else: - _json = None - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - vcenter_name=vcenter_name, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self._create_initial.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize('VCenter', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('VCenter', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}"} # type: ignore - - - @distributed_trace_async - async def begin_create( - self, - resource_group_name: str, - vcenter_name: str, - body: Optional[_models.VCenter] = None, - **kwargs: Any - ) -> AsyncLROPoller[_models.VCenter]: - """Implements vCenter PUT method. - - Create Or Update vCenter. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param vcenter_name: Name of the vCenter. - :type vcenter_name: str - :param body: Request payload. Default value is None. - :type body: ~azure.mgmt.connectedvmware.models.VCenter - :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: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either VCenter or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.VCenter] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.VCenter] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - 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_initial( # type: ignore - resource_group_name=resource_group_name, - vcenter_name=vcenter_name, - body=body, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize('VCenter', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'azure-async-operation'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}"} # type: ignore - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - vcenter_name: str, - **kwargs: Any - ) -> _models.VCenter: - """Gets a vCenter. - - Implements vCenter GET method. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param vcenter_name: Name of the vCenter. - :type vcenter_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: VCenter, or the result of cls(response) - :rtype: ~azure.mgmt.connectedvmware.models.VCenter - :raises: ~azure.core.exceptions.HttpResponseError - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.VCenter] - - - request = build_get_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - vcenter_name=vcenter_name, - api_version=api_version, - template_url=self.get.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('VCenter', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}"} # type: ignore - - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - vcenter_name: str, - body: Optional[_models.ResourcePatch] = None, - **kwargs: Any - ) -> _models.VCenter: - """Updates a vCenter. - - API to update certain properties of the vCenter resource. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param vcenter_name: Name of the vCenter. - :type vcenter_name: str - :param body: Resource properties to update. Default value is None. - :type body: ~azure.mgmt.connectedvmware.models.ResourcePatch - :keyword callable cls: A custom type or function that will be passed the direct response - :return: VCenter, or the result of cls(response) - :rtype: ~azure.mgmt.connectedvmware.models.VCenter - :raises: ~azure.core.exceptions.HttpResponseError - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.VCenter] - - if body is not None: - _json = self._serialize.body(body, 'ResourcePatch') - else: - _json = None - - request = build_update_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - vcenter_name=vcenter_name, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self.update.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('VCenter', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}"} # type: ignore - - - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - vcenter_name: str, - force: Optional[bool] = None, - **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - vcenter_name=vcenter_name, - api_version=api_version, - force=force, - template_url=self._delete_initial.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}"} # type: ignore - - - @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - vcenter_name: str, - force: Optional[bool] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes an vCenter. - - Implements vCenter DELETE method. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param vcenter_name: Name of the vCenter. - :type vcenter_name: str - :param force: Whether force delete was specified. Default value is None. - :type force: bool - :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: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - 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._delete_initial( # type: ignore - resource_group_name=resource_group_name, - vcenter_name=vcenter_name, - force=force, - api_version=api_version, - cls=lambda x,y,z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters/{vcenterName}"} # type: ignore - - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.VCentersList]: - """Implements GET vCenters in a subscription. - - List of vCenters in a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either VCentersList or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.VCentersList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.VCentersList] - - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("VCentersList", 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/vcenters"} # type: ignore - - @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.VCentersList]: - """Implements GET vCenters in a resource group. - - List of vCenters in a resource group. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either VCentersList or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.VCentersList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.VCentersList] - - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("VCentersList", 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/vcenters"} # type: ignore diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_virtual_machine_templates_operations.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_virtual_machine_templates_operations.py deleted file mode 100644 index 8d5fef85e36..00000000000 --- a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_virtual_machine_templates_operations.py +++ /dev/null @@ -1,636 +0,0 @@ -# pylint: disable=too-many-lines -# 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, Optional, TypeVar, Union, cast - -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 -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._virtual_machine_templates_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_request, build_update_request -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class VirtualMachineTemplatesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.connectedvmware.aio.AzureArcVMwareManagementServiceAPI`'s - :attr:`virtual_machine_templates` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - - async def _create_initial( - self, - resource_group_name: str, - virtual_machine_template_name: str, - body: Optional[_models.VirtualMachineTemplate] = None, - **kwargs: Any - ) -> _models.VirtualMachineTemplate: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineTemplate] - - if body is not None: - _json = self._serialize.body(body, 'VirtualMachineTemplate') - else: - _json = None - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - virtual_machine_template_name=virtual_machine_template_name, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self._create_initial.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize('VirtualMachineTemplate', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('VirtualMachineTemplate', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}"} # type: ignore - - - @distributed_trace_async - async def begin_create( - self, - resource_group_name: str, - virtual_machine_template_name: str, - body: Optional[_models.VirtualMachineTemplate] = None, - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineTemplate]: - """Implements virtual machine template PUT method. - - Create Or Update virtual machine template. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param virtual_machine_template_name: Name of the virtual machine template resource. - :type virtual_machine_template_name: str - :param body: Request payload. Default value is None. - :type body: ~azure.mgmt.connectedvmware.models.VirtualMachineTemplate - :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: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either VirtualMachineTemplate or the result - of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.VirtualMachineTemplate] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineTemplate] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - 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_initial( # type: ignore - resource_group_name=resource_group_name, - virtual_machine_template_name=virtual_machine_template_name, - body=body, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize('VirtualMachineTemplate', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'azure-async-operation'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}"} # type: ignore - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - virtual_machine_template_name: str, - **kwargs: Any - ) -> _models.VirtualMachineTemplate: - """Gets a virtual machine template. - - Implements virtual machine template GET method. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param virtual_machine_template_name: Name of the virtual machine template resource. - :type virtual_machine_template_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: VirtualMachineTemplate, or the result of cls(response) - :rtype: ~azure.mgmt.connectedvmware.models.VirtualMachineTemplate - :raises: ~azure.core.exceptions.HttpResponseError - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineTemplate] - - - request = build_get_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - virtual_machine_template_name=virtual_machine_template_name, - api_version=api_version, - template_url=self.get.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('VirtualMachineTemplate', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}"} # type: ignore - - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - virtual_machine_template_name: str, - body: Optional[_models.ResourcePatch] = None, - **kwargs: Any - ) -> _models.VirtualMachineTemplate: - """Updates a virtual machine template. - - API to update certain properties of the virtual machine template resource. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param virtual_machine_template_name: Name of the virtual machine template resource. - :type virtual_machine_template_name: str - :param body: Resource properties to update. Default value is None. - :type body: ~azure.mgmt.connectedvmware.models.ResourcePatch - :keyword callable cls: A custom type or function that will be passed the direct response - :return: VirtualMachineTemplate, or the result of cls(response) - :rtype: ~azure.mgmt.connectedvmware.models.VirtualMachineTemplate - :raises: ~azure.core.exceptions.HttpResponseError - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineTemplate] - - if body is not None: - _json = self._serialize.body(body, 'ResourcePatch') - else: - _json = None - - request = build_update_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - virtual_machine_template_name=virtual_machine_template_name, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self.update.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('VirtualMachineTemplate', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}"} # type: ignore - - - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - virtual_machine_template_name: str, - force: Optional[bool] = None, - **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - virtual_machine_template_name=virtual_machine_template_name, - api_version=api_version, - force=force, - template_url=self._delete_initial.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}"} # type: ignore - - - @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - virtual_machine_template_name: str, - force: Optional[bool] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes an virtual machine template. - - Implements virtual machine template DELETE method. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param virtual_machine_template_name: Name of the virtual machine template resource. - :type virtual_machine_template_name: str - :param force: Whether force delete was specified. Default value is None. - :type force: bool - :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: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - 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._delete_initial( # type: ignore - resource_group_name=resource_group_name, - virtual_machine_template_name=virtual_machine_template_name, - force=force, - api_version=api_version, - cls=lambda x,y,z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates/{virtualMachineTemplateName}"} # type: ignore - - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.VirtualMachineTemplatesList]: - """Implements GET virtualMachineTemplates in a subscription. - - List of virtualMachineTemplates in a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either VirtualMachineTemplatesList or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.VirtualMachineTemplatesList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineTemplatesList] - - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineTemplatesList", 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates"} # type: ignore - - @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.VirtualMachineTemplatesList]: - """Implements GET virtualMachineTemplates in a resource group. - - List of virtualMachineTemplates in a resource group. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either VirtualMachineTemplatesList or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.VirtualMachineTemplatesList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineTemplatesList] - - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachineTemplatesList", 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachineTemplates"} # type: ignore diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_virtual_machines_operations.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_virtual_machines_operations.py index 56432841bcc..9316d03f374 100644 --- a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_virtual_machines_operations.py +++ b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_virtual_machines_operations.py @@ -22,7 +22,7 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._virtual_machines_operations import build_assess_patches_request_initial, build_create_request_initial, build_delete_request_initial, build_get_request, build_install_patches_request_initial, build_list_by_resource_group_request, build_list_request, build_restart_request_initial, build_start_request_initial, build_stop_request_initial, build_update_request_initial +from ...operations._virtual_machines_operations import build_get_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -45,426 +45,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - async def _assess_patches_initial( - self, - resource_group_name: str, - name: str, - **kwargs: Any - ) -> Optional[_models.VirtualMachineAssessPatchesResult]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.VirtualMachineAssessPatchesResult]] - - - request = build_assess_patches_request_initial( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - name=name, - api_version=api_version, - template_url=self._assess_patches_initial.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('VirtualMachineAssessPatchesResult', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _assess_patches_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/assessPatches"} # type: ignore - - - @distributed_trace_async - async def begin_assess_patches( - self, - resource_group_name: str, - name: str, - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineAssessPatchesResult]: - """The operation to assess patches on a vSphere VMware machine identity in Azure. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param name: The name of the vSphere VMware machine. - :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either VirtualMachineAssessPatchesResult or - the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.VirtualMachineAssessPatchesResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineAssessPatchesResult] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - 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._assess_patches_initial( # type: ignore - resource_group_name=resource_group_name, - name=name, - api_version=api_version, - cls=lambda x,y,z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize('VirtualMachineAssessPatchesResult', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_assess_patches.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/assessPatches"} # type: ignore - - async def _install_patches_initial( - self, - resource_group_name: str, - name: str, - install_patches_input: _models.VirtualMachineInstallPatchesParameters, - **kwargs: Any - ) -> Optional[_models.VirtualMachineInstallPatchesResult]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.VirtualMachineInstallPatchesResult]] - - _json = self._serialize.body(install_patches_input, 'VirtualMachineInstallPatchesParameters') - - request = build_install_patches_request_initial( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - name=name, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self._install_patches_initial.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('VirtualMachineInstallPatchesResult', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _install_patches_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/installPatches"} # type: ignore - - - @distributed_trace_async - async def begin_install_patches( - self, - resource_group_name: str, - name: str, - install_patches_input: _models.VirtualMachineInstallPatchesParameters, - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachineInstallPatchesResult]: - """The operation to install patches on a vSphere VMware machine identity in Azure. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param name: The name of the vSphere VMware machine. - :type name: str - :param install_patches_input: Input for InstallPatches as directly received by the API. - :type install_patches_input: - ~azure.mgmt.connectedvmware.models.VirtualMachineInstallPatchesParameters - :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: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either VirtualMachineInstallPatchesResult - or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.VirtualMachineInstallPatchesResult] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachineInstallPatchesResult] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - 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._install_patches_initial( # type: ignore - resource_group_name=resource_group_name, - name=name, - install_patches_input=install_patches_input, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize('VirtualMachineInstallPatchesResult', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_install_patches.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{name}/installPatches"} # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - virtual_machine_name: str, - body: Optional[_models.VirtualMachine] = None, - **kwargs: Any - ) -> _models.VirtualMachine: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] - - if body is not None: - _json = self._serialize.body(body, 'VirtualMachine') - else: - _json = None - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - virtual_machine_name=virtual_machine_name, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self._create_initial.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize('VirtualMachine', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('VirtualMachine', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}"} # type: ignore - - - @distributed_trace_async - async def begin_create( - self, - resource_group_name: str, - virtual_machine_name: str, - body: Optional[_models.VirtualMachine] = None, - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachine]: - """Implements virtual machine PUT method. - - Create Or Update virtual machine. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param virtual_machine_name: Name of the virtual machine resource. - :type virtual_machine_name: str - :param body: Request payload. Default value is None. - :type body: ~azure.mgmt.connectedvmware.models.VirtualMachine - :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: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.VirtualMachine] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - 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_initial( # type: ignore - resource_group_name=resource_group_name, - virtual_machine_name=virtual_machine_name, - body=body, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize('VirtualMachine', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'azure-async-operation'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}"} # type: ignore - @distributed_trace_async async def get( self, @@ -529,836 +109,3 @@ async def get( return deserialized get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}"} # type: ignore - - - async def _update_initial( - self, - resource_group_name: str, - virtual_machine_name: str, - body: Optional[_models.VirtualMachineUpdate] = None, - **kwargs: Any - ) -> Optional[_models.VirtualMachine]: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.VirtualMachine]] - - if body is not None: - _json = self._serialize.body(body, 'VirtualMachineUpdate') - else: - _json = None - - request = build_update_request_initial( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - virtual_machine_name=virtual_machine_name, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self._update_initial.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200, 201, 202]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = None - if response.status_code == 200: - deserialized = self._deserialize('VirtualMachine', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('VirtualMachine', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}"} # type: ignore - - - @distributed_trace_async - async def begin_update( - self, - resource_group_name: str, - virtual_machine_name: str, - body: Optional[_models.VirtualMachineUpdate] = None, - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualMachine]: - """Updates a virtual machine. - - API to update certain properties of the virtual machine resource. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param virtual_machine_name: Name of the virtual machine resource. - :type virtual_machine_name: str - :param body: Resource properties to update. Default value is None. - :type body: ~azure.mgmt.connectedvmware.models.VirtualMachineUpdate - :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: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either VirtualMachine or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.VirtualMachine] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachine] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - 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( # type: ignore - resource_group_name=resource_group_name, - virtual_machine_name=virtual_machine_name, - body=body, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize('VirtualMachine', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}"} # type: ignore - - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - virtual_machine_name: str, - force: Optional[bool] = None, - retain: Optional[bool] = None, - **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - virtual_machine_name=virtual_machine_name, - api_version=api_version, - force=force, - retain=retain, - template_url=self._delete_initial.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}"} # type: ignore - - - @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - virtual_machine_name: str, - force: Optional[bool] = None, - retain: Optional[bool] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes an virtual machine. - - Implements virtual machine DELETE method. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param virtual_machine_name: Name of the virtual machine resource. - :type virtual_machine_name: str - :param force: Whether force delete was specified. Default value is None. - :type force: bool - :param retain: Whether to just disable the VM from azure and retain the VM in the VMM. Default - value is None. - :type retain: bool - :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: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - 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._delete_initial( # type: ignore - resource_group_name=resource_group_name, - virtual_machine_name=virtual_machine_name, - force=force, - retain=retain, - api_version=api_version, - cls=lambda x,y,z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}"} # type: ignore - - async def _stop_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - virtual_machine_name: str, - body: Optional[_models.StopVirtualMachineOptions] = None, - **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] - - if body is not None: - _json = self._serialize.body(body, 'StopVirtualMachineOptions') - else: - _json = None - - request = build_stop_request_initial( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - virtual_machine_name=virtual_machine_name, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self._stop_initial.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _stop_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/stop"} # type: ignore - - - @distributed_trace_async - async def begin_stop( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - virtual_machine_name: str, - body: Optional[_models.StopVirtualMachineOptions] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Implements the operation to stop a virtual machine. - - Stop virtual machine. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param virtual_machine_name: Name of the virtual machine resource. - :type virtual_machine_name: str - :param body: Virtualmachine stop action payload. Default value is None. - :type body: ~azure.mgmt.connectedvmware.models.StopVirtualMachineOptions - :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: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - 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._stop_initial( # type: ignore - resource_group_name=resource_group_name, - virtual_machine_name=virtual_machine_name, - body=body, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_stop.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/stop"} # type: ignore - - async def _start_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - virtual_machine_name: str, - **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_start_request_initial( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - virtual_machine_name=virtual_machine_name, - api_version=api_version, - template_url=self._start_initial.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _start_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/start"} # type: ignore - - - @distributed_trace_async - async def begin_start( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - virtual_machine_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Implements the operation to start a virtual machine. - - Start virtual machine. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param virtual_machine_name: Name of the virtual machine resource. - :type virtual_machine_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - 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._start_initial( # type: ignore - resource_group_name=resource_group_name, - virtual_machine_name=virtual_machine_name, - api_version=api_version, - cls=lambda x,y,z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_start.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/start"} # type: ignore - - async def _restart_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - virtual_machine_name: str, - **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_restart_request_initial( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - virtual_machine_name=virtual_machine_name, - api_version=api_version, - template_url=self._restart_initial.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _restart_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/restart"} # type: ignore - - - @distributed_trace_async - async def begin_restart( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - virtual_machine_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Implements the operation to restart a virtual machine. - - Restart virtual machine. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param virtual_machine_name: Name of the virtual machine resource. - :type virtual_machine_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - 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._restart_initial( # type: ignore - resource_group_name=resource_group_name, - virtual_machine_name=virtual_machine_name, - api_version=api_version, - cls=lambda x,y,z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_restart.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines/{virtualMachineName}/restart"} # type: ignore - - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.VirtualMachinesList]: - """Implements GET virtualMachines in a subscription. - - List of virtualMachines in a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either VirtualMachinesList or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.VirtualMachinesList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachinesList] - - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachinesList", 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines"} # type: ignore - - @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.VirtualMachinesList]: - """Implements GET virtualMachines in a resource group. - - List of virtualMachines in a resource group. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either VirtualMachinesList or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.VirtualMachinesList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualMachinesList] - - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualMachinesList", 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualMachines"} # type: ignore diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_virtual_networks_operations.py b/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_virtual_networks_operations.py deleted file mode 100644 index 5fd4e997199..00000000000 --- a/src/ssh/azext_ssh/vendored_sdks/connectedvmware/aio/operations/_virtual_networks_operations.py +++ /dev/null @@ -1,633 +0,0 @@ -# pylint: disable=too-many-lines -# 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, Optional, TypeVar, Union, cast - -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 -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest -from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async -from azure.core.utils import case_insensitive_dict -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling - -from ... import models as _models -from ..._vendor import _convert_request -from ...operations._virtual_networks_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_request, build_update_request -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class VirtualNetworksOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.connectedvmware.aio.AzureArcVMwareManagementServiceAPI`'s - :attr:`virtual_networks` attribute. - """ - - models = _models - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - - async def _create_initial( - self, - resource_group_name: str, - virtual_network_name: str, - body: Optional[_models.VirtualNetwork] = None, - **kwargs: Any - ) -> _models.VirtualNetwork: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualNetwork] - - if body is not None: - _json = self._serialize.body(body, 'VirtualNetwork') - else: - _json = None - - request = build_create_request_initial( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - virtual_network_name=virtual_network_name, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self._create_initial.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize('VirtualNetwork', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('VirtualNetwork', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}"} # type: ignore - - - @distributed_trace_async - async def begin_create( - self, - resource_group_name: str, - virtual_network_name: str, - body: Optional[_models.VirtualNetwork] = None, - **kwargs: Any - ) -> AsyncLROPoller[_models.VirtualNetwork]: - """Implements virtual network PUT method. - - Create Or Update virtual network. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param virtual_network_name: Name of the virtual network resource. - :type virtual_network_name: str - :param body: Request payload. Default value is None. - :type body: ~azure.mgmt.connectedvmware.models.VirtualNetwork - :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: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either VirtualNetwork or the result of - cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.connectedvmware.models.VirtualNetwork] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualNetwork] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - 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_initial( # type: ignore - resource_group_name=resource_group_name, - virtual_network_name=virtual_network_name, - body=body, - api_version=api_version, - content_type=content_type, - cls=lambda x,y,z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize('VirtualNetwork', pipeline_response) - if cls: - return cls(pipeline_response, deserialized, {}) - return deserialized - - - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'azure-async-operation'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}"} # type: ignore - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - virtual_network_name: str, - **kwargs: Any - ) -> _models.VirtualNetwork: - """Gets a virtual network. - - Implements virtual network GET method. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param virtual_network_name: Name of the virtual network resource. - :type virtual_network_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: VirtualNetwork, or the result of cls(response) - :rtype: ~azure.mgmt.connectedvmware.models.VirtualNetwork - :raises: ~azure.core.exceptions.HttpResponseError - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualNetwork] - - - request = build_get_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - virtual_network_name=virtual_network_name, - api_version=api_version, - template_url=self.get.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('VirtualNetwork', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}"} # type: ignore - - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - virtual_network_name: str, - body: Optional[_models.ResourcePatch] = None, - **kwargs: Any - ) -> _models.VirtualNetwork: - """Updates a virtual network. - - API to update certain properties of the virtual network resource. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param virtual_network_name: Name of the virtual network resource. - :type virtual_network_name: str - :param body: Resource properties to update. Default value is None. - :type body: ~azure.mgmt.connectedvmware.models.ResourcePatch - :keyword callable cls: A custom type or function that will be passed the direct response - :return: VirtualNetwork, or the result of cls(response) - :rtype: ~azure.mgmt.connectedvmware.models.VirtualNetwork - :raises: ~azure.core.exceptions.HttpResponseError - """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualNetwork] - - if body is not None: - _json = self._serialize.body(body, 'ResourcePatch') - else: - _json = None - - request = build_update_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - virtual_network_name=virtual_network_name, - api_version=api_version, - content_type=content_type, - json=_json, - template_url=self.update.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('VirtualNetwork', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}"} # type: ignore - - - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - virtual_network_name: str, - force: Optional[bool] = None, - **kwargs: Any - ) -> None: - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - virtual_network_name=virtual_network_name, - api_version=api_version, - force=force, - template_url=self._delete_initial.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}"} # type: ignore - - - @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - virtual_network_name: str, - force: Optional[bool] = None, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes an virtual network. - - Implements virtual network DELETE method. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :param virtual_network_name: Name of the virtual network resource. - :type virtual_network_name: str - :param force: Whether force delete was specified. Default value is None. - :type force: bool - :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: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - 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._delete_initial( # type: ignore - resource_group_name=resource_group_name, - virtual_network_name=virtual_network_name, - force=force, - api_version=api_version, - cls=lambda x,y,z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop('error_map', None) - - def get_long_running_output(pipeline_response): - if cls: - return cls(pipeline_response, None, {}) - - - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output - ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks/{virtualNetworkName}"} # type: ignore - - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.VirtualNetworksList]: - """Implements GET virtualNetworks in a subscription. - - List of virtualNetworks in a subscription. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either VirtualNetworksList or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.VirtualNetworksList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualNetworksList] - - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualNetworksList", 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks"} # type: ignore - - @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.VirtualNetworksList]: - """Implements GET virtualNetworks in a resource group. - - List of virtualNetworks in a resource group. - - :param resource_group_name: The Resource Group Name. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either VirtualNetworksList or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.connectedvmware.models.VirtualNetworksList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-01-10-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.VirtualNetworksList] - - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("VirtualNetworksList", 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( # pylint: disable=protected-access - request, - stream=False, - **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualNetworks"} # type: ignore From 531fac43a9b49d7e23487ca4132c4edd9e68dd93 Mon Sep 17 00:00:00 2001 From: Vivian Thiebaut Date: Fri, 7 Oct 2022 14:57:25 -0400 Subject: [PATCH 11/15] Add support to Microsoft.ScVmm/virtualMachines and Microsoft.AzureStackHCI/virtualMachines without adding it to documentation --- src/ssh/azext_ssh/constants.py | 16 ++++++++++++---- src/ssh/azext_ssh/custom.py | 4 ++-- src/ssh/azext_ssh/ssh_info.py | 4 +++- src/ssh/azext_ssh/target_os_utils.py | 2 +- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/ssh/azext_ssh/constants.py b/src/ssh/azext_ssh/constants.py index 638c824b445..56af79ada28 100644 --- a/src/ssh/azext_ssh/constants.py +++ b/src/ssh/azext_ssh/constants.py @@ -23,22 +23,30 @@ SUPPORTED_RESOURCE_TYPES = ["microsoft.hybridcompute/machines", "microsoft.compute/virtualmachines", - "microsoft.connectedvmwarevsphere/virtualmachines"] + "microsoft.connectedvmwarevsphere/virtualmachines", + "microsoft.scvmm/virtualmachines", + "microsoft.azurestackhci/virtualmachines"] # Old version incorrectly used resource providers instead of resource type. # Will continue to support to avoid breaking backwards compatibility. LEGACY_SUPPORTED_RESOURCE_TYPES = ["microsoft.hybridcompute", "microsoft.compute", - "microsoft.connectedvmwarevsphere"] + "microsoft.connectedvmwarevsphere", + "microsoft.scvmm", + "microsoft.azurestackhci"] RESOURCE_PROVIDER_TO_RESOURCE_TYPE = { "microsoft.hybridcompute": "Microsoft.HybridCompute/machines", "microsoft.compute": "Microsoft.Compute/virtualMachines", - "microsoft.connectedvmwarevsphere": "Microsoft.ConnectedVMwarevSphere/virtualMachines" + "microsoft.connectedvmwarevsphere": "Microsoft.ConnectedVMwarevSphere/virtualMachines", + "microsoft.azurestackhci": "Microsoft.AzureStackHCI/virtualMachines", + "microsoft.scvmm": "Microsoft.ScVmm/virtualMachines" } RESOURCE_TYPE_LOWER_CASE_TO_CORRECT_CASE = { "microsoft.hybridcompute/machines": "Microsoft.HybridCompute/machines", "microsoft.compute/virtualmachines": "Microsoft.Compute/virtualMachines", - "microsoft.connectedvmwarevsphere/virtualmachines": "Microsoft.ConnectedVMwarevSphere/virtualMachines" + "microsoft.connectedvmwarevsphere/virtualmachines": "Microsoft.ConnectedVMwarevSphere/virtualMachines", + "microsoft.scvmm/virtualmachines": "Microsoft.ScVmm/virtualMachines", + "microsoft.azurestackhci/virtualmachines": "Microsoft.AzureStackHCI/virtualMachines" } diff --git a/src/ssh/azext_ssh/custom.py b/src/ssh/azext_ssh/custom.py index c366a942efe..0515106c569 100644 --- a/src/ssh/azext_ssh/custom.py +++ b/src/ssh/azext_ssh/custom.py @@ -61,7 +61,7 @@ def ssh_vm(cmd, resource_group_name=None, vm_name=None, ssh_ip=None, public_key_ ssh_client_folder, ssh_args, delete_credentials, resource_type, ssh_proxy_folder, credentials_folder, winrdp) ssh_session.resource_type = resource_type_utils.decide_resource_type(cmd, ssh_session) - target_os_utils.send_target_os_telemetry(cmd, ssh_session) + target_os_utils.handle_target_os_type(cmd, ssh_session) _do_ssh_op(cmd, ssh_session, op_call) @@ -83,7 +83,7 @@ def ssh_config(cmd, config_path, resource_group_name=None, vm_name=None, ssh_ip= op_call = ssh_utils.write_ssh_config config_session.resource_type = resource_type_utils.decide_resource_type(cmd, config_session) - target_os_utils.send_target_os_telemetry(cmd, config_session) + target_os_utils.handle_target_os_type(cmd, config_session) # if the folder doesn't exist, this extension won't create a new one. config_folder = os.path.dirname(config_session.config_path) diff --git a/src/ssh/azext_ssh/ssh_info.py b/src/ssh/azext_ssh/ssh_info.py index 07a09f9f916..60c53f49cbc 100644 --- a/src/ssh/azext_ssh/ssh_info.py +++ b/src/ssh/azext_ssh/ssh_info.py @@ -42,7 +42,9 @@ def __init__(self, resource_group_name, vm_name, ssh_ip, public_key_file, privat def is_arc(self): if self.resource_type in ["Microsoft.HybridCompute/machines", - "Microsoft.ConnectedVMwarevSphere/virtualMachines"]: + "Microsoft.ConnectedVMwarevSphere/virtualMachines", + "Microsoft.ScVmm/virtualMachines", + "Microsoft.AzureStackHCI/virtualMachines"]: return True return False diff --git a/src/ssh/azext_ssh/target_os_utils.py b/src/ssh/azext_ssh/target_os_utils.py index b351de47df2..0490db26395 100644 --- a/src/ssh/azext_ssh/target_os_utils.py +++ b/src/ssh/azext_ssh/target_os_utils.py @@ -12,7 +12,7 @@ logger = log.get_logger(__name__) -def send_target_os_telemetry(cmd, op_info): +def handle_target_os_type(cmd, op_info): os_type = None From 875604496fa158d73728998e0ecbe3d59e6a3961 Mon Sep 17 00:00:00 2001 From: Vivian Thiebaut Date: Tue, 11 Oct 2022 12:28:48 -0400 Subject: [PATCH 12/15] Fix style error --- src/ssh/azext_ssh/constants.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ssh/azext_ssh/constants.py b/src/ssh/azext_ssh/constants.py index 56af79ada28..62a6575f2df 100644 --- a/src/ssh/azext_ssh/constants.py +++ b/src/ssh/azext_ssh/constants.py @@ -23,7 +23,7 @@ SUPPORTED_RESOURCE_TYPES = ["microsoft.hybridcompute/machines", "microsoft.compute/virtualmachines", - "microsoft.connectedvmwarevsphere/virtualmachines", + "microsoft.connectedvmwarevsphere/virtualmachines", "microsoft.scvmm/virtualmachines", "microsoft.azurestackhci/virtualmachines"] From 1c9fc0d4b20a1725ad27c7f43e484441e5b1e5bf Mon Sep 17 00:00:00 2001 From: Vivian Thiebaut Date: Tue, 18 Oct 2022 19:31:42 -0400 Subject: [PATCH 13/15] Create customResourceType for vmware client --- src/ssh/HISTORY.md | 5 +++++ src/ssh/azext_ssh/_client_factory.py | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ssh/HISTORY.md b/src/ssh/HISTORY.md index 4ecef1cb840..2195e11021c 100644 --- a/src/ssh/HISTORY.md +++ b/src/ssh/HISTORY.md @@ -1,5 +1,10 @@ Release History =============== +1.1.3 +----- +* Add support to Microsoft.ConnectedVMwarevSphere/virtualMachines Resource Type +* Correct the format of expected input for --resource-type parameter + 1.1.2 ----- * Remove dependency to cryptography (Az CLI core alredy has cryptography) diff --git a/src/ssh/azext_ssh/_client_factory.py b/src/ssh/azext_ssh/_client_factory.py index 8c33c6f3ccb..eec6b6e1452 100644 --- a/src/ssh/azext_ssh/_client_factory.py +++ b/src/ssh/azext_ssh/_client_factory.py @@ -9,7 +9,9 @@ # -------------------------------------------------------------------------- from azure.cli.core.commands.client_factory import get_mgmt_service_client +from azure.cli.core.profiles import CustomResourceType +CUSTOM_MGMT_CONNECTED_VMWARE = CustomResourceType('azext_ssh.vendored_sdks.connectedvmware', 'AzureArcVMwareManagementServiceAPI') def cf_hybridconnectivity_cl(cli_ctx, *_): from azext_ssh.vendored_sdks.hybridconnectivity import HybridConnectivityManagementAPI @@ -32,9 +34,8 @@ def cf_machine(cli_ctx, *_): def cf_connectedvmware_cl(cli_ctx, *_): - from azext_ssh.vendored_sdks.connectedvmware import AzureArcVMwareManagementServiceAPI return get_mgmt_service_client(cli_ctx, - AzureArcVMwareManagementServiceAPI) + CUSTOM_MGMT_CONNECTED_VMWARE) def cf_vmware(cli_ctx, *_): From 84c3096aa70c557715d2b69cc51c383e3c5a3763 Mon Sep 17 00:00:00 2001 From: Vivian Thiebaut Date: Thu, 20 Oct 2022 15:17:43 -0400 Subject: [PATCH 14/15] Remove CustomResourceType for vmware client --- src/ssh/azext_ssh/_client_factory.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/ssh/azext_ssh/_client_factory.py b/src/ssh/azext_ssh/_client_factory.py index eec6b6e1452..ca0a6d469b7 100644 --- a/src/ssh/azext_ssh/_client_factory.py +++ b/src/ssh/azext_ssh/_client_factory.py @@ -9,9 +9,6 @@ # -------------------------------------------------------------------------- from azure.cli.core.commands.client_factory import get_mgmt_service_client -from azure.cli.core.profiles import CustomResourceType - -CUSTOM_MGMT_CONNECTED_VMWARE = CustomResourceType('azext_ssh.vendored_sdks.connectedvmware', 'AzureArcVMwareManagementServiceAPI') def cf_hybridconnectivity_cl(cli_ctx, *_): from azext_ssh.vendored_sdks.hybridconnectivity import HybridConnectivityManagementAPI @@ -34,8 +31,9 @@ def cf_machine(cli_ctx, *_): def cf_connectedvmware_cl(cli_ctx, *_): + from azext_ssh.vendored_sdks.connectedvmware import AzureArcVMwareManagementServiceAPI return get_mgmt_service_client(cli_ctx, - CUSTOM_MGMT_CONNECTED_VMWARE) + AzureArcVMwareManagementServiceAPI) def cf_vmware(cli_ctx, *_): From 2ad695f5a1437f9a7f619d9bc89ce9a0b5e53661 Mon Sep 17 00:00:00 2001 From: Vivian Thiebaut Date: Thu, 20 Oct 2022 17:10:11 -0400 Subject: [PATCH 15/15] Fix comments, style, and history --- src/ssh/HISTORY.md | 4 ++-- src/ssh/azext_ssh/_client_factory.py | 1 + src/ssh/azext_ssh/target_os_utils.py | 1 + src/ssh/azext_ssh/tests/latest/test_ssh_utils.py | 3 --- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/ssh/HISTORY.md b/src/ssh/HISTORY.md index 2195e11021c..3479a558d2f 100644 --- a/src/ssh/HISTORY.md +++ b/src/ssh/HISTORY.md @@ -2,8 +2,8 @@ Release History =============== 1.1.3 ----- -* Add support to Microsoft.ConnectedVMwarevSphere/virtualMachines Resource Type -* Correct the format of expected input for --resource-type parameter +* Add support to Microsoft.ConnectedVMwarevSphere/virtualMachines Resource Type. +* Correct the format of expected input for --resource-type parameter. From Resource Provider name (e.g. "Microsoft.HybridCompute") to Resource Type name (e.g. "Microsoft.HybridCompute/machines"). 1.1.2 ----- diff --git a/src/ssh/azext_ssh/_client_factory.py b/src/ssh/azext_ssh/_client_factory.py index ca0a6d469b7..8c33c6f3ccb 100644 --- a/src/ssh/azext_ssh/_client_factory.py +++ b/src/ssh/azext_ssh/_client_factory.py @@ -10,6 +10,7 @@ from azure.cli.core.commands.client_factory import get_mgmt_service_client + def cf_hybridconnectivity_cl(cli_ctx, *_): from azext_ssh.vendored_sdks.hybridconnectivity import HybridConnectivityManagementAPI return get_mgmt_service_client(cli_ctx, diff --git a/src/ssh/azext_ssh/target_os_utils.py b/src/ssh/azext_ssh/target_os_utils.py index 0490db26395..81a2333fce8 100644 --- a/src/ssh/azext_ssh/target_os_utils.py +++ b/src/ssh/azext_ssh/target_os_utils.py @@ -12,6 +12,7 @@ logger = log.get_logger(__name__) +# Send target OS type telemetry and check if authentication options are valid for that OS. def handle_target_os_type(cmd, op_info): os_type = None diff --git a/src/ssh/azext_ssh/tests/latest/test_ssh_utils.py b/src/ssh/azext_ssh/tests/latest/test_ssh_utils.py index 0ee4e1932af..1ab0ce261a1 100644 --- a/src/ssh/azext_ssh/tests/latest/test_ssh_utils.py +++ b/src/ssh/azext_ssh/tests/latest/test_ssh_utils.py @@ -6,9 +6,6 @@ from azure.cli.core import azclierror from unittest import mock import unittest -import platform -import os - from azext_ssh import ssh_utils from azext_ssh import ssh_info