diff --git a/src/ssh/azext_ssh/_client_factory.py b/src/ssh/azext_ssh/_client_factory.py index f2b14f3e0b1..e91e3a9b8bc 100644 --- a/src/ssh/azext_ssh/_client_factory.py +++ b/src/ssh/azext_ssh/_client_factory.py @@ -8,9 +8,20 @@ # regenerated. # -------------------------------------------------------------------------- +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, + HybridConnectivityManagementAPI) + + +def cf_endpoint(cli_ctx, *_): + return cf_hybridconnectivity_cl(cli_ctx).endpoints + def cf_connectedmachine_cl(cli_ctx, *_): - from azure.cli.core.commands.client_factory import get_mgmt_service_client from azext_ssh.vendored_sdks.connectedmachine import ConnectedMachine return get_mgmt_service_client(cli_ctx, ConnectedMachine) @@ -18,19 +29,3 @@ def cf_connectedmachine_cl(cli_ctx, *_): def cf_machine(cli_ctx, *_): return cf_connectedmachine_cl(cli_ctx).machines - - -def cf_machine_extension(cli_ctx, *_): - return cf_connectedmachine_cl(cli_ctx).machine_extensions - - -def cf_private_link_scope(cli_ctx, *_): - return cf_connectedmachine_cl(cli_ctx).private_link_scopes - - -def cf_private_link_resource(cli_ctx, *_): - return cf_connectedmachine_cl(cli_ctx).private_link_resources - - -def cf_private_endpoint_connection(cli_ctx, *_): - return cf_connectedmachine_cl(cli_ctx).private_endpoint_connections diff --git a/src/ssh/azext_ssh/_help.py b/src/ssh/azext_ssh/_help.py index d7537b43b8e..d13621bd6b5 100644 --- a/src/ssh/azext_ssh/_help.py +++ b/src/ssh/azext_ssh/_help.py @@ -28,9 +28,9 @@ - name: Using additional ssh arguments text: | az ssh vm --ip 1.2.3.4 -- -A -o ForwardX11=yes - - name: Give the Resource ID of a VM to SSH using AAD issued certificates. Using the resource ID to identify the target machine is useful when there is an Azure VM and a Arc Server with the same name in the same resource group. + - name: Give the Resource Type of a VM to SSH using AAD issued certificates. Using the resource type is useful when there is an Azure VM and a Arc Server with the same name in the same resource group. text: | - az ssh vm --resource-id /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myRG/providers/Microsoft.Compute/virtualMachines/myVM + az ssh vm --resource-type Microsoft.Compute --resource-group myResourceGroup --vm-name myVM - name: Give a local user name to SSH using local user credentials on the target machine using certificate based authentication. text: | az ssh vm --local-user username --ip 1.2.3.4 --certificate-file cert.pub --private-key key @@ -39,7 +39,7 @@ az ssh vm --local-user username --resource-group myResourceGroup --vm-name myVM --private-key-file key - name: Give a local user name to SSH using local user credentials on the target machine using password based authentication. text: | - az ssh vm --local-user username --resource-id /subscriptions/mySubsription/resourceGroups/myResourceGroup/providers/Microsoft.HybridCompute/machines/myArcServer + az ssh vm --local-user username --resource-group myResourceGroup --vm-name myArcServer """ helps['ssh config'] = """ @@ -85,9 +85,6 @@ - name: Give a resource group and Arc Server Name to SSH using AAD issued certificates text: | az ssh arc --resource-group myResourceGroup --vm-name myArcServer - - name: Give the Resource ID of an Arc Server to SSH using AAD issued certificates - text: | - az ssh arc --resource-id /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myRG/providers/Microsoft.HybridCompute/machines/myArcServer - name: Using a custom private key file text: | az ssh arc --resource-group myResourceGroup --vm-name myArcServer --private-key-file key --public-key-file key.pub @@ -99,5 +96,5 @@ az ssh arc --resource-group myRG --vm-name myVM --local-user name --private-key-file key - name: Give a local user name to SSH to a local user using password-based authentication text: | - az ssh arc --resource-id /subscriptions/mySubsription/resourceGroups/myRG/providers/Microsoft.HybridCompute/machines/myArcServer --local-user username + az ssh arc --resource-group myResourceGroup --vm-name myArcServer --local-user username """ diff --git a/src/ssh/azext_ssh/_params.py b/src/ssh/azext_ssh/_params.py index ce3ad0b4dd5..a01c787d61f 100644 --- a/src/ssh/azext_ssh/_params.py +++ b/src/ssh/azext_ssh/_params.py @@ -3,14 +3,12 @@ # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- - def load_arguments(self, _): with self.argument_context('ssh vm') as c: c.argument('vm_name', options_list=['--vm-name', '--name', '-n'], help='The name of the VM') c.argument('ssh_ip', options_list=['--ip', '--hostname'], help='The public (or reachable private) IP address (or hostname) of the VM') - c.argument('resource_id', options_list=['--resource-id'], help='The Resource ID of the Azure VM or Arc Server') c.argument('public_key_file', options_list=['--public-key-file', '-p'], help='The RSA public key file path') c.argument('private_key_file', options_list=['--private-key-file', '-i'], help='The RSA private key file path') c.argument('use_private_ip', options_list=['--prefer-private-ip'], @@ -20,9 +18,12 @@ def load_arguments(self, _): c.argument('cert_file', options_list=['--certificate-file', '-c'], 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', + completer=["Microsoft.HybridCompute", "Microsoft.Compute"]) c.argument('ssh_client_path', options_list=['--ssh-client-path'], help='Path to ssh executable. Default to ssh pre-installed if not provided.') - c.argument('delete_privkey', options_list=['--delete-private-key'], + c.argument('delete_credentials', options_list=['--force-delete-credentials', '--delete-private-key'], help=('This is an internal argument. This argument is used by Azure Portal to provide a one click ' 'SSH login experience in Cloud shell.'), deprecate_info=c.deprecate(hide=True), action='store_true') @@ -32,7 +33,6 @@ def load_arguments(self, _): c.argument('config_path', options_list=['--file', '-f'], help='The file path to write the SSH config to') c.argument('vm_name', options_list=['--vm-name', '--name', '-n'], help='The name of the VM') c.argument('ssh_ip', options_list=['--ip'], help='The public IP address (or hostname) of the VM') - c.argument('resource_id', options_list=['--resource-id'], help='The Resource ID of the Azure VM or Arc Server') c.argument('public_key_file', options_list=['--public-key-file', '-p'], help='The RSA public key file path') c.argument('private_key_file', options_list=['--private-key-file', '-i'], help='The RSA private key file path') c.argument('use_private_ip', options_list=['--prefer-private-ip'], @@ -41,13 +41,19 @@ def load_arguments(self, _): help='The username for a local user') c.argument('overwrite', action='store_true', options_list=['--overwrite'], help='Overwrites the config file if this flag is set') + c.argument('credentials_folder', options_list=['--keys-destination-folder', '--keys-dest-folder'], + help='Folder where new generated keys will be stored.') 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 or Microsoft.HybridCompute') c.argument('cert_file', options_list=['--certificate-file', '-c'], help='Path to certificate file') with self.argument_context('ssh cert') as c: c.argument('cert_path', options_list=['--file', '-f'], help='The file path to write the SSH cert to, defaults to public key path with -aadcert.pub appened') - c.argument('public_key_file', options_list=['--public-key-file', '-p'], help='The RSA public key file path') + c.argument('public_key_file', options_list=['--public-key-file', '-p'], + help='The RSA public key file path. If not provided, ' + 'generated key pair is stored in the same directory as --file.') with self.argument_context('ssh arc') as c: c.argument('vm_name', options_list=['--vm-name', '--name', '-n'], help='The name of the Arc Server') @@ -56,11 +62,10 @@ def load_arguments(self, _): c.argument('local_user', options_list=['--local-user'], help='The username for a local user') c.argument('cert_file', options_list=['--certificate-file', '-c'], help='Path to certificate file') - c.argument('resource_id', options_list=['--resource-id'], help='The Resource ID of the Arc Server') c.argument('port', options_list=['--port'], help='Port to connect to on the remote host.') c.argument('ssh_client_path', options_list=['--ssh-client-path'], help='Path to ssh executable. Default to ssh pre-installed if not provided.') - c.argument('delete_privkey', options_list=['--delete-private-key'], + c.argument('delete_credentials', options_list=['--force-delete-credentials', '--delete-private-key'], help=('This is an internal argument. This argument is used by Azure Portal to provide a one click ' 'SSH login experience in Cloud shell.'), deprecate_info=c.deprecate(hide=True), action='store_true') diff --git a/src/ssh/azext_ssh/constants.py b/src/ssh/azext_ssh/constants.py index 9be7ef75418..1731ec2df75 100644 --- a/src/ssh/azext_ssh/constants.py +++ b/src/ssh/azext_ssh/constants.py @@ -3,8 +3,13 @@ # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- -CLIENT_PROXY_VERSION = "1.3.017131" -CLIENT_PROXY_RELEASE = "release10-09-21" +CLIENT_PROXY_VERSION = "1.3.017634" +CLIENT_PROXY_RELEASE = "release01-11-21" CLIENT_PROXY_STORAGE_URL = "https://sshproxysa.blob.core.windows.net" CLEANUP_TOTAL_TIME_LIMIT_IN_SECONDS = 120 CLEANUP_TIME_INTERVAL_IN_SECONDS = 10 +CLEANUP_AWAIT_TERMINATION_IN_SECONDS = 30 +PROXY_UNSUPPORTED_ARCH_FAULT_TYPE = 'client-proxy-unsupported-architecture-error' +PROXY_UNSUPPORTED_OS_FAULT_TYPE = 'client-proxy-unsupported-os-error' +PROXY_DOWNLOAD_FAILED_FAULT_TYPE = 'client-proxy-download-failed-error' +LIST_CREDENTIALS_FAILED_FAULT_TYPE = 'get-relay-information-failed-error' diff --git a/src/ssh/azext_ssh/custom.py b/src/ssh/azext_ssh/custom.py index 4d2198f8af3..78076119964 100644 --- a/src/ssh/azext_ssh/custom.py +++ b/src/ssh/azext_ssh/custom.py @@ -11,10 +11,12 @@ import urllib.request import base64 import stat +import time from glob import glob +from knack import log from azure.cli.core import azclierror -from msrestazure import tools +from azure.cli.core import telemetry from . import ip_utils from . import rsa_parser @@ -22,58 +24,85 @@ from . import constants as consts from . import file_utils +logger = log.get_logger(__name__) -def ssh_vm(cmd, resource_group_name=None, vm_name=None, resource_id=None, ssh_ip=None, public_key_file=None, + +def ssh_vm(cmd, resource_group_name=None, vm_name=None, ssh_ip=None, public_key_file=None, private_key_file=None, use_private_ip=False, local_user=None, cert_file=None, port=None, - ssh_client_path=None, delete_privkey=False, ssh_args=None): + ssh_client_path=None, delete_credentials=False, resource_type=None, ssh_args=None): + + if delete_credentials and os.environ.get("AZUREPS_HOST_ENVIRONMENT") != "cloud-shell/1.0": + raise azclierror.ArgumentUsageError("Can't use --delete-private-key outside an Azure Cloud Shell session.") - _assert_args(resource_group_name, vm_name, ssh_ip, resource_id, cert_file, local_user) - do_ssh_op = _decide_op_call(cmd, resource_group_name, vm_name, resource_id, ssh_ip, None, None, - ssh_client_path, ssh_args, delete_privkey) - do_ssh_op(cmd, ssh_ip, public_key_file, private_key_file, local_user, - cert_file, port, use_private_ip) + _assert_args(resource_group_name, vm_name, ssh_ip, resource_type, cert_file, local_user) + credentials_folder = None + do_ssh_op = _decide_op_call(cmd, resource_group_name, vm_name, ssh_ip, resource_type, None, None, + ssh_client_path, ssh_args, delete_credentials, credentials_folder) + do_ssh_op(cmd, vm_name, resource_group_name, ssh_ip, public_key_file, private_key_file, local_user, + cert_file, port, use_private_ip, credentials_folder) -def ssh_config(cmd, config_path, resource_group_name=None, vm_name=None, ssh_ip=None, resource_id=None, +def ssh_config(cmd, config_path, resource_group_name=None, vm_name=None, ssh_ip=None, public_key_file=None, private_key_file=None, overwrite=False, use_private_ip=False, - local_user=None, cert_file=None, port=None): + local_user=None, cert_file=None, port=None, resource_type=None, credentials_folder=None): + + if (public_key_file or private_key_file) and credentials_folder: + raise azclierror.ArgumentUsageError("--keys-destination-folder can't be used in conjunction with " + "--public-key-file/-p or --private-key-file/-i.") + _assert_args(resource_group_name, vm_name, ssh_ip, resource_type, cert_file, local_user) - _assert_args(resource_group_name, vm_name, ssh_ip, resource_id, cert_file, local_user) - do_ssh_op = _decide_op_call(cmd, resource_group_name, vm_name, resource_id, ssh_ip, config_path, overwrite, - None, None, None) - do_ssh_op(cmd, ssh_ip, public_key_file, private_key_file, local_user, - cert_file, port, use_private_ip) + # Default credential location + if not credentials_folder: + config_folder = os.path.dirname(config_path) + if not os.path.isdir(config_folder): + raise azclierror.InvalidArgumentValueError(f"Config file destination folder {config_folder} " + "does not exist.") + folder_name = ssh_ip + if resource_group_name and vm_name: + folder_name = resource_group_name + "-" + vm_name + + credentials_folder = os.path.join(config_folder, os.path.join("az_ssh_config", folder_name)) + + do_ssh_op = _decide_op_call(cmd, resource_group_name, vm_name, ssh_ip, resource_type, config_path, overwrite, + None, None, False, credentials_folder) + do_ssh_op(cmd, vm_name, resource_group_name, ssh_ip, public_key_file, private_key_file, local_user, + cert_file, port, use_private_ip, credentials_folder) def ssh_cert(cmd, cert_path=None, public_key_file=None): - public_key_file, _ = _check_or_create_public_private_files(public_key_file, None) + if not cert_path and not public_key_file: + raise azclierror.RequiredArgumentMissingError("--file or --public-key-file must be provided.") + if cert_path and not os.path.isdir(os.path.dirname(cert_path)): + raise azclierror.InvalidArgumentValueError(f"{os.path.dirname(cert_path)} folder doesn't exist") + # If user doesn't provide a public key, save generated key pair to the same folder as --file + keys_folder = None + if not public_key_file: + keys_folder = os.path.dirname(cert_path) + logger.warning("The generated SSH keys are stored at %s. Please delete SSH keys when the certificate " + "is no longer being used.", keys_folder) + public_key_file, _, _ = _check_or_create_public_private_files(public_key_file, None, keys_folder) cert_file, _ = _get_and_write_certificate(cmd, public_key_file, cert_path) print(cert_file + "\n") -def ssh_arc(cmd, resource_group_name=None, vm_name=None, resource_id=None, public_key_file=None, private_key_file=None, - local_user=None, cert_file=None, port=None, ssh_client_path=None, delete_privkey=False, ssh_args=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_path=None, delete_credentials=False, ssh_args=None): - _assert_args(resource_group_name, vm_name, None, resource_id, cert_file, local_user) + if delete_credentials and os.environ.get("AZUREPS_HOST_ENVIRONMENT") != "cloud-shell/1.0": + raise azclierror.ArgumentUsageError("Can't use --delete-private-key outside an Azure Cloud Shell session.") - if resource_id: - resource_info = tools.parse_resource_id(resource_id) - if not set(['resource_group', 'resource_name', 'resource_namespace']).issubset(set(resource_info.keys())): - raise azclierror.InvalidArgumentValueError("Resource ID not formated correctly.") - if resource_info['resource_namespace'] != "Microsoft.HybridCompute": - raise azclierror.InvalidArgumentValueError("Resource provider in the Resource ID must be " - "'Microsoft.HybridCompute'") - resource_group_name = resource_info['resource_group'] - vm_name = resource_info['resource_name'] + _assert_args(resource_group_name, vm_name, None, "Microsoft.HybridCompute", cert_file, local_user) + + credentials_folder = None op_call = functools.partial(ssh_utils.start_ssh_connection, ssh_client_path=ssh_client_path, ssh_args=ssh_args, - delete_privkey=delete_privkey) - _do_ssh_op(cmd, None, public_key_file, private_key_file, local_user, cert_file, port, - False, resource_group_name, vm_name, op_call, True) + delete_credentials=delete_credentials) + _do_ssh_op(cmd, vm_name, resource_group_name, None, public_key_file, private_key_file, local_user, cert_file, port, + False, credentials_folder, op_call, True) -def _do_ssh_op(cmd, ssh_ip, public_key_file, private_key_file, username, - cert_file, port, use_private_ip, resource_group_name, vm_name, op_call, is_arc): +def _do_ssh_op(cmd, vm_name, resource_group_name, ssh_ip, public_key_file, private_key_file, username, + cert_file, port, use_private_ip, credentials_folder, op_call, is_arc): proxy_path = None relay_info = None @@ -88,11 +117,19 @@ def _do_ssh_op(cmd, ssh_ip, public_key_file, private_key_file, username, raise azclierror.ResourceNotFoundError(f"VM '{vm_name}' does not have a public or private IP address to" "SSH to") + # If user provides local user, no credentials should be deleted. + delete_keys = False + delete_cert = False if not username: - public_key_file, private_key_file = _check_or_create_public_private_files(public_key_file, private_key_file) + delete_cert = True + public_key_file, private_key_file, delete_keys = _check_or_create_public_private_files(public_key_file, + private_key_file, + credentials_folder) cert_file, username = _get_and_write_certificate(cmd, public_key_file, None) - op_call(relay_info, proxy_path, vm_name, ssh_ip, username, cert_file, private_key_file, port, is_arc) + print(cert_file) + op_call(relay_info, proxy_path, vm_name, ssh_ip, username, cert_file, private_key_file, port, is_arc, delete_keys, + delete_cert, public_key_file) def _get_and_write_certificate(cmd, public_key_file, cert_file): @@ -112,6 +149,7 @@ def _get_and_write_certificate(cmd, public_key_file, cert_file): from azure.cli.core._profile import Profile profile = Profile(cli_ctx=cmd.cli_ctx) + t0 = time.time() # We currently are using the presence of get_msal_token to detect if we are running on an older azure cli client # TODO: Remove when adal has been deprecated for a while if hasattr(profile, "get_msal_token"): @@ -122,6 +160,9 @@ def _get_and_write_certificate(cmd, public_key_file, cert_file): certificatedata = credential.get_token(*scopes, data=data) certificate = certificatedata.token + time_elapsed = time.time() - t0 + telemetry.add_extension_event('ssh', {'Context.Default.AzureCLI.SSHGetCertificateTime': time_elapsed}) + if not cert_file: cert_file = public_key_file + "-aadcert.pub" _write_cert_file(certificate, cert_file) @@ -151,11 +192,15 @@ def _prepare_jwk_data(public_key_file): return data -def _assert_args(resource_group, vm_name, ssh_ip, resource_id, cert_file, username): - if not (resource_group or vm_name or ssh_ip or resource_id): +def _assert_args(resource_group, vm_name, ssh_ip, resource_type, cert_file, username): + if resource_type and resource_type != "Microsoft.Compute" and resource_type != "Microsoft.HybridCompute": + raise azclierror.InvalidArgumentValueError("--resource-type must be either \"Microsoft.Compute\" " + "for Azure VMs or \"Microsoft.HybridCompute\" for Arc Servers.") + + if not (resource_group or vm_name or ssh_ip): raise azclierror.RequiredArgumentMissingError( "The VM must be specified by --ip or --resource-group and " - "--vm-name/--name or --resource_id") + "--vm-name/--name") if resource_group and not vm_name or vm_name and not resource_group: raise azclierror.MutuallyExclusiveArgumentError( @@ -165,14 +210,6 @@ def _assert_args(resource_group, vm_name, ssh_ip, resource_id, cert_file, userna raise azclierror.MutuallyExclusiveArgumentError( "--ip cannot be used with --resource-group or --vm-name/--name") - if ssh_ip and resource_id: - raise azclierror.MutuallyExclusiveArgumentError( - "--ip cannot be used with --resource-id") - - if resource_id and (vm_name or resource_group): - raise azclierror.MutuallyExclusiveArgumentError( - "--resource-id cannot be used with --resource-group or --vm-name/--name") - if cert_file and not username: raise azclierror.MutuallyExclusiveArgumentError( "To authenticate with a certificate you need to provide a --local-user") @@ -181,12 +218,23 @@ def _assert_args(resource_group, vm_name, ssh_ip, resource_id, cert_file, userna raise azclierror.FileOperationError(f"Certificate file {cert_file} not found") -def _check_or_create_public_private_files(public_key_file, private_key_file): +def _check_or_create_public_private_files(public_key_file, private_key_file, credentials_folder): + delete_keys = False # If nothing is passed in create a temporary directory with a ephemeral keypair if not public_key_file and not private_key_file: - temp_dir = tempfile.mkdtemp(prefix="aadsshcert") - public_key_file = os.path.join(temp_dir, "id_rsa.pub") - private_key_file = os.path.join(temp_dir, "id_rsa") + # We only want to delete the keys if the user hasn't provided their own keys + # Only ssh vm deletes generated keys. + delete_keys = True + if not credentials_folder: + # az ssh vm: Create keys on temp folder and delete folder once connection succeeds/fails. + credentials_folder = tempfile.mkdtemp(prefix="aadsshcert") + else: + # az ssh config: Keys saved to the same folder as --file or to --keys-destination-folder. + # az ssh cert: Keys saved to the same folder as --file. + if not os.path.isdir(credentials_folder): + os.makedirs(credentials_folder) + public_key_file = os.path.join(credentials_folder, "id_rsa.pub") + private_key_file = os.path.join(credentials_folder, "id_rsa") ssh_utils.create_ssh_keyfile(private_key_file) if not public_key_file: @@ -204,7 +252,7 @@ def _check_or_create_public_private_files(public_key_file, private_key_file): if not os.path.isfile(private_key_file): raise azclierror.FileOperationError(f"Private key file {private_key_file} not found") - return public_key_file, private_key_file + return public_key_file, private_key_file, delete_keys def _write_cert_file(certificate_contents, cert_file): @@ -238,6 +286,9 @@ def _arc_get_client_side_proxy(): operating_system = platform.system() machine = platform.machine() + logger.debug("Platform OS: %s", operating_system) + logger.debug("Platform architecture: %s", machine) + if machine.endswith('64'): architecture = 'amd64' elif machine.endswith('86'): @@ -245,6 +296,9 @@ def _arc_get_client_side_proxy(): elif machine == '': raise azclierror.BadRequestError("Couldn't identify the platform architecture.") else: + telemetry.set_exception(exception='Unsuported architecture for installing proxy', + fault_type=consts.PROXY_UNSUPPORTED_ARCH_FAULT_TYPE, + summary=f'{machine} is not supported for installing client proxy') raise azclierror.BadRequestError(f"Unsuported architecture: {machine} is not currently supported") # define the request url and install location based on the os and architecture @@ -259,6 +313,9 @@ def _arc_get_client_side_proxy(): install_location = install_location + ".exe" older_version_location = older_version_location + ".exe" elif operating_system not in ('Linux', 'Darwin'): + telemetry.set_exception(exception='Unsuported OS for installing ssh client proxy', + fault_type=consts.PROXY_UNSUPPORTED_OS_FAULT_TYPE, + summary=f'{operating_system} is not supported for installing client proxy') raise azclierror.BadRequestError(f"Unsuported OS: {operating_system} platform is not currently supported") install_location = os.path.expanduser(os.path.join('~', install_location)) @@ -267,14 +324,24 @@ def _arc_get_client_side_proxy(): # Only download new proxy if it doesn't exist already if not os.path.isfile(install_location): + t0 = time.time() # download the executable try: with urllib.request.urlopen(request_uri) as response: response_content = response.read() response.close() except Exception as e: + telemetry.set_exception(exception=e, fault_type=consts.PROXY_DOWNLOAD_FAILED_FAULT_TYPE, + summary=f'Failed to download proxy from {request_uri}') raise azclierror.ClientRequestError(f"Failed to download client proxy executable from {request_uri}. " "Error: " + str(e)) from e + time_elapsed = time.time() - t0 + + proxy_data = { + 'Context.Default.AzureCLI.SSHProxyDownloadTime': time_elapsed, + 'Context.Default.AzureCLI.SSHProxyVersion': consts.CLIENT_PROXY_VERSION + } + telemetry.add_extension_event('ssh', proxy_data) # if directory doesn't exist, create it if not os.path.exists(install_dir): @@ -292,26 +359,40 @@ def _arc_get_client_side_proxy(): return install_location -# Get the Access Details to connect to Arc Connectivity platform from the HybridCompute Resource Provider -# TO DO: This is a temporary API call to get the relay info. We will move to a different one in the future. +# Get the Access Details to connect to Arc Connectivity platform from the HybridConnectivity RP def _arc_list_access_details(cmd, resource_group, vm_name): - from azext_ssh._client_factory import cf_machine - client = cf_machine(cmd.cli_ctx) - status_code, result = client.list_access_details(resource_group_name=resource_group, machine_name=vm_name) - if status_code in [501, 404]: - error = {404: 'Not Found', 501: 'Not Implemented'} - raise azclierror.BadRequestError("REST API request for access information returned an invalid status " - f"\"{error[status_code]}\". Please update the current version of the SSH" - "extension by runing \"az extension update ssh\".") - result = result.replace("\'", "\"") - result_bytes = result.encode("ascii") + from azext_ssh._client_factory import cf_endpoint + client = cf_endpoint(cmd.cli_ctx) + try: + t0 = time.time() + result = client.list_credentials(resource_group_name=resource_group, machine_name=vm_name, + endpoint_name="default") + time_elapsed = time.time() - t0 + telemetry.add_extension_event('ssh', {'Context.Default.AzureCLI.SSHListCredentialsTime': time_elapsed}) + except Exception as e: + telemetry.set_exception(exception='Call to listCredentials failed', + fault_type=consts.LIST_CREDENTIALS_FAILED_FAULT_TYPE, + summary=f'listCredentials failed with error: {str(e)}.') + raise azclierror.ClientRequestError(f"Request for Azure Relay Information Failed: {str(e)}") + + result_string = json.dumps( + { + "relay": { + "namespaceName": result.namespace_name, + "namespaceNameSuffix": result.namespace_name_suffix, + "hybridConnectionName": result.hybrid_connection_name, + "accessKey": result.access_key, + "expiresOn": result.expires_on + } + }) + result_bytes = result_string.encode("ascii") enc = base64.b64encode(result_bytes) base64_result_string = enc.decode("ascii") return base64_result_string -def _decide_op_call(cmd, resource_group_name, vm_name, resource_id, ssh_ip, config_path, overwrite, - ssh_client_path, ssh_args, delete_privkey): +def _decide_op_call(cmd, resource_group_name, vm_name, ssh_ip, resource_type, config_path, overwrite, + ssh_client_path, ssh_args, delete_credentials, credentials_folder): # 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. @@ -320,62 +401,60 @@ def _decide_op_call(cmd, resource_group_name, vm_name, resource_id, ssh_ip, conf if ssh_ip: is_arc_server = False - elif resource_id: - resource_info = tools.parse_resource_id(resource_id) - if not set(['resource_group', 'resource_name', 'resource_namespace']).issubset(set(resource_info.keys())): - raise azclierror.InvalidArgumentValueError("Resource ID not formated correctly.") - resource_group_name = resource_info['resource_group'] - vm_name = resource_info['resource_name'] - if resource_info['resource_namespace'] == "Microsoft.HybridCompute": + elif resource_type: + if resource_type == "Microsoft.HybridCompute": is_arc_server = True - elif resource_info['resource_namespace'] != "Microsoft.Compute": - error = ("Invalid Resource ID. Resource provider must be Microsoft.Compute if resource is an " - "Azure Virtual Machine, or Microsoft.HybridCompute if it is an Arc Server.") - raise azclierror.InvalidArgumentValueError(error) else: - is_azure_vm = _check_if_azure_vm(cmd, resource_group_name, vm_name) - is_arc_server = _check_if_arc_server(cmd, resource_group_name, vm_name) + vm_error, is_azure_vm = _check_if_azure_vm(cmd, resource_group_name, vm_name) + arc_error, is_arc_server = _check_if_arc_server(cmd, resource_group_name, vm_name) if is_azure_vm and is_arc_server: raise azclierror.BadRequestError(f"{resource_group_name} has Azure VM and Arc Server with the " - f"same name: {vm_name}. Please try with --resource-id instead " - "of --vm-name and --resource-group") + f"same name: {vm_name}. Please provide a --resource-type.") if not is_azure_vm and not is_arc_server: from azure.core.exceptions import ResourceNotFoundError - raise ResourceNotFoundError(f"The Resource {vm_name} under resource group '{resource_group_name}' " - "was not found.") + if isinstance(arc_error, ResourceNotFoundError) and isinstance(vm_error, ResourceNotFoundError): + raise azclierror.ResourceNotFoundError(f"The resource {vm_name} in the resource group " + f"{resource_group_name} was not found. Erros:\n" + f"{str(arc_error)}\n{str(vm_error)}") + 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)}") if config_path: op_call = functools.partial(ssh_utils.write_ssh_config, config_path=config_path, overwrite=overwrite, - resource_group=resource_group_name) + resource_group=resource_group_name, credentials_folder=credentials_folder) else: op_call = functools.partial(ssh_utils.start_ssh_connection, ssh_client_path=ssh_client_path, ssh_args=ssh_args, - delete_privkey=delete_privkey) - do_ssh_op = functools.partial(_do_ssh_op, resource_group_name=resource_group_name, vm_name=vm_name, - is_arc=is_arc_server, op_call=op_call) - + delete_credentials=delete_credentials) + do_ssh_op = functools.partial(_do_ssh_op, is_arc=is_arc_server, op_call=op_call) return do_ssh_op 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 - from azure.core.exceptions import ResourceNotFoundError + from azure.core.exceptions import ResourceNotFoundError, HttpResponseError try: compute_client = client_factory.get_mgmt_service_client(cmd.cli_ctx, profiles.ResourceType.MGMT_COMPUTE) compute_client.virtual_machines.get(resource_group_name, vm_name) - except ResourceNotFoundError: - return False - return True + except ResourceNotFoundError as e: + return e, False + # If user is not authorized to get the VM, it will throw a HttpResponseError + except HttpResponseError as e: + return e, False + return None, True def _check_if_arc_server(cmd, resource_group_name, vm_name): - from azure.core.exceptions import ResourceNotFoundError + from azure.core.exceptions import ResourceNotFoundError, HttpResponseError from azext_ssh._client_factory import cf_machine client = cf_machine(cmd.cli_ctx) try: client.get(resource_group_name=resource_group_name, machine_name=vm_name) - except ResourceNotFoundError: - return False - return True + except ResourceNotFoundError as e: + return e, False + # If user is not authorized to get the arc server, it will throw a HttpResponseError + except HttpResponseError as e: + return e, False + return None, True diff --git a/src/ssh/azext_ssh/file_utils.py b/src/ssh/azext_ssh/file_utils.py index f3ecebf8b7f..2628133aba9 100644 --- a/src/ssh/azext_ssh/file_utils.py +++ b/src/ssh/azext_ssh/file_utils.py @@ -27,13 +27,25 @@ def mkdir_p(path): def delete_file(file_path, message, warning=False): - try: - os.remove(file_path) - except Exception as e: - if warning: - logger.warning(message) - else: - raise azclierror.FileOperationError(message + "Error: " + str(e)) from e + if os.path.isfile(file_path): + try: + os.remove(file_path) + except Exception as e: + if warning: + logger.warning(message) + else: + raise azclierror.FileOperationError(message + "Error: " + str(e)) from e + + +def delete_folder(dir_path, message, warning=False): + if os.path.isdir(dir_path): + try: + os.rmdir(dir_path) + except Exception as e: + if warning: + logger.warning(message) + else: + raise azclierror.FileOperationError(message + "Error: " + str(e)) from e def create_directory(file_path, error_message): diff --git a/src/ssh/azext_ssh/ssh_utils.py b/src/ssh/azext_ssh/ssh_utils.py index f1f221aa172..66cc1ce1d10 100644 --- a/src/ssh/azext_ssh/ssh_utils.py +++ b/src/ssh/azext_ssh/ssh_utils.py @@ -5,15 +5,14 @@ import os import platform import subprocess -import tempfile import stat import multiprocessing as mp import time -import re import oschmod from knack import log from azure.cli.core import azclierror +from azure.cli.core import telemetry from . import file_utils from . import constants as const @@ -22,33 +21,17 @@ def start_ssh_connection(relay_info, proxy_path, vm_name, ip, username, cert_file, private_key_file, port, - is_arc, ssh_client_path, ssh_args, delete_privkey): + is_arc, delete_keys, delete_cert, public_key_file, ssh_client_path, ssh_args, + delete_credentials): if not ssh_client_path: ssh_client_path = _get_ssh_path() + ssh_arg_list = [] if ssh_args: ssh_arg_list = ssh_args - env = os.environ.copy() - - ssh_client_log_file_arg = [] - # delete_privkey is only true for injected commands in the portal one click ssh experience - if delete_privkey and (cert_file or private_key_file): - if '-E' in ssh_arg_list: - # This condition should rarely be true - index = ssh_arg_list.index('-E') - log_file = ssh_arg_list[index + 1] - else: - if cert_file: - log_dir = os.path.dirname(cert_file) - elif private_key_file: - log_dir = os.path.dirname(private_key_file) - log_file_name = 'ssh_client_log_' + str(os.getpid()) - log_file = os.path.join(log_dir, log_file_name) - ssh_client_log_file_arg = ['-E', log_file] - if '-v' not in ssh_arg_list and '-vv' not in ssh_arg_list and '-vvv' not in ssh_arg_list: - ssh_client_log_file_arg = ssh_client_log_file_arg + ['-v'] + env = os.environ.copy() if is_arc: env['SSHPROXY_RELAY_INFO'] = relay_info @@ -62,28 +45,31 @@ def start_ssh_connection(relay_info, proxy_path, vm_name, ip, username, cert_fil host = _get_host(username, ip) args = _build_args(cert_file, private_key_file, port) + if not cert_file and not private_key_file: + # In this case, even if delete_credentials is true, there is nothing to clean-up. + delete_credentials = False + + log_file, ssh_arg_list, cleanup_process = _start_cleanup(cert_file, private_key_file, + public_key_file, delete_credentials, + delete_keys, delete_cert, ssh_arg_list) + command = [ssh_client_path, host] - command = command + args + ssh_client_log_file_arg + ssh_arg_list - - # If delete_privkey flag is true, we will try to clean the private key file and the certificate file - # once the connection has been established. If it's not possible to open the log file, we default to - # waiting for about 2 minutes once the ssh process starts before cleaning up the files. - if delete_privkey and (cert_file or private_key_file): - if os.path.isfile(log_file): - file_utils.delete_file(log_file, f"Couldn't delete existing log file {log_file}", True) - cleanup_process = mp.Process(target=_do_cleanup, args=(private_key_file, cert_file, log_file)) - cleanup_process.start() + command = command + args + ssh_arg_list + + connection_duration = time.time() logger.debug("Running ssh command %s", ' '.join(command)) subprocess.call(command, shell=platform.system() == 'Windows', env=env) - # If the cleanup process is still alive once the ssh process is terminated, we terminate it and make - # sure the private key and certificate are deleted. - if delete_privkey and (cert_file or private_key_file): - if cleanup_process.is_alive(): - cleanup_process.terminate() - time.sleep(1) - _do_cleanup(private_key_file, cert_file) + connection_duration = (time.time() - connection_duration) / 60 + + ssh_connection_data = {'Context.Default.AzureCLI.SSHConnectionDurationInMinutes': connection_duration} + if log_file and _get_connection_status(log_file): + ssh_connection_data['Context.Default.AzureCLI.SSHConnectionStatus'] = "Success" + telemetry.add_extension_event('ssh', ssh_connection_data) + + _terminate_cleanup(delete_keys, delete_cert, delete_credentials, cleanup_process, cert_file, + private_key_file, public_key_file, log_file) def create_ssh_keyfile(private_key_file): @@ -114,8 +100,18 @@ def get_ssh_cert_principals(cert_file): return principals +def get_ssh_cert_validity(cert_file): + if cert_file: + info = get_ssh_cert_info(cert_file) + for line in info: + if "Valid:" in line: + return line.strip() + return None + + def write_ssh_config(relay_info, proxy_path, vm_name, ip, username, - cert_file, private_key_file, port, is_arc, config_path, overwrite, resource_group): + cert_file, private_key_file, port, is_arc, delete_keys, delete_cert, _, + config_path, overwrite, resource_group, credentials_folder): common_lines = [] common_lines.append("\tUser " + username) @@ -125,17 +121,12 @@ def write_ssh_config(relay_info, proxy_path, vm_name, ip, username, common_lines.append("\tIdentityFile " + private_key_file) lines = [""] + relay_info_path = None + relay_info_filename = None if is_arc: - if cert_file: - relay_info_dir = os.path.dirname(cert_file) - elif private_key_file: - relay_info_dir = os.path.dirname(private_key_file) - else: - relay_info_dir = tempfile.mkdtemp(prefix="ssharcrelayinfo") - relay_info_path = os.path.join(relay_info_dir, "relay_info") - file_utils.write_to_file(relay_info_path, 'w', relay_info, - f"Couldn't write relay information to file {relay_info_path}", 'utf-8') - oschmod.set_mode(relay_info_path, stat.S_IRUSR) + relay_info_path, relay_info_filename = _prepare_relay_info_file(relay_info, cert_file, + private_key_file, credentials_folder, + vm_name, resource_group) lines.append("Host " + resource_group + "-" + vm_name) lines.append("\tHostName " + vm_name) @@ -169,6 +160,8 @@ def write_ssh_config(relay_info, proxy_path, vm_name, ip, username, with open(config_path, mode) as f: f.write('\n'.join(lines)) + _issue_config_cleanup_warning(delete_cert, delete_keys, is_arc, cert_file, relay_info_filename, relay_info_path) + def _get_ssh_path(ssh_command="ssh"): ssh_path = ssh_command @@ -209,11 +202,7 @@ def _build_args(cert_file, private_key_file, port): return private_key + certificate + port_arg -def _do_cleanup(private_key_file, cert_file, log_file=None): - if os.environ.get("AZUREPS_HOST_ENVIRONMENT") != "cloud-shell/1.0": - raise azclierror.BadRequestError("Can't delete private key file. " - "The --delete-private-key flag set to True, " - "but this is not an Azure Cloud Shell session.") +def _do_cleanup(delete_keys, delete_cert, cert_file, private_key, public_key, log_file=None, wait=False): if log_file: t0 = time.time() match = False @@ -221,17 +210,133 @@ def _do_cleanup(private_key_file, cert_file, log_file=None): time.sleep(const.CLEANUP_TIME_INTERVAL_IN_SECONDS) try: with open(log_file, 'r') as ssh_client_log: - for line in ssh_client_log: - if re.search("debug1: Authentication succeeded", line): - match = True - ssh_client_log.close() + match = "debug1: Authentication succeeded" in ssh_client_log.read() + ssh_client_log.close() except: - t1 = time.time() - t0 - if t1 < const.CLEANUP_TOTAL_TIME_LIMIT_IN_SECONDS: - time.sleep(const.CLEANUP_TOTAL_TIME_LIMIT_IN_SECONDS - t1) + # If there is an exception, wait for a little bit and try again + time.sleep(const.CLEANUP_TIME_INTERVAL_IN_SECONDS) + + elif wait: + # if we are not checking the logs, but still want to wait for connection before deleting files + time.sleep(const.CLEANUP_TOTAL_TIME_LIMIT_IN_SECONDS) + + if delete_keys and private_key: + file_utils.delete_file(private_key, f"Couldn't delete private key {private_key}. ", True) + if delete_keys and public_key: + file_utils.delete_file(public_key, f"Couldn't delete public key {public_key}. ", True) + if delete_cert and cert_file: + file_utils.delete_file(cert_file, f"Couldn't delete certificate {cert_file}. ", True) + + +def _start_cleanup(cert_file, private_key_file, public_key_file, delete_credentials, delete_keys, + delete_cert, ssh_arg_list): + + log_file = None + cleanup_process = None + if delete_keys or delete_cert or delete_credentials: + if '-E' not in ssh_arg_list and set(['-v', '-vv', '-vvv']).isdisjoint(ssh_arg_list): + # If the user either provides his own client log file (-E) or + # wants the client log messages to be printed to the console (-vvv/-vv/-v), + # we should not use the log files to check for connection success. + if cert_file: + log_dir = os.path.dirname(cert_file) + elif private_key_file: + log_dir = os.path.dirname(private_key_file) + log_file_name = 'ssh_client_log_' + str(os.getpid()) + log_file = os.path.join(log_dir, log_file_name) + ssh_arg_list = ssh_arg_list + ['-E', log_file, '-v'] + # Create a new process that will wait until the connection is established and then delete keys. + cleanup_process = mp.Process(target=_do_cleanup, args=(delete_keys or delete_credentials, + delete_cert or delete_credentials, + cert_file, private_key_file, public_key_file, + log_file, True)) + cleanup_process.start() - if private_key_file and os.path.isfile(private_key_file): - file_utils.delete_file(private_key_file, f"Failed to delete private key file '{private_key_file}'. ") + return log_file, ssh_arg_list, cleanup_process - if cert_file and os.path.isfile(cert_file): - file_utils.delete_file(cert_file, f"Failed to delete certificate file '{cert_file}'. ") + +def _terminate_cleanup(delete_keys, delete_cert, delete_credentials, cleanup_process, cert_file, + private_key_file, public_key_file, log_file): + if delete_keys or delete_cert or delete_credentials: + if cleanup_process.is_alive(): + cleanup_process.terminate() + # wait for process to terminate + t0 = time.time() + while cleanup_process.is_alive() and (time.time() - t0) < const.CLEANUP_AWAIT_TERMINATION_IN_SECONDS: + time.sleep(1) + + # Make sure all files have been properly removed. + _do_cleanup(delete_keys or delete_credentials, delete_cert or delete_credentials, + cert_file, private_key_file, public_key_file) + if log_file: + file_utils.delete_file(log_file, f"Couldn't delete temporary log file {log_file}. ", True) + if delete_keys: + # This is only true if keys were generated, so they must be in a temp folder. + temp_dir = os.path.dirname(cert_file) + file_utils.delete_folder(temp_dir, f"Couldn't delete temporary folder {temp_dir}", True) + + +def _prepare_relay_info_file(relay_info, cert_file, private_key_file, credentials_folder, vm_name, resource_group): + if cert_file: + relay_info_dir = os.path.dirname(cert_file) + elif private_key_file: + relay_info_dir = os.path.dirname(private_key_file) + else: + # create the custom folder + relay_info_dir = credentials_folder + if not os.path.isdir(relay_info_dir): + os.makedirs(relay_info_dir) + + if vm_name and resource_group: + relay_info_filename = resource_group + "-" + vm_name + "-relay_info" + + relay_info_path = os.path.join(relay_info_dir, relay_info_filename) + # Overwrite relay_info if it already exists in that folder. + file_utils.delete_file(relay_info_path, f"{relay_info_path} already exists, and couldn't be overwritten.") + file_utils.write_to_file(relay_info_path, 'w', relay_info, + f"Couldn't write relay information to file {relay_info_path}.", 'utf-8') + oschmod.set_mode(relay_info_path, stat.S_IRUSR) + + return relay_info_path, relay_info_filename + + +def _issue_config_cleanup_warning(delete_cert, delete_keys, is_arc, cert_file, relay_info_filename, relay_info_path): + if delete_keys or delete_cert or is_arc: + # Warn users to delete credentials once config file is no longer being used. + # If user provided keys, only ask them to delete the certificate. + if is_arc: + if delete_keys and delete_cert: + path_to_delete = os.path.dirname(cert_file) + items_to_delete = f" (id_rsa, id_rsa.pub, id_rsa.pub-aadcert.pub, {relay_info_filename})" + elif delete_cert: + path_to_delete = os.path.dirname(cert_file) + items_to_delete = f" (id_rsa.pub-aadcert.pub, {relay_info_filename})" + else: + path_to_delete = relay_info_path + items_to_delete = "" + else: + path_to_delete = os.path.dirname(cert_file) + items_to_delete = " (id_rsa, id_rsa.pub, id_rsa.pub-aadcert.pub)" + if not delete_keys: + path_to_delete = cert_file + items_to_delete = "" + + validity_warning = "" + if delete_cert: + validity = get_ssh_cert_validity(cert_file) + if validity: + validity_warning = f" {validity.lower()}" + + logger.warning("%s contains sensitive information%s%s\n" + "Please delete it once you no longer need this config file. ", + path_to_delete, items_to_delete, validity_warning) + + +def _get_connection_status(log_file): + try: + with open(log_file, 'r') as ssh_client_log: + match = "debug1: Authentication succeeded" in ssh_client_log.read() + ssh_client_log.close() + except: + return False + return match diff --git a/src/ssh/azext_ssh/tests/latest/test_custom.py b/src/ssh/azext_ssh/tests/latest/test_custom.py index 49580239e07..1a1c309adbc 100644 --- a/src/ssh/azext_ssh/tests/latest/test_custom.py +++ b/src/ssh/azext_ssh/tests/latest/test_custom.py @@ -17,137 +17,146 @@ class SshCustomCommandTest(unittest.TestCase): - + @mock.patch('azext_ssh.custom._assert_args') @mock.patch('azext_ssh.custom._do_ssh_op') @mock.patch('azext_ssh.custom._decide_op_call') def test_ssh_vm(self, mock_decide_op, mock_do_op, mock_assert_args): cmd = mock.Mock() - op_call = functools.partial(ssh_utils.start_ssh_connection, ssh_client_path='path/to/ssh', ssh_args='ssh_args', delete_privkey=False) - mock_decide_op.return_value = functools.partial(mock_do_op, resource_group_name='rg', vm_name='vm', is_arc=True, op_call=op_call) - custom.ssh_vm(cmd, 'rg', 'vm', 'id', 'ip', 'public', 'private', False, 'user', 'cert', 'port', 'path/to/ssh', False, 'ssh_args') - mock_decide_op.assert_called_once_with(cmd, 'rg', 'vm', 'id', 'ip', None, None, 'path/to/ssh', 'ssh_args', False) - mock_assert_args.assert_called_once_with('rg', 'vm', 'ip', 'id', 'cert', 'user') - mock_do_op.assert_called_once_with(cmd, 'ip', 'public', 'private', 'user', 'cert', 'port', False, resource_group_name='rg', vm_name='vm', is_arc=True, op_call=op_call) - + #op_call = functools.partial(ssh_utils.start_ssh_connection, ssh_client_path='path/to/ssh', ssh_args='ssh_args', delete_privkey=False) + mock_decide_op.return_value = functools.partial(mock_do_op, is_arc=True, op_call=mock.ANY) + custom.ssh_vm(cmd, 'rg', 'vm', 'ip', 'public', 'private', False, 'user', 'cert', 'port', 'path/to/ssh', False, 'type' ,'ssh_args') + mock_decide_op.assert_called_once_with(cmd, 'rg', 'vm', 'ip', 'type', None, None, 'path/to/ssh', 'ssh_args', False, None) + mock_assert_args.assert_called_once_with('rg', 'vm', 'ip', 'type', 'cert', 'user') + mock_do_op.assert_called_once_with(cmd, 'vm', 'rg', 'ip', 'public', 'private', 'user', 'cert', 'port', False, None, is_arc=True, op_call=mock.ANY) + @mock.patch('azext_ssh.custom._assert_args') @mock.patch('azext_ssh.custom._do_ssh_op') @mock.patch('azext_ssh.custom._decide_op_call') - def test_ssh_config(self, mock_decide_op, mock_do_op, mock_assert_args): + @mock.patch('os.environ.get') + def test_ssh_vm_delete_credentials_cloudshell(self, mock_getenv, mock_decide_op, mock_do_op, mock_assert_args): + mock_getenv.return_value = "cloud-shell/1.0" cmd = mock.Mock() - op_call = functools.partial(ssh_utils.write_ssh_config, config_path='config path', overwrite=False, resource_group='rg') - mock_decide_op.return_value = functools.partial(mock_do_op, resource_group_name='rg', vm_name='vm', is_arc=False, op_call=op_call) - custom.ssh_config(cmd, 'config path', 'rg', 'vm', 'ip', 'id', 'public', 'private', False, False, 'user', 'cert', 'port') - mock_decide_op.assert_called_once_with(cmd, 'rg', 'vm', 'id', 'ip', 'config path', False, None, None, None) - mock_assert_args.assert_called_once_with('rg', 'vm', 'ip', 'id', 'cert', 'user') - mock_do_op.assert_called_once_with(cmd, 'ip', 'public', 'private', 'user', 'cert', 'port', False, resource_group_name='rg', vm_name='vm', is_arc=False, op_call=op_call) + mock_decide_op.return_value = functools.partial(mock_do_op, is_arc=False, op_call=mock.ANY) + custom.ssh_vm(cmd, 'rg', 'vm', 'ip', 'public', 'private', False, 'user', 'cert', 'port', 'path/to/ssh', True, 'type' ,'ssh_args') + mock_decide_op.assert_called_once_with(cmd, 'rg', 'vm', 'ip', 'type', None, None, 'path/to/ssh', 'ssh_args', True, None) + mock_assert_args.assert_called_once_with('rg', 'vm', 'ip', 'type', 'cert', 'user') + mock_do_op.assert_called_once_with(cmd, 'vm', 'rg', 'ip', 'public', 'private', 'user', 'cert', 'port', False, None, is_arc=False, op_call=mock.ANY) @mock.patch('azext_ssh.custom._assert_args') - @mock.patch('msrestazure.tools.parse_resource_id') @mock.patch('azext_ssh.custom._do_ssh_op') - def test_ssh_arc_resource_id(self, mock_do_op, mock_parse_id, mock_assert_args): + @mock.patch('azext_ssh.custom._decide_op_call') + @mock.patch('os.path.dirname') + @mock.patch('os.path.isdir') + def test_ssh_config_no_cred_folder(self, mock_isdir, mock_dirname, mock_decide_op, mock_do_op, mock_assert_args): cmd = mock.Mock() - op_call = functools.partial(ssh_utils.start_ssh_connection, ssh_client_path="path_to_ssh", ssh_args="ssh_args", delete_privkey=False) - mock_parse_id.return_value = {'subscription': '00000000-0000-0000-0000-000000000000', - 'resource_group': 'rg', - 'resource_namespace': 'Microsoft.HybridCompute', - 'resource_name': 'vm'} - custom.ssh_arc(cmd, None, None, "id", "public", "private", "user", "certificate", "port", "path/to/ssh", False, "ssh_args") - mock_assert_args.assert_called_once_with(None, None, None, "id", "certificate", "user") - mock_parse_id.assert_called_once_with("id") - # This doesn't work because there is no way to compare the functools objects - #mock_do_op.assert_called_once_with(cmd, None, "public", "private", "user", "certificate", "port", False, "rg", "vm", op_call, True) + mock_decide_op.return_value = functools.partial(mock_do_op, is_arc=False, op_call=mock.ANY) + mock_isdir.return_value = True + mock_dirname.return_value = "config_folder" + import os + expected_credentials_folder = os.path.join("config_folder", "az_ssh_config", "rg-vm") + custom.ssh_config(cmd, 'config path', 'rg', 'vm', 'ip', 'public', 'private', False, False, 'user', 'cert', 'port', 'type', ) + mock_decide_op.assert_called_once_with(cmd, 'rg', 'vm', 'ip', 'type', 'config path', False, None, None, False, expected_credentials_folder) + mock_assert_args.assert_called_once_with('rg', 'vm', 'ip', 'type', 'cert', 'user') + mock_do_op.assert_called_once_with(cmd, 'vm', 'rg', 'ip', 'public', 'private', 'user', 'cert', 'port', False, expected_credentials_folder, is_arc=False, op_call=mock.ANY) @mock.patch('azext_ssh.custom._assert_args') - @mock.patch('msrestazure.tools.parse_resource_id') - def test_ssh_arc_invalid_resource_provider(self, mock_parse_id, mock_assert_args): + @mock.patch('azext_ssh.custom._do_ssh_op') + @mock.patch('azext_ssh.custom._decide_op_call') + def test_ssh_config_cred_folder(self, mock_decide_op, mock_do_op, mock_assert_args): + cmd = mock.Mock() + mock_decide_op.return_value = functools.partial(mock_do_op, is_arc=True, op_call=mock.ANY) + custom.ssh_config(cmd, 'config path', 'rg', 'vm', 'ip', None, None, True, False, 'user', 'cert', 'port', 'type', 'cred folder') + mock_decide_op.assert_called_once_with(cmd, 'rg', 'vm', 'ip', 'type', 'config path', True, None, None, False, 'cred folder') + mock_assert_args.assert_called_once_with('rg', 'vm', 'ip', 'type', 'cert', 'user') + mock_do_op.assert_called_once_with(cmd, 'vm', 'rg', 'ip', None, None, 'user', 'cert', 'port', False, 'cred folder', is_arc=True, op_call=mock.ANY) + + def test_ssh_config_credentials_folder_and_key(self): cmd = mock.Mock() - mock_parse_id.return_value = {'subscription': '00000000-0000-0000-0000-000000000000', - 'resource_group': 'rg', - 'resource_namespace': 'Microsoft.Compute', - 'resource_name': 'vm'} self.assertRaises( - azclierror.InvalidArgumentValueError, custom.ssh_arc, cmd, None, None, "id", "public", "private", "user", "cert", "port", "path", False, "args") - mock_assert_args.assert_called_once_with(None, None, None, "id", "cert", "user") - mock_parse_id.assert_called_once_with("id") + azclierror.ArgumentUsageError, custom.ssh_config, cmd, 'path', 'rg', 'vm', 'ip', 'public', 'private', True, False, 'user', 'cert', 'port', 'type', 'cred folder' + ) - def test_decide_op_call_vm_with_ip(self): + @mock.patch('azext_ssh.custom._assert_args') + @mock.patch('azext_ssh.custom._do_ssh_op') + def test_ssh_arc(self, mock_do_op, mock_assert_args): cmd = mock.Mock() - expected_result = functools.partial(custom._do_ssh_op, resource_group_name=None, vm_name=None, is_arc=False, - op_call=functools.partial(ssh_utils.start_ssh_connection, ssh_client_path="path", ssh_args="args", delete_privkey=True)) - result = custom._decide_op_call(cmd, None, None, None, "ip", None, None, "path", "args", True) - self.assertEqual(expected_result.func, result.func) - self.assertEqual(expected_result.args, result.args) - self.assertEqual(expected_result.keywords['resource_group_name'], result.keywords['resource_group_name']) - self.assertEqual(expected_result.keywords['vm_name'], result.keywords['vm_name']) - self.assertEqual(expected_result.keywords['is_arc'], result.keywords['is_arc']) - self.assertEqual(expected_result.keywords['op_call'].func, result.keywords['op_call'].func) - self.assertEqual(expected_result.keywords['op_call'].args, result.keywords['op_call'].args) - self.assertEqual(expected_result.keywords['op_call'].keywords, result.keywords['op_call'].keywords) + custom.ssh_arc(cmd, 'rg', 'vm', 'public', 'private', 'user', 'cert', 'port', 'path/to/ssh', False, 'ssh_args') + mock_assert_args.assert_called_once_with('rg', 'vm', None, 'Microsoft.HybridCompute', 'cert', 'user') + mock_do_op.assert_called_once_with(cmd, 'vm', 'rg', None, 'public', 'private', 'user', 'cert', 'port', False, None, mock.ANY, True) - def test_decide_op_call_config_with_ip(self): + def test_ssh_cert_no_args(self): cmd = mock.Mock() - expected_result = functools.partial(custom._do_ssh_op, resource_group_name=None, vm_name=None, is_arc=False, - op_call=functools.partial(ssh_utils.write_ssh_config, config_path='config_path', overwrite=True, resource_group=None)) - result = custom._decide_op_call(cmd, None, None, None, "ip", 'config_path', True, None, None, False) - self.assertEqual(expected_result.func, result.func) - self.assertEqual(expected_result.args, result.args) - self.assertEqual(expected_result.keywords['resource_group_name'], result.keywords['resource_group_name']) - self.assertEqual(expected_result.keywords['vm_name'], result.keywords['vm_name']) - self.assertEqual(expected_result.keywords['is_arc'], result.keywords['is_arc']) - self.assertEqual(expected_result.keywords['op_call'].func, result.keywords['op_call'].func) - self.assertEqual(expected_result.keywords['op_call'].args, result.keywords['op_call'].args) - self.assertEqual(expected_result.keywords['op_call'].keywords, result.keywords['op_call'].keywords) - - @mock.patch('msrestazure.tools.parse_resource_id') - def test_decide_op_call_invalid_resource_id(self, mock_parse_id): + self.assertRaises( + azclierror.RequiredArgumentMissingError, custom.ssh_cert, cmd, None, None + ) + + @mock.patch('azext_ssh.custom._check_or_create_public_private_files') + @mock.patch('azext_ssh.custom._get_and_write_certificate') + @mock.patch('os.path.isdir') + def test_ssh_cert_pubkey_and_certpath(self, mock_isdir, mock_writecert, mock_checkkeys): cmd = mock.Mock() - mock_parse_id.return_value = {'subscription': '00000000-0000-0000-0000-000000000000', 'resource_group': 'rg', 'resource_name': 'vm'} + mock_isdir.return_value = True + mock_checkkeys.return_value = 'pubkey', 'privkey', False + mock_writecert.return_value = 'cert', 'user' + custom.ssh_cert(cmd, 'cert path', 'pubkey') + mock_writecert.assert_called_once_with(cmd, 'pubkey', 'cert path') + mock_checkkeys.assert_called_once_with('pubkey', None, None) + + @mock.patch('os.environ.get') + def test_delete_credentials_not_cloudshell(self, mock_getenv): + mock_getenv.return_value = None + cmd = mock.Mock() + self.assertRaises( + azclierror.ArgumentUsageError, custom.ssh_vm, cmd, 'rg', 'vm', 'ip', 'public', 'private', False, 'user', 'cert', 'port', 'path/to/ssh', True, 'type' ,'ssh_args') self.assertRaises( - azclierror.InvalidArgumentValueError, custom._decide_op_call, cmd, None, None, "id", None, None, False, None, None, False) - - @mock.patch('msrestazure.tools.parse_resource_id') - def test_decide_op_call_vm_with_resource_id(self, mock_parse_id): + azclierror.ArgumentUsageError, custom.ssh_arc, cmd, 'rg', 'vm', 'public', 'private', 'user', 'cert', 'port', 'path/to/ssh', True,'ssh_args') + + @mock.patch('azext_ssh.custom._assert_args') + @mock.patch('azext_ssh.custom._do_ssh_op') + @mock.patch('os.environ.get') + def test_ssh_arc_delete_credentials_cloudshell(self, mock_getenv, mock_do_op, mock_assert_args): + mock_getenv.return_value = "cloud-shell/1.0" cmd = mock.Mock() - mock_parse_id.return_value = {'subscription': '00000000-0000-0000-0000-000000000000', 'resource_group': 'rg', 'resource_namespace': 'Microsoft.HybridCompute', 'resource_name': 'vm'} - expected_result = functools.partial(custom._do_ssh_op, resource_group_name='rg', vm_name='vm', is_arc=True, - op_call=functools.partial(ssh_utils.start_ssh_connection, ssh_client_path='path', ssh_args='args', delete_privkey=False)) - result = custom._decide_op_call(cmd, None, None, 'id', None, None, False, 'path', 'args', False) - mock_parse_id.assert_called_once_with('id') + custom.ssh_arc(cmd, 'rg', 'vm', 'public', 'private', 'user', 'cert', 'port', 'path/to/ssh', True, 'ssh_args') + mock_assert_args.assert_called_once_with('rg', 'vm', None, 'Microsoft.HybridCompute', 'cert', 'user') + mock_do_op.assert_called_once_with(cmd, 'vm', 'rg', None, 'public', 'private', 'user', 'cert', 'port', False, None, mock.ANY, True) + + + def test_decide_op_call_vm_with_ip(self): + cmd = mock.Mock() + expected_result = functools.partial(custom._do_ssh_op, is_arc=False, + op_call=functools.partial(ssh_utils.start_ssh_connection, ssh_client_path="path", ssh_args="args", delete_credentials=True)) + result = custom._decide_op_call(cmd, None, None, "ip", None, None, None, "path", "args", True, None) self.assertEqual(expected_result.func, result.func) self.assertEqual(expected_result.args, result.args) - self.assertEqual(expected_result.keywords['resource_group_name'], result.keywords['resource_group_name']) - self.assertEqual(expected_result.keywords['vm_name'], result.keywords['vm_name']) + self.assertEqual(expected_result.keywords.keys(), result.keywords.keys()) self.assertEqual(expected_result.keywords['is_arc'], result.keywords['is_arc']) self.assertEqual(expected_result.keywords['op_call'].func, result.keywords['op_call'].func) self.assertEqual(expected_result.keywords['op_call'].args, result.keywords['op_call'].args) self.assertEqual(expected_result.keywords['op_call'].keywords, result.keywords['op_call'].keywords) - - @mock.patch('msrestazure.tools.parse_resource_id') - def test_decide_op_call_config_with_resource_id(self, mock_parse_id): + + def test_decide_op_call_config_with_ip(self): cmd = mock.Mock() - mock_parse_id.return_value = {'subscription': '00000000-0000-0000-0000-000000000000', 'resource_group': 'rg', 'resource_namespace': 'Microsoft.Compute', 'resource_name': 'vm'} - expected_result = functools.partial(custom._do_ssh_op, resource_group_name='rg', vm_name='vm', is_arc=False, - op_call=functools.partial(ssh_utils.write_ssh_config, config_path='config path', overwrite=True, resource_group='rg')) - result = custom._decide_op_call(cmd, None, None, 'id', None, 'config path', True, None, None, None) - mock_parse_id.assert_called_once_with('id') + expected_result = functools.partial(custom._do_ssh_op, is_arc=False, + op_call=functools.partial(ssh_utils.write_ssh_config, config_path='config_path', overwrite=True, resource_group=None, credentials_folder="cred folder")) + result = custom._decide_op_call(cmd, None, None,"ip", None, 'config_path', True, None, None, False, 'cred folder') self.assertEqual(expected_result.func, result.func) self.assertEqual(expected_result.args, result.args) - self.assertEqual(expected_result.keywords['resource_group_name'], result.keywords['resource_group_name']) - self.assertEqual(expected_result.keywords['vm_name'], result.keywords['vm_name']) + self.assertEqual(expected_result.keywords.keys(), result.keywords.keys()) self.assertEqual(expected_result.keywords['is_arc'], result.keywords['is_arc']) self.assertEqual(expected_result.keywords['op_call'].func, result.keywords['op_call'].func) self.assertEqual(expected_result.keywords['op_call'].args, result.keywords['op_call'].args) self.assertEqual(expected_result.keywords['op_call'].keywords, result.keywords['op_call'].keywords) - + @mock.patch('azext_ssh.custom._check_if_azure_vm') @mock.patch('azext_ssh.custom._check_if_arc_server') def test_decide_op_call_vm_with_name_and_resource_group_both_true(self, mock_check_arc, mock_check_az_vm): cmd = mock.Mock() - mock_check_arc.return_value = True - mock_check_az_vm.return_value = True + mock_check_arc.return_value = None, True + mock_check_az_vm.return_value = None, True self.assertRaises( - azclierror.BadRequestError, custom._decide_op_call, cmd, 'rg', 'vm', None, None, None, False, None, None, False) + azclierror.BadRequestError, custom._decide_op_call, cmd, 'rg', 'vm', None, None, None, False, None, None, False, None) mock_check_arc.assert_called_once_with(cmd, 'rg', 'vm') mock_check_az_vm.assert_called_once_with(cmd, 'rg', 'vm') @@ -155,27 +164,29 @@ def test_decide_op_call_vm_with_name_and_resource_group_both_true(self, mock_che @mock.patch('azext_ssh.custom._check_if_arc_server') def test_decide_op_call_vm_with_name_and_resource_group_both_false(self, mock_check_arc, mock_check_az_vm): cmd = mock.Mock() - mock_check_arc.return_value = False - mock_check_az_vm.return_value = False from azure.core.exceptions import ResourceNotFoundError + mock_check_arc.return_value = ResourceNotFoundError(), False + mock_check_az_vm.return_value = ResourceNotFoundError(), False + self.assertRaises( - ResourceNotFoundError, custom._decide_op_call, cmd, "rg", "vm", None, None, 'config_path', True, None, None, None) + azclierror.ResourceNotFoundError, custom._decide_op_call, cmd, "rg", "vm", None, None, 'config_path', True, None, None, False, None) mock_check_arc.assert_called_once_with(cmd, 'rg', 'vm') mock_check_az_vm.assert_called_once_with(cmd, 'rg', 'vm') - + @mock.patch('azext_ssh.custom._check_if_azure_vm') @mock.patch('azext_ssh.custom._check_if_arc_server') def test_decide_op_call_vm_with_name_and_resource_group(self, mock_check_arc, mock_check_az_vm): cmd = mock.Mock() - mock_check_arc.return_value = False - mock_check_az_vm.return_value = True - expected_result = functools.partial(custom._do_ssh_op, resource_group_name='rg', vm_name='vm', is_arc=False, - op_call=functools.partial(ssh_utils.start_ssh_connection, ssh_client_path='path', ssh_args='args', delete_privkey=True)) - result = custom._decide_op_call(cmd, 'rg', 'vm', None, None, None, False, "path", "args", True) + from azure.core.exceptions import ResourceNotFoundError + mock_check_arc.return_value = ResourceNotFoundError(), False + mock_check_az_vm.return_value = None, True + + expected_result = functools.partial(custom._do_ssh_op, is_arc=False, + op_call=functools.partial(ssh_utils.start_ssh_connection, ssh_client_path='path', ssh_args='args', delete_credentials=True)) + result = custom._decide_op_call(cmd, 'rg', 'vm', None, None, None, False, "path", "args", True, None) self.assertEqual(expected_result.func, result.func) self.assertEqual(expected_result.args, result.args) - self.assertEqual(expected_result.keywords['resource_group_name'], result.keywords['resource_group_name']) - self.assertEqual(expected_result.keywords['vm_name'], result.keywords['vm_name']) + self.assertEqual(expected_result.keywords.keys(), result.keywords.keys()) self.assertEqual(expected_result.keywords['is_arc'], result.keywords['is_arc']) self.assertEqual(expected_result.keywords['op_call'].func, result.keywords['op_call'].func) self.assertEqual(expected_result.keywords['op_call'].args, result.keywords['op_call'].args) @@ -187,15 +198,15 @@ def test_decide_op_call_vm_with_name_and_resource_group(self, mock_check_arc, mo @mock.patch('azext_ssh.custom._check_if_arc_server') def test_decide_op_call_config_with_name_and_resource_group(self, mock_check_arc, mock_check_az_vm): cmd = mock.Mock() - mock_check_arc.return_value = True - mock_check_az_vm.return_value = False - expected_result = functools.partial(custom._do_ssh_op, resource_group_name='rg', vm_name='vm', is_arc=True, - op_call=functools.partial(ssh_utils.write_ssh_config, config_path='config path', overwrite=True, resource_group='rg')) - result = custom._decide_op_call(cmd, 'rg', 'vm', None, None, 'config path', True, None, None, False) + from azure.core.exceptions import ResourceNotFoundError + mock_check_arc.return_value = None, True + mock_check_az_vm.return_value = ResourceNotFoundError(), False + expected_result = functools.partial(custom._do_ssh_op, is_arc=True, + op_call=functools.partial(ssh_utils.write_ssh_config, config_path='config path', overwrite=True, resource_group='rg', credentials_folder='cred folder')) + result = custom._decide_op_call(cmd, 'rg', 'vm', None, None, 'config path', True, None, None, False, 'cred folder') self.assertEqual(expected_result.func, result.func) self.assertEqual(expected_result.args, result.args) - self.assertEqual(expected_result.keywords['resource_group_name'], result.keywords['resource_group_name']) - self.assertEqual(expected_result.keywords['vm_name'], result.keywords['vm_name']) + self.assertEqual(expected_result.keywords.keys(), result.keywords.keys()) self.assertEqual(expected_result.keywords['is_arc'], result.keywords['is_arc']) self.assertEqual(expected_result.keywords['op_call'].func, result.keywords['op_call'].func) self.assertEqual(expected_result.keywords['op_call'].args, result.keywords['op_call'].args) @@ -203,7 +214,36 @@ def test_decide_op_call_config_with_name_and_resource_group(self, mock_check_arc mock_check_arc.assert_called_once_with(cmd, 'rg', 'vm') mock_check_az_vm.assert_called_once_with(cmd, 'rg', 'vm') - def test_assert_args_no_ip_or_id_or_vm(self): + def test_decide_op_call_arc_with_resource_type(self): + cmd = mock.Mock() + expected_result = functools.partial(custom._do_ssh_op, is_arc=True, + op_call=functools.partial(ssh_utils.start_ssh_connection, ssh_client_path='path', ssh_args='args', delete_credentials=True)) + result = custom._decide_op_call(cmd, 'rg', 'vm', None, 'Microsoft.HybridCompute', None, False, "path", "args", True, None) + self.assertEqual(expected_result.func, result.func) + self.assertEqual(expected_result.args, result.args) + self.assertEqual(expected_result.keywords.keys(), result.keywords.keys()) + self.assertEqual(expected_result.keywords['is_arc'], result.keywords['is_arc']) + self.assertEqual(expected_result.keywords['op_call'].func, result.keywords['op_call'].func) + self.assertEqual(expected_result.keywords['op_call'].args, result.keywords['op_call'].args) + self.assertEqual(expected_result.keywords['op_call'].keywords, result.keywords['op_call'].keywords) + + def test_decide_op_call_azurevm_with_resource_type(self): + cmd = mock.Mock() + expected_result = functools.partial(custom._do_ssh_op, is_arc=False, + op_call=functools.partial(ssh_utils.write_ssh_config, config_path='config path', overwrite=False, resource_group='rg', credentials_folder='cred folder')) + result = custom._decide_op_call(cmd, 'rg', 'vm', None, 'Microsoft.Compute', 'config path', False, None, None, False, 'cred folder') + self.assertEqual(expected_result.func, result.func) + self.assertEqual(expected_result.args, result.args) + self.assertEqual(expected_result.keywords.keys(), result.keywords.keys()) + self.assertEqual(expected_result.keywords['is_arc'], result.keywords['is_arc']) + self.assertEqual(expected_result.keywords['op_call'].func, result.keywords['op_call'].func) + self.assertEqual(expected_result.keywords['op_call'].args, result.keywords['op_call'].args) + self.assertEqual(expected_result.keywords['op_call'].keywords, result.keywords['op_call'].keywords) + + 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) def test_assert_args_vm_rg_mismatch(self): @@ -214,23 +254,15 @@ def test_assert_args_ip_with_vm_or_rg(self): self.assertRaises(azclierror.MutuallyExclusiveArgumentError, custom._assert_args, None, "vm", "ip", None, None, None) self.assertRaises(azclierror.MutuallyExclusiveArgumentError, custom._assert_args, "rg", None, "ip", None, None, None) self.assertRaises(azclierror.MutuallyExclusiveArgumentError, custom._assert_args, "rg", "vm", "ip", None, None, None) - - def test_assert_args_id_with_vm_or_rg(self): - self.assertRaises(azclierror.MutuallyExclusiveArgumentError, custom._assert_args, None, "vm", None, "id", None, None) - self.assertRaises(azclierror.MutuallyExclusiveArgumentError, custom._assert_args, "rg", None, None, "id", None, None) - self.assertRaises(azclierror.MutuallyExclusiveArgumentError, custom._assert_args, "rg", "vm", None, "id", None, None) - - def test_assert_args_id_with_ip(self): - self.assertRaises(azclierror.MutuallyExclusiveArgumentError, custom._assert_args, None, None, "ip", "id", None, None) - + def test_assert_args_cert_with_no_user(self): self.assertRaises(azclierror.MutuallyExclusiveArgumentError, custom._assert_args, None, None, "ip", None, "certificate", None) @mock.patch('os.path.isfile') def test_assert_args_invalid_cert_filepath(self, mock_is_file): mock_is_file.return_value = False - self.assertRaises(azclierror.FileOperationError, custom._assert_args, 'rg', 'vm', None, None, 'cert_path', 'username') - + 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') @@ -240,10 +272,11 @@ def test_check_or_create_public_private_files_defaults(self, mock_join, mock_isf mock_temp.return_value = "/tmp/aadtemp" mock_join.side_effect = ['/tmp/aadtemp/id_rsa.pub', '/tmp/aadtemp/id_rsa'] - public, private = custom._check_or_create_public_private_files(None, None) + public, private, delete_key = custom._check_or_create_public_private_files(None, None, None) self.assertEqual('/tmp/aadtemp/id_rsa.pub', public) self.assertEqual('/tmp/aadtemp/id_rsa', private) + self.assertEqual(True, delete_key) mock_join.assert_has_calls([ mock.call("/tmp/aadtemp", "id_rsa.pub"), mock.call("/tmp/aadtemp", "id_rsa") @@ -256,12 +289,37 @@ def test_check_or_create_public_private_files_defaults(self, mock_join, mock_isf mock.call('/tmp/aadtemp/id_rsa') ]) + @mock.patch('azext_ssh.ssh_utils.create_ssh_keyfile') + @mock.patch('os.path.isdir') + @mock.patch('os.path.isfile') + @mock.patch('os.path.join') + def test_check_or_create_public_private_files_defaults_with_cred_folder(self,mock_join, mock_isfile, mock_isdir, mock_create): + mock_isfile.return_value = True + mock_isdir.return_value = True + mock_join.side_effect = ['/cred/folder/id_rsa.pub', '/cred/folder/id_rsa'] + public, private, delete_key = custom._check_or_create_public_private_files(None, None, '/cred/folder') + self.assertEqual('/cred/folder/id_rsa.pub', public) + self.assertEqual('/cred/folder/id_rsa', private) + self.assertEqual(True, delete_key) + mock_join.assert_has_calls([ + mock.call("/cred/folder", "id_rsa.pub"), + mock.call("/cred/folder", "id_rsa") + ]) + mock_isfile.assert_has_calls([ + mock.call('/cred/folder/id_rsa.pub'), + mock.call('/cred/folder/id_rsa') + ]) + mock_create.assert_has_calls([ + mock.call('/cred/folder/id_rsa') + ]) + + @mock.patch('os.path.isfile') @mock.patch('os.path.join') def test_check_or_create_public_private_files_no_public(self, mock_join, mock_isfile): mock_isfile.side_effect = [False] self.assertRaises( - azclierror.FileOperationError, custom._check_or_create_public_private_files, "public", None) + azclierror.FileOperationError, custom._check_or_create_public_private_files, "public", None, None) mock_isfile.assert_called_once_with("public") @@ -271,13 +329,14 @@ def test_check_or_create_public_private_files_no_private(self, mock_join, mock_i mock_isfile.side_effect = [True, False] self.assertRaises( - azclierror.FileOperationError, custom._check_or_create_public_private_files, "public", "private") + azclierror.FileOperationError, custom._check_or_create_public_private_files, "public", "private", None) mock_join.assert_not_called() mock_isfile.assert_has_calls([ mock.call("public"), mock.call("private") ]) + @mock.patch('builtins.open') def test_write_cert_file(self, mock_open): @@ -322,7 +381,7 @@ def test_get_modulus_exponent_parse_error(self, mock_open, mock_isfile, mock_par mock_parser_obj.parse.side_effect = ValueError self.assertRaises(azclierror.FileOperationError, custom._get_modulus_exponent, 'file') - + @mock.patch('azext_ssh.ip_utils.get_ssh_ip') @mock.patch('azext_ssh.ssh_utils.start_ssh_connection') @mock.patch('azext_ssh.custom._check_or_create_public_private_files') @@ -331,22 +390,22 @@ def test_get_modulus_exponent_parse_error(self, mock_open, mock_isfile, mock_par @mock.patch('azext_ssh.custom._arc_list_access_details') def test_do_ssh_op_ip_and_local_user_compute(self, mock_get_access, mock_get_proxy, mock_get_cert, mock_check_keys, mock_start_ssh, mock_get_ip): cmd = mock.Mock() - custom._do_ssh_op(cmd, 'ip', 'public', 'private', 'user', 'cert', 'port', 'False', None, None, mock_start_ssh, False) + custom._do_ssh_op(cmd, None, None, 'ip', 'public', 'private', 'user', 'cert', 'port', 'False', None, mock_start_ssh, False) mock_get_ip.assert_not_called() mock_get_cert.assert_not_called() mock_check_keys.assert_not_called() mock_get_access.assert_not_called() mock_get_proxy.assert_not_called() - mock_start_ssh.assert_called_once_with(None, None, None, 'ip', 'user', 'cert', 'private', 'port', False) - + mock_start_ssh.assert_called_once_with(None, None, None, 'ip', 'user', 'cert', 'private', 'port', False, False, False, 'public') + @mock.patch('azext_ssh.ip_utils.get_ssh_ip') def test_do_ssh_op_with_no_ip(self, mock_get_ip): cmd = mock.Mock() mock_get_ip.return_value = None self.assertRaises( - azclierror.ResourceNotFoundError, custom._do_ssh_op, cmd, None, 'public', 'private', 'user', 'cert', 'port', False, 'rg', 'vm', 'op_call', False) + azclierror.ResourceNotFoundError, custom._do_ssh_op, cmd, 'vm', 'rg', None, 'public', 'private', 'user', 'cert', 'port', False, None, 'op_call', False) mock_get_ip.assert_called_once_with(cmd, 'rg', 'vm', False) - + @mock.patch('azext_ssh.ssh_utils.get_ssh_cert_principals') @mock.patch('os.path.join') @mock.patch('azext_ssh.custom._check_or_create_public_private_files') @@ -361,7 +420,7 @@ def test_do_ssh_op_rg_and_vm_and_aad_user(self, mock_start_ssh, mock_write_cert, cmd.cli_ctx = mock.Mock() cmd.cli_ctx.cloud = mock.Mock() cmd.cli_ctx.cloud.name = "azurecloud" - mock_check_files.return_value = "public", "private" + mock_check_files.return_value = "public", "private", True mock_principal.return_value = ["username"] mock_get_mod_exp.return_value = "modulus", "exponent" profile = mock_ssh_creds.return_value @@ -370,30 +429,30 @@ def test_do_ssh_op_rg_and_vm_and_aad_user(self, mock_start_ssh, mock_write_cert, mock_join.return_value = "public-aadcert.pub" mock_ip.return_value = 'ip' - custom._do_ssh_op(cmd, None, "publicfile", "privatefile", None, None, "port", False, "rg", "vm", mock_start_ssh, False) + custom._do_ssh_op(cmd, 'vm', 'rg', None, None, None, None, None, "port", False, 'cred folder', mock_start_ssh, False) - mock_check_files.assert_called_once_with("publicfile", "privatefile") + mock_check_files.assert_called_once_with(None, None, 'cred folder') mock_ip.assert_called_once_with(cmd, 'rg', 'vm', False) mock_get_mod_exp.assert_called_once_with("public") mock_write_cert.assert_called_once_with("certificate", "public-aadcert.pub") - mock_start_ssh.assert_called_once_with(None, None, 'vm', 'ip', 'username', 'public-aadcert.pub', 'private', 'port', False) + mock_start_ssh.assert_called_once_with(None, None, 'vm', 'ip', 'username', 'public-aadcert.pub', 'private', 'port', False, True, True, 'public') @mock.patch('azext_ssh.custom._arc_get_client_side_proxy') @mock.patch('azext_ssh.custom._arc_list_access_details') @mock.patch('azext_ssh.ssh_utils.start_ssh_connection') @mock.patch('azext_ssh.custom._check_or_create_public_private_files') @mock.patch('azext_ssh.custom._get_and_write_certificate') - def test_do_ssh_arc_op_local_user(self, mock_get_cert, mock_check_keys, mock_start_ssh, mock_get_relay_info, mock_get_proxy): + def test_do_ssh_op_arc_local_user(self, mock_get_cert, mock_check_keys, mock_start_ssh, mock_get_relay_info, mock_get_proxy): cmd = mock.Mock() mock_get_proxy.return_value = '/path/to/proxy' mock_get_relay_info.return_value = 'relay' - custom._do_ssh_op(cmd, None, 'public', 'private', 'user', 'cert', 'port', False, 'rg', 'vm', mock_start_ssh, True) + custom._do_ssh_op(cmd, 'vm', 'rg', None, 'public', 'private', 'user', 'cert', 'port', False, None, mock_start_ssh, True) mock_get_proxy.assert_called_once_with() mock_get_relay_info.assert_called_once_with(cmd, 'rg', 'vm') - mock_start_ssh.assert_called_once_with('relay', '/path/to/proxy', 'vm', None, 'user', 'cert', 'private', 'port', True) + mock_start_ssh.assert_called_once_with('relay', '/path/to/proxy', 'vm', None, 'user', 'cert', 'private', 'port', True, False, False, 'public') mock_get_cert.assert_not_called() mock_check_keys.assert_not_called() - + @mock.patch('azext_ssh.custom._arc_get_client_side_proxy') @mock.patch('azext_ssh.custom._arc_list_access_details') @mock.patch('azext_ssh.ssh_utils.get_ssh_cert_principals') @@ -412,7 +471,7 @@ def test_do_ssh_arc_op_aad_user(self, mock_start_ssh, mock_write_cert, mock_ssh_ cmd.cli_ctx = mock.Mock() cmd.cli_ctx.cloud = mock.Mock() cmd.cli_ctx.cloud.name = "azurecloud" - mock_check_files.return_value = "public", "private" + mock_check_files.return_value = "public", "private", False mock_principal.return_value = ["username"] mock_get_mod_exp.return_value = "modulus", "exponent" profile = mock_ssh_creds.return_value @@ -420,14 +479,14 @@ def test_do_ssh_arc_op_aad_user(self, mock_start_ssh, mock_write_cert, mock_ssh_ profile.get_msal_token.return_value = "username", "certificate" mock_join.return_value = "public-aadcert.pub" - custom._do_ssh_op(cmd, None, 'publicfile', 'privatefile', None, None, 'port', False, 'rg', 'vm', mock_start_ssh, True) + custom._do_ssh_op(cmd, 'vm', 'rg', None, 'publicfile', 'privatefile', None, None, 'port', False, None, mock_start_ssh, True) - mock_check_files.assert_called_once_with("publicfile", "privatefile") + mock_check_files.assert_called_once_with("publicfile", "privatefile", None) 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() mock_get_relay_info.assert_called_once_with(cmd, 'rg', 'vm') - mock_start_ssh.assert_called_once_with('relay', '/path/to/proxy', 'vm', None, 'username', 'public-aadcert.pub', 'private', 'port', True) + mock_start_ssh.assert_called_once_with('relay', '/path/to/proxy', 'vm', None, 'username', 'public-aadcert.pub', 'private', 'port', True, False, True, 'public') if __name__ == '__main__': unittest.main() 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 c76177f3d5f..088e08cf02e 100644 --- a/src/ssh/azext_ssh/tests/latest/test_ssh_utils.py +++ b/src/ssh/azext_ssh/tests/latest/test_ssh_utils.py @@ -14,159 +14,183 @@ class SSHUtilsTests(unittest.TestCase): - - @mock.patch.object(ssh_utils, '_do_cleanup') + + @mock.patch.object(ssh_utils, '_start_cleanup') + @mock.patch.object(ssh_utils, '_terminate_cleanup') @mock.patch.object(ssh_utils, '_get_ssh_path') @mock.patch.object(ssh_utils, '_get_host') @mock.patch.object(ssh_utils, '_build_args') @mock.patch('subprocess.call') @mock.patch('os.environ.copy') - def test_start_ssh_connection_cert_azurevm(self, mock_copy_env, mock_call, mock_build, mock_host, mock_path, mock_cleanup): + def test_start_ssh_connection_cert_azurevm(self, mock_copy_env, mock_call, mock_build, mock_host, mock_path, mock_terminatecleanup, mock_startcleanup): mock_path.return_value = 'ssh' mock_host.return_value = 'user@ip' mock_build.return_value = ['-i', 'file', '-o', 'option', '-p', 'port'] mock_copy_env.return_value = {'var1':'value1', 'var2':'value2', 'var3':'value3'} - expected_command = ['ssh', 'user@ip', '-i', 'file', '-o', 'option', '-p', 'port', 'arg1', 'arg2', 'arg3'] + mock_startcleanup.return_value = 'log', ['arg1', 'arg2', 'arg3', '-E', 'log', '-v'], 'cleanup process' + expected_command = ['ssh', 'user@ip', '-i', 'file', '-o', 'option', '-p', 'port', 'arg1', 'arg2', 'arg3', '-E', 'log', '-v'] expected_env = {'var1':'value1', 'var2':'value2', 'var3':'value3'} - ssh_utils.start_ssh_connection(None, None, 'vm', 'ip', 'user', 'cert', 'private', 'port', False, None, ['arg1', 'arg2', 'arg3'], False) + ssh_utils.start_ssh_connection(None, None, 'vm', 'ip', 'user', 'cert', 'private', 'port', False, True, True, 'public', None, ['arg1', 'arg2', 'arg3'], False) mock_path.assert_called_once_with() mock_host.assert_called_once_with('user', 'ip') mock_build.assert_called_once_with('cert', 'private', 'port') - mock_cleanup.assert_not_called() + mock_startcleanup.assert_called_with('cert', 'private', 'public', False, True, True, ['arg1', 'arg2', 'arg3']) mock_call.assert_called_once_with(expected_command, shell=platform.system() == 'Windows', env=expected_env) - - @mock.patch.object(ssh_utils, '_do_cleanup') + mock_terminatecleanup.assert_called_once_with(True, True, False, 'cleanup process', 'cert', 'private', 'public', 'log') + + @mock.patch.object(ssh_utils, '_start_cleanup') + @mock.patch.object(ssh_utils, '_terminate_cleanup') @mock.patch.object(ssh_utils, '_get_ssh_path') @mock.patch.object(ssh_utils, '_get_host') @mock.patch.object(ssh_utils, '_build_args') @mock.patch('subprocess.call') @mock.patch('os.environ.copy') - def test_start_ssh_connection_private_key_azurevm(self, mock_copy_env, mock_call, mock_build, mock_host, mock_path, mock_cleanup): + def test_start_ssh_connection_private_key_azurevm(self, mock_copy_env, mock_call, mock_build, mock_host, mock_path, mock_terminatecleanup, mock_startcleanup): mock_host.return_value = 'user@ip' mock_build.return_value = ["-i", "private", "-p", "port"] - expected_command = ["path", "user@ip", "-i", "private", "-p", "port"] + expected_command = ["path", "user@ip", "-i", "private", "-p", "port", '-E', 'log', '-v'] mock_copy_env.return_value = {'var1':'value1', 'var2':'value2', 'var3':'value3'} expected_env = {'var1':'value1', 'var2':'value2', 'var3':'value3'} + mock_startcleanup.return_value = 'log', ['-E', 'log', '-v'], 'cleanup process' - ssh_utils.start_ssh_connection(None, None, 'vm', 'ip', 'user', None, 'private', 'port', False, 'path', None ,False) + ssh_utils.start_ssh_connection(None, None, 'vm', 'ip', 'user', None, 'private', 'port', False, False, False, None, 'path', None, True) mock_build.assert_called_once_with(None, "private", "port") mock_path.assert_not_called() mock_host.assert_called_once_with("user", "ip") + mock_startcleanup.assert_called_with(None, 'private', None, True, False, False, []) mock_call.assert_called_once_with(expected_command, shell=platform.system() == 'Windows', env=expected_env) - - @mock.patch.object(ssh_utils, '_do_cleanup') + mock_terminatecleanup.assert_called_once_with(False, False, True, 'cleanup process', None, 'private', None, 'log') + + + @mock.patch.object(ssh_utils, '_start_cleanup') + @mock.patch.object(ssh_utils, '_terminate_cleanup') @mock.patch.object(ssh_utils, '_get_ssh_path') @mock.patch.object(ssh_utils, '_get_host') @mock.patch.object(ssh_utils, '_build_args') @mock.patch('subprocess.call') @mock.patch('os.environ.copy') - def test_start_ssh_connection_cert_no_private_key_azurevm(self, mock_copy_env, mock_call, mock_build, mock_host, mock_path, mock_cleanup): + def test_start_ssh_connection_cert_no_private_key_azurevm(self, mock_copy_env, mock_call, mock_build, mock_host, mock_path, mock_terminatecleanup, mock_startcleanup): mock_path.return_value = 'ssh' mock_host.return_value = 'user@ip' mock_build.return_value = ['-o', 'option'] + mock_startcleanup.return_value = None, ['arg1', 'arg2', 'arg3'], None expected_command = ['ssh', 'user@ip', '-o', 'option', 'arg1', 'arg2', 'arg3'] mock_copy_env.return_value = {'var1':'value1', 'var2':'value2', 'var3':'value3'} expected_env = {'var1':'value1', 'var2':'value2', 'var3':'value3'} - ssh_utils.start_ssh_connection(None, None, 'vm', 'ip', 'user', 'cert', None, None, False, None, ['arg1', 'arg2', 'arg3'], False) + ssh_utils.start_ssh_connection(None, None, 'vm', 'ip', 'user', 'cert', None, None, False, False, False, None, None, ['arg1', 'arg2', 'arg3'], False) mock_build.assert_called_once_with('cert', None, None) mock_path.assert_called_once_with() mock_host.assert_called_once_with('user', 'ip') - mock_cleanup.assert_not_called() + mock_startcleanup.assert_called_with('cert', None, None, False, False, False, ['arg1', 'arg2', 'arg3']) mock_call.assert_called_once_with(expected_command, shell=platform.system() == 'Windows', env=expected_env) - - @mock.patch.object(ssh_utils, '_do_cleanup') + mock_terminatecleanup.assert_called_once_with(False, False, False, None, 'cert', None, None, None) + + @mock.patch.object(ssh_utils, '_start_cleanup') + @mock.patch.object(ssh_utils, '_terminate_cleanup') @mock.patch.object(ssh_utils, '_get_ssh_path') @mock.patch.object(ssh_utils, '_get_host') @mock.patch.object(ssh_utils, '_build_args') @mock.patch('subprocess.call') @mock.patch('os.environ.copy') - def test_start_ssh_connection_password_azurevm(self, mock_copy_env, mock_call, mock_build, mock_host, mock_path, mock_cleanup): + def test_start_ssh_connection_password_azurevm(self, mock_copy_env, mock_call, mock_build, mock_host, mock_path, mock_terminatecleanup, mock_startcleanup): mock_path.return_value = 'ssh' mock_host.return_value = 'user@ip' mock_build.return_value = ['-p', 'port'] + mock_startcleanup.return_value = None, [], None expected_command = ['ssh', 'user@ip', '-p', 'port'] mock_copy_env.return_value = {'var1':'value1', 'var2':'value2', 'var3':'value3'} expected_env = {'var1':'value1', 'var2':'value2', 'var3':'value3'} - ssh_utils.start_ssh_connection(None, None, 'vm', 'ip', 'user', None, None, 'port', False, None, None, False) + ssh_utils.start_ssh_connection(None, None, 'vm', 'ip', 'user', None, None, 'port', False, False, False, None, None, None, True) mock_build.assert_called_once_with(None, None, 'port') mock_path.assert_called_once_with() mock_host.assert_called_once_with('user', 'ip') - mock_cleanup.assert_not_called() + mock_startcleanup.assert_called_once_with(None, None, None, False, False, False, []) mock_call.assert_called_once_with(expected_command, shell=platform.system() == 'Windows', env=expected_env) - - @mock.patch.object(ssh_utils, '_do_cleanup') + mock_terminatecleanup.assert_called_once_with(False, False, False, None, None, None, None, None) + + @mock.patch.object(ssh_utils, '_start_cleanup') + @mock.patch.object(ssh_utils, '_terminate_cleanup') @mock.patch('os.environ.copy') @mock.patch.object(ssh_utils, '_get_ssh_path') @mock.patch.object(ssh_utils, '_build_args') @mock.patch('subprocess.call') @mock.patch.object(ssh_utils, '_get_host') - def test_start_ssh_connection_cert_arc(self, mock_host, mock_call, mock_build, mock_path, mock_copy_env, mock_cleanup): + def test_start_ssh_connection_cert_arc(self, mock_host, mock_call, mock_build, mock_path, mock_copy_env, mock_terminatecleanup, mock_startcleanup): mock_copy_env.return_value = {'var1':'value1', 'var2':'value2', 'var3':'value3'} mock_path.return_value = 'ssh' mock_build.return_value = ['-i', 'private', '-o', 'option'] mock_host.return_value = 'user@vm' - expected_command = ['ssh', 'user@vm', '-o', 'ProxyCommand=/path/to/proxy -p port', '-i', 'private', '-o', 'option'] + mock_startcleanup.return_value = None, ['arg1'], None + expected_command = ['ssh', 'user@vm', '-o', 'ProxyCommand=/path/to/proxy -p port', '-i', 'private', '-o', 'option', 'arg1'] expected_env = {'var1':'value1', 'var2':'value2', 'var3':'value3', 'SSHPROXY_RELAY_INFO':'relay'} - ssh_utils.start_ssh_connection('relay', '/path/to/proxy', 'vm', None, 'user', 'cert', 'private', 'port', True, None, None, False) + ssh_utils.start_ssh_connection('relay', '/path/to/proxy', 'vm', None, 'user', 'cert', 'private', 'port', True, False, False, None, None, ['arg1'], False) mock_path.assert_called_once_with() mock_build.assert_called_once_with('cert', 'private', None) - mock_cleanup.assert_not_called() mock_host.assert_called_once_with('user', 'vm') + mock_startcleanup.assert_called_once_with('cert', 'private', None, False, False, False, ['arg1']) mock_call.assert_called_once_with(expected_command, shell=platform.system() == 'Windows', env=expected_env) + mock_terminatecleanup.assert_called_once_with(False, False, False, None, 'cert', 'private', None, None) - @mock.patch.object(ssh_utils, '_do_cleanup') + @mock.patch.object(ssh_utils, '_start_cleanup') + @mock.patch.object(ssh_utils, '_terminate_cleanup') @mock.patch('os.environ.copy') @mock.patch.object(ssh_utils, '_get_ssh_path') @mock.patch.object(ssh_utils, '_build_args') @mock.patch('subprocess.call') @mock.patch.object(ssh_utils, '_get_host') - def test_start_ssh_connection_private_key_arc(self, mock_host, mock_call, mock_build, mock_path, mock_copy_env, mock_cleanup): + def test_start_ssh_connection_private_key_arc(self, mock_host, mock_call, mock_build, mock_path, mock_copy_env, mock_terminatecleanup, mock_startcleanup): mock_copy_env.return_value = {'var1':'value1', 'var2':'value2', 'var3':'value3'} mock_build.return_value = ['-i', 'private'] expected_command = ['path', 'user@vm', '-o', 'ProxyCommand=/path/to/proxy', '-i', 'private', 'arg1', 'arg2', 'arg3'] expected_env = {'var1':'value1', 'var2':'value2', 'var3':'value3', 'SSHPROXY_RELAY_INFO':'relay'} mock_host.return_value = 'user@vm' + mock_startcleanup.return_value = None, ['arg1', 'arg2', 'arg3'], None - ssh_utils.start_ssh_connection('relay', '/path/to/proxy', 'vm', None, 'user', None, 'private', None, True, 'path', ['arg1', 'arg2', 'arg3'], False) + ssh_utils.start_ssh_connection('relay', '/path/to/proxy', 'vm', None, 'user', None, 'private', None, True, False, False, None, 'path', ['arg1', 'arg2', 'arg3'], False) mock_path.assert_not_called() mock_host.assert_called_once_with('user', 'vm') mock_build.assert_called_once_with(None, 'private', None) - mock_cleanup.assert_not_called() + mock_startcleanup.assert_called_once_with(None, 'private', None, False, False, False, ['arg1', 'arg2', 'arg3']) mock_call.assert_called_once_with(expected_command, shell=platform.system() == 'Windows', env=expected_env) + mock_terminatecleanup.assert_called_once_with(False, False, False, None, None, 'private', None, None) - @mock.patch.object(ssh_utils, '_do_cleanup') + @mock.patch.object(ssh_utils, '_start_cleanup') + @mock.patch.object(ssh_utils, '_terminate_cleanup') @mock.patch('os.environ.copy') @mock.patch.object(ssh_utils, '_get_ssh_path') @mock.patch.object(ssh_utils, '_build_args') @mock.patch('subprocess.call') @mock.patch.object(ssh_utils, '_get_host') - def test_start_ssh_connection_cert_no_private_key_arc(self, mock_host, mock_call, mock_build, mock_path, mock_copy_env, mock_cleanup): + def test_start_ssh_connection_cert_no_private_key_arc(self, mock_host, mock_call, mock_build, mock_path, mock_copy_env, mock_terminatecleanup, mock_startcleanup): mock_copy_env.return_value = {'var1':'value1', 'var2':'value2', 'var3':'value3'} mock_path.return_value = 'ssh' mock_build.return_value = ['-o', 'option'] - expected_command = ['ssh', 'user@vm', '-o', 'ProxyCommand=/path/to/proxy -p port', '-o', 'option', 'arg1', 'arg2'] + mock_startcleanup.return_value = 'log', ['arg1', 'arg2', '-E', 'log', '-v'], 'cleanup process' + expected_command = ['ssh', 'user@vm', '-o', 'ProxyCommand=/path/to/proxy -p port', '-o', 'option', 'arg1', 'arg2', '-E', 'log', '-v'] expected_env = {'var1':'value1', 'var2':'value2', 'var3':'value3', 'SSHPROXY_RELAY_INFO':'relay'} mock_host.return_value = 'user@vm' - ssh_utils.start_ssh_connection('relay', '/path/to/proxy', 'vm', None, 'user', 'cert', None, 'port', True, None, ['arg1', 'arg2'], False) + ssh_utils.start_ssh_connection('relay', '/path/to/proxy', 'vm', None, 'user', 'cert', None, 'port', True, False, True, 'public', None, ['arg1', 'arg2'], False) mock_path.assert_called_once_with() mock_build.assert_called_once_with('cert', None, None) mock_host.assert_called_once_with('user', 'vm') - mock_cleanup.assert_not_called() + mock_startcleanup.assert_called_once_with('cert', None, 'public', False, False, True, ['arg1', 'arg2']) mock_call.assert_called_once_with(expected_command, shell=platform.system() == 'Windows', env=expected_env) - - def test_write_ssh_config_ip_and_vm_azurevm(self): + mock_terminatecleanup.assert_called_once_with(False, True, False, 'cleanup process', 'cert', None, 'public', 'log') + + @mock.patch.object(ssh_utils, '_issue_config_cleanup_warning') + def test_write_ssh_config_ip_and_vm_azurevm(self, mock_warning): expected_lines = [ "", "Host rg-vm", @@ -186,24 +210,24 @@ def test_write_ssh_config_ip_and_vm_azurevm(self): mock_file = mock.Mock() mock_open.return_value.__enter__.return_value = mock_file ssh_utils.write_ssh_config( - None, None, 'vm', '1.2.3.4', 'username', 'cert', 'privatekey', 'port', False, 'path/to/file', True, 'rg') + None, None, 'vm', '1.2.3.4', 'username', 'cert', 'privatekey', 'port', False, True, True, 'publickey', 'path/to/file', True, 'rg', 'cred folder') mock_open.assert_called_once_with("path/to/file", "w") + mock_warning.assert_called_once_with(True, True, False, 'cert', None, None) mock_file.write.assert_called_once_with('\n'.join(expected_lines)) - def test_write_ssh_config_append_azurevm(self): + @mock.patch.object(ssh_utils, '_issue_config_cleanup_warning') + def test_write_ssh_config_append_azurevm(self, mock_warning): expected_lines = [ "", "Host rg-vm", "\tHostName 1.2.3.4", "\tUser username", "\tCertificateFile cert", - "\tIdentityFile privatekey", "\tPort port", "Host 1.2.3.4", "\tUser username", "\tCertificateFile cert", - "\tIdentityFile privatekey", "\tPort port" ] @@ -211,12 +235,14 @@ def test_write_ssh_config_append_azurevm(self): mock_file = mock.Mock() mock_open.return_value.__enter__.return_value = mock_file ssh_utils.write_ssh_config( - None, None, 'vm', '1.2.3.4', 'username', 'cert', 'privatekey', 'port', False, 'path/to/file', False, 'rg') + None, None, 'vm', '1.2.3.4', 'username', 'cert', None, 'port', False, False, True, 'public', 'path/to/file', False, 'rg', 'cred folder') mock_open.assert_called_once_with("path/to/file", "a") + mock_warning.assert_called_once_with(True, False, False, 'cert', None, None) mock_file.write.assert_called_once_with('\n'.join(expected_lines)) - - def test_write_ssh_config_ip_only(self): + + @mock.patch.object(ssh_utils, '_issue_config_cleanup_warning') + def test_write_ssh_config_ip_only(self, mock_warning): expected_lines = [ "", "Host 1.2.3.4", @@ -230,16 +256,15 @@ def test_write_ssh_config_ip_only(self): mock_file = mock.Mock() mock_open.return_value.__enter__.return_value = mock_file ssh_utils.write_ssh_config( - None, None, None, '1.2.3.4', 'username', 'cert', 'privatekey', 'port', False, 'path/to/file', True, None) + None, None, None, '1.2.3.4', 'username', 'cert', 'privatekey', 'port', False, True, True, 'public', 'path/to/file', True, None, 'cred folder') mock_open.assert_called_once_with("path/to/file", "w") + mock_warning.assert_called_once_with(True, True, False, 'cert', None, None) mock_file.write.assert_called_once_with('\n'.join(expected_lines)) - - @mock.patch('os.path.dirname') - @mock.patch('oschmod.set_mode') - @mock.patch('azext_ssh.file_utils.write_to_file') - def test_write_ssh_config_append_arc(self, mock_write, mock_set_mode, mock_dirname): - import stat + + @mock.patch.object(ssh_utils, '_prepare_relay_info_file') + @mock.patch.object(ssh_utils, '_issue_config_cleanup_warning') + def test_write_ssh_config_append_arc(self, mock_warning, mock_relay): expected_lines = [ "", "Host rg-vm", @@ -253,21 +278,19 @@ def test_write_ssh_config_append_arc(self, mock_write, mock_set_mode, mock_dirna with mock.patch('builtins.open') as mock_open: mock_file = mock.Mock() mock_open.return_value.__enter__.return_value = mock_file - mock_dirname.return_value = '/path/to/' + mock_relay.return_value = '/path/to/relay_info', 'relay name' ssh_utils.write_ssh_config( - 'relay_info', '/path/to/proxy', 'vm', None, 'username', 'cert', 'privatekey', 'port', True, 'path/to/file', False, 'rg' + 'relay_info', '/path/to/proxy', 'vm', None, 'username', 'cert', 'privatekey', 'port', True, True, True, 'publickey', 'path/to/file', False, 'rg', 'cred folder' ) - mock_write.assert_called_once_with('/path/to/relay_info', 'w', 'relay_info', "Couldn't write relay information to file /path/to/relay_info", 'utf-8') mock_open.assert_called_once_with("path/to/file", "a") mock_file.write.assert_called_with('\n'.join(expected_lines)) - mock_set_mode.assert_called_once_with("/path/to/relay_info", stat.S_IRUSR) + mock_relay.assert_called_once_with('relay_info', 'cert', 'privatekey', 'cred folder', 'vm', 'rg') + mock_warning.assert_called_once_with(True, True, True, 'cert', 'relay name', '/path/to/relay_info') - @mock.patch('os.path.dirname') - @mock.patch('oschmod.set_mode') - @mock.patch('azext_ssh.file_utils.write_to_file') - def test_write_ssh_config_overwrite_arc(self, mock_write, mock_set_mode, mock_dirname): - import stat + @mock.patch.object(ssh_utils, '_prepare_relay_info_file') + @mock.patch.object(ssh_utils, '_issue_config_cleanup_warning') + def test_write_ssh_config_overwrite_arc(self, mock_warning, mock_relay): expected_lines = [ "", "Host rg-vm", @@ -281,16 +304,17 @@ def test_write_ssh_config_overwrite_arc(self, mock_write, mock_set_mode, mock_di with mock.patch('builtins.open') as mock_open: mock_file = mock.Mock() mock_open.return_value.__enter__.return_value = mock_file - mock_dirname.return_value = '/path/to/' + mock_relay.return_value = '/path/to/relay_info', 'relay name' ssh_utils.write_ssh_config( - 'relay_info', '/path/to/proxy', 'vm', None, 'username', 'cert', 'privatekey', 'port', True, 'path/to/file', True, 'rg' + 'relay_info', '/path/to/proxy', 'vm', None, 'username', 'cert', 'privatekey', 'port', True, False, False, 'publickey', 'path/to/file', True, 'rg', 'cred folder' ) - mock_write.assert_called_once_with('/path/to/relay_info', 'w', 'relay_info', "Couldn't write relay information to file /path/to/relay_info", 'utf-8') mock_open.assert_any_call("path/to/file", "w") mock_file.write.assert_called_with('\n'.join(expected_lines)) - mock_set_mode.assert_called_once_with("/path/to/relay_info", stat.S_IRUSR) - + mock_relay.assert_called_once_with('relay_info', 'cert', 'privatekey', 'cred folder', 'vm', 'rg') + mock_warning.assert_called_once_with(False, False, True, 'cert', 'relay name', '/path/to/relay_info') + + @mock.patch('platform.system') def test_get_ssh_path_non_windows(self, mock_system): mock_system.return_value = "Mac" @@ -350,18 +374,4 @@ def _test_ssh_path_windows(self, arch, expected_sys_path, mock_isfile, mock_envi mock_environ.__getitem__.assert_called_once_with("SystemRoot") mock_join.assert_has_calls(expected_join_calls) mock_isfile.assert_called_once_with("sshfilepath") - - @mock.patch('os.environ.get') - def test_do_cleanup_not_cloudshell(self, mock_getenv): - mock_getenv.return_value = None - self.assertRaises( - azclierror.BadRequestError, ssh_utils._do_cleanup, 'private', 'cert', None) - - @mock.patch('os.path.isfile') - @mock.patch('os.remove') - @mock.patch('os.environ.get') - def test_do_cleanup_cloudshell(self, mock_getenv, mock_remove, mock_isfile): - mock_isfile.return_value = True - mock_getenv.return_value = "cloud-shell/1.0" - ssh_utils._do_cleanup('private', 'cert', None) - mock_remove.assert_has_calls([mock.call('private'), mock.call('cert')]) + \ No newline at end of file diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedmachine/__init__.py b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/__init__.py index 35ef17cd924..9a8a1b4dcf8 100644 --- a/src/ssh/azext_ssh/vendored_sdks/connectedmachine/__init__.py +++ b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/__init__.py @@ -7,6 +7,9 @@ # -------------------------------------------------------------------------- from ._connected_machine import ConnectedMachine +from ._version import VERSION + +__version__ = VERSION __all__ = ['ConnectedMachine'] try: diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedmachine/_configuration.py b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/_configuration.py index a369296810e..102684e1826 100644 --- a/src/ssh/azext_ssh/vendored_sdks/connectedmachine/_configuration.py +++ b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/_configuration.py @@ -12,13 +12,14 @@ from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from ._version import VERSION + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any from azure.core.credentials import TokenCredential -VERSION = "unknown" class ConnectedMachineConfiguration(Configuration): """Configuration for ConnectedMachine. @@ -47,9 +48,9 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-06-10-preview" + self.api_version = "2021-05-20" self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'connectedmachine/{}'.format(VERSION)) + kwargs.setdefault('sdk_moniker', 'mgmt-hybridcompute/{}'.format(VERSION)) self._configure(**kwargs) def _configure( diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedmachine/_connected_machine.py b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/_connected_machine.py index a740f6f0196..75b9809af78 100644 --- a/src/ssh/azext_ssh/vendored_sdks/connectedmachine/_connected_machine.py +++ b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/_connected_machine.py @@ -32,17 +32,17 @@ class ConnectedMachine(ConnectedMachineOperationsMixin): """The Hybrid Compute Management Client. :ivar machines: MachinesOperations operations - :vartype machines: connected_machine.operations.MachinesOperations + :vartype machines: azure.mgmt.hybridcompute.operations.MachinesOperations :ivar machine_extensions: MachineExtensionsOperations operations - :vartype machine_extensions: connected_machine.operations.MachineExtensionsOperations + :vartype machine_extensions: azure.mgmt.hybridcompute.operations.MachineExtensionsOperations :ivar operations: Operations operations - :vartype operations: connected_machine.operations.Operations + :vartype operations: azure.mgmt.hybridcompute.operations.Operations :ivar private_link_scopes: PrivateLinkScopesOperations operations - :vartype private_link_scopes: connected_machine.operations.PrivateLinkScopesOperations + :vartype private_link_scopes: azure.mgmt.hybridcompute.operations.PrivateLinkScopesOperations :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: connected_machine.operations.PrivateLinkResourcesOperations + :vartype private_link_resources: azure.mgmt.hybridcompute.operations.PrivateLinkResourcesOperations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: connected_machine.operations.PrivateEndpointConnectionsOperations + :vartype private_endpoint_connections: azure.mgmt.hybridcompute.operations.PrivateEndpointConnectionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. @@ -66,6 +66,7 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) + self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) self.machines = MachinesOperations( diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedmachine/_version.py b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/_version.py new file mode 100644 index 00000000000..e5754a47ce6 --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/_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.0b1" diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedmachine/aio/_configuration.py b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/aio/_configuration.py index 248e7a48540..04e5e5f423c 100644 --- a/src/ssh/azext_ssh/vendored_sdks/connectedmachine/aio/_configuration.py +++ b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/aio/_configuration.py @@ -12,11 +12,12 @@ from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from .._version import VERSION + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -VERSION = "unknown" class ConnectedMachineConfiguration(Configuration): """Configuration for ConnectedMachine. @@ -44,9 +45,9 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-06-10-preview" + self.api_version = "2021-05-20" self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'connectedmachine/{}'.format(VERSION)) + kwargs.setdefault('sdk_moniker', 'mgmt-hybridcompute/{}'.format(VERSION)) self._configure(**kwargs) def _configure( diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedmachine/aio/_connected_machine.py b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/aio/_connected_machine.py index 5eea54c2534..e5dbf9451bd 100644 --- a/src/ssh/azext_ssh/vendored_sdks/connectedmachine/aio/_connected_machine.py +++ b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/aio/_connected_machine.py @@ -30,17 +30,17 @@ class ConnectedMachine(ConnectedMachineOperationsMixin): """The Hybrid Compute Management Client. :ivar machines: MachinesOperations operations - :vartype machines: connected_machine.aio.operations.MachinesOperations + :vartype machines: azure.mgmt.hybridcompute.aio.operations.MachinesOperations :ivar machine_extensions: MachineExtensionsOperations operations - :vartype machine_extensions: connected_machine.aio.operations.MachineExtensionsOperations + :vartype machine_extensions: azure.mgmt.hybridcompute.aio.operations.MachineExtensionsOperations :ivar operations: Operations operations - :vartype operations: connected_machine.aio.operations.Operations + :vartype operations: azure.mgmt.hybridcompute.aio.operations.Operations :ivar private_link_scopes: PrivateLinkScopesOperations operations - :vartype private_link_scopes: connected_machine.aio.operations.PrivateLinkScopesOperations + :vartype private_link_scopes: azure.mgmt.hybridcompute.aio.operations.PrivateLinkScopesOperations :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: connected_machine.aio.operations.PrivateLinkResourcesOperations + :vartype private_link_resources: azure.mgmt.hybridcompute.aio.operations.PrivateLinkResourcesOperations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: connected_machine.aio.operations.PrivateEndpointConnectionsOperations + :vartype private_endpoint_connections: azure.mgmt.hybridcompute.aio.operations.PrivateEndpointConnectionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. @@ -63,6 +63,7 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) + self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) self.machines = MachinesOperations( diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedmachine/aio/operations/_connected_machine_operations.py b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/aio/operations/_connected_machine_operations.py index 67684c5203e..b05efa22595 100644 --- a/src/ssh/azext_ssh/vendored_sdks/connectedmachine/aio/operations/_connected_machine_operations.py +++ b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/aio/operations/_connected_machine_operations.py @@ -34,7 +34,7 @@ async def _upgrade_extensions_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" @@ -87,7 +87,7 @@ async def begin_upgrade_extensions( :param machine_name: The name of the hybrid machine. :type machine_name: str :param extension_upgrade_parameters: Parameters supplied to the Upgrade Extensions operation. - :type extension_upgrade_parameters: ~connected_machine.models.MachineExtensionUpgrade + :type extension_upgrade_parameters: ~azure.mgmt.hybridcompute.models.MachineExtensionUpgrade :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: True for ARMPolling, False for no polling, or a diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedmachine/aio/operations/_machine_extensions_operations.py b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/aio/operations/_machine_extensions_operations.py index 8ff9c9cc8ff..b9868deb183 100644 --- a/src/ssh/azext_ssh/vendored_sdks/connectedmachine/aio/operations/_machine_extensions_operations.py +++ b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/aio/operations/_machine_extensions_operations.py @@ -28,7 +28,7 @@ class MachineExtensionsOperations: instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. - :type models: ~connected_machine.models + :type models: ~azure.mgmt.hybridcompute.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. @@ -56,7 +56,7 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" @@ -118,7 +118,7 @@ async def begin_create_or_update( :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: ~connected_machine.models.MachineExtension + :type extension_parameters: ~azure.mgmt.hybridcompute.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: True for ARMPolling, False for no polling, or a @@ -126,7 +126,7 @@ async def begin_create_or_update( :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[~connected_machine.models.MachineExtension] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hybridcompute.models.MachineExtension] :raises ~azure.core.exceptions.HttpResponseError: """ polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] @@ -190,7 +190,7 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" @@ -252,7 +252,7 @@ async def begin_update( :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: ~connected_machine.models.MachineExtensionUpdate + :type extension_parameters: ~azure.mgmt.hybridcompute.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: True for ARMPolling, False for no polling, or a @@ -260,7 +260,7 @@ async def begin_update( :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[~connected_machine.models.MachineExtension] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hybridcompute.models.MachineExtension] :raises ~azure.core.exceptions.HttpResponseError: """ polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] @@ -323,7 +323,7 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" accept = "application/json" # Construct URL @@ -444,7 +444,7 @@ async def get( :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: ~connected_machine.models.MachineExtension + :rtype: ~azure.mgmt.hybridcompute.models.MachineExtension :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.MachineExtension"] @@ -452,7 +452,7 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" accept = "application/json" # Construct URL @@ -507,7 +507,7 @@ def list( :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[~connected_machine.models.MachineExtensionsListResult] + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hybridcompute.models.MachineExtensionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.MachineExtensionsListResult"] @@ -515,7 +515,7 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" accept = "application/json" def prepare_request(next_link=None): diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedmachine/aio/operations/_machines_operations.py b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/aio/operations/_machines_operations.py index ca11a2e9b14..c066f92566e 100644 --- a/src/ssh/azext_ssh/vendored_sdks/connectedmachine/aio/operations/_machines_operations.py +++ b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/aio/operations/_machines_operations.py @@ -26,7 +26,7 @@ class MachinesOperations: instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. - :type models: ~connected_machine.models + :type models: ~azure.mgmt.hybridcompute.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. @@ -41,198 +41,6 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config - async def list_access_details( - self, - resource_group_name: str, - machine_name: str, - **kwargs - ) -> str: - """The operation to create or update a hybrid machine resource identity in Azure. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param machine_name: The name of the hybrid machine. - :type machine_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: str, or the result of cls(response) - :rtype: str - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[str] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" - accept = "application/json" - - # Construct URL - url = self.list_access_details.metadata['url'] # type: ignore - path_format_arguments = { - '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'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('str', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - list_access_details.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/listAccessDetails'} # type: ignore - - async def create_or_update( - self, - resource_group_name: str, - machine_name: str, - parameters: "models.Machine", - **kwargs - ) -> "models.Machine": - """The operation to create or update a hybrid machine resource identity in Azure. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param machine_name: The name of the hybrid machine. - :type machine_name: str - :param parameters: Parameters supplied to the Create hybrid machine operation. - :type parameters: ~connected_machine.models.Machine - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Machine, or the result of cls(response) - :rtype: ~connected_machine.models.Machine - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.Machine"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - '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'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Machine') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('Machine', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}'} # type: ignore - - async def update( - self, - resource_group_name: str, - machine_name: str, - parameters: "models.MachineUpdate", - **kwargs - ) -> "models.Machine": - """The operation to update a hybrid machine. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param machine_name: The name of the hybrid machine. - :type machine_name: str - :param parameters: Parameters supplied to the Update hybrid machine operation. - :type parameters: ~connected_machine.models.MachineUpdate - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Machine, or the result of cls(response) - :rtype: ~connected_machine.models.Machine - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.Machine"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', 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'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'MachineUpdate') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('Machine', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}'} # type: ignore - async def delete( self, resource_group_name: str, @@ -255,7 +63,7 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" accept = "application/json" # Construct URL @@ -303,10 +111,10 @@ async def get( :param machine_name: The name of the hybrid machine. :type machine_name: str :param expand: The expand expression to apply on the operation. - :type expand: str or ~connected_machine.models.InstanceViewTypes + :type expand: str or ~azure.mgmt.hybridcompute.models.InstanceViewTypes :keyword callable cls: A custom type or function that will be passed the direct response :return: Machine, or the result of cls(response) - :rtype: ~connected_machine.models.Machine + :rtype: ~azure.mgmt.hybridcompute.models.Machine :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.Machine"] @@ -314,7 +122,7 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" accept = "application/json" # Construct URL @@ -365,7 +173,7 @@ def list_by_resource_group( :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 MachineListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~connected_machine.models.MachineListResult] + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hybridcompute.models.MachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.MachineListResult"] @@ -373,7 +181,7 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" accept = "application/json" def prepare_request(next_link=None): @@ -434,7 +242,7 @@ def list_by_subscription( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either MachineListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~connected_machine.models.MachineListResult] + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hybridcompute.models.MachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.MachineListResult"] @@ -442,7 +250,7 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" accept = "application/json" def prepare_request(next_link=None): diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedmachine/aio/operations/_operations.py b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/aio/operations/_operations.py index eb7be25ef1f..581f88b893a 100644 --- a/src/ssh/azext_ssh/vendored_sdks/connectedmachine/aio/operations/_operations.py +++ b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/aio/operations/_operations.py @@ -26,7 +26,7 @@ class Operations: instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. - :type models: ~connected_machine.models + :type models: ~azure.mgmt.hybridcompute.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. @@ -49,7 +49,7 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~connected_machine.models.OperationListResult] + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hybridcompute.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.OperationListResult"] @@ -57,7 +57,7 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" accept = "application/json" def prepare_request(next_link=None): diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedmachine/aio/operations/_private_endpoint_connections_operations.py b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/aio/operations/_private_endpoint_connections_operations.py index c4a9770a927..29a4616941d 100644 --- a/src/ssh/azext_ssh/vendored_sdks/connectedmachine/aio/operations/_private_endpoint_connections_operations.py +++ b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/aio/operations/_private_endpoint_connections_operations.py @@ -28,7 +28,7 @@ class PrivateEndpointConnectionsOperations: instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. - :type models: ~connected_machine.models + :type models: ~azure.mgmt.hybridcompute.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. @@ -60,7 +60,7 @@ async def get( :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection, or the result of cls(response) - :rtype: ~connected_machine.models.PrivateEndpointConnection + :rtype: ~azure.mgmt.hybridcompute.models.PrivateEndpointConnection :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.PrivateEndpointConnection"] @@ -68,7 +68,7 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" accept = "application/json" # Construct URL @@ -106,7 +106,7 @@ async def get( return deserialized get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - async def _create_or_update_initial( + async def _update_initial( self, resource_group_name: str, scope_name: str, @@ -119,12 +119,12 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore + url = self._update_initial.metadata['url'] # type: ignore path_format_arguments = { '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), @@ -162,9 +162,9 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - async def begin_create_or_update( + async def begin_update( self, resource_group_name: str, scope_name: str, @@ -181,7 +181,7 @@ async def begin_create_or_update( :param private_endpoint_connection_name: The name of the private endpoint connection. :type private_endpoint_connection_name: str :param parameters: - :type parameters: ~connected_machine.models.PrivateEndpointConnection + :type parameters: ~azure.mgmt.hybridcompute.models.PrivateEndpointConnection :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: True for ARMPolling, False for no polling, or a @@ -189,7 +189,7 @@ async def begin_create_or_update( :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 PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~connected_machine.models.PrivateEndpointConnection] + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.hybridcompute.models.PrivateEndpointConnection] :raises ~azure.core.exceptions.HttpResponseError: """ polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] @@ -200,7 +200,7 @@ async def begin_create_or_update( ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._update_initial( resource_group_name=resource_group_name, scope_name=scope_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -238,7 +238,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore async def _delete_initial( self, @@ -252,7 +252,7 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" accept = "application/json" # Construct URL @@ -370,7 +370,7 @@ def list_by_private_link_scope( :type scope_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~connected_machine.models.PrivateEndpointConnectionListResult] + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hybridcompute.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.PrivateEndpointConnectionListResult"] @@ -378,7 +378,7 @@ def list_by_private_link_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" accept = "application/json" def prepare_request(next_link=None): diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedmachine/aio/operations/_private_link_resources_operations.py b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/aio/operations/_private_link_resources_operations.py index b474778b42e..59d91002542 100644 --- a/src/ssh/azext_ssh/vendored_sdks/connectedmachine/aio/operations/_private_link_resources_operations.py +++ b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/aio/operations/_private_link_resources_operations.py @@ -26,7 +26,7 @@ class PrivateLinkResourcesOperations: instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. - :type models: ~connected_machine.models + :type models: ~azure.mgmt.hybridcompute.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. @@ -55,7 +55,7 @@ def list_by_private_link_scope( :type scope_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PrivateLinkResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~connected_machine.models.PrivateLinkResourceListResult] + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hybridcompute.models.PrivateLinkResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.PrivateLinkResourceListResult"] @@ -63,7 +63,7 @@ def list_by_private_link_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" accept = "application/json" def prepare_request(next_link=None): @@ -133,7 +133,7 @@ async def get( :type group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateLinkResource, or the result of cls(response) - :rtype: ~connected_machine.models.PrivateLinkResource + :rtype: ~azure.mgmt.hybridcompute.models.PrivateLinkResource :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.PrivateLinkResource"] @@ -141,7 +141,7 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" accept = "application/json" # Construct URL diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedmachine/aio/operations/_private_link_scopes_operations.py b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/aio/operations/_private_link_scopes_operations.py index b906775b085..dcc71ced523 100644 --- a/src/ssh/azext_ssh/vendored_sdks/connectedmachine/aio/operations/_private_link_scopes_operations.py +++ b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/aio/operations/_private_link_scopes_operations.py @@ -28,7 +28,7 @@ class PrivateLinkScopesOperations: instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. - :type models: ~connected_machine.models + :type models: ~azure.mgmt.hybridcompute.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. @@ -51,7 +51,7 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either HybridComputePrivateLinkScopeListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~connected_machine.models.HybridComputePrivateLinkScopeListResult] + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hybridcompute.models.HybridComputePrivateLinkScopeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.HybridComputePrivateLinkScopeListResult"] @@ -59,7 +59,7 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" accept = "application/json" def prepare_request(next_link=None): @@ -121,7 +121,7 @@ def list_by_resource_group( :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 HybridComputePrivateLinkScopeListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~connected_machine.models.HybridComputePrivateLinkScopeListResult] + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.hybridcompute.models.HybridComputePrivateLinkScopeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.HybridComputePrivateLinkScopeListResult"] @@ -129,7 +129,7 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" accept = "application/json" def prepare_request(next_link=None): @@ -192,7 +192,7 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" accept = "application/json" # Construct URL @@ -304,7 +304,7 @@ async def get( :type scope_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: HybridComputePrivateLinkScope, or the result of cls(response) - :rtype: ~connected_machine.models.HybridComputePrivateLinkScope + :rtype: ~azure.mgmt.hybridcompute.models.HybridComputePrivateLinkScope :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.HybridComputePrivateLinkScope"] @@ -312,7 +312,7 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" accept = "application/json" # Construct URL @@ -365,10 +365,10 @@ async def create_or_update( :type scope_name: str :param parameters: Properties that need to be specified to create or update a Azure Arc for Servers and Clusters PrivateLinkScope. - :type parameters: ~connected_machine.models.HybridComputePrivateLinkScope + :type parameters: ~azure.mgmt.hybridcompute.models.HybridComputePrivateLinkScope :keyword callable cls: A custom type or function that will be passed the direct response :return: HybridComputePrivateLinkScope, or the result of cls(response) - :rtype: ~connected_machine.models.HybridComputePrivateLinkScope + :rtype: ~azure.mgmt.hybridcompute.models.HybridComputePrivateLinkScope :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.HybridComputePrivateLinkScope"] @@ -376,7 +376,7 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" @@ -438,10 +438,10 @@ async def update_tags( :type scope_name: str :param private_link_scope_tags: Updated tag information to set into the PrivateLinkScope instance. - :type private_link_scope_tags: ~connected_machine.models.TagsResource + :type private_link_scope_tags: ~azure.mgmt.hybridcompute.models.TagsResource :keyword callable cls: A custom type or function that will be passed the direct response :return: HybridComputePrivateLinkScope, or the result of cls(response) - :rtype: ~connected_machine.models.HybridComputePrivateLinkScope + :rtype: ~azure.mgmt.hybridcompute.models.HybridComputePrivateLinkScope :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.HybridComputePrivateLinkScope"] @@ -449,7 +449,7 @@ async def update_tags( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" @@ -505,7 +505,7 @@ async def get_validation_details( :type private_link_scope_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateLinkScopeValidationDetails, or the result of cls(response) - :rtype: ~connected_machine.models.PrivateLinkScopeValidationDetails + :rtype: ~azure.mgmt.hybridcompute.models.PrivateLinkScopeValidationDetails :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.PrivateLinkScopeValidationDetails"] @@ -513,7 +513,7 @@ async def get_validation_details( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" accept = "application/json" # Construct URL @@ -565,7 +565,7 @@ async def get_validation_details_for_machine( :type machine_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateLinkScopeValidationDetails, or the result of cls(response) - :rtype: ~connected_machine.models.PrivateLinkScopeValidationDetails + :rtype: ~azure.mgmt.hybridcompute.models.PrivateLinkScopeValidationDetails :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.PrivateLinkScopeValidationDetails"] @@ -573,7 +573,7 @@ async def get_validation_details_for_machine( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" accept = "application/json" # Construct URL diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedmachine/models/__init__.py b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/models/__init__.py index ecac1656673..1046533c5d8 100644 --- a/src/ssh/azext_ssh/vendored_sdks/connectedmachine/models/__init__.py +++ b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/models/__init__.py @@ -34,10 +34,7 @@ from ._models_py3 import OperationValue from ._models_py3 import OperationValueDisplay from ._models_py3 import OsProfile - from ._models_py3 import OsProfileLinuxConfiguration - from ._models_py3 import OsProfileWindowsConfiguration from ._models_py3 import PrivateEndpointConnection - from ._models_py3 import PrivateEndpointConnectionDataModel from ._models_py3 import PrivateEndpointConnectionListResult from ._models_py3 import PrivateEndpointConnectionProperties from ._models_py3 import PrivateEndpointProperty @@ -81,10 +78,7 @@ from ._models import OperationValue # type: ignore from ._models import OperationValueDisplay # type: ignore from ._models import OsProfile # type: ignore - from ._models import OsProfileLinuxConfiguration # type: ignore - from ._models import OsProfileWindowsConfiguration # type: ignore from ._models import PrivateEndpointConnection # type: ignore - from ._models import PrivateEndpointConnectionDataModel # type: ignore from ._models import PrivateEndpointConnectionListResult # type: ignore from ._models import PrivateEndpointConnectionProperties # type: ignore from ._models import PrivateEndpointProperty # type: ignore @@ -137,10 +131,7 @@ 'OperationValue', 'OperationValueDisplay', 'OsProfile', - 'OsProfileLinuxConfiguration', - 'OsProfileWindowsConfiguration', 'PrivateEndpointConnection', - 'PrivateEndpointConnectionDataModel', 'PrivateEndpointConnectionListResult', 'PrivateEndpointConnectionProperties', 'PrivateEndpointProperty', diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedmachine/models/_models.py b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/models/_models.py index 483bb7efb0b..c430690dd8d 100644 --- a/src/ssh/azext_ssh/vendored_sdks/connectedmachine/models/_models.py +++ b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/models/_models.py @@ -97,9 +97,9 @@ class ErrorDetail(msrest.serialization.Model): :ivar target: The error target. :vartype target: str :ivar details: The error details. - :vartype details: list[~connected_machine.models.ErrorDetail] + :vartype details: list[~azure.mgmt.hybridcompute.models.ErrorDetail] :ivar additional_info: The error additional info. - :vartype additional_info: list[~connected_machine.models.ErrorAdditionalInfo] + :vartype additional_info: list[~azure.mgmt.hybridcompute.models.ErrorAdditionalInfo] """ _validation = { @@ -134,7 +134,7 @@ class ErrorResponse(msrest.serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). :param error: The error object. - :type error: ~connected_machine.models.ErrorDetail + :type error: ~azure.mgmt.hybridcompute.models.ErrorDetail """ _attribute_map = { @@ -232,9 +232,9 @@ class HybridComputePrivateLinkScope(PrivateLinkScopesResource): :param tags: A set of tags. Resource tags. :type tags: dict[str, str] :param properties: Properties that define a Azure Arc PrivateLinkScope resource. - :type properties: ~connected_machine.models.HybridComputePrivateLinkScopeProperties + :type properties: ~azure.mgmt.hybridcompute.models.HybridComputePrivateLinkScopeProperties :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~connected_machine.models.SystemData + :vartype system_data: ~azure.mgmt.hybridcompute.models.SystemData """ _validation = { @@ -270,7 +270,7 @@ class HybridComputePrivateLinkScopeListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :param value: Required. List of Azure Arc PrivateLinkScope definitions. - :type value: list[~connected_machine.models.HybridComputePrivateLinkScope] + :type value: list[~azure.mgmt.hybridcompute.models.HybridComputePrivateLinkScope] :param next_link: The URI to get the next set of Azure Arc PrivateLinkScope definitions if too many PrivateLinkScopes where returned in the result set. :type next_link: str @@ -302,29 +302,24 @@ class HybridComputePrivateLinkScopeProperties(msrest.serialization.Model): :param public_network_access: Indicates whether machines associated with the private link scope can also use public Azure Arc service endpoints. Possible values include: "Enabled", "Disabled". Default value: "Disabled". - :type public_network_access: str or ~connected_machine.models.PublicNetworkAccessType + :type public_network_access: str or ~azure.mgmt.hybridcompute.models.PublicNetworkAccessType :ivar provisioning_state: Current state of this PrivateLinkScope: whether or not is has been provisioned within the resource group it is defined. Users cannot change this value but are able to read from it. Values will include Provisioning ,Succeeded, Canceled and Failed. :vartype provisioning_state: str :ivar private_link_scope_id: The Guid id of the private link scope. :vartype private_link_scope_id: str - :ivar private_endpoint_connections: The collection of associated Private Endpoint Connections. - :vartype private_endpoint_connections: - list[~connected_machine.models.PrivateEndpointConnectionDataModel] """ _validation = { 'provisioning_state': {'readonly': True}, 'private_link_scope_id': {'readonly': True}, - 'private_endpoint_connections': {'readonly': True}, } _attribute_map = { 'public_network_access': {'key': 'publicNetworkAccess', 'type': 'str'}, 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, 'private_link_scope_id': {'key': 'privateLinkScopeId', 'type': 'str'}, - 'private_endpoint_connections': {'key': 'privateEndpointConnections', 'type': '[PrivateEndpointConnectionDataModel]'}, } def __init__( @@ -335,7 +330,6 @@ def __init__( self.public_network_access = kwargs.get('public_network_access', "Disabled") self.provisioning_state = None self.private_link_scope_id = None - self.private_endpoint_connections = None class Identity(msrest.serialization.Model): @@ -513,11 +507,11 @@ class Machine(TrackedResource): :param location: Required. The geo-location where the resource lives. :type location: str :param properties: Hybrid Compute Machine properties. - :type properties: ~connected_machine.models.MachineProperties + :type properties: ~azure.mgmt.hybridcompute.models.MachineProperties :param identity: Identity for the resource. - :type identity: ~connected_machine.models.Identity + :type identity: ~azure.mgmt.hybridcompute.models.Identity :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~connected_machine.models.SystemData + :vartype system_data: ~azure.mgmt.hybridcompute.models.SystemData """ _validation = { @@ -569,9 +563,9 @@ class MachineExtension(TrackedResource): :param location: Required. The geo-location where the resource lives. :type location: str :param properties: Describes Machine Extension Properties. - :type properties: ~connected_machine.models.MachineExtensionProperties + :type properties: ~azure.mgmt.hybridcompute.models.MachineExtensionProperties :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~connected_machine.models.SystemData + :vartype system_data: ~azure.mgmt.hybridcompute.models.SystemData """ _validation = { @@ -611,7 +605,7 @@ class MachineExtensionInstanceView(msrest.serialization.Model): :param type_handler_version: Specifies the version of the script handler. :type type_handler_version: str :param status: Instance view status. - :type status: ~connected_machine.models.MachineExtensionInstanceViewStatus + :type status: ~azure.mgmt.hybridcompute.models.MachineExtensionInstanceViewStatus """ _attribute_map = { @@ -638,7 +632,7 @@ class MachineExtensionInstanceViewStatus(msrest.serialization.Model): :param code: The status code. :type code: str :param level: The level code. Possible values include: "Info", "Warning", "Error". - :type level: str or ~connected_machine.models.StatusLevelTypes + :type level: str or ~azure.mgmt.hybridcompute.models.StatusLevelTypes :param display_status: The short localizable label for the status. :type display_status: str :param message: The detailed status message, including for alerts and error messages. @@ -681,6 +675,9 @@ class MachineExtensionProperties(msrest.serialization.Model): :type type: str :param type_handler_version: Specifies the version of the script handler. :type type_handler_version: str + :param enable_auto_upgrade: Indicates whether the extension should be automatically + upgraded by the platform if there is a newer version available. + :type enable_auto_upgrade: bool :param 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. @@ -693,7 +690,7 @@ class MachineExtensionProperties(msrest.serialization.Model): :ivar provisioning_state: The provisioning state, which only appears in the response. :vartype provisioning_state: str :param instance_view: The machine extension instance view. - :type instance_view: ~connected_machine.models.MachineExtensionInstanceView + :type instance_view: ~azure.mgmt.hybridcompute.models.MachineExtensionInstanceView """ _validation = { @@ -705,6 +702,7 @@ class MachineExtensionProperties(msrest.serialization.Model): 'publisher': {'key': 'publisher', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'type_handler_version': {'key': 'typeHandlerVersion', 'type': 'str'}, + 'enable_auto_upgrade': {'key': 'enableAutomaticUpgrade', 'type': 'bool'}, 'auto_upgrade_minor_version': {'key': 'autoUpgradeMinorVersion', 'type': 'bool'}, 'settings': {'key': 'settings', 'type': 'object'}, 'protected_settings': {'key': 'protectedSettings', 'type': 'object'}, @@ -721,6 +719,7 @@ def __init__( self.publisher = kwargs.get('publisher', None) self.type = kwargs.get('type', None) self.type_handler_version = kwargs.get('type_handler_version', None) + self.enable_auto_upgrade = kwargs.get('enable_auto_upgrade', None) self.auto_upgrade_minor_version = kwargs.get('auto_upgrade_minor_version', None) self.settings = kwargs.get('settings', None) self.protected_settings = kwargs.get('protected_settings', None) @@ -732,7 +731,7 @@ class MachineExtensionsListResult(msrest.serialization.Model): """Describes the Machine Extensions List Result. :param value: The list of extensions. - :type value: list[~connected_machine.models.MachineExtension] + :type value: list[~azure.mgmt.hybridcompute.models.MachineExtension] :param next_link: The uri to fetch the next page of machine extensions. Call ListNext() with this to fetch the next page of extensions. :type next_link: str @@ -777,7 +776,7 @@ class MachineExtensionUpdate(ResourceUpdate): :param tags: A set of tags. Resource tags. :type tags: dict[str, str] :param properties: Describes Machine Extension Update Properties. - :type properties: ~connected_machine.models.MachineExtensionUpdateProperties + :type properties: ~azure.mgmt.hybridcompute.models.MachineExtensionUpdateProperties """ _attribute_map = { @@ -805,6 +804,9 @@ class MachineExtensionUpdateProperties(msrest.serialization.Model): :type type: str :param type_handler_version: Specifies the version of the script handler. :type type_handler_version: str + :param enable_auto_upgrade: Indicates whether the extension should be automatically + upgraded by the platform if there is a newer version available. + :type enable_auto_upgrade: bool :param 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. @@ -821,6 +823,7 @@ class MachineExtensionUpdateProperties(msrest.serialization.Model): 'publisher': {'key': 'publisher', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'type_handler_version': {'key': 'typeHandlerVersion', 'type': 'str'}, + 'enable_auto_upgrade': {'key': 'enableAutomaticUpgrade', 'type': 'bool'}, 'auto_upgrade_minor_version': {'key': 'autoUpgradeMinorVersion', 'type': 'bool'}, 'settings': {'key': 'settings', 'type': 'object'}, 'protected_settings': {'key': 'protectedSettings', 'type': 'object'}, @@ -835,6 +838,7 @@ def __init__( self.publisher = kwargs.get('publisher', None) self.type = kwargs.get('type', None) self.type_handler_version = kwargs.get('type_handler_version', None) + self.enable_auto_upgrade = kwargs.get('enable_auto_upgrade', None) self.auto_upgrade_minor_version = kwargs.get('auto_upgrade_minor_version', None) self.settings = kwargs.get('settings', None) self.protected_settings = kwargs.get('protected_settings', None) @@ -844,7 +848,7 @@ class MachineExtensionUpgrade(msrest.serialization.Model): """Describes the Machine Extension Upgrade Properties. :param extension_targets: Describes the Extension Target Properties. - :type extension_targets: dict[str, ~connected_machine.models.ExtensionTargetProperties] + :type extension_targets: dict[str, ~azure.mgmt.hybridcompute.models.ExtensionTargetProperties] """ _attribute_map = { @@ -865,7 +869,7 @@ class MachineListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :param value: Required. The list of hybrid machines. - :type value: list[~connected_machine.models.Machine] + :type value: list[~azure.mgmt.hybridcompute.models.Machine] :param next_link: The URI to fetch the next page of Machines. Call ListNext() with this URI to fetch the next page of hybrid machines. :type next_link: str @@ -895,18 +899,18 @@ class MachineProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :param location_data: Metadata pertaining to the geographic location of the resource. - :type location_data: ~connected_machine.models.LocationData - :param os_profile: Specifies the operating system settings for the hybrid machine. - :type os_profile: ~connected_machine.models.OsProfile + :type location_data: ~azure.mgmt.hybridcompute.models.LocationData + :ivar os_profile: Specifies the operating system settings for the hybrid machine. + :vartype os_profile: ~azure.mgmt.hybridcompute.models.OsProfile :ivar provisioning_state: The provisioning state, which only appears in the response. :vartype provisioning_state: str :ivar status: The status of the hybrid machine agent. Possible values include: "Connected", "Disconnected", "Error". - :vartype status: str or ~connected_machine.models.StatusTypes + :vartype status: str or ~azure.mgmt.hybridcompute.models.StatusTypes :ivar last_status_change: The time of the last status change. :vartype last_status_change: ~datetime.datetime :ivar error_details: Details about the error state. - :vartype error_details: list[~connected_machine.models.ErrorDetail] + :vartype error_details: list[~azure.mgmt.hybridcompute.models.ErrorDetail] :ivar agent_version: The hybrid machine agent full version. :vartype agent_version: str :param vm_id: Specifies the hybrid machine unique ID. @@ -922,12 +926,10 @@ class MachineProperties(msrest.serialization.Model): :vartype os_name: str :ivar os_version: The version of Operating System running on the hybrid machine. :vartype os_version: str - :param os_type: The type of Operating System (windows/linux). - :type os_type: str :ivar vm_uuid: Specifies the Arc Machine's unique SMBIOS ID. :vartype vm_uuid: str :param extensions: Machine Extensions information. - :type extensions: list[~connected_machine.models.MachineExtensionInstanceView] + :type extensions: list[~azure.mgmt.hybridcompute.models.MachineExtensionInstanceView] :ivar os_sku: Specifies the Operating System product SKU. :vartype os_sku: str :ivar domain_name: Specifies the Windows domain name. @@ -942,13 +944,12 @@ class MachineProperties(msrest.serialization.Model): :param parent_cluster_resource_id: The resource id of the parent cluster (Azure HCI) this machine is assigned to, if any. :type parent_cluster_resource_id: str - :param mssql_discovered: Specifies whether any MS SQL instance is discovered on the machine. - :type mssql_discovered: str :ivar detected_properties: Detected properties from the machine. :vartype detected_properties: dict[str, str] """ _validation = { + 'os_profile': {'readonly': True}, 'provisioning_state': {'readonly': True}, 'status': {'readonly': True}, 'last_status_change': {'readonly': True}, @@ -980,7 +981,6 @@ class MachineProperties(msrest.serialization.Model): 'client_public_key': {'key': 'clientPublicKey', 'type': 'str'}, 'os_name': {'key': 'osName', 'type': 'str'}, 'os_version': {'key': 'osVersion', 'type': 'str'}, - 'os_type': {'key': 'osType', 'type': 'str'}, 'vm_uuid': {'key': 'vmUuid', 'type': 'str'}, 'extensions': {'key': 'extensions', 'type': '[MachineExtensionInstanceView]'}, 'os_sku': {'key': 'osSku', 'type': 'str'}, @@ -989,7 +989,6 @@ class MachineProperties(msrest.serialization.Model): 'dns_fqdn': {'key': 'dnsFqdn', 'type': 'str'}, 'private_link_scope_resource_id': {'key': 'privateLinkScopeResourceId', 'type': 'str'}, 'parent_cluster_resource_id': {'key': 'parentClusterResourceId', 'type': 'str'}, - 'mssql_discovered': {'key': 'mssqlDiscovered', 'type': 'str'}, 'detected_properties': {'key': 'detectedProperties', 'type': '{str}'}, } @@ -999,7 +998,7 @@ def __init__( ): super(MachineProperties, self).__init__(**kwargs) self.location_data = kwargs.get('location_data', None) - self.os_profile = kwargs.get('os_profile', None) + self.os_profile = None self.provisioning_state = None self.status = None self.last_status_change = None @@ -1011,7 +1010,6 @@ def __init__( self.client_public_key = kwargs.get('client_public_key', None) self.os_name = None self.os_version = None - self.os_type = kwargs.get('os_type', None) self.vm_uuid = None self.extensions = kwargs.get('extensions', None) self.os_sku = None @@ -1020,7 +1018,6 @@ def __init__( self.dns_fqdn = None self.private_link_scope_resource_id = kwargs.get('private_link_scope_resource_id', None) self.parent_cluster_resource_id = kwargs.get('parent_cluster_resource_id', None) - self.mssql_discovered = kwargs.get('mssql_discovered', None) self.detected_properties = None @@ -1030,9 +1027,9 @@ class MachineUpdate(ResourceUpdate): :param tags: A set of tags. Resource tags. :type tags: dict[str, str] :param identity: Identity for the resource. - :type identity: ~connected_machine.models.Identity + :type identity: ~azure.mgmt.hybridcompute.models.Identity :param properties: Hybrid Compute Machine properties. - :type properties: ~connected_machine.models.MachineUpdateProperties + :type properties: ~azure.mgmt.hybridcompute.models.MachineUpdateProperties """ _attribute_map = { @@ -1054,9 +1051,7 @@ class MachineUpdateProperties(msrest.serialization.Model): """Describes the ARM updatable properties of a hybrid machine. :param location_data: Metadata pertaining to the geographic location of the resource. - :type location_data: ~connected_machine.models.LocationData - :param os_profile: Specifies the operating system settings for the hybrid machine. - :type os_profile: ~connected_machine.models.OsProfile + :type location_data: ~azure.mgmt.hybridcompute.models.LocationData :param parent_cluster_resource_id: The resource id of the parent cluster (Azure HCI) this machine is assigned to, if any. :type parent_cluster_resource_id: str @@ -1067,7 +1062,6 @@ class MachineUpdateProperties(msrest.serialization.Model): _attribute_map = { 'location_data': {'key': 'locationData', 'type': 'LocationData'}, - 'os_profile': {'key': 'osProfile', 'type': 'OsProfile'}, 'parent_cluster_resource_id': {'key': 'parentClusterResourceId', 'type': 'str'}, 'private_link_scope_resource_id': {'key': 'privateLinkScopeResourceId', 'type': 'str'}, } @@ -1078,7 +1072,6 @@ def __init__( ): super(MachineUpdateProperties, self).__init__(**kwargs) self.location_data = kwargs.get('location_data', None) - self.os_profile = kwargs.get('os_profile', None) self.parent_cluster_resource_id = kwargs.get('parent_cluster_resource_id', None) self.private_link_scope_resource_id = kwargs.get('private_link_scope_resource_id', None) @@ -1089,7 +1082,7 @@ class OperationListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar value: The list of compute operations. - :vartype value: list[~connected_machine.models.OperationValue] + :vartype value: list[~azure.mgmt.hybridcompute.models.OperationValue] """ _validation = { @@ -1118,7 +1111,7 @@ class OperationValue(msrest.serialization.Model): :ivar name: The name of the compute operation. :vartype name: str :param display: Display properties. - :type display: ~connected_machine.models.OperationValueDisplay + :type display: ~azure.mgmt.hybridcompute.models.OperationValueDisplay """ _validation = { @@ -1189,10 +1182,6 @@ class OsProfile(msrest.serialization.Model): :ivar computer_name: Specifies the host OS name of the hybrid machine. :vartype computer_name: str - :param windows_configuration: Specifies the windows configuration for update management. - :type windows_configuration: ~connected_machine.models.OsProfileWindowsConfiguration - :param linux_configuration: Specifies the linux configuration for update management. - :type linux_configuration: ~connected_machine.models.OsProfileLinuxConfiguration """ _validation = { @@ -1201,8 +1190,6 @@ class OsProfile(msrest.serialization.Model): _attribute_map = { 'computer_name': {'key': 'computerName', 'type': 'str'}, - 'windows_configuration': {'key': 'windowsConfiguration', 'type': 'OsProfileWindowsConfiguration'}, - 'linux_configuration': {'key': 'linuxConfiguration', 'type': 'OsProfileLinuxConfiguration'}, } def __init__( @@ -1211,46 +1198,6 @@ def __init__( ): super(OsProfile, self).__init__(**kwargs) self.computer_name = None - self.windows_configuration = kwargs.get('windows_configuration', None) - self.linux_configuration = kwargs.get('linux_configuration', None) - - -class OsProfileLinuxConfiguration(msrest.serialization.Model): - """Specifies the linux configuration for update management. - - :param assessment_mode: Specifies the assessment mode. - :type assessment_mode: str - """ - - _attribute_map = { - 'assessment_mode': {'key': 'patchSettings.assessmentMode', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OsProfileLinuxConfiguration, self).__init__(**kwargs) - self.assessment_mode = kwargs.get('assessment_mode', None) - - -class OsProfileWindowsConfiguration(msrest.serialization.Model): - """Specifies the windows configuration for update management. - - :param assessment_mode: Specifies the assessment mode. - :type assessment_mode: str - """ - - _attribute_map = { - 'assessment_mode': {'key': 'patchSettings.assessmentMode', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OsProfileWindowsConfiguration, self).__init__(**kwargs) - self.assessment_mode = kwargs.get('assessment_mode', None) class PrivateEndpointConnection(Resource): @@ -1267,9 +1214,9 @@ class PrivateEndpointConnection(Resource): "Microsoft.Storage/storageAccounts". :vartype type: str :param properties: Resource properties. - :type properties: ~connected_machine.models.PrivateEndpointConnectionProperties + :type properties: ~azure.mgmt.hybridcompute.models.PrivateEndpointConnectionProperties :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~connected_machine.models.SystemData + :vartype system_data: ~azure.mgmt.hybridcompute.models.SystemData """ _validation = { @@ -1296,52 +1243,13 @@ def __init__( self.system_data = None -class PrivateEndpointConnectionDataModel(msrest.serialization.Model): - """The Data Model for a Private Endpoint Connection associated with a Private Link Scope. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The ARM Resource Id of the Private Endpoint. - :vartype id: str - :ivar name: The Name of the Private Endpoint. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :param properties: The Private Endpoint Connection properties. - :type properties: ~connected_machine.models.PrivateEndpointConnectionProperties - """ - - _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'}, - 'properties': {'key': 'properties', 'type': 'PrivateEndpointConnectionProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateEndpointConnectionDataModel, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.properties = kwargs.get('properties', None) - - class PrivateEndpointConnectionListResult(msrest.serialization.Model): """A list of private endpoint connections. Variables are only populated by the server, and will be ignored when sending a request. :ivar value: Array of results. - :vartype value: list[~connected_machine.models.PrivateEndpointConnection] + :vartype value: list[~azure.mgmt.hybridcompute.models.PrivateEndpointConnection] :ivar next_link: Link to retrieve next page of results. :vartype next_link: str """ @@ -1371,11 +1279,11 @@ class PrivateEndpointConnectionProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :param private_endpoint: Private endpoint which the connection belongs to. - :type private_endpoint: ~connected_machine.models.PrivateEndpointProperty + :type private_endpoint: ~azure.mgmt.hybridcompute.models.PrivateEndpointProperty :param private_link_service_connection_state: Connection state of the private endpoint connection. :type private_link_service_connection_state: - ~connected_machine.models.PrivateLinkServiceConnectionStateProperty + ~azure.mgmt.hybridcompute.models.PrivateLinkServiceConnectionStateProperty :ivar provisioning_state: State of the private endpoint connection. :vartype provisioning_state: str """ @@ -1433,9 +1341,9 @@ class PrivateLinkResource(Resource): "Microsoft.Storage/storageAccounts". :vartype type: str :param properties: Resource properties. - :type properties: ~connected_machine.models.PrivateLinkResourceProperties + :type properties: ~azure.mgmt.hybridcompute.models.PrivateLinkResourceProperties :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~connected_machine.models.SystemData + :vartype system_data: ~azure.mgmt.hybridcompute.models.SystemData """ _validation = { @@ -1468,7 +1376,7 @@ class PrivateLinkResourceListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar value: Array of results. - :vartype value: list[~connected_machine.models.PrivateLinkResource] + :vartype value: list[~azure.mgmt.hybridcompute.models.PrivateLinkResource] :ivar next_link: Link to retrieve next page of results. :vartype next_link: str """ @@ -1537,9 +1445,9 @@ class PrivateLinkScopeValidationDetails(msrest.serialization.Model): :param public_network_access: Indicates whether machines associated with the private link scope can also use public Azure Arc service endpoints. Possible values include: "Enabled", "Disabled". Default value: "Disabled". - :type public_network_access: str or ~connected_machine.models.PublicNetworkAccessType + :type public_network_access: str or ~azure.mgmt.hybridcompute.models.PublicNetworkAccessType :param connection_details: List of Private Endpoint Connection details. - :type connection_details: list[~connected_machine.models.ConnectionDetail] + :type connection_details: list[~azure.mgmt.hybridcompute.models.ConnectionDetail] """ _validation = { @@ -1640,14 +1548,14 @@ class SystemData(msrest.serialization.Model): :type created_by: str :param created_by_type: The type of identity that created the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~connected_machine.models.CreatedByType + :type created_by_type: str or ~azure.mgmt.hybridcompute.models.CreatedByType :param created_at: The timestamp of resource creation (UTC). :type created_at: ~datetime.datetime :param last_modified_by: The identity that last modified the resource. :type last_modified_by: str :param last_modified_by_type: The type of identity that last modified the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or ~connected_machine.models.CreatedByType + :type last_modified_by_type: str or ~azure.mgmt.hybridcompute.models.CreatedByType :param last_modified_at: The timestamp of resource last modification (UTC). :type last_modified_at: ~datetime.datetime """ diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedmachine/models/_models_py3.py b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/models/_models_py3.py index 5b26cd7616b..53262b0d285 100644 --- a/src/ssh/azext_ssh/vendored_sdks/connectedmachine/models/_models_py3.py +++ b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/models/_models_py3.py @@ -102,9 +102,9 @@ class ErrorDetail(msrest.serialization.Model): :ivar target: The error target. :vartype target: str :ivar details: The error details. - :vartype details: list[~connected_machine.models.ErrorDetail] + :vartype details: list[~azure.mgmt.hybridcompute.models.ErrorDetail] :ivar additional_info: The error additional info. - :vartype additional_info: list[~connected_machine.models.ErrorAdditionalInfo] + :vartype additional_info: list[~azure.mgmt.hybridcompute.models.ErrorAdditionalInfo] """ _validation = { @@ -139,7 +139,7 @@ class ErrorResponse(msrest.serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). :param error: The error object. - :type error: ~connected_machine.models.ErrorDetail + :type error: ~azure.mgmt.hybridcompute.models.ErrorDetail """ _attribute_map = { @@ -244,9 +244,9 @@ class HybridComputePrivateLinkScope(PrivateLinkScopesResource): :param tags: A set of tags. Resource tags. :type tags: dict[str, str] :param properties: Properties that define a Azure Arc PrivateLinkScope resource. - :type properties: ~connected_machine.models.HybridComputePrivateLinkScopeProperties + :type properties: ~azure.mgmt.hybridcompute.models.HybridComputePrivateLinkScopeProperties :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~connected_machine.models.SystemData + :vartype system_data: ~azure.mgmt.hybridcompute.models.SystemData """ _validation = { @@ -286,7 +286,7 @@ class HybridComputePrivateLinkScopeListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :param value: Required. List of Azure Arc PrivateLinkScope definitions. - :type value: list[~connected_machine.models.HybridComputePrivateLinkScope] + :type value: list[~azure.mgmt.hybridcompute.models.HybridComputePrivateLinkScope] :param next_link: The URI to get the next set of Azure Arc PrivateLinkScope definitions if too many PrivateLinkScopes where returned in the result set. :type next_link: str @@ -321,29 +321,24 @@ class HybridComputePrivateLinkScopeProperties(msrest.serialization.Model): :param public_network_access: Indicates whether machines associated with the private link scope can also use public Azure Arc service endpoints. Possible values include: "Enabled", "Disabled". Default value: "Disabled". - :type public_network_access: str or ~connected_machine.models.PublicNetworkAccessType + :type public_network_access: str or ~azure.mgmt.hybridcompute.models.PublicNetworkAccessType :ivar provisioning_state: Current state of this PrivateLinkScope: whether or not is has been provisioned within the resource group it is defined. Users cannot change this value but are able to read from it. Values will include Provisioning ,Succeeded, Canceled and Failed. :vartype provisioning_state: str :ivar private_link_scope_id: The Guid id of the private link scope. :vartype private_link_scope_id: str - :ivar private_endpoint_connections: The collection of associated Private Endpoint Connections. - :vartype private_endpoint_connections: - list[~connected_machine.models.PrivateEndpointConnectionDataModel] """ _validation = { 'provisioning_state': {'readonly': True}, 'private_link_scope_id': {'readonly': True}, - 'private_endpoint_connections': {'readonly': True}, } _attribute_map = { 'public_network_access': {'key': 'publicNetworkAccess', 'type': 'str'}, 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, 'private_link_scope_id': {'key': 'privateLinkScopeId', 'type': 'str'}, - 'private_endpoint_connections': {'key': 'privateEndpointConnections', 'type': '[PrivateEndpointConnectionDataModel]'}, } def __init__( @@ -356,7 +351,6 @@ def __init__( self.public_network_access = public_network_access self.provisioning_state = None self.private_link_scope_id = None - self.private_endpoint_connections = None class Identity(msrest.serialization.Model): @@ -542,11 +536,11 @@ class Machine(TrackedResource): :param location: Required. The geo-location where the resource lives. :type location: str :param properties: Hybrid Compute Machine properties. - :type properties: ~connected_machine.models.MachineProperties + :type properties: ~azure.mgmt.hybridcompute.models.MachineProperties :param identity: Identity for the resource. - :type identity: ~connected_machine.models.Identity + :type identity: ~azure.mgmt.hybridcompute.models.Identity :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~connected_machine.models.SystemData + :vartype system_data: ~azure.mgmt.hybridcompute.models.SystemData """ _validation = { @@ -603,9 +597,9 @@ class MachineExtension(TrackedResource): :param location: Required. The geo-location where the resource lives. :type location: str :param properties: Describes Machine Extension Properties. - :type properties: ~connected_machine.models.MachineExtensionProperties + :type properties: ~azure.mgmt.hybridcompute.models.MachineExtensionProperties :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~connected_machine.models.SystemData + :vartype system_data: ~azure.mgmt.hybridcompute.models.SystemData """ _validation = { @@ -649,7 +643,7 @@ class MachineExtensionInstanceView(msrest.serialization.Model): :param type_handler_version: Specifies the version of the script handler. :type type_handler_version: str :param status: Instance view status. - :type status: ~connected_machine.models.MachineExtensionInstanceViewStatus + :type status: ~azure.mgmt.hybridcompute.models.MachineExtensionInstanceViewStatus """ _attribute_map = { @@ -681,7 +675,7 @@ class MachineExtensionInstanceViewStatus(msrest.serialization.Model): :param code: The status code. :type code: str :param level: The level code. Possible values include: "Info", "Warning", "Error". - :type level: str or ~connected_machine.models.StatusLevelTypes + :type level: str or ~azure.mgmt.hybridcompute.models.StatusLevelTypes :param display_status: The short localizable label for the status. :type display_status: str :param message: The detailed status message, including for alerts and error messages. @@ -730,6 +724,9 @@ class MachineExtensionProperties(msrest.serialization.Model): :type type: str :param type_handler_version: Specifies the version of the script handler. :type type_handler_version: str + :param enable_auto_upgrade: Indicates whether the extension should be automatically + upgraded by the platform if there is a newer version available. + :type enable_auto_upgrade: bool :param 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. @@ -742,7 +739,7 @@ class MachineExtensionProperties(msrest.serialization.Model): :ivar provisioning_state: The provisioning state, which only appears in the response. :vartype provisioning_state: str :param instance_view: The machine extension instance view. - :type instance_view: ~connected_machine.models.MachineExtensionInstanceView + :type instance_view: ~azure.mgmt.hybridcompute.models.MachineExtensionInstanceView """ _validation = { @@ -754,6 +751,7 @@ class MachineExtensionProperties(msrest.serialization.Model): 'publisher': {'key': 'publisher', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'type_handler_version': {'key': 'typeHandlerVersion', 'type': 'str'}, + 'enable_auto_upgrade': {'key': 'enableAutomaticUpgrade', 'type': 'bool'}, 'auto_upgrade_minor_version': {'key': 'autoUpgradeMinorVersion', 'type': 'bool'}, 'settings': {'key': 'settings', 'type': 'object'}, 'protected_settings': {'key': 'protectedSettings', 'type': 'object'}, @@ -768,6 +766,7 @@ def __init__( publisher: Optional[str] = None, type: Optional[str] = None, type_handler_version: Optional[str] = None, + enable_auto_upgrade: Optional[bool] = None, auto_upgrade_minor_version: Optional[bool] = None, settings: Optional[object] = None, protected_settings: Optional[object] = None, @@ -779,6 +778,7 @@ def __init__( self.publisher = publisher self.type = type self.type_handler_version = type_handler_version + self.enable_auto_upgrade = enable_auto_upgrade self.auto_upgrade_minor_version = auto_upgrade_minor_version self.settings = settings self.protected_settings = protected_settings @@ -790,7 +790,7 @@ class MachineExtensionsListResult(msrest.serialization.Model): """Describes the Machine Extensions List Result. :param value: The list of extensions. - :type value: list[~connected_machine.models.MachineExtension] + :type value: list[~azure.mgmt.hybridcompute.models.MachineExtension] :param next_link: The uri to fetch the next page of machine extensions. Call ListNext() with this to fetch the next page of extensions. :type next_link: str @@ -840,7 +840,7 @@ class MachineExtensionUpdate(ResourceUpdate): :param tags: A set of tags. Resource tags. :type tags: dict[str, str] :param properties: Describes Machine Extension Update Properties. - :type properties: ~connected_machine.models.MachineExtensionUpdateProperties + :type properties: ~azure.mgmt.hybridcompute.models.MachineExtensionUpdateProperties """ _attribute_map = { @@ -871,6 +871,9 @@ class MachineExtensionUpdateProperties(msrest.serialization.Model): :type type: str :param type_handler_version: Specifies the version of the script handler. :type type_handler_version: str + :param enable_auto_upgrade: Indicates whether the extension should be automatically + upgraded by the platform if there is a newer version available. + :type enable_auto_upgrade: bool :param 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. @@ -887,6 +890,7 @@ class MachineExtensionUpdateProperties(msrest.serialization.Model): 'publisher': {'key': 'publisher', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'type_handler_version': {'key': 'typeHandlerVersion', 'type': 'str'}, + 'enable_auto_upgrade': {'key': 'enableAutomaticUpgrade', 'type': 'bool'}, 'auto_upgrade_minor_version': {'key': 'autoUpgradeMinorVersion', 'type': 'bool'}, 'settings': {'key': 'settings', 'type': 'object'}, 'protected_settings': {'key': 'protectedSettings', 'type': 'object'}, @@ -899,6 +903,7 @@ def __init__( publisher: Optional[str] = None, type: Optional[str] = None, type_handler_version: Optional[str] = None, + enable_auto_upgrade: Optional[bool] = None, auto_upgrade_minor_version: Optional[bool] = None, settings: Optional[object] = None, protected_settings: Optional[object] = None, @@ -909,6 +914,7 @@ def __init__( self.publisher = publisher self.type = type self.type_handler_version = type_handler_version + self.enable_auto_upgrade = enable_auto_upgrade self.auto_upgrade_minor_version = auto_upgrade_minor_version self.settings = settings self.protected_settings = protected_settings @@ -918,7 +924,7 @@ class MachineExtensionUpgrade(msrest.serialization.Model): """Describes the Machine Extension Upgrade Properties. :param extension_targets: Describes the Extension Target Properties. - :type extension_targets: dict[str, ~connected_machine.models.ExtensionTargetProperties] + :type extension_targets: dict[str, ~azure.mgmt.hybridcompute.models.ExtensionTargetProperties] """ _attribute_map = { @@ -941,7 +947,7 @@ class MachineListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. :param value: Required. The list of hybrid machines. - :type value: list[~connected_machine.models.Machine] + :type value: list[~azure.mgmt.hybridcompute.models.Machine] :param next_link: The URI to fetch the next page of Machines. Call ListNext() with this URI to fetch the next page of hybrid machines. :type next_link: str @@ -974,18 +980,18 @@ class MachineProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :param location_data: Metadata pertaining to the geographic location of the resource. - :type location_data: ~connected_machine.models.LocationData - :param os_profile: Specifies the operating system settings for the hybrid machine. - :type os_profile: ~connected_machine.models.OsProfile + :type location_data: ~azure.mgmt.hybridcompute.models.LocationData + :ivar os_profile: Specifies the operating system settings for the hybrid machine. + :vartype os_profile: ~azure.mgmt.hybridcompute.models.OsProfile :ivar provisioning_state: The provisioning state, which only appears in the response. :vartype provisioning_state: str :ivar status: The status of the hybrid machine agent. Possible values include: "Connected", "Disconnected", "Error". - :vartype status: str or ~connected_machine.models.StatusTypes + :vartype status: str or ~azure.mgmt.hybridcompute.models.StatusTypes :ivar last_status_change: The time of the last status change. :vartype last_status_change: ~datetime.datetime :ivar error_details: Details about the error state. - :vartype error_details: list[~connected_machine.models.ErrorDetail] + :vartype error_details: list[~azure.mgmt.hybridcompute.models.ErrorDetail] :ivar agent_version: The hybrid machine agent full version. :vartype agent_version: str :param vm_id: Specifies the hybrid machine unique ID. @@ -1001,12 +1007,10 @@ class MachineProperties(msrest.serialization.Model): :vartype os_name: str :ivar os_version: The version of Operating System running on the hybrid machine. :vartype os_version: str - :param os_type: The type of Operating System (windows/linux). - :type os_type: str :ivar vm_uuid: Specifies the Arc Machine's unique SMBIOS ID. :vartype vm_uuid: str :param extensions: Machine Extensions information. - :type extensions: list[~connected_machine.models.MachineExtensionInstanceView] + :type extensions: list[~azure.mgmt.hybridcompute.models.MachineExtensionInstanceView] :ivar os_sku: Specifies the Operating System product SKU. :vartype os_sku: str :ivar domain_name: Specifies the Windows domain name. @@ -1021,13 +1025,12 @@ class MachineProperties(msrest.serialization.Model): :param parent_cluster_resource_id: The resource id of the parent cluster (Azure HCI) this machine is assigned to, if any. :type parent_cluster_resource_id: str - :param mssql_discovered: Specifies whether any MS SQL instance is discovered on the machine. - :type mssql_discovered: str :ivar detected_properties: Detected properties from the machine. :vartype detected_properties: dict[str, str] """ _validation = { + 'os_profile': {'readonly': True}, 'provisioning_state': {'readonly': True}, 'status': {'readonly': True}, 'last_status_change': {'readonly': True}, @@ -1059,7 +1062,6 @@ class MachineProperties(msrest.serialization.Model): 'client_public_key': {'key': 'clientPublicKey', 'type': 'str'}, 'os_name': {'key': 'osName', 'type': 'str'}, 'os_version': {'key': 'osVersion', 'type': 'str'}, - 'os_type': {'key': 'osType', 'type': 'str'}, 'vm_uuid': {'key': 'vmUuid', 'type': 'str'}, 'extensions': {'key': 'extensions', 'type': '[MachineExtensionInstanceView]'}, 'os_sku': {'key': 'osSku', 'type': 'str'}, @@ -1068,7 +1070,6 @@ class MachineProperties(msrest.serialization.Model): 'dns_fqdn': {'key': 'dnsFqdn', 'type': 'str'}, 'private_link_scope_resource_id': {'key': 'privateLinkScopeResourceId', 'type': 'str'}, 'parent_cluster_resource_id': {'key': 'parentClusterResourceId', 'type': 'str'}, - 'mssql_discovered': {'key': 'mssqlDiscovered', 'type': 'str'}, 'detected_properties': {'key': 'detectedProperties', 'type': '{str}'}, } @@ -1076,19 +1077,16 @@ def __init__( self, *, location_data: Optional["LocationData"] = None, - os_profile: Optional["OsProfile"] = None, vm_id: Optional[str] = None, client_public_key: Optional[str] = None, - os_type: Optional[str] = None, extensions: Optional[List["MachineExtensionInstanceView"]] = None, private_link_scope_resource_id: Optional[str] = None, parent_cluster_resource_id: Optional[str] = None, - mssql_discovered: Optional[str] = None, **kwargs ): super(MachineProperties, self).__init__(**kwargs) self.location_data = location_data - self.os_profile = os_profile + self.os_profile = None self.provisioning_state = None self.status = None self.last_status_change = None @@ -1100,7 +1098,6 @@ def __init__( self.client_public_key = client_public_key self.os_name = None self.os_version = None - self.os_type = os_type self.vm_uuid = None self.extensions = extensions self.os_sku = None @@ -1109,7 +1106,6 @@ def __init__( self.dns_fqdn = None self.private_link_scope_resource_id = private_link_scope_resource_id self.parent_cluster_resource_id = parent_cluster_resource_id - self.mssql_discovered = mssql_discovered self.detected_properties = None @@ -1119,9 +1115,9 @@ class MachineUpdate(ResourceUpdate): :param tags: A set of tags. Resource tags. :type tags: dict[str, str] :param identity: Identity for the resource. - :type identity: ~connected_machine.models.Identity + :type identity: ~azure.mgmt.hybridcompute.models.Identity :param properties: Hybrid Compute Machine properties. - :type properties: ~connected_machine.models.MachineUpdateProperties + :type properties: ~azure.mgmt.hybridcompute.models.MachineUpdateProperties """ _attribute_map = { @@ -1147,9 +1143,7 @@ class MachineUpdateProperties(msrest.serialization.Model): """Describes the ARM updatable properties of a hybrid machine. :param location_data: Metadata pertaining to the geographic location of the resource. - :type location_data: ~connected_machine.models.LocationData - :param os_profile: Specifies the operating system settings for the hybrid machine. - :type os_profile: ~connected_machine.models.OsProfile + :type location_data: ~azure.mgmt.hybridcompute.models.LocationData :param parent_cluster_resource_id: The resource id of the parent cluster (Azure HCI) this machine is assigned to, if any. :type parent_cluster_resource_id: str @@ -1160,7 +1154,6 @@ class MachineUpdateProperties(msrest.serialization.Model): _attribute_map = { 'location_data': {'key': 'locationData', 'type': 'LocationData'}, - 'os_profile': {'key': 'osProfile', 'type': 'OsProfile'}, 'parent_cluster_resource_id': {'key': 'parentClusterResourceId', 'type': 'str'}, 'private_link_scope_resource_id': {'key': 'privateLinkScopeResourceId', 'type': 'str'}, } @@ -1169,14 +1162,12 @@ def __init__( self, *, location_data: Optional["LocationData"] = None, - os_profile: Optional["OsProfile"] = None, parent_cluster_resource_id: Optional[str] = None, private_link_scope_resource_id: Optional[str] = None, **kwargs ): super(MachineUpdateProperties, self).__init__(**kwargs) self.location_data = location_data - self.os_profile = os_profile self.parent_cluster_resource_id = parent_cluster_resource_id self.private_link_scope_resource_id = private_link_scope_resource_id @@ -1187,7 +1178,7 @@ class OperationListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar value: The list of compute operations. - :vartype value: list[~connected_machine.models.OperationValue] + :vartype value: list[~azure.mgmt.hybridcompute.models.OperationValue] """ _validation = { @@ -1216,7 +1207,7 @@ class OperationValue(msrest.serialization.Model): :ivar name: The name of the compute operation. :vartype name: str :param display: Display properties. - :type display: ~connected_machine.models.OperationValueDisplay + :type display: ~azure.mgmt.hybridcompute.models.OperationValueDisplay """ _validation = { @@ -1289,10 +1280,6 @@ class OsProfile(msrest.serialization.Model): :ivar computer_name: Specifies the host OS name of the hybrid machine. :vartype computer_name: str - :param windows_configuration: Specifies the windows configuration for update management. - :type windows_configuration: ~connected_machine.models.OsProfileWindowsConfiguration - :param linux_configuration: Specifies the linux configuration for update management. - :type linux_configuration: ~connected_machine.models.OsProfileLinuxConfiguration """ _validation = { @@ -1301,63 +1288,14 @@ class OsProfile(msrest.serialization.Model): _attribute_map = { 'computer_name': {'key': 'computerName', 'type': 'str'}, - 'windows_configuration': {'key': 'windowsConfiguration', 'type': 'OsProfileWindowsConfiguration'}, - 'linux_configuration': {'key': 'linuxConfiguration', 'type': 'OsProfileLinuxConfiguration'}, } def __init__( self, - *, - windows_configuration: Optional["OsProfileWindowsConfiguration"] = None, - linux_configuration: Optional["OsProfileLinuxConfiguration"] = None, **kwargs ): super(OsProfile, self).__init__(**kwargs) self.computer_name = None - self.windows_configuration = windows_configuration - self.linux_configuration = linux_configuration - - -class OsProfileLinuxConfiguration(msrest.serialization.Model): - """Specifies the linux configuration for update management. - - :param assessment_mode: Specifies the assessment mode. - :type assessment_mode: str - """ - - _attribute_map = { - 'assessment_mode': {'key': 'patchSettings.assessmentMode', 'type': 'str'}, - } - - def __init__( - self, - *, - assessment_mode: Optional[str] = None, - **kwargs - ): - super(OsProfileLinuxConfiguration, self).__init__(**kwargs) - self.assessment_mode = assessment_mode - - -class OsProfileWindowsConfiguration(msrest.serialization.Model): - """Specifies the windows configuration for update management. - - :param assessment_mode: Specifies the assessment mode. - :type assessment_mode: str - """ - - _attribute_map = { - 'assessment_mode': {'key': 'patchSettings.assessmentMode', 'type': 'str'}, - } - - def __init__( - self, - *, - assessment_mode: Optional[str] = None, - **kwargs - ): - super(OsProfileWindowsConfiguration, self).__init__(**kwargs) - self.assessment_mode = assessment_mode class PrivateEndpointConnection(Resource): @@ -1374,9 +1312,9 @@ class PrivateEndpointConnection(Resource): "Microsoft.Storage/storageAccounts". :vartype type: str :param properties: Resource properties. - :type properties: ~connected_machine.models.PrivateEndpointConnectionProperties + :type properties: ~azure.mgmt.hybridcompute.models.PrivateEndpointConnectionProperties :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~connected_machine.models.SystemData + :vartype system_data: ~azure.mgmt.hybridcompute.models.SystemData """ _validation = { @@ -1405,54 +1343,13 @@ def __init__( self.system_data = None -class PrivateEndpointConnectionDataModel(msrest.serialization.Model): - """The Data Model for a Private Endpoint Connection associated with a Private Link Scope. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: The ARM Resource Id of the Private Endpoint. - :vartype id: str - :ivar name: The Name of the Private Endpoint. - :vartype name: str - :ivar type: Azure resource type. - :vartype type: str - :param properties: The Private Endpoint Connection properties. - :type properties: ~connected_machine.models.PrivateEndpointConnectionProperties - """ - - _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'}, - 'properties': {'key': 'properties', 'type': 'PrivateEndpointConnectionProperties'}, - } - - def __init__( - self, - *, - properties: Optional["PrivateEndpointConnectionProperties"] = None, - **kwargs - ): - super(PrivateEndpointConnectionDataModel, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.properties = properties - - class PrivateEndpointConnectionListResult(msrest.serialization.Model): """A list of private endpoint connections. Variables are only populated by the server, and will be ignored when sending a request. :ivar value: Array of results. - :vartype value: list[~connected_machine.models.PrivateEndpointConnection] + :vartype value: list[~azure.mgmt.hybridcompute.models.PrivateEndpointConnection] :ivar next_link: Link to retrieve next page of results. :vartype next_link: str """ @@ -1482,11 +1379,11 @@ class PrivateEndpointConnectionProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :param private_endpoint: Private endpoint which the connection belongs to. - :type private_endpoint: ~connected_machine.models.PrivateEndpointProperty + :type private_endpoint: ~azure.mgmt.hybridcompute.models.PrivateEndpointProperty :param private_link_service_connection_state: Connection state of the private endpoint connection. :type private_link_service_connection_state: - ~connected_machine.models.PrivateLinkServiceConnectionStateProperty + ~azure.mgmt.hybridcompute.models.PrivateLinkServiceConnectionStateProperty :ivar provisioning_state: State of the private endpoint connection. :vartype provisioning_state: str """ @@ -1549,9 +1446,9 @@ class PrivateLinkResource(Resource): "Microsoft.Storage/storageAccounts". :vartype type: str :param properties: Resource properties. - :type properties: ~connected_machine.models.PrivateLinkResourceProperties + :type properties: ~azure.mgmt.hybridcompute.models.PrivateLinkResourceProperties :ivar system_data: The system meta data relating to this resource. - :vartype system_data: ~connected_machine.models.SystemData + :vartype system_data: ~azure.mgmt.hybridcompute.models.SystemData """ _validation = { @@ -1586,7 +1483,7 @@ class PrivateLinkResourceListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar value: Array of results. - :vartype value: list[~connected_machine.models.PrivateLinkResource] + :vartype value: list[~azure.mgmt.hybridcompute.models.PrivateLinkResource] :ivar next_link: Link to retrieve next page of results. :vartype next_link: str """ @@ -1655,9 +1552,9 @@ class PrivateLinkScopeValidationDetails(msrest.serialization.Model): :param public_network_access: Indicates whether machines associated with the private link scope can also use public Azure Arc service endpoints. Possible values include: "Enabled", "Disabled". Default value: "Disabled". - :type public_network_access: str or ~connected_machine.models.PublicNetworkAccessType + :type public_network_access: str or ~azure.mgmt.hybridcompute.models.PublicNetworkAccessType :param connection_details: List of Private Endpoint Connection details. - :type connection_details: list[~connected_machine.models.ConnectionDetail] + :type connection_details: list[~azure.mgmt.hybridcompute.models.ConnectionDetail] """ _validation = { @@ -1764,14 +1661,14 @@ class SystemData(msrest.serialization.Model): :type created_by: str :param created_by_type: The type of identity that created the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~connected_machine.models.CreatedByType + :type created_by_type: str or ~azure.mgmt.hybridcompute.models.CreatedByType :param created_at: The timestamp of resource creation (UTC). :type created_at: ~datetime.datetime :param last_modified_by: The identity that last modified the resource. :type last_modified_by: str :param last_modified_by_type: The type of identity that last modified the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or ~connected_machine.models.CreatedByType + :type last_modified_by_type: str or ~azure.mgmt.hybridcompute.models.CreatedByType :param last_modified_at: The timestamp of resource last modification (UTC). :type last_modified_at: ~datetime.datetime """ diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedmachine/operations/_connected_machine_operations.py b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/operations/_connected_machine_operations.py index b2ce759835f..a3ba7e9ea79 100644 --- a/src/ssh/azext_ssh/vendored_sdks/connectedmachine/operations/_connected_machine_operations.py +++ b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/operations/_connected_machine_operations.py @@ -39,7 +39,7 @@ def _upgrade_extensions_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" @@ -93,7 +93,7 @@ def begin_upgrade_extensions( :param machine_name: The name of the hybrid machine. :type machine_name: str :param extension_upgrade_parameters: Parameters supplied to the Upgrade Extensions operation. - :type extension_upgrade_parameters: ~connected_machine.models.MachineExtensionUpgrade + :type extension_upgrade_parameters: ~azure.mgmt.hybridcompute.models.MachineExtensionUpgrade :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: True for ARMPolling, False for no polling, or a diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedmachine/operations/_machine_extensions_operations.py b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/operations/_machine_extensions_operations.py index 77b77d6226d..63bc7c881c3 100644 --- a/src/ssh/azext_ssh/vendored_sdks/connectedmachine/operations/_machine_extensions_operations.py +++ b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/operations/_machine_extensions_operations.py @@ -32,7 +32,7 @@ class MachineExtensionsOperations(object): instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. - :type models: ~connected_machine.models + :type models: ~azure.mgmt.hybridcompute.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. @@ -61,7 +61,7 @@ def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" @@ -124,7 +124,7 @@ def begin_create_or_update( :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: ~connected_machine.models.MachineExtension + :type extension_parameters: ~azure.mgmt.hybridcompute.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: True for ARMPolling, False for no polling, or a @@ -132,7 +132,7 @@ def begin_create_or_update( :paramtype polling: bool or ~azure.core.polling.PollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. :return: An instance of LROPoller that returns either MachineExtension or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~connected_machine.models.MachineExtension] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hybridcompute.models.MachineExtension] :raises ~azure.core.exceptions.HttpResponseError: """ polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] @@ -197,7 +197,7 @@ def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" @@ -260,7 +260,7 @@ def begin_update( :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: ~connected_machine.models.MachineExtensionUpdate + :type extension_parameters: ~azure.mgmt.hybridcompute.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: True for ARMPolling, False for no polling, or a @@ -268,7 +268,7 @@ def begin_update( :paramtype polling: bool or ~azure.core.polling.PollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. :return: An instance of LROPoller that returns either MachineExtension or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~connected_machine.models.MachineExtension] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hybridcompute.models.MachineExtension] :raises ~azure.core.exceptions.HttpResponseError: """ polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] @@ -332,7 +332,7 @@ def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" accept = "application/json" # Construct URL @@ -455,7 +455,7 @@ def get( :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: ~connected_machine.models.MachineExtension + :rtype: ~azure.mgmt.hybridcompute.models.MachineExtension :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.MachineExtension"] @@ -463,7 +463,7 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" accept = "application/json" # Construct URL @@ -519,7 +519,7 @@ def list( :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.paging.ItemPaged[~connected_machine.models.MachineExtensionsListResult] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hybridcompute.models.MachineExtensionsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.MachineExtensionsListResult"] @@ -527,7 +527,7 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" accept = "application/json" def prepare_request(next_link=None): diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedmachine/operations/_machines_operations.py b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/operations/_machines_operations.py index 74f0dd7cd4f..2c809786d69 100644 --- a/src/ssh/azext_ssh/vendored_sdks/connectedmachine/operations/_machines_operations.py +++ b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/operations/_machines_operations.py @@ -30,7 +30,7 @@ class MachinesOperations(object): instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. - :type models: ~connected_machine.models + :type models: ~azure.mgmt.hybridcompute.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. @@ -45,201 +45,6 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config - def list_access_details( - self, - resource_group_name, # type: str - machine_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> str - """The operation to create or update a hybrid machine resource identity in Azure. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param machine_name: The name of the hybrid machine. - :type machine_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: str, or the result of cls(response) - :rtype: str - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[str] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" - accept = "application/json" - - # Construct URL - url = self.list_access_details.metadata['url'] # type: ignore - path_format_arguments = { - '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'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.post(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200, 501, 404]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = self._deserialize('str', pipeline_response) - - if cls: - return response.status_code, cls(pipeline_response, deserialized, {}) - - return response.status_code, deserialized - list_access_details.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}/listAccessDetails'} # type: ignore - - def create_or_update( - self, - resource_group_name, # type: str - machine_name, # type: str - parameters, # type: "models.Machine" - **kwargs # type: Any - ): - # type: (...) -> "models.Machine" - """The operation to create or update a hybrid machine resource identity in Azure. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param machine_name: The name of the hybrid machine. - :type machine_name: str - :param parameters: Parameters supplied to the Create hybrid machine operation. - :type parameters: ~connected_machine.models.Machine - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Machine, or the result of cls(response) - :rtype: ~connected_machine.models.Machine - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.Machine"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - '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'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'Machine') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('Machine', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}'} # type: ignore - - def update( - self, - resource_group_name, # type: str - machine_name, # type: str - parameters, # type: "models.MachineUpdate" - **kwargs # type: Any - ): - # type: (...) -> "models.Machine" - """The operation to update a hybrid machine. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - :type resource_group_name: str - :param machine_name: The name of the hybrid machine. - :type machine_name: str - :param parameters: Parameters supplied to the Update hybrid machine operation. - :type parameters: ~connected_machine.models.MachineUpdate - :keyword callable cls: A custom type or function that will be passed the direct response - :return: Machine, or the result of cls(response) - :rtype: ~connected_machine.models.Machine - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["models.Machine"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', 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'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'MachineUpdate') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('Machine', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}'} # type: ignore - def delete( self, resource_group_name, # type: str @@ -263,7 +68,7 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" accept = "application/json" # Construct URL @@ -312,10 +117,10 @@ def get( :param machine_name: The name of the hybrid machine. :type machine_name: str :param expand: The expand expression to apply on the operation. - :type expand: str or ~connected_machine.models.InstanceViewTypes + :type expand: str or ~azure.mgmt.hybridcompute.models.InstanceViewTypes :keyword callable cls: A custom type or function that will be passed the direct response :return: Machine, or the result of cls(response) - :rtype: ~connected_machine.models.Machine + :rtype: ~azure.mgmt.hybridcompute.models.Machine :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.Machine"] @@ -323,7 +128,7 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" accept = "application/json" # Construct URL @@ -375,7 +180,7 @@ def list_by_resource_group( :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 MachineListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~connected_machine.models.MachineListResult] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hybridcompute.models.MachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.MachineListResult"] @@ -383,7 +188,7 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" accept = "application/json" def prepare_request(next_link=None): @@ -445,7 +250,7 @@ def list_by_subscription( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either MachineListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~connected_machine.models.MachineListResult] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hybridcompute.models.MachineListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.MachineListResult"] @@ -453,7 +258,7 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" accept = "application/json" def prepare_request(next_link=None): diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedmachine/operations/_operations.py b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/operations/_operations.py index f3bfcef08e4..d5605a36454 100644 --- a/src/ssh/azext_ssh/vendored_sdks/connectedmachine/operations/_operations.py +++ b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/operations/_operations.py @@ -30,7 +30,7 @@ class Operations(object): instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. - :type models: ~connected_machine.models + :type models: ~azure.mgmt.hybridcompute.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. @@ -54,7 +54,7 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~connected_machine.models.OperationListResult] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hybridcompute.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.OperationListResult"] @@ -62,7 +62,7 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" accept = "application/json" def prepare_request(next_link=None): diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedmachine/operations/_private_endpoint_connections_operations.py b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/operations/_private_endpoint_connections_operations.py index b9bf818d4bc..48c2e530400 100644 --- a/src/ssh/azext_ssh/vendored_sdks/connectedmachine/operations/_private_endpoint_connections_operations.py +++ b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/operations/_private_endpoint_connections_operations.py @@ -32,7 +32,7 @@ class PrivateEndpointConnectionsOperations(object): instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. - :type models: ~connected_machine.models + :type models: ~azure.mgmt.hybridcompute.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. @@ -65,7 +65,7 @@ def get( :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection, or the result of cls(response) - :rtype: ~connected_machine.models.PrivateEndpointConnection + :rtype: ~azure.mgmt.hybridcompute.models.PrivateEndpointConnection :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.PrivateEndpointConnection"] @@ -73,7 +73,7 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" accept = "application/json" # Construct URL @@ -111,7 +111,7 @@ def get( return deserialized get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - def _create_or_update_initial( + def _update_initial( self, resource_group_name, # type: str scope_name, # type: str @@ -125,12 +125,12 @@ def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore + url = self._update_initial.metadata['url'] # type: ignore path_format_arguments = { '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), @@ -168,9 +168,9 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - def begin_create_or_update( + def begin_update( self, resource_group_name, # type: str scope_name, # type: str @@ -188,7 +188,7 @@ def begin_create_or_update( :param private_endpoint_connection_name: The name of the private endpoint connection. :type private_endpoint_connection_name: str :param parameters: - :type parameters: ~connected_machine.models.PrivateEndpointConnection + :type parameters: ~azure.mgmt.hybridcompute.models.PrivateEndpointConnection :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: True for ARMPolling, False for no polling, or a @@ -196,7 +196,7 @@ def begin_create_or_update( :paramtype polling: bool or ~azure.core.polling.PollingMethod :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~connected_machine.models.PrivateEndpointConnection] + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.hybridcompute.models.PrivateEndpointConnection] :raises ~azure.core.exceptions.HttpResponseError: """ polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] @@ -207,7 +207,7 @@ def begin_create_or_update( ) cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._update_initial( resource_group_name=resource_group_name, scope_name=scope_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -245,7 +245,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore def _delete_initial( self, @@ -260,7 +260,7 @@ def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" accept = "application/json" # Construct URL @@ -380,7 +380,7 @@ def list_by_private_link_scope( :type scope_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~connected_machine.models.PrivateEndpointConnectionListResult] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hybridcompute.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.PrivateEndpointConnectionListResult"] @@ -388,7 +388,7 @@ def list_by_private_link_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" accept = "application/json" def prepare_request(next_link=None): diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedmachine/operations/_private_link_resources_operations.py b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/operations/_private_link_resources_operations.py index 8bc4b5ff49e..07efc46cf79 100644 --- a/src/ssh/azext_ssh/vendored_sdks/connectedmachine/operations/_private_link_resources_operations.py +++ b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/operations/_private_link_resources_operations.py @@ -30,7 +30,7 @@ class PrivateLinkResourcesOperations(object): instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. - :type models: ~connected_machine.models + :type models: ~azure.mgmt.hybridcompute.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. @@ -60,7 +60,7 @@ def list_by_private_link_scope( :type scope_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PrivateLinkResourceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~connected_machine.models.PrivateLinkResourceListResult] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hybridcompute.models.PrivateLinkResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.PrivateLinkResourceListResult"] @@ -68,7 +68,7 @@ def list_by_private_link_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" accept = "application/json" def prepare_request(next_link=None): @@ -139,7 +139,7 @@ def get( :type group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateLinkResource, or the result of cls(response) - :rtype: ~connected_machine.models.PrivateLinkResource + :rtype: ~azure.mgmt.hybridcompute.models.PrivateLinkResource :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.PrivateLinkResource"] @@ -147,7 +147,7 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" accept = "application/json" # Construct URL diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedmachine/operations/_private_link_scopes_operations.py b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/operations/_private_link_scopes_operations.py index c0e63eaeeee..547e69394c8 100644 --- a/src/ssh/azext_ssh/vendored_sdks/connectedmachine/operations/_private_link_scopes_operations.py +++ b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/operations/_private_link_scopes_operations.py @@ -32,7 +32,7 @@ class PrivateLinkScopesOperations(object): instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. - :type models: ~connected_machine.models + :type models: ~azure.mgmt.hybridcompute.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. @@ -56,7 +56,7 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either HybridComputePrivateLinkScopeListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~connected_machine.models.HybridComputePrivateLinkScopeListResult] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hybridcompute.models.HybridComputePrivateLinkScopeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.HybridComputePrivateLinkScopeListResult"] @@ -64,7 +64,7 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" accept = "application/json" def prepare_request(next_link=None): @@ -127,7 +127,7 @@ def list_by_resource_group( :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 HybridComputePrivateLinkScopeListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~connected_machine.models.HybridComputePrivateLinkScopeListResult] + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.hybridcompute.models.HybridComputePrivateLinkScopeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.HybridComputePrivateLinkScopeListResult"] @@ -135,7 +135,7 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" accept = "application/json" def prepare_request(next_link=None): @@ -199,7 +199,7 @@ def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" accept = "application/json" # Construct URL @@ -313,7 +313,7 @@ def get( :type scope_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: HybridComputePrivateLinkScope, or the result of cls(response) - :rtype: ~connected_machine.models.HybridComputePrivateLinkScope + :rtype: ~azure.mgmt.hybridcompute.models.HybridComputePrivateLinkScope :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.HybridComputePrivateLinkScope"] @@ -321,7 +321,7 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" accept = "application/json" # Construct URL @@ -375,10 +375,10 @@ def create_or_update( :type scope_name: str :param parameters: Properties that need to be specified to create or update a Azure Arc for Servers and Clusters PrivateLinkScope. - :type parameters: ~connected_machine.models.HybridComputePrivateLinkScope + :type parameters: ~azure.mgmt.hybridcompute.models.HybridComputePrivateLinkScope :keyword callable cls: A custom type or function that will be passed the direct response :return: HybridComputePrivateLinkScope, or the result of cls(response) - :rtype: ~connected_machine.models.HybridComputePrivateLinkScope + :rtype: ~azure.mgmt.hybridcompute.models.HybridComputePrivateLinkScope :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.HybridComputePrivateLinkScope"] @@ -386,7 +386,7 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" @@ -449,10 +449,10 @@ def update_tags( :type scope_name: str :param private_link_scope_tags: Updated tag information to set into the PrivateLinkScope instance. - :type private_link_scope_tags: ~connected_machine.models.TagsResource + :type private_link_scope_tags: ~azure.mgmt.hybridcompute.models.TagsResource :keyword callable cls: A custom type or function that will be passed the direct response :return: HybridComputePrivateLinkScope, or the result of cls(response) - :rtype: ~connected_machine.models.HybridComputePrivateLinkScope + :rtype: ~azure.mgmt.hybridcompute.models.HybridComputePrivateLinkScope :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.HybridComputePrivateLinkScope"] @@ -460,7 +460,7 @@ def update_tags( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" @@ -517,7 +517,7 @@ def get_validation_details( :type private_link_scope_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateLinkScopeValidationDetails, or the result of cls(response) - :rtype: ~connected_machine.models.PrivateLinkScopeValidationDetails + :rtype: ~azure.mgmt.hybridcompute.models.PrivateLinkScopeValidationDetails :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.PrivateLinkScopeValidationDetails"] @@ -525,7 +525,7 @@ def get_validation_details( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" accept = "application/json" # Construct URL @@ -578,7 +578,7 @@ def get_validation_details_for_machine( :type machine_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateLinkScopeValidationDetails, or the result of cls(response) - :rtype: ~connected_machine.models.PrivateLinkScopeValidationDetails + :rtype: ~azure.mgmt.hybridcompute.models.PrivateLinkScopeValidationDetails :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["models.PrivateLinkScopeValidationDetails"] @@ -586,7 +586,7 @@ def get_validation_details_for_machine( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-06-10-preview" + api_version = "2021-05-20" accept = "application/json" # Construct URL diff --git a/src/ssh/azext_ssh/vendored_sdks/connectedmachine/setup.py b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/setup.py new file mode 100644 index 00000000000..f0a42bc98f8 --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/connectedmachine/setup.py @@ -0,0 +1,37 @@ +# 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. +# -------------------------------------------------------------------------- +# coding: utf-8 + +from setuptools import setup, find_packages + +NAME = "azure-mgmt-hybridcompute" +VERSION = "1.0.0b1" + +# To install the library, run the following +# +# python setup.py install +# +# prerequisite: setuptools +# http://pypi.python.org/pypi/setuptools + +REQUIRES = ["msrest>=0.6.18", "azure-core<2.0.0,>=1.8.2", "azure-mgmt-core<2.0.0,>=1.2.1"] + +setup( + name=NAME, + version=VERSION, + description="azure-mgmt-hybridcompute", + author_email="", + url="", + keywords=["Swagger", "ConnectedMachine"], + install_requires=REQUIRES, + packages=find_packages(), + include_package_data=True, + long_description="""\ + The Hybrid Compute Management Client. + """ +) diff --git a/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/__init__.py b/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/__init__.py new file mode 100644 index 00000000000..9d5f8048ff1 --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/__init__.py @@ -0,0 +1,16 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._hybrid_connectivity_management_api import HybridConnectivityManagementAPI +__all__ = ['HybridConnectivityManagementAPI'] + +try: + from ._patch import patch_sdk # type: ignore + patch_sdk() +except ImportError: + pass diff --git a/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/_configuration.py b/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/_configuration.py new file mode 100644 index 00000000000..3d6b6c94096 --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/_configuration.py @@ -0,0 +1,68 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +class HybridConnectivityManagementAPIConfiguration(Configuration): + """Configuration for HybridConnectivityManagementAPI. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + """ + + def __init__( + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + super(HybridConnectivityManagementAPIConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2021-10-06-preview" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'hybridconnectivitymanagementapi/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/_hybrid_connectivity_management_api.py b/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/_hybrid_connectivity_management_api.py new file mode 100644 index 00000000000..7b1c37cd7ea --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/_hybrid_connectivity_management_api.py @@ -0,0 +1,71 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.credentials import TokenCredential + +from ._configuration import HybridConnectivityManagementAPIConfiguration +from .operations import Operations +from .operations import EndpointsOperations +from . import models + + +class HybridConnectivityManagementAPI(object): + """REST API for Hybrid Connectivity. + + :ivar operations: Operations operations + :vartype operations: hybrid_connectivity_management_api.operations.Operations + :ivar endpoints: EndpointsOperations operations + :vartype endpoints: hybrid_connectivity_management_api.operations.EndpointsOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param str base_url: Service URL + """ + + def __init__( + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = 'https://management.azure.com' + self._config = HybridConnectivityManagementAPIConfiguration(credential, 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.operations = Operations( + self._client, self._config, self._serialize, self._deserialize) + self.endpoints = EndpointsOperations( + self._client, self._config, self._serialize, self._deserialize) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> HybridConnectivityManagementAPI + 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/hybridconnectivity/aio/__init__.py b/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/aio/__init__.py new file mode 100644 index 00000000000..785b5445cc3 --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/aio/__init__.py @@ -0,0 +1,10 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._hybrid_connectivity_management_api import HybridConnectivityManagementAPI +__all__ = ['HybridConnectivityManagementAPI'] diff --git a/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/aio/_configuration.py b/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/aio/_configuration.py new file mode 100644 index 00000000000..41f28de96ba --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/aio/_configuration.py @@ -0,0 +1,60 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +VERSION = "unknown" + +class HybridConnectivityManagementAPIConfiguration(Configuration): + """Configuration for HybridConnectivityManagementAPI. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + **kwargs: Any + ) -> None: + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + super(HybridConnectivityManagementAPIConfiguration, self).__init__(**kwargs) + + self.credential = credential + self.api_version = "2021-10-06-preview" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'hybridconnectivitymanagementapi/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/aio/_hybrid_connectivity_management_api.py b/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/aio/_hybrid_connectivity_management_api.py new file mode 100644 index 00000000000..837237055a5 --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/aio/_hybrid_connectivity_management_api.py @@ -0,0 +1,64 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from typing import Any, Optional, TYPE_CHECKING + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +from ._configuration import HybridConnectivityManagementAPIConfiguration +from .operations import Operations +from .operations import EndpointsOperations +from .. import models + + +class HybridConnectivityManagementAPI(object): + """REST API for Hybrid Connectivity. + + :ivar operations: Operations operations + :vartype operations: hybrid_connectivity_management_api.aio.operations.Operations + :ivar endpoints: EndpointsOperations operations + :vartype endpoints: hybrid_connectivity_management_api.aio.operations.EndpointsOperations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param str base_url: Service URL + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + base_url: Optional[str] = None, + **kwargs: Any + ) -> None: + if not base_url: + base_url = 'https://management.azure.com' + self._config = HybridConnectivityManagementAPIConfiguration(credential, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.operations = Operations( + self._client, self._config, self._serialize, self._deserialize) + self.endpoints = EndpointsOperations( + self._client, self._config, self._serialize, self._deserialize) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "HybridConnectivityManagementAPI": + 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/hybridconnectivity/aio/operations/__init__.py b/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/aio/operations/__init__.py new file mode 100644 index 00000000000..d9149323f40 --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/aio/operations/__init__.py @@ -0,0 +1,15 @@ +# 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 ._endpoints_operations import EndpointsOperations + +__all__ = [ + 'Operations', + 'EndpointsOperations', +] diff --git a/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/aio/operations/_endpoints_operations.py b/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/aio/operations/_endpoints_operations.py new file mode 100644 index 00000000000..16f77d06ff6 --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/aio/operations/_endpoints_operations.py @@ -0,0 +1,426 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class EndpointsOperations: + """EndpointsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~hybrid_connectivity_management_api.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + resource_uri: str, + **kwargs + ) -> AsyncIterable["models.EndpointsList"]: + """List of endpoints to the target resource. + + :param resource_uri: The fully qualified Azure Resource manager identifier of the resource to + be connected. + :type resource_uri: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either EndpointsList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~hybrid_connectivity_management_api.models.EndpointsList] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.EndpointsList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-10-06-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('EndpointsList', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/{resourceUri}/providers/Microsoft.HybridConnectivity/endpoints'} # type: ignore + + async def get( + self, + resource_uri: str, + endpoint_name: str, + **kwargs + ) -> "models.EndpointResource": + """Gets the endpoint to the resource. + + :param resource_uri: The fully qualified Azure Resource manager identifier of the resource to + be connected. + :type resource_uri: str + :param endpoint_name: The endpoint name. + :type endpoint_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EndpointResource, or the result of cls(response) + :rtype: ~hybrid_connectivity_management_api.models.EndpointResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.EndpointResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-10-06-preview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), + 'endpointName': self._serialize.url("endpoint_name", endpoint_name, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('EndpointResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/{resourceUri}/providers/Microsoft.HybridConnectivity/endpoints/{endpointName}'} # type: ignore + + async def create_or_update( + self, + resource_uri: str, + endpoint_name: str, + endpoint_resource: "models.EndpointResource", + **kwargs + ) -> "models.EndpointResource": + """Create or update the endpoint to the target resource. + + :param resource_uri: The fully qualified Azure Resource manager identifier of the resource to + be connected. + :type resource_uri: str + :param endpoint_name: The endpoint name. + :type endpoint_name: str + :param endpoint_resource: Endpoint details. + :type endpoint_resource: ~hybrid_connectivity_management_api.models.EndpointResource + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EndpointResource, or the result of cls(response) + :rtype: ~hybrid_connectivity_management_api.models.EndpointResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.EndpointResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-10-06-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create_or_update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), + 'endpointName': self._serialize.url("endpoint_name", endpoint_name, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(endpoint_resource, 'EndpointResource') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('EndpointResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create_or_update.metadata = {'url': '/{resourceUri}/providers/Microsoft.HybridConnectivity/endpoints/{endpointName}'} # type: ignore + + async def update( + self, + resource_uri: str, + endpoint_name: str, + endpoint_resource: "models.EndpointResource", + **kwargs + ) -> "models.EndpointResource": + """Update the endpoint to the target resource. + + :param resource_uri: The fully qualified Azure Resource manager identifier of the resource to + be connected. + :type resource_uri: str + :param endpoint_name: The endpoint name. + :type endpoint_name: str + :param endpoint_resource: Endpoint details. + :type endpoint_resource: ~hybrid_connectivity_management_api.models.EndpointResource + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EndpointResource, or the result of cls(response) + :rtype: ~hybrid_connectivity_management_api.models.EndpointResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.EndpointResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-10-06-preview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.update.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), + 'endpointName': self._serialize.url("endpoint_name", endpoint_name, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(endpoint_resource, 'EndpointResource') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('EndpointResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + update.metadata = {'url': '/{resourceUri}/providers/Microsoft.HybridConnectivity/endpoints/{endpointName}'} # type: ignore + + async def delete( + self, + resource_uri: str, + endpoint_name: str, + **kwargs + ) -> None: + """Deletes the endpoint access to the target resource. + + :param resource_uri: The fully qualified Azure Resource manager identifier of the resource to + be connected. + :type resource_uri: str + :param endpoint_name: The endpoint name. + :type endpoint_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 + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-10-06-preview" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), + 'endpointName': self._serialize.url("endpoint_name", endpoint_name, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/{resourceUri}/providers/Microsoft.HybridConnectivity/endpoints/{endpointName}'} # type: ignore + + async def list_credentials( + self, + resource_uri: str, + endpoint_name: str, + expiresin: Optional[int] = 10800, + **kwargs + ) -> "models.EndpointAccessResource": + """Gets the endpoint access credentials to the resource. + + :param resource_uri: The fully qualified Azure Resource manager identifier of the resource to + be connected. + :type resource_uri: str + :param endpoint_name: The endpoint name. + :type endpoint_name: str + :param expiresin: The is how long the endpoint access token is valid (in seconds). + :type expiresin: long + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EndpointAccessResource, or the result of cls(response) + :rtype: ~hybrid_connectivity_management_api.models.EndpointAccessResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.EndpointAccessResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-10-06-preview" + accept = "application/json" + + # Construct URL + url = self.list_credentials.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), + 'endpointName': self._serialize.url("endpoint_name", endpoint_name, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if expiresin is not None: + query_parameters['expiresin'] = self._serialize.query("expiresin", expiresin, 'long', maximum=10800, minimum=600) + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('EndpointAccessResource', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + list_credentials.metadata = {'url': '/{resourceUri}/providers/Microsoft.HybridConnectivity/endpoints/{endpointName}/listCredentials'} # type: ignore diff --git a/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/aio/operations/_operations.py b/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/aio/operations/_operations.py new file mode 100644 index 00000000000..e06178d99d0 --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/aio/operations/_operations.py @@ -0,0 +1,105 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class Operations: + """Operations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~hybrid_connectivity_management_api.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs + ) -> AsyncIterable["models.OperationListResult"]: + """Lists the available Hybrid Connectivity REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~hybrid_connectivity_management_api.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-10-06-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.HybridConnectivity/operations'} # type: ignore diff --git a/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/models/__init__.py b/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/models/__init__.py new file mode 100644 index 00000000000..a60914d57d3 --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/models/__init__.py @@ -0,0 +1,57 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +try: + from ._models_py3 import EndpointAccessResource + from ._models_py3 import EndpointResource + from ._models_py3 import EndpointsList + from ._models_py3 import ErrorAdditionalInfo + from ._models_py3 import ErrorDetail + from ._models_py3 import ErrorResponse + from ._models_py3 import Operation + from ._models_py3 import OperationDisplay + from ._models_py3 import OperationListResult + from ._models_py3 import ProxyResource + from ._models_py3 import Resource +except (SyntaxError, ImportError): + from ._models import EndpointAccessResource # type: ignore + from ._models import EndpointResource # type: ignore + from ._models import EndpointsList # type: ignore + from ._models import ErrorAdditionalInfo # type: ignore + from ._models import ErrorDetail # type: ignore + from ._models import ErrorResponse # type: ignore + from ._models import Operation # type: ignore + from ._models import OperationDisplay # type: ignore + from ._models import OperationListResult # type: ignore + from ._models import ProxyResource # type: ignore + from ._models import Resource # type: ignore + +from ._hybrid_connectivity_management_api_enums import ( + ActionType, + CreatedByType, + Origin, + Type, +) + +__all__ = [ + 'EndpointAccessResource', + 'EndpointResource', + 'EndpointsList', + 'ErrorAdditionalInfo', + 'ErrorDetail', + 'ErrorResponse', + 'Operation', + 'OperationDisplay', + 'OperationListResult', + 'ProxyResource', + 'Resource', + 'ActionType', + 'CreatedByType', + 'Origin', + 'Type', +] diff --git a/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/models/_hybrid_connectivity_management_api_enums.py b/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/models/_hybrid_connectivity_management_api_enums.py new file mode 100644 index 00000000000..fa857d49db8 --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/models/_hybrid_connectivity_management_api_enums.py @@ -0,0 +1,58 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum, EnumMeta +from six import with_metaclass + +class _CaseInsensitiveEnumMeta(EnumMeta): + def __getitem__(self, name): + return super().__getitem__(name.upper()) + + def __getattr__(cls, name): + """Return the enum member matching `name` + We use __getattr__ instead of descriptors or inserting into the enum + class' __dict__ in order to support `name` and `value` being both + properties for enum members (which live in the class' __dict__) and + enum members themselves. + """ + try: + return cls._member_map_[name.upper()] + except KeyError: + raise AttributeError(name) + + +class ActionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + """ + + INTERNAL = "Internal" + +class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The type of identity that created the resource. + """ + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + +class Origin(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit + logs UX. Default value is "user,system" + """ + + USER = "user" + SYSTEM = "system" + USER_SYSTEM = "user,system" + +class Type(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The type of endpoint. + """ + + DEFAULT = "default" + CUSTOM = "custom" diff --git a/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/models/_models.py b/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/models/_models.py new file mode 100644 index 00000000000..1dd6479ee07 --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/models/_models.py @@ -0,0 +1,438 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + + +class EndpointAccessResource(msrest.serialization.Model): + """The endpoint access for the target resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param namespace_name: The namespace name. + :type namespace_name: str + :param namespace_name_suffix: The suffix domain name of relay namespace. + :type namespace_name_suffix: str + :param hybrid_connection_name: Azure Relay hybrid connection name for the resource. + :type hybrid_connection_name: str + :ivar access_key: Access key for hybrid connection. + :vartype access_key: str + :param expires_on: The expiration of access key in unix time. + :type expires_on: long + """ + + _validation = { + 'namespace_name': {'max_length': 200, 'min_length': 1}, + 'namespace_name_suffix': {'max_length': 100, 'min_length': 1}, + 'access_key': {'readonly': True}, + } + + _attribute_map = { + 'namespace_name': {'key': 'relay.namespaceName', 'type': 'str'}, + 'namespace_name_suffix': {'key': 'relay.namespaceNameSuffix', 'type': 'str'}, + 'hybrid_connection_name': {'key': 'relay.hybridConnectionName', 'type': 'str'}, + 'access_key': {'key': 'relay.accessKey', 'type': 'str'}, + 'expires_on': {'key': 'relay.expiresOn', 'type': 'long'}, + } + + def __init__( + self, + **kwargs + ): + super(EndpointAccessResource, self).__init__(**kwargs) + self.namespace_name = kwargs.get('namespace_name', None) + self.namespace_name_suffix = kwargs.get('namespace_name_suffix', None) + self.hybrid_connection_name = kwargs.get('hybrid_connection_name', None) + self.access_key = None + self.expires_on = kwargs.get('expires_on', None) + + +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 EndpointResource(Resource): + """The endpoint for the target resource. + + 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 + :param type_properties_type: The type of endpoint. Possible values include: "default", + "custom". + :type type_properties_type: str or ~hybrid_connectivity_management_api.models.Type + :param resource_id: The resource Id of the connectivity endpoint (optional). + :type resource_id: str + :ivar provisioning_state: + :vartype provisioning_state: str + :param created_by: The identity that created the resource. + :type created_by: str + :param created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :type created_by_type: str or ~hybrid_connectivity_management_api.models.CreatedByType + :param created_at: The timestamp of resource creation (UTC). + :type created_at: ~datetime.datetime + :param last_modified_by: The identity that last modified the resource. + :type last_modified_by: str + :param last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :type last_modified_by_type: str or ~hybrid_connectivity_management_api.models.CreatedByType + :param last_modified_at: The timestamp of resource last modification (UTC). + :type last_modified_at: ~datetime.datetime + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'type_properties_type': {'key': 'properties.type', 'type': 'str'}, + 'resource_id': {'key': 'properties.resourceId', 'type': 'str'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'created_by': {'key': 'systemData.createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'systemData.createdByType', 'type': 'str'}, + 'created_at': {'key': 'systemData.createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'systemData.lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'systemData.lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'systemData.lastModifiedAt', 'type': 'iso-8601'}, + } + + def __init__( + self, + **kwargs + ): + super(EndpointResource, self).__init__(**kwargs) + self.type_properties_type = kwargs.get('type_properties_type', None) + self.resource_id = kwargs.get('resource_id', None) + self.provisioning_state = None + self.created_by = kwargs.get('created_by', None) + self.created_by_type = kwargs.get('created_by_type', None) + self.created_at = kwargs.get('created_at', None) + self.last_modified_by = kwargs.get('last_modified_by', None) + self.last_modified_by_type = kwargs.get('last_modified_by_type', None) + self.last_modified_at = kwargs.get('last_modified_at', None) + + +class EndpointsList(msrest.serialization.Model): + """The list of endpoints. + + :param next_link: The link used to get the next page of endpoints list. + :type next_link: str + :param value: The list of endpoint. + :type value: list[~hybrid_connectivity_management_api.models.EndpointResource] + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[EndpointResource]'}, + } + + def __init__( + self, + **kwargs + ): + super(EndpointsList, self).__init__(**kwargs) + self.next_link = kwargs.get('next_link', None) + self.value = kwargs.get('value', None) + + +class ErrorAdditionalInfo(msrest.serialization.Model): + """The resource management error additional info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: object + """ + + _validation = { + 'type': {'readonly': True}, + 'info': {'readonly': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'info': {'key': 'info', 'type': 'object'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorAdditionalInfo, self).__init__(**kwargs) + self.type = None + self.info = None + + +class ErrorDetail(msrest.serialization.Model): + """The error detail. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~hybrid_connectivity_management_api.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~hybrid_connectivity_management_api.models.ErrorAdditionalInfo] + """ + + _validation = { + 'code': {'readonly': True}, + 'message': {'readonly': True}, + 'target': {'readonly': True}, + 'details': {'readonly': True}, + 'additional_info': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[ErrorDetail]'}, + 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorDetail, self).__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class ErrorResponse(msrest.serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). + + :param error: The error object. + :type error: ~hybrid_connectivity_management_api.models.ErrorDetail + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDetail'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorResponse, self).__init__(**kwargs) + self.error = kwargs.get('error', None) + + +class Operation(msrest.serialization.Model): + """Details of a REST API operation, returned from the Resource Provider Operations API. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + :vartype name: str + :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for data- + plane operations and "false" for ARM/control-plane operations. + :vartype is_data_action: bool + :param display: Localized display information for this particular operation. + :type display: ~hybrid_connectivity_management_api.models.OperationDisplay + :ivar origin: The intended executor of the operation; as in Resource Based Access Control + (RBAC) and audit logs UX. Default value is "user,system". Possible values include: "user", + "system", "user,system". + :vartype origin: str or ~hybrid_connectivity_management_api.models.Origin + :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for + internal only APIs. Possible values include: "Internal". + :vartype action_type: str or ~hybrid_connectivity_management_api.models.ActionType + """ + + _validation = { + 'name': {'readonly': True}, + 'is_data_action': {'readonly': True}, + 'origin': {'readonly': True}, + 'action_type': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + 'origin': {'key': 'origin', 'type': 'str'}, + 'action_type': {'key': 'actionType', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Operation, self).__init__(**kwargs) + self.name = None + self.is_data_action = None + self.display = kwargs.get('display', None) + self.origin = None + self.action_type = None + + +class OperationDisplay(msrest.serialization.Model): + """Localized display information for this particular operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft + Monitoring Insights" or "Microsoft Compute". + :vartype provider: str + :ivar resource: The localized friendly name of the resource type related to this operation. + E.g. "Virtual Machines" or "Job Schedule Collections". + :vartype resource: str + :ivar operation: The concise, localized friendly name for the operation; suitable for + dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + :vartype operation: str + :ivar description: The short, localized friendly description of the operation; suitable for + tool tips and detailed views. + :vartype description: str + """ + + _validation = { + 'provider': {'readonly': True}, + 'resource': {'readonly': True}, + 'operation': {'readonly': True}, + 'description': {'readonly': True}, + } + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationDisplay, self).__init__(**kwargs) + self.provider = None + self.resource = None + self.operation = None + self.description = None + + +class OperationListResult(msrest.serialization.Model): + """A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of operations supported by the resource provider. + :vartype value: list[~hybrid_connectivity_management_api.models.Operation] + :ivar next_link: URL to get the next set of operation list results (if there are any). + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class 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) diff --git a/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/models/_models_py3.py b/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/models/_models_py3.py new file mode 100644 index 00000000000..97400905724 --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/models/_models_py3.py @@ -0,0 +1,464 @@ +# 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 List, Optional, Union + +from azure.core.exceptions import HttpResponseError +import msrest.serialization + +from ._hybrid_connectivity_management_api_enums import * + + +class EndpointAccessResource(msrest.serialization.Model): + """The endpoint access for the target resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param namespace_name: The namespace name. + :type namespace_name: str + :param namespace_name_suffix: The suffix domain name of relay namespace. + :type namespace_name_suffix: str + :param hybrid_connection_name: Azure Relay hybrid connection name for the resource. + :type hybrid_connection_name: str + :ivar access_key: Access key for hybrid connection. + :vartype access_key: str + :param expires_on: The expiration of access key in unix time. + :type expires_on: long + """ + + _validation = { + 'namespace_name': {'max_length': 200, 'min_length': 1}, + 'namespace_name_suffix': {'max_length': 100, 'min_length': 1}, + 'access_key': {'readonly': True}, + } + + _attribute_map = { + 'namespace_name': {'key': 'relay.namespaceName', 'type': 'str'}, + 'namespace_name_suffix': {'key': 'relay.namespaceNameSuffix', 'type': 'str'}, + 'hybrid_connection_name': {'key': 'relay.hybridConnectionName', 'type': 'str'}, + 'access_key': {'key': 'relay.accessKey', 'type': 'str'}, + 'expires_on': {'key': 'relay.expiresOn', 'type': 'long'}, + } + + def __init__( + self, + *, + namespace_name: Optional[str] = None, + namespace_name_suffix: Optional[str] = None, + hybrid_connection_name: Optional[str] = None, + expires_on: Optional[int] = None, + **kwargs + ): + super(EndpointAccessResource, self).__init__(**kwargs) + self.namespace_name = namespace_name + self.namespace_name_suffix = namespace_name_suffix + self.hybrid_connection_name = hybrid_connection_name + self.access_key = None + self.expires_on = expires_on + + +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 EndpointResource(Resource): + """The endpoint for the target resource. + + 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 + :param type_properties_type: The type of endpoint. Possible values include: "default", + "custom". + :type type_properties_type: str or ~hybrid_connectivity_management_api.models.Type + :param resource_id: The resource Id of the connectivity endpoint (optional). + :type resource_id: str + :ivar provisioning_state: + :vartype provisioning_state: str + :param created_by: The identity that created the resource. + :type created_by: str + :param created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :type created_by_type: str or ~hybrid_connectivity_management_api.models.CreatedByType + :param created_at: The timestamp of resource creation (UTC). + :type created_at: ~datetime.datetime + :param last_modified_by: The identity that last modified the resource. + :type last_modified_by: str + :param last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :type last_modified_by_type: str or ~hybrid_connectivity_management_api.models.CreatedByType + :param last_modified_at: The timestamp of resource last modification (UTC). + :type last_modified_at: ~datetime.datetime + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'type_properties_type': {'key': 'properties.type', 'type': 'str'}, + 'resource_id': {'key': 'properties.resourceId', 'type': 'str'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'created_by': {'key': 'systemData.createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'systemData.createdByType', 'type': 'str'}, + 'created_at': {'key': 'systemData.createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'systemData.lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'systemData.lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'systemData.lastModifiedAt', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + type_properties_type: Optional[Union[str, "Type"]] = None, + resource_id: Optional[str] = None, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs + ): + super(EndpointResource, self).__init__(**kwargs) + self.type_properties_type = type_properties_type + self.resource_id = resource_id + self.provisioning_state = None + 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 EndpointsList(msrest.serialization.Model): + """The list of endpoints. + + :param next_link: The link used to get the next page of endpoints list. + :type next_link: str + :param value: The list of endpoint. + :type value: list[~hybrid_connectivity_management_api.models.EndpointResource] + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[EndpointResource]'}, + } + + def __init__( + self, + *, + next_link: Optional[str] = None, + value: Optional[List["EndpointResource"]] = None, + **kwargs + ): + super(EndpointsList, self).__init__(**kwargs) + self.next_link = next_link + self.value = value + + +class ErrorAdditionalInfo(msrest.serialization.Model): + """The resource management error additional info. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: object + """ + + _validation = { + 'type': {'readonly': True}, + 'info': {'readonly': True}, + } + + _attribute_map = { + 'type': {'key': 'type', 'type': 'str'}, + 'info': {'key': 'info', 'type': 'object'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorAdditionalInfo, self).__init__(**kwargs) + self.type = None + self.info = None + + +class ErrorDetail(msrest.serialization.Model): + """The error detail. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~hybrid_connectivity_management_api.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~hybrid_connectivity_management_api.models.ErrorAdditionalInfo] + """ + + _validation = { + 'code': {'readonly': True}, + 'message': {'readonly': True}, + 'target': {'readonly': True}, + 'details': {'readonly': True}, + 'additional_info': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[ErrorDetail]'}, + 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, + } + + def __init__( + self, + **kwargs + ): + super(ErrorDetail, self).__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class ErrorResponse(msrest.serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). + + :param error: The error object. + :type error: ~hybrid_connectivity_management_api.models.ErrorDetail + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorDetail'}, + } + + def __init__( + self, + *, + error: Optional["ErrorDetail"] = None, + **kwargs + ): + super(ErrorResponse, self).__init__(**kwargs) + self.error = error + + +class Operation(msrest.serialization.Model): + """Details of a REST API operation, returned from the Resource Provider Operations API. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + :vartype name: str + :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for data- + plane operations and "false" for ARM/control-plane operations. + :vartype is_data_action: bool + :param display: Localized display information for this particular operation. + :type display: ~hybrid_connectivity_management_api.models.OperationDisplay + :ivar origin: The intended executor of the operation; as in Resource Based Access Control + (RBAC) and audit logs UX. Default value is "user,system". Possible values include: "user", + "system", "user,system". + :vartype origin: str or ~hybrid_connectivity_management_api.models.Origin + :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for + internal only APIs. Possible values include: "Internal". + :vartype action_type: str or ~hybrid_connectivity_management_api.models.ActionType + """ + + _validation = { + 'name': {'readonly': True}, + 'is_data_action': {'readonly': True}, + 'origin': {'readonly': True}, + 'action_type': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + 'origin': {'key': 'origin', 'type': 'str'}, + 'action_type': {'key': 'actionType', 'type': 'str'}, + } + + def __init__( + self, + *, + display: Optional["OperationDisplay"] = None, + **kwargs + ): + super(Operation, self).__init__(**kwargs) + self.name = None + self.is_data_action = None + self.display = display + self.origin = None + self.action_type = None + + +class OperationDisplay(msrest.serialization.Model): + """Localized display information for this particular operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft + Monitoring Insights" or "Microsoft Compute". + :vartype provider: str + :ivar resource: The localized friendly name of the resource type related to this operation. + E.g. "Virtual Machines" or "Job Schedule Collections". + :vartype resource: str + :ivar operation: The concise, localized friendly name for the operation; suitable for + dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + :vartype operation: str + :ivar description: The short, localized friendly description of the operation; suitable for + tool tips and detailed views. + :vartype description: str + """ + + _validation = { + 'provider': {'readonly': True}, + 'resource': {'readonly': True}, + 'operation': {'readonly': True}, + 'description': {'readonly': True}, + } + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationDisplay, self).__init__(**kwargs) + self.provider = None + self.resource = None + self.operation = None + self.description = None + + +class OperationListResult(msrest.serialization.Model): + """A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of operations supported by the resource provider. + :vartype value: list[~hybrid_connectivity_management_api.models.Operation] + :ivar next_link: URL to get the next set of operation list results (if there are any). + :vartype next_link: str + """ + + _validation = { + 'value': {'readonly': True}, + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = None + self.next_link = None + + +class 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) diff --git a/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/operations/__init__.py b/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/operations/__init__.py new file mode 100644 index 00000000000..d9149323f40 --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/operations/__init__.py @@ -0,0 +1,15 @@ +# 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 ._endpoints_operations import EndpointsOperations + +__all__ = [ + 'Operations', + 'EndpointsOperations', +] 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 new file mode 100644 index 00000000000..b29bf835c13 --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/operations/_endpoints_operations.py @@ -0,0 +1,116 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class EndpointsOperations(object): + """EndpointsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~hybrid_connectivity_management_api.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list_credentials( + self, + resource_group_name, # type: str + machine_name, # type: str + endpoint_name, # type: str + expiresin=10800, # type: Optional[int] + **kwargs # type: Any + ): + # type: (...) -> "models.EndpointAccessResource" + """Gets the endpoint access credentials to the resource. + + :param resource_uri: The fully qualified Azure Resource manager identifier of the resource to + be connected. + :type resource_uri: str + :param endpoint_name: The endpoint name. + :type endpoint_name: str + :param expiresin: The is how long the endpoint access token is valid (in seconds). + :type expiresin: long + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EndpointAccessResource, or the result of cls(response) + :rtype: ~hybrid_connectivity_management_api.models.EndpointAccessResource + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.EndpointAccessResource"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + # api_version = "2021-10-06-preview" + # api_version = "2021-10-01-privatepreview" + api_version = "2021-07-08-privatepreview" + accept = "application/json" + + # Construct URL + url = self.list_credentials.metadata['url'] # type: ignore + path_format_arguments = { + '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'), + 'endpointName': self._serialize.url("endpoint_name", endpoint_name, 'str', skip_quote=True), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + if expiresin is not None: + query_parameters['expiresin'] = self._serialize.query("expiresin", expiresin, 'long', maximum=10800, minimum=600) + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(models.ErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('EndpointAccessResource', pipeline_response) + + if cls: + 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 diff --git a/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/operations/_operations.py b/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/operations/_operations.py new file mode 100644 index 00000000000..02d52e6a4f6 --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/operations/_operations.py @@ -0,0 +1,110 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class Operations(object): + """Operations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~hybrid_connectivity_management_api.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def list( + self, + **kwargs # type: Any + ): + # type: (...) -> Iterable["models.OperationListResult"] + """Lists the available Hybrid Connectivity REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~hybrid_connectivity_management_api.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2021-10-06-preview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize('OperationListResult', pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + error = self._deserialize(models.ErrorResponse, response) + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.HybridConnectivity/operations'} # type: ignore diff --git a/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/py.typed b/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/src/ssh/azext_ssh/vendored_sdks/hybridconnectivity/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/src/ssh/setup.py b/src/ssh/setup.py index 1615ce2dde6..860e04cb9b8 100644 --- a/src/ssh/setup.py +++ b/src/ssh/setup.py @@ -7,7 +7,7 @@ from setuptools import setup, find_packages -VERSION = "0.1.9" +VERSION = "0.2.1" CLASSIFIERS = [ 'Development Status :: 4 - Beta',