diff --git a/sdk/serialconsole/azure-mgmt-serialconsole/MANIFEST.in b/sdk/serialconsole/azure-mgmt-serialconsole/MANIFEST.in index a3cb07df8765..3a9b6517412b 100644 --- a/sdk/serialconsole/azure-mgmt-serialconsole/MANIFEST.in +++ b/sdk/serialconsole/azure-mgmt-serialconsole/MANIFEST.in @@ -1,3 +1,4 @@ +include _meta.json recursive-include tests *.py *.yaml include *.md include azure/__init__.py diff --git a/sdk/serialconsole/azure-mgmt-serialconsole/_meta.json b/sdk/serialconsole/azure-mgmt-serialconsole/_meta.json new file mode 100644 index 000000000000..7d383f5ab45e --- /dev/null +++ b/sdk/serialconsole/azure-mgmt-serialconsole/_meta.json @@ -0,0 +1,8 @@ +{ + "autorest": "3.3.0", + "use": "@autorest/python@5.6.6", + "commit": "c5778f6fc0d6679b10e78ee56ac2206afaf689eb", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest_command": "autorest specification/serialconsole/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.6.6 --version=3.3.0", + "readme": "specification/serialconsole/resource-manager/readme.md" +} \ No newline at end of file diff --git a/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/_metadata.json b/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/_metadata.json new file mode 100644 index 000000000000..351eddb5d534 --- /dev/null +++ b/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/_metadata.json @@ -0,0 +1,157 @@ +{ + "chosen_version": "2018-05-01", + "total_api_version_list": ["2018-05-01"], + "client": { + "name": "MicrosoftSerialConsoleClient", + "filename": "_microsoft_serial_console_client", + "description": "The Azure Serial Console allows you to access the serial console of a Virtual Machine or VM scale set instance.", + "base_url": "\u0027https://management.azure.com\u0027", + "custom_base_url": null, + "azure_arm": true, + "has_lro_operations": false, + "client_side_validation": false, + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MicrosoftSerialConsoleClientConfiguration\"], \"._operations_mixin\": [\"MicrosoftSerialConsoleClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MicrosoftSerialConsoleClientConfiguration\"], \"._operations_mixin\": [\"MicrosoftSerialConsoleClientOperationsMixin\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id, # type: str", + "description": "Subscription ID which uniquely identifies the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call requiring it.", + "docstring_type": "str", + "required": true + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "Subscription ID which uniquely identifies the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call requiring it.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=None, # type: Optional[str]", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: Optional[str] = None,", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_default_policy_type": "BearerTokenCredentialPolicy", + "credential_default_policy_type_has_async_version": true, + "credential_key_header_name": null, + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "serial_ports": "SerialPortsOperations" + }, + "operation_mixins": { + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\", \"Union\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.exceptions\": [\"ClientAuthenticationError\", \"HttpResponseError\", \"ResourceExistsError\", \"ResourceNotFoundError\", \"map_error\"], \"azure.mgmt.core.exceptions\": [\"ARMErrorFormat\"], \"azure.core.pipeline\": [\"PipelineResponse\"], \"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}, \"stdlib\": {\"warnings\": [null]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Callable\", \"Dict\", \"Generic\", \"Optional\", \"TypeVar\", \"Union\"]}}}", + "operations": { + "list_operations" : { + "sync": { + "signature": "def list_operations(\n self,\n **kwargs # type: Any\n):\n", + "doc": "\"\"\"Gets a list of Serial Console API operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: SerialConsoleOperations, or the result of cls(response)\n:rtype: ~azure.mgmt.serialconsole.models.SerialConsoleOperations\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "async": { + "coroutine": true, + "signature": "async def list_operations(\n self,\n **kwargs\n) -\u003e \"_models.SerialConsoleOperations\":\n", + "doc": "\"\"\"Gets a list of Serial Console API operations.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: SerialConsoleOperations, or the result of cls(response)\n:rtype: ~azure.mgmt.serialconsole.models.SerialConsoleOperations\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "call": "" + }, + "get_console_status" : { + "sync": { + "signature": "def get_console_status(\n self,\n default, # type: str\n **kwargs # type: Any\n):\n", + "doc": "\"\"\"Get the disabled status for a subscription.\n\nGets whether or not Serial Console is disabled for a given subscription.\n\n:param default: Default parameter. Leave the value as \"default\".\n:type default: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: SerialConsoleStatus or GetSerialConsoleSubscriptionNotFound, or the result of cls(response)\n:rtype: ~azure.mgmt.serialconsole.models.SerialConsoleStatus or ~azure.mgmt.serialconsole.models.GetSerialConsoleSubscriptionNotFound\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "async": { + "coroutine": true, + "signature": "async def get_console_status(\n self,\n default: str,\n **kwargs\n) -\u003e Union[\"_models.SerialConsoleStatus\", \"_models.GetSerialConsoleSubscriptionNotFound\"]:\n", + "doc": "\"\"\"Get the disabled status for a subscription.\n\nGets whether or not Serial Console is disabled for a given subscription.\n\n:param default: Default parameter. Leave the value as \"default\".\n:type default: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: SerialConsoleStatus or GetSerialConsoleSubscriptionNotFound, or the result of cls(response)\n:rtype: ~azure.mgmt.serialconsole.models.SerialConsoleStatus or ~azure.mgmt.serialconsole.models.GetSerialConsoleSubscriptionNotFound\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "call": "default" + }, + "disable_console" : { + "sync": { + "signature": "def disable_console(\n self,\n default, # type: str\n **kwargs # type: Any\n):\n", + "doc": "\"\"\"Disable Serial Console for a subscription.\n\nDisables the Serial Console service for all VMs and VM scale sets in the provided subscription.\n\n:param default: Default parameter. Leave the value as \"default\".\n:type default: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: DisableSerialConsoleResult or GetSerialConsoleSubscriptionNotFound, or the result of cls(response)\n:rtype: ~azure.mgmt.serialconsole.models.DisableSerialConsoleResult or ~azure.mgmt.serialconsole.models.GetSerialConsoleSubscriptionNotFound\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "async": { + "coroutine": true, + "signature": "async def disable_console(\n self,\n default: str,\n **kwargs\n) -\u003e Union[\"_models.DisableSerialConsoleResult\", \"_models.GetSerialConsoleSubscriptionNotFound\"]:\n", + "doc": "\"\"\"Disable Serial Console for a subscription.\n\nDisables the Serial Console service for all VMs and VM scale sets in the provided subscription.\n\n:param default: Default parameter. Leave the value as \"default\".\n:type default: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: DisableSerialConsoleResult or GetSerialConsoleSubscriptionNotFound, or the result of cls(response)\n:rtype: ~azure.mgmt.serialconsole.models.DisableSerialConsoleResult or ~azure.mgmt.serialconsole.models.GetSerialConsoleSubscriptionNotFound\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "call": "default" + }, + "enable_console" : { + "sync": { + "signature": "def enable_console(\n self,\n default, # type: str\n **kwargs # type: Any\n):\n", + "doc": "\"\"\"Enable Serial Console for a subscription.\n\nEnables the Serial Console service for all VMs and VM scale sets in the provided subscription.\n\n:param default: Default parameter. Leave the value as \"default\".\n:type default: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: EnableSerialConsoleResult or GetSerialConsoleSubscriptionNotFound, or the result of cls(response)\n:rtype: ~azure.mgmt.serialconsole.models.EnableSerialConsoleResult or ~azure.mgmt.serialconsole.models.GetSerialConsoleSubscriptionNotFound\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "async": { + "coroutine": true, + "signature": "async def enable_console(\n self,\n default: str,\n **kwargs\n) -\u003e Union[\"_models.EnableSerialConsoleResult\", \"_models.GetSerialConsoleSubscriptionNotFound\"]:\n", + "doc": "\"\"\"Enable Serial Console for a subscription.\n\nEnables the Serial Console service for all VMs and VM scale sets in the provided subscription.\n\n:param default: Default parameter. Leave the value as \"default\".\n:type default: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: EnableSerialConsoleResult or GetSerialConsoleSubscriptionNotFound, or the result of cls(response)\n:rtype: ~azure.mgmt.serialconsole.models.EnableSerialConsoleResult or ~azure.mgmt.serialconsole.models.GetSerialConsoleSubscriptionNotFound\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "call": "default" + } + } + } +} \ No newline at end of file diff --git a/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/_microsoft_serial_console_client.py b/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/_microsoft_serial_console_client.py index 6755ba6aa1d6..2918deff33a0 100644 --- a/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/_microsoft_serial_console_client.py +++ b/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/_microsoft_serial_console_client.py @@ -16,15 +16,19 @@ from typing import Any, Optional from azure.core.credentials import TokenCredential + from azure.core.pipeline.transport import HttpRequest, HttpResponse from ._configuration import MicrosoftSerialConsoleClientConfiguration from .operations import MicrosoftSerialConsoleClientOperationsMixin +from .operations import SerialPortsOperations from . import models class MicrosoftSerialConsoleClient(MicrosoftSerialConsoleClientOperationsMixin): """The Azure Serial Console allows you to access the serial console of a Virtual Machine or VM scale set instance. + :ivar serial_ports: SerialPortsOperations operations + :vartype serial_ports: azure.mgmt.serialconsole.operations.SerialPortsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Subscription ID which uniquely identifies the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call requiring it. @@ -50,6 +54,26 @@ def __init__( self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self.serial_ports = SerialPortsOperations( + self._client, self._config, self._serialize, self._deserialize) + + def _send_request(self, http_request, **kwargs): + # type: (HttpRequest, Any) -> HttpResponse + """Runs the network request through the client's chained policies. + + :param http_request: The network request you want to make. Required. + :type http_request: ~azure.core.pipeline.transport.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.pipeline.transport.HttpResponse + """ + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + http_request.url = self._client.format_url(http_request.url, **path_format_arguments) + stream = kwargs.pop("stream", True) + pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) + return pipeline_response.http_response def close(self): # type: () -> None diff --git a/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/_version.py b/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/_version.py index 515f51c112dd..eae7c95b6fbd 100644 --- a/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/_version.py +++ b/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/_version.py @@ -6,5 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0b1" - +VERSION = "0.1.0" diff --git a/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/aio/_microsoft_serial_console_client.py b/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/aio/_microsoft_serial_console_client.py index 8b2529cb3c2d..c13d53e4d8a6 100644 --- a/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/aio/_microsoft_serial_console_client.py +++ b/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/aio/_microsoft_serial_console_client.py @@ -8,6 +8,7 @@ from typing import Any, Optional, TYPE_CHECKING +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer @@ -17,12 +18,15 @@ from ._configuration import MicrosoftSerialConsoleClientConfiguration from .operations import MicrosoftSerialConsoleClientOperationsMixin +from .operations import SerialPortsOperations from .. import models class MicrosoftSerialConsoleClient(MicrosoftSerialConsoleClientOperationsMixin): """The Azure Serial Console allows you to access the serial console of a Virtual Machine or VM scale set instance. + :ivar serial_ports: SerialPortsOperations operations + :vartype serial_ports: azure.mgmt.serialconsole.aio.operations.SerialPortsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Subscription ID which uniquely identifies the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call requiring it. @@ -47,6 +51,25 @@ def __init__( self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self.serial_ports = SerialPortsOperations( + self._client, self._config, self._serialize, self._deserialize) + + async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + """Runs the network request through the client's chained policies. + + :param http_request: The network request you want to make. Required. + :type http_request: ~azure.core.pipeline.transport.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + """ + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + http_request.url = self._client.format_url(http_request.url, **path_format_arguments) + stream = kwargs.pop("stream", True) + pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) + return pipeline_response.http_response async def close(self) -> None: await self._client.close() diff --git a/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/aio/operations/__init__.py b/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/aio/operations/__init__.py index f496cdba67ec..7c0e862d8de7 100644 --- a/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/aio/operations/__init__.py +++ b/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/aio/operations/__init__.py @@ -7,7 +7,9 @@ # -------------------------------------------------------------------------- from ._microsoft_serial_console_client_operations import MicrosoftSerialConsoleClientOperationsMixin +from ._serial_ports_operations import SerialPortsOperations __all__ = [ 'MicrosoftSerialConsoleClientOperationsMixin', + 'SerialPortsOperations', ] diff --git a/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/aio/operations/_serial_ports_operations.py b/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/aio/operations/_serial_ports_operations.py new file mode 100644 index 000000000000..5bd6a37be07f --- /dev/null +++ b/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/aio/operations/_serial_ports_operations.py @@ -0,0 +1,450 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class SerialPortsOperations: + """SerialPortsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.serialconsole.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def list( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_type: str, + parent_resource: str, + **kwargs + ) -> "_models.SerialPortListResult": + """Lists all of the configured serial ports for a parent resource. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_type: The resource type of the parent resource. For example: + 'virtualMachines' or 'virtualMachineScaleSets'. + :type parent_resource_type: str + :param parent_resource: The resource name, or subordinate path, for the parent of the serial + port. For example: the name of the virtual machine. + :type parent_resource: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SerialPortListResult, or the result of cls(response) + :rtype: ~azure.mgmt.serialconsole.models.SerialPortListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SerialPortListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + accept = "application/json" + + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'parentResourceType': self._serialize.url("parent_resource_type", parent_resource_type, 'str', skip_quote=True), + 'parentResource': self._serialize.url("parent_resource", parent_resource, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('SerialPortListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourceType}/{parentResource}/providers/Microsoft.SerialConsole/serialPorts'} # type: ignore + + async def get( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_type: str, + parent_resource: str, + serial_port: str, + **kwargs + ) -> "_models.SerialPort": + """Gets the configured settings for a serial port. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_type: The resource type of the parent resource. For example: + 'virtualMachines' or 'virtualMachineScaleSets'. + :type parent_resource_type: str + :param parent_resource: The resource name, or subordinate path, for the parent of the serial + port. For example: the name of the virtual machine. + :type parent_resource: str + :param serial_port: The name of the serial port to connect to. + :type serial_port: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SerialPort, or the result of cls(response) + :rtype: ~azure.mgmt.serialconsole.models.SerialPort + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SerialPort"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'parentResourceType': self._serialize.url("parent_resource_type", parent_resource_type, 'str', skip_quote=True), + 'parentResource': self._serialize.url("parent_resource", parent_resource, 'str'), + 'serialPort': self._serialize.url("serial_port", serial_port, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('SerialPort', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourceType}/{parentResource}/providers/Microsoft.SerialConsole/serialPorts/{serialPort}'} # type: ignore + + async def create( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_type: str, + parent_resource: str, + serial_port: str, + parameters: "_models.SerialPort", + **kwargs + ) -> "_models.SerialPort": + """Creates or updates a serial port. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_type: The resource type of the parent resource. For example: + 'virtualMachines' or 'virtualMachineScaleSets'. + :type parent_resource_type: str + :param parent_resource: The resource name, or subordinate path, for the parent of the serial + port. For example: the name of the virtual machine. + :type parent_resource: str + :param serial_port: The name of the serial port to create. + :type serial_port: str + :param parameters: Parameters supplied to create the serial port. + :type parameters: ~azure.mgmt.serialconsole.models.SerialPort + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SerialPort, or the result of cls(response) + :rtype: ~azure.mgmt.serialconsole.models.SerialPort + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SerialPort"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'parentResourceType': self._serialize.url("parent_resource_type", parent_resource_type, 'str', skip_quote=True), + 'parentResource': self._serialize.url("parent_resource", parent_resource, 'str'), + 'serialPort': self._serialize.url("serial_port", serial_port, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['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, 'SerialPort') + 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 [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('SerialPort', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourceType}/{parentResource}/providers/Microsoft.SerialConsole/serialPorts/{serialPort}'} # type: ignore + + async def delete( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_type: str, + parent_resource: str, + serial_port: str, + **kwargs + ) -> None: + """Deletes a serial port. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_type: The resource type of the parent resource. For example: + 'virtualMachines' or 'virtualMachineScaleSets'. + :type parent_resource_type: str + :param parent_resource: The resource name, or subordinate path, for the parent of the serial + port. For example: the name of the virtual machine. + :type parent_resource: str + :param serial_port: The name of the serial port to delete. + :type serial_port: 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 = "2018-05-01" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'parentResourceType': self._serialize.url("parent_resource_type", parent_resource_type, 'str', skip_quote=True), + 'parentResource': self._serialize.url("parent_resource", parent_resource, 'str'), + 'serialPort': self._serialize.url("serial_port", serial_port, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourceType}/{parentResource}/providers/Microsoft.SerialConsole/serialPorts/{serialPort}'} # type: ignore + + async def list_by_subscriptions( + self, + **kwargs + ) -> "_models.SerialPortListResult": + """Handles requests to list all SerialPort resources in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SerialPortListResult, or the result of cls(response) + :rtype: ~azure.mgmt.serialconsole.models.SerialPortListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SerialPortListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + accept = "application/json" + + # Construct URL + url = self.list_by_subscriptions.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + + # 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('SerialPortListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + list_by_subscriptions.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.SerialConsole/serialPorts'} # type: ignore + + async def connect( + self, + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_type: str, + parent_resource: str, + serial_port: str, + **kwargs + ) -> "_models.SerialPortConnectResult": + """Connect to serial port of the target resource. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_type: The resource type of the parent resource. For example: + 'virtualMachines' or 'virtualMachineScaleSets'. + :type parent_resource_type: str + :param parent_resource: The resource name, or subordinate path, for the parent of the serial + port. For example: the name of the virtual machine. + :type parent_resource: str + :param serial_port: The name of the serial port to connect to. + :type serial_port: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SerialPortConnectResult, or the result of cls(response) + :rtype: ~azure.mgmt.serialconsole.models.SerialPortConnectResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SerialPortConnectResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + accept = "application/json" + + # Construct URL + url = self.connect.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'parentResourceType': self._serialize.url("parent_resource_type", parent_resource_type, 'str', skip_quote=True), + 'parentResource': self._serialize.url("parent_resource", parent_resource, 'str'), + 'serialPort': self._serialize.url("serial_port", serial_port, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = 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('SerialPortConnectResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + connect.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourceType}/{parentResource}/providers/Microsoft.SerialConsole/serialPorts/{serialPort}/connect'} # type: ignore diff --git a/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/models/__init__.py b/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/models/__init__.py index 40a6a100381a..68eace947f80 100644 --- a/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/models/__init__.py +++ b/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/models/__init__.py @@ -7,28 +7,51 @@ # -------------------------------------------------------------------------- try: + from ._models_py3 import CloudErrorBody from ._models_py3 import DisableSerialConsoleResult from ._models_py3 import EnableSerialConsoleResult from ._models_py3 import GetSerialConsoleSubscriptionNotFound + from ._models_py3 import ProxyResource + from ._models_py3 import Resource from ._models_py3 import SerialConsoleOperations from ._models_py3 import SerialConsoleOperationsValueItem from ._models_py3 import SerialConsoleOperationsValueItemDisplay from ._models_py3 import SerialConsoleStatus + from ._models_py3 import SerialPort + from ._models_py3 import SerialPortConnectResult + from ._models_py3 import SerialPortListResult except (SyntaxError, ImportError): + from ._models import CloudErrorBody # type: ignore from ._models import DisableSerialConsoleResult # type: ignore from ._models import EnableSerialConsoleResult # type: ignore from ._models import GetSerialConsoleSubscriptionNotFound # type: ignore + from ._models import ProxyResource # type: ignore + from ._models import Resource # type: ignore from ._models import SerialConsoleOperations # type: ignore from ._models import SerialConsoleOperationsValueItem # type: ignore from ._models import SerialConsoleOperationsValueItemDisplay # type: ignore from ._models import SerialConsoleStatus # type: ignore + from ._models import SerialPort # type: ignore + from ._models import SerialPortConnectResult # type: ignore + from ._models import SerialPortListResult # type: ignore + +from ._microsoft_serial_console_client_enums import ( + SerialPortState, +) __all__ = [ + 'CloudErrorBody', 'DisableSerialConsoleResult', 'EnableSerialConsoleResult', 'GetSerialConsoleSubscriptionNotFound', + 'ProxyResource', + 'Resource', 'SerialConsoleOperations', 'SerialConsoleOperationsValueItem', 'SerialConsoleOperationsValueItemDisplay', 'SerialConsoleStatus', + 'SerialPort', + 'SerialPortConnectResult', + 'SerialPortListResult', + 'SerialPortState', ] diff --git a/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/models/_microsoft_serial_console_client_enums.py b/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/models/_microsoft_serial_console_client_enums.py new file mode 100644 index 000000000000..1125b26eca62 --- /dev/null +++ b/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/models/_microsoft_serial_console_client_enums.py @@ -0,0 +1,34 @@ +# 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 SerialPortState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Specifies whether the port is enabled for a serial console connection. + """ + + ENABLED = "enabled" + DISABLED = "disabled" diff --git a/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/models/_models.py b/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/models/_models.py index 1ffd879e0c6c..06ca40862d24 100644 --- a/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/models/_models.py +++ b/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/models/_models.py @@ -9,6 +9,40 @@ import msrest.serialization +class CloudErrorBody(msrest.serialization.Model): + """An error response from the Batch service. + + :param code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :type code: str + :param message: A message describing the error, intended to be suitable for display in a user + interface. + :type message: str + :param target: The target of the particular error. For example, the name of the property in + error. + :type target: str + :param details: A list of additional details about the error. + :type details: list[~azure.mgmt.serialconsole.models.CloudErrorBody] + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, + } + + def __init__( + self, + **kwargs + ): + super(CloudErrorBody, self).__init__(**kwargs) + self.code = kwargs.get('code', None) + self.message = kwargs.get('message', None) + self.target = kwargs.get('target', None) + self.details = kwargs.get('details', None) + + class DisableSerialConsoleResult(msrest.serialization.Model): """Returns whether or not Serial Console is disabled. @@ -70,6 +104,73 @@ def __init__( self.message = kwargs.get('message', None) +class Resource(msrest.serialization.Model): + """The Resource model definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class ProxyResource(Resource): + """The resource model definition for a ARM proxy resource. It will have everything other than required location and tags. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ProxyResource, self).__init__(**kwargs) + + class SerialConsoleOperations(msrest.serialization.Model): """Serial Console operations. @@ -164,3 +265,78 @@ def __init__( ): super(SerialConsoleStatus, self).__init__(**kwargs) self.disabled = kwargs.get('disabled', None) + + +class SerialPort(ProxyResource): + """Represents the serial port of the parent resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :param state: Specifies whether the port is enabled for a serial console connection. Possible + values include: "enabled", "disabled". + :type state: str or ~azure.mgmt.serialconsole.models.SerialPortState + """ + + _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'}, + 'state': {'key': 'properties.state', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(SerialPort, self).__init__(**kwargs) + self.state = kwargs.get('state', None) + + +class SerialPortConnectResult(msrest.serialization.Model): + """Returns a connection string to the serial port of the resource. + + :param connection_string: Connection string to the serial port of the resource. + :type connection_string: str + """ + + _attribute_map = { + 'connection_string': {'key': 'connectionString', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(SerialPortConnectResult, self).__init__(**kwargs) + self.connection_string = kwargs.get('connection_string', None) + + +class SerialPortListResult(msrest.serialization.Model): + """The list serial ports operation response. + + :param value: The list of serial ports. + :type value: list[~azure.mgmt.serialconsole.models.SerialPort] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[SerialPort]'}, + } + + def __init__( + self, + **kwargs + ): + super(SerialPortListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) diff --git a/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/models/_models_py3.py b/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/models/_models_py3.py index 7245a0c3765b..01f8f10906a4 100644 --- a/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/models/_models_py3.py +++ b/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/models/_models_py3.py @@ -6,10 +6,51 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, Optional +from typing import List, Optional, Union import msrest.serialization +from ._microsoft_serial_console_client_enums import * + + +class CloudErrorBody(msrest.serialization.Model): + """An error response from the Batch service. + + :param code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :type code: str + :param message: A message describing the error, intended to be suitable for display in a user + interface. + :type message: str + :param target: The target of the particular error. For example, the name of the property in + error. + :type target: str + :param details: A list of additional details about the error. + :type details: list[~azure.mgmt.serialconsole.models.CloudErrorBody] + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + target: Optional[str] = None, + details: Optional[List["CloudErrorBody"]] = None, + **kwargs + ): + super(CloudErrorBody, self).__init__(**kwargs) + self.code = code + self.message = message + self.target = target + self.details = details + class DisableSerialConsoleResult(msrest.serialization.Model): """Returns whether or not Serial Console is disabled. @@ -79,6 +120,73 @@ def __init__( self.message = message +class Resource(msrest.serialization.Model): + """The Resource model definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class ProxyResource(Resource): + """The resource model definition for a ARM proxy resource. It will have everything other than required location and tags. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ProxyResource, self).__init__(**kwargs) + + class SerialConsoleOperations(msrest.serialization.Model): """Serial Console operations. @@ -186,3 +294,84 @@ def __init__( ): super(SerialConsoleStatus, self).__init__(**kwargs) self.disabled = disabled + + +class SerialPort(ProxyResource): + """Represents the serial port of the parent resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :param state: Specifies whether the port is enabled for a serial console connection. Possible + values include: "enabled", "disabled". + :type state: str or ~azure.mgmt.serialconsole.models.SerialPortState + """ + + _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'}, + 'state': {'key': 'properties.state', 'type': 'str'}, + } + + def __init__( + self, + *, + state: Optional[Union[str, "SerialPortState"]] = None, + **kwargs + ): + super(SerialPort, self).__init__(**kwargs) + self.state = state + + +class SerialPortConnectResult(msrest.serialization.Model): + """Returns a connection string to the serial port of the resource. + + :param connection_string: Connection string to the serial port of the resource. + :type connection_string: str + """ + + _attribute_map = { + 'connection_string': {'key': 'connectionString', 'type': 'str'}, + } + + def __init__( + self, + *, + connection_string: Optional[str] = None, + **kwargs + ): + super(SerialPortConnectResult, self).__init__(**kwargs) + self.connection_string = connection_string + + +class SerialPortListResult(msrest.serialization.Model): + """The list serial ports operation response. + + :param value: The list of serial ports. + :type value: list[~azure.mgmt.serialconsole.models.SerialPort] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[SerialPort]'}, + } + + def __init__( + self, + *, + value: Optional[List["SerialPort"]] = None, + **kwargs + ): + super(SerialPortListResult, self).__init__(**kwargs) + self.value = value diff --git a/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/operations/__init__.py b/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/operations/__init__.py index f496cdba67ec..7c0e862d8de7 100644 --- a/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/operations/__init__.py +++ b/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/operations/__init__.py @@ -7,7 +7,9 @@ # -------------------------------------------------------------------------- from ._microsoft_serial_console_client_operations import MicrosoftSerialConsoleClientOperationsMixin +from ._serial_ports_operations import SerialPortsOperations __all__ = [ 'MicrosoftSerialConsoleClientOperationsMixin', + 'SerialPortsOperations', ] diff --git a/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/operations/_serial_ports_operations.py b/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/operations/_serial_ports_operations.py new file mode 100644 index 000000000000..20decfe90584 --- /dev/null +++ b/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/operations/_serial_ports_operations.py @@ -0,0 +1,460 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class SerialPortsOperations(object): + """SerialPortsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.serialconsole.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, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_type, # type: str + parent_resource, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.SerialPortListResult" + """Lists all of the configured serial ports for a parent resource. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_type: The resource type of the parent resource. For example: + 'virtualMachines' or 'virtualMachineScaleSets'. + :type parent_resource_type: str + :param parent_resource: The resource name, or subordinate path, for the parent of the serial + port. For example: the name of the virtual machine. + :type parent_resource: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SerialPortListResult, or the result of cls(response) + :rtype: ~azure.mgmt.serialconsole.models.SerialPortListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SerialPortListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + accept = "application/json" + + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'parentResourceType': self._serialize.url("parent_resource_type", parent_resource_type, 'str', skip_quote=True), + 'parentResource': self._serialize.url("parent_resource", parent_resource, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('SerialPortListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourceType}/{parentResource}/providers/Microsoft.SerialConsole/serialPorts'} # type: ignore + + def get( + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_type, # type: str + parent_resource, # type: str + serial_port, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.SerialPort" + """Gets the configured settings for a serial port. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_type: The resource type of the parent resource. For example: + 'virtualMachines' or 'virtualMachineScaleSets'. + :type parent_resource_type: str + :param parent_resource: The resource name, or subordinate path, for the parent of the serial + port. For example: the name of the virtual machine. + :type parent_resource: str + :param serial_port: The name of the serial port to connect to. + :type serial_port: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SerialPort, or the result of cls(response) + :rtype: ~azure.mgmt.serialconsole.models.SerialPort + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SerialPort"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'parentResourceType': self._serialize.url("parent_resource_type", parent_resource_type, 'str', skip_quote=True), + 'parentResource': self._serialize.url("parent_resource", parent_resource, 'str'), + 'serialPort': self._serialize.url("serial_port", serial_port, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('SerialPort', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourceType}/{parentResource}/providers/Microsoft.SerialConsole/serialPorts/{serialPort}'} # type: ignore + + def create( + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_type, # type: str + parent_resource, # type: str + serial_port, # type: str + parameters, # type: "_models.SerialPort" + **kwargs # type: Any + ): + # type: (...) -> "_models.SerialPort" + """Creates or updates a serial port. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_type: The resource type of the parent resource. For example: + 'virtualMachines' or 'virtualMachineScaleSets'. + :type parent_resource_type: str + :param parent_resource: The resource name, or subordinate path, for the parent of the serial + port. For example: the name of the virtual machine. + :type parent_resource: str + :param serial_port: The name of the serial port to create. + :type serial_port: str + :param parameters: Parameters supplied to create the serial port. + :type parameters: ~azure.mgmt.serialconsole.models.SerialPort + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SerialPort, or the result of cls(response) + :rtype: ~azure.mgmt.serialconsole.models.SerialPort + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SerialPort"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.create.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'parentResourceType': self._serialize.url("parent_resource_type", parent_resource_type, 'str', skip_quote=True), + 'parentResource': self._serialize.url("parent_resource", parent_resource, 'str'), + 'serialPort': self._serialize.url("serial_port", serial_port, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['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, 'SerialPort') + 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 [201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('SerialPort', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + create.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourceType}/{parentResource}/providers/Microsoft.SerialConsole/serialPorts/{serialPort}'} # type: ignore + + def delete( + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_type, # type: str + parent_resource, # type: str + serial_port, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Deletes a serial port. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_type: The resource type of the parent resource. For example: + 'virtualMachines' or 'virtualMachineScaleSets'. + :type parent_resource_type: str + :param parent_resource: The resource name, or subordinate path, for the parent of the serial + port. For example: the name of the virtual machine. + :type parent_resource: str + :param serial_port: The name of the serial port to delete. + :type serial_port: 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 = "2018-05-01" + accept = "application/json" + + # Construct URL + url = self.delete.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'parentResourceType': self._serialize.url("parent_resource_type", parent_resource_type, 'str', skip_quote=True), + 'parentResource': self._serialize.url("parent_resource", parent_resource, 'str'), + 'serialPort': self._serialize.url("serial_port", serial_port, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourceType}/{parentResource}/providers/Microsoft.SerialConsole/serialPorts/{serialPort}'} # type: ignore + + def list_by_subscriptions( + self, + **kwargs # type: Any + ): + # type: (...) -> "_models.SerialPortListResult" + """Handles requests to list all SerialPort resources in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SerialPortListResult, or the result of cls(response) + :rtype: ~azure.mgmt.serialconsole.models.SerialPortListResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SerialPortListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + accept = "application/json" + + # Construct URL + url = self.list_by_subscriptions.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('SerialPortListResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + list_by_subscriptions.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.SerialConsole/serialPorts'} # type: ignore + + def connect( + self, + resource_group_name, # type: str + resource_provider_namespace, # type: str + parent_resource_type, # type: str + parent_resource, # type: str + serial_port, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_models.SerialPortConnectResult" + """Connect to serial port of the target resource. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param resource_provider_namespace: The namespace of the resource provider. + :type resource_provider_namespace: str + :param parent_resource_type: The resource type of the parent resource. For example: + 'virtualMachines' or 'virtualMachineScaleSets'. + :type parent_resource_type: str + :param parent_resource: The resource name, or subordinate path, for the parent of the serial + port. For example: the name of the virtual machine. + :type parent_resource: str + :param serial_port: The name of the serial port to connect to. + :type serial_port: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SerialPortConnectResult, or the result of cls(response) + :rtype: ~azure.mgmt.serialconsole.models.SerialPortConnectResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.SerialPortConnectResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2018-05-01" + accept = "application/json" + + # Construct URL + url = self.connect.metadata['url'] # type: ignore + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'resourceProviderNamespace': self._serialize.url("resource_provider_namespace", resource_provider_namespace, 'str'), + 'parentResourceType': self._serialize.url("parent_resource_type", parent_resource_type, 'str', skip_quote=True), + 'parentResource': self._serialize.url("parent_resource", parent_resource, 'str'), + 'serialPort': self._serialize.url("serial_port", serial_port, 'str'), + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = 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) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('SerialPortConnectResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + connect.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourceType}/{parentResource}/providers/Microsoft.SerialConsole/serialPorts/{serialPort}/connect'} # type: ignore