diff --git a/sdk/serialconsole/azure-mgmt-serialconsole/_meta.json b/sdk/serialconsole/azure-mgmt-serialconsole/_meta.json index 4f33b8841efb..7bae4a17667f 100644 --- a/sdk/serialconsole/azure-mgmt-serialconsole/_meta.json +++ b/sdk/serialconsole/azure-mgmt-serialconsole/_meta.json @@ -1,8 +1,11 @@ { - "autorest": "3.3.0", - "use": "@autorest/python@5.6.6", - "commit": "7f3fdacba501b8639f1ac6a38058d219f5c5395e", + "autorest": "3.7.2", + "use": [ + "@autorest/python@5.12.0", + "@autorest/modelerfour@4.19.3" + ], + "commit": "1197aec6f7a9ef9a5a61891b3004b213f6f3ee70", "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", + "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 --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", "readme": "specification/serialconsole/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/__init__.py b/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/__init__.py index 1def651ee872..72713836bb03 100644 --- a/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/__init__.py +++ b/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['MicrosoftSerialConsoleClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/_configuration.py b/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/_configuration.py index ed77ae761bfe..5010b9a0ee9a 100644 --- a/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/_configuration.py +++ b/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/_configuration.py @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +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 +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class MicrosoftSerialConsoleClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(MicrosoftSerialConsoleClientConfiguration, self).__init__(**kwargs) 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(MicrosoftSerialConsoleClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +65,4 @@ def _configure( 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) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/_metadata.json b/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/_metadata.json index 351eddb5d534..73416b09809f 100644 --- a/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/_metadata.json +++ b/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/_metadata.json @@ -5,13 +5,13 @@ "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, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": 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\"]}}}" + "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\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"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\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,64 +91,63 @@ "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\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "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\"]}}}", + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Union\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Union\"]}}}", "operations": { "list_operations" : { "sync": { - "signature": "def list_operations(\n self,\n **kwargs # type: Any\n):\n", + "signature": "def list_operations(\n self,\n **kwargs # type: Any\n):\n # type: (...) -\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\"\"\"" }, "async": { "coroutine": true, - "signature": "async def list_operations(\n self,\n **kwargs\n) -\u003e \"_models.SerialConsoleOperations\":\n", + "signature": "async def list_operations(\n self,\n **kwargs: Any\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\"\"\"" + "signature": "def get_console_status(\n self,\n default, # type: str\n **kwargs # type: Any\n):\n # type: (...) -\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\n cls(response)\n:rtype: ~azure.mgmt.serialconsole.models.SerialConsoleStatus or\n ~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\"\"\"" + "signature": "async def get_console_status(\n self,\n default: str,\n **kwargs: Any\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\n cls(response)\n:rtype: ~azure.mgmt.serialconsole.models.SerialConsoleStatus or\n ~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\"\"\"" + "signature": "def disable_console(\n self,\n default, # type: str\n **kwargs # type: Any\n):\n # type: (...) -\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\n cls(response)\n:rtype: ~azure.mgmt.serialconsole.models.DisableSerialConsoleResult or\n ~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\"\"\"" + "signature": "async def disable_console(\n self,\n default: str,\n **kwargs: Any\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\n cls(response)\n:rtype: ~azure.mgmt.serialconsole.models.DisableSerialConsoleResult or\n ~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\"\"\"" + "signature": "def enable_console(\n self,\n default, # type: str\n **kwargs # type: Any\n):\n # type: (...) -\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\n cls(response)\n:rtype: ~azure.mgmt.serialconsole.models.EnableSerialConsoleResult or\n ~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\"\"\"" + "signature": "async def enable_console(\n self,\n default: str,\n **kwargs: Any\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\n cls(response)\n:rtype: ~azure.mgmt.serialconsole.models.EnableSerialConsoleResult or\n ~azure.mgmt.serialconsole.models.GetSerialConsoleSubscriptionNotFound\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "default" } 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 2918deff33a0..8652637cc691 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 @@ -6,23 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import MicrosoftSerialConsoleClientConfiguration +from .operations import MicrosoftSerialConsoleClientOperationsMixin, SerialPortsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - 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. @@ -31,49 +28,55 @@ class MicrosoftSerialConsoleClient(MicrosoftSerialConsoleClientOperationsMixin): :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. + :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. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ 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 = MicrosoftSerialConsoleClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = MicrosoftSerialConsoleClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.serial_ports = SerialPortsOperations(self._client, self._config, self._serialize, self._deserialize) - self.serial_ports = SerialPortsOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs: 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. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.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 + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/_patch.py b/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/_vendor.py b/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/_version.py b/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/_version.py index c47f66669f1b..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,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0" +VERSION = "0.1.0" diff --git a/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/aio/__init__.py b/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/aio/__init__.py index b03132c538a7..f706b866db18 100644 --- a/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/aio/__init__.py +++ b/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/aio/__init__.py @@ -8,3 +8,8 @@ from ._microsoft_serial_console_client import MicrosoftSerialConsoleClient __all__ = ['MicrosoftSerialConsoleClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/aio/_configuration.py b/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/aio/_configuration.py index 2c527215b323..24f169b48a81 100644 --- a/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/aio/_configuration.py +++ b/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(MicrosoftSerialConsoleClientConfiguration, self).__init__(**kwargs) 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(MicrosoftSerialConsoleClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,4 @@ def _configure( 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) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) 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 c13d53e4d8a6..fed4a8d2e2a8 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 @@ -6,22 +6,21 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import MicrosoftSerialConsoleClientConfiguration +from .operations import MicrosoftSerialConsoleClientOperationsMixin, SerialPortsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -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. @@ -29,47 +28,55 @@ class MicrosoftSerialConsoleClient(MicrosoftSerialConsoleClientOperationsMixin): :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. + :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. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = MicrosoftSerialConsoleClientConfiguration(credential, subscription_id, **kwargs) + self._config = MicrosoftSerialConsoleClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.serial_ports = SerialPortsOperations(self._client, self._config, self._serialize, self._deserialize) - self.serial_ports = SerialPortsOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[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. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.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 + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/aio/_patch.py b/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/aio/operations/_microsoft_serial_console_client_operations.py b/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/aio/operations/_microsoft_serial_console_client_operations.py index 7d58b40df27e..fdbcefeb2e56 100644 --- a/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/aio/operations/_microsoft_serial_console_client_operations.py +++ b/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/aio/operations/_microsoft_serial_console_client_operations.py @@ -5,24 +5,29 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._microsoft_serial_console_client_operations import build_disable_console_request, build_enable_console_request, build_get_console_status_request, build_list_operations_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class MicrosoftSerialConsoleClientOperationsMixin: + @distributed_trace_async async def list_operations( self, - **kwargs + **kwargs: Any ) -> "_models.SerialConsoleOperations": """Gets a list of Serial Console API operations. @@ -36,21 +41,14 @@ async def list_operations( 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_operations.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_operations_request( + template_url=self.list_operations.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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 @@ -64,12 +62,15 @@ async def list_operations( return cls(pipeline_response, deserialized, {}) return deserialized + list_operations.metadata = {'url': '/providers/Microsoft.SerialConsole/operations'} # type: ignore + + @distributed_trace_async async def get_console_status( self, default: str, - **kwargs + **kwargs: Any ) -> Union["_models.SerialConsoleStatus", "_models.GetSerialConsoleSubscriptionNotFound"]: """Get the disabled status for a subscription. @@ -78,8 +79,10 @@ async def get_console_status( :param default: Default parameter. Leave the value as "default". :type default: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SerialConsoleStatus or GetSerialConsoleSubscriptionNotFound, or the result of cls(response) - :rtype: ~azure.mgmt.serialconsole.models.SerialConsoleStatus or ~azure.mgmt.serialconsole.models.GetSerialConsoleSubscriptionNotFound + :return: SerialConsoleStatus or GetSerialConsoleSubscriptionNotFound, or the result of + cls(response) + :rtype: ~azure.mgmt.serialconsole.models.SerialConsoleStatus or + ~azure.mgmt.serialconsole.models.GetSerialConsoleSubscriptionNotFound :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.SerialConsoleStatus", "_models.GetSerialConsoleSubscriptionNotFound"]] @@ -87,26 +90,16 @@ async def get_console_status( 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_console_status.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'default': self._serialize.url("default", default, '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 = build_get_console_status_request( + subscription_id=self._config.subscription_id, + default=default, + template_url=self.get_console_status.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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 @@ -124,12 +117,15 @@ async def get_console_status( return cls(pipeline_response, deserialized, {}) return deserialized + get_console_status.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.SerialConsole/consoleServices/{default}'} # type: ignore + + @distributed_trace_async async def disable_console( self, default: str, - **kwargs + **kwargs: Any ) -> Union["_models.DisableSerialConsoleResult", "_models.GetSerialConsoleSubscriptionNotFound"]: """Disable Serial Console for a subscription. @@ -138,8 +134,10 @@ async def disable_console( :param default: Default parameter. Leave the value as "default". :type default: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DisableSerialConsoleResult or GetSerialConsoleSubscriptionNotFound, or the result of cls(response) - :rtype: ~azure.mgmt.serialconsole.models.DisableSerialConsoleResult or ~azure.mgmt.serialconsole.models.GetSerialConsoleSubscriptionNotFound + :return: DisableSerialConsoleResult or GetSerialConsoleSubscriptionNotFound, or the result of + cls(response) + :rtype: ~azure.mgmt.serialconsole.models.DisableSerialConsoleResult or + ~azure.mgmt.serialconsole.models.GetSerialConsoleSubscriptionNotFound :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.DisableSerialConsoleResult", "_models.GetSerialConsoleSubscriptionNotFound"]] @@ -147,26 +145,16 @@ async def disable_console( 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.disable_console.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'default': self._serialize.url("default", default, '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 = build_disable_console_request( + subscription_id=self._config.subscription_id, + default=default, + template_url=self.disable_console.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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 @@ -184,12 +172,15 @@ async def disable_console( return cls(pipeline_response, deserialized, {}) return deserialized + disable_console.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.SerialConsole/consoleServices/{default}/disableConsole'} # type: ignore + + @distributed_trace_async async def enable_console( self, default: str, - **kwargs + **kwargs: Any ) -> Union["_models.EnableSerialConsoleResult", "_models.GetSerialConsoleSubscriptionNotFound"]: """Enable Serial Console for a subscription. @@ -198,8 +189,10 @@ async def enable_console( :param default: Default parameter. Leave the value as "default". :type default: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EnableSerialConsoleResult or GetSerialConsoleSubscriptionNotFound, or the result of cls(response) - :rtype: ~azure.mgmt.serialconsole.models.EnableSerialConsoleResult or ~azure.mgmt.serialconsole.models.GetSerialConsoleSubscriptionNotFound + :return: EnableSerialConsoleResult or GetSerialConsoleSubscriptionNotFound, or the result of + cls(response) + :rtype: ~azure.mgmt.serialconsole.models.EnableSerialConsoleResult or + ~azure.mgmt.serialconsole.models.GetSerialConsoleSubscriptionNotFound :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.EnableSerialConsoleResult", "_models.GetSerialConsoleSubscriptionNotFound"]] @@ -207,26 +200,16 @@ async def enable_console( 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.enable_console.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'default': self._serialize.url("default", default, '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 = build_enable_console_request( + subscription_id=self._config.subscription_id, + default=default, + template_url=self.enable_console.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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 @@ -244,4 +227,6 @@ async def enable_console( return cls(pipeline_response, deserialized, {}) return deserialized + enable_console.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.SerialConsole/consoleServices/{default}/enableConsole'} # type: ignore + 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 index 5bd6a37be07f..1b50a677ecd0 100644 --- 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 @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools 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.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._serial_ports_operations import build_connect_request, build_create_request, build_delete_request, build_get_request, build_list_by_subscriptions_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,13 +44,14 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list( self, resource_group_name: str, resource_provider_namespace: str, parent_resource_type: str, parent_resource: str, - **kwargs + **kwargs: Any ) -> "_models.SerialPortListResult": """Lists all of the configured serial ports for a parent resource. @@ -70,29 +75,19 @@ async def list( 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') + + request = build_list_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_type=parent_resource_type, + parent_resource=parent_resource, + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # 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 @@ -106,8 +101,11 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourceType}/{parentResource}/providers/Microsoft.SerialConsole/serialPorts'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -115,7 +113,7 @@ async def get( parent_resource_type: str, parent_resource: str, serial_port: str, - **kwargs + **kwargs: Any ) -> "_models.SerialPort": """Gets the configured settings for a serial port. @@ -141,30 +139,20 @@ async def get( 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 = build_get_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_type=parent_resource_type, + parent_resource=parent_resource, + serial_port=serial_port, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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 @@ -178,8 +166,11 @@ async def get( 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 + + @distributed_trace_async async def create( self, resource_group_name: str, @@ -188,7 +179,7 @@ async def create( parent_resource: str, serial_port: str, parameters: "_models.SerialPort", - **kwargs + **kwargs: Any ) -> "_models.SerialPort": """Creates or updates a serial port. @@ -216,35 +207,25 @@ async def create( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'SerialPort') + + request = build_create_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_type=parent_resource_type, + parent_resource=parent_resource, + serial_port=serial_port, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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 @@ -258,8 +239,11 @@ async def create( 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 + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -267,7 +251,7 @@ async def delete( parent_resource_type: str, parent_resource: str, serial_port: str, - **kwargs + **kwargs: Any ) -> None: """Deletes a serial port. @@ -293,30 +277,20 @@ async def delete( 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 = build_delete_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_type=parent_resource_type, + parent_resource=parent_resource, + serial_port=serial_port, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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 @@ -329,9 +303,11 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourceType}/{parentResource}/providers/Microsoft.SerialConsole/serialPorts/{serialPort}'} # type: ignore + + @distributed_trace_async async def list_by_subscriptions( self, - **kwargs + **kwargs: Any ) -> "_models.SerialPortListResult": """Handles requests to list all SerialPort resources in a subscription. @@ -345,23 +321,15 @@ async def list_by_subscriptions( 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 = build_list_by_subscriptions_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscriptions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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 @@ -375,8 +343,11 @@ async def list_by_subscriptions( return cls(pipeline_response, deserialized, {}) return deserialized + list_by_subscriptions.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.SerialConsole/serialPorts'} # type: ignore + + @distributed_trace_async async def connect( self, resource_group_name: str, @@ -384,7 +355,7 @@ async def connect( parent_resource_type: str, parent_resource: str, serial_port: str, - **kwargs + **kwargs: Any ) -> "_models.SerialPortConnectResult": """Connect to serial port of the target resource. @@ -410,30 +381,20 @@ async def connect( 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') + + request = build_connect_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_type=parent_resource_type, + parent_resource=parent_resource, + serial_port=serial_port, + subscription_id=self._config.subscription_id, + template_url=self.connect.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # 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 @@ -447,4 +408,6 @@ async def connect( 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 68eace947f80..019400e8232c 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 @@ -6,34 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -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 ._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 + from ._microsoft_serial_console_client_enums import ( 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 index 1125b26eca62..220d761c4928 100644 --- 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 @@ -6,27 +6,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -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)): +class SerialPortState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Specifies whether the port is enabled for a serial console connection. """ 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 deleted file mode 100644 index 06ca40862d24..000000000000 --- a/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/models/_models.py +++ /dev/null @@ -1,342 +0,0 @@ -# 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 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. - - :param disabled: Whether or not Serial Console is disabled. - :type disabled: bool - """ - - _attribute_map = { - 'disabled': {'key': 'disabled', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(DisableSerialConsoleResult, self).__init__(**kwargs) - self.disabled = kwargs.get('disabled', None) - - -class EnableSerialConsoleResult(msrest.serialization.Model): - """Returns whether or not Serial Console is disabled (enabled). - - :param disabled: Whether or not Serial Console is disabled (enabled). - :type disabled: bool - """ - - _attribute_map = { - 'disabled': {'key': 'disabled', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(EnableSerialConsoleResult, self).__init__(**kwargs) - self.disabled = kwargs.get('disabled', None) - - -class GetSerialConsoleSubscriptionNotFound(msrest.serialization.Model): - """Error saying that the provided subscription could not be found. - - :param code: Error code. - :type code: str - :param message: Subscription not found message. - :type message: str - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(GetSerialConsoleSubscriptionNotFound, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - 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. - - :param value: A list of Serial Console operations. - :type value: list[~azure.mgmt.serialconsole.models.SerialConsoleOperationsValueItem] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SerialConsoleOperationsValueItem]'}, - } - - def __init__( - self, - **kwargs - ): - super(SerialConsoleOperations, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class SerialConsoleOperationsValueItem(msrest.serialization.Model): - """SerialConsoleOperationsValueItem. - - :param name: - :type name: str - :param is_data_action: - :type is_data_action: str - :param display: - :type display: ~azure.mgmt.serialconsole.models.SerialConsoleOperationsValueItemDisplay - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'SerialConsoleOperationsValueItemDisplay'}, - } - - def __init__( - self, - **kwargs - ): - super(SerialConsoleOperationsValueItem, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.is_data_action = kwargs.get('is_data_action', None) - self.display = kwargs.get('display', None) - - -class SerialConsoleOperationsValueItemDisplay(msrest.serialization.Model): - """SerialConsoleOperationsValueItemDisplay. - - :param provider: - :type provider: str - :param resource: - :type resource: str - :param operation: - :type operation: str - :param description: - :type description: str - """ - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SerialConsoleOperationsValueItemDisplay, self).__init__(**kwargs) - self.provider = kwargs.get('provider', None) - self.resource = kwargs.get('resource', None) - self.operation = kwargs.get('operation', None) - self.description = kwargs.get('description', None) - - -class SerialConsoleStatus(msrest.serialization.Model): - """Returns whether or not Serial Console is disabled. - - :param disabled: Whether or not Serial Console is disabled. - :type disabled: bool - """ - - _attribute_map = { - 'disabled': {'key': 'disabled', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - 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 01f8f10906a4..bed27a033be4 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 @@ -16,17 +16,17 @@ 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 + :ivar 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 + :vartype code: str + :ivar 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 + :vartype message: str + :ivar 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] + :vartype target: str + :ivar details: A list of additional details about the error. + :vartype details: list[~azure.mgmt.serialconsole.models.CloudErrorBody] """ _attribute_map = { @@ -45,6 +45,19 @@ def __init__( details: Optional[List["CloudErrorBody"]] = None, **kwargs ): + """ + :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :paramtype code: str + :keyword message: A message describing the error, intended to be suitable for display in a user + interface. + :paramtype message: str + :keyword target: The target of the particular error. For example, the name of the property in + error. + :paramtype target: str + :keyword details: A list of additional details about the error. + :paramtype details: list[~azure.mgmt.serialconsole.models.CloudErrorBody] + """ super(CloudErrorBody, self).__init__(**kwargs) self.code = code self.message = message @@ -55,8 +68,8 @@ def __init__( class DisableSerialConsoleResult(msrest.serialization.Model): """Returns whether or not Serial Console is disabled. - :param disabled: Whether or not Serial Console is disabled. - :type disabled: bool + :ivar disabled: Whether or not Serial Console is disabled. + :vartype disabled: bool """ _attribute_map = { @@ -69,6 +82,10 @@ def __init__( disabled: Optional[bool] = None, **kwargs ): + """ + :keyword disabled: Whether or not Serial Console is disabled. + :paramtype disabled: bool + """ super(DisableSerialConsoleResult, self).__init__(**kwargs) self.disabled = disabled @@ -76,8 +93,8 @@ def __init__( class EnableSerialConsoleResult(msrest.serialization.Model): """Returns whether or not Serial Console is disabled (enabled). - :param disabled: Whether or not Serial Console is disabled (enabled). - :type disabled: bool + :ivar disabled: Whether or not Serial Console is disabled (enabled). + :vartype disabled: bool """ _attribute_map = { @@ -90,6 +107,10 @@ def __init__( disabled: Optional[bool] = None, **kwargs ): + """ + :keyword disabled: Whether or not Serial Console is disabled (enabled). + :paramtype disabled: bool + """ super(EnableSerialConsoleResult, self).__init__(**kwargs) self.disabled = disabled @@ -97,10 +118,10 @@ def __init__( class GetSerialConsoleSubscriptionNotFound(msrest.serialization.Model): """Error saying that the provided subscription could not be found. - :param code: Error code. - :type code: str - :param message: Subscription not found message. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Subscription not found message. + :vartype message: str """ _attribute_map = { @@ -115,6 +136,12 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Subscription not found message. + :paramtype message: str + """ super(GetSerialConsoleSubscriptionNotFound, self).__init__(**kwargs) self.code = code self.message = message @@ -149,6 +176,8 @@ def __init__( self, **kwargs ): + """ + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -184,14 +213,16 @@ def __init__( self, **kwargs ): + """ + """ super(ProxyResource, self).__init__(**kwargs) class SerialConsoleOperations(msrest.serialization.Model): """Serial Console operations. - :param value: A list of Serial Console operations. - :type value: list[~azure.mgmt.serialconsole.models.SerialConsoleOperationsValueItem] + :ivar value: A list of Serial Console operations. + :vartype value: list[~azure.mgmt.serialconsole.models.SerialConsoleOperationsValueItem] """ _attribute_map = { @@ -204,6 +235,10 @@ def __init__( value: Optional[List["SerialConsoleOperationsValueItem"]] = None, **kwargs ): + """ + :keyword value: A list of Serial Console operations. + :paramtype value: list[~azure.mgmt.serialconsole.models.SerialConsoleOperationsValueItem] + """ super(SerialConsoleOperations, self).__init__(**kwargs) self.value = value @@ -211,12 +246,12 @@ def __init__( class SerialConsoleOperationsValueItem(msrest.serialization.Model): """SerialConsoleOperationsValueItem. - :param name: - :type name: str - :param is_data_action: - :type is_data_action: str - :param display: - :type display: ~azure.mgmt.serialconsole.models.SerialConsoleOperationsValueItemDisplay + :ivar name: + :vartype name: str + :ivar is_data_action: + :vartype is_data_action: str + :ivar display: + :vartype display: ~azure.mgmt.serialconsole.models.SerialConsoleOperationsValueItemDisplay """ _attribute_map = { @@ -233,6 +268,14 @@ def __init__( display: Optional["SerialConsoleOperationsValueItemDisplay"] = None, **kwargs ): + """ + :keyword name: + :paramtype name: str + :keyword is_data_action: + :paramtype is_data_action: str + :keyword display: + :paramtype display: ~azure.mgmt.serialconsole.models.SerialConsoleOperationsValueItemDisplay + """ super(SerialConsoleOperationsValueItem, self).__init__(**kwargs) self.name = name self.is_data_action = is_data_action @@ -242,14 +285,14 @@ def __init__( class SerialConsoleOperationsValueItemDisplay(msrest.serialization.Model): """SerialConsoleOperationsValueItemDisplay. - :param provider: - :type provider: str - :param resource: - :type resource: str - :param operation: - :type operation: str - :param description: - :type description: str + :ivar provider: + :vartype provider: str + :ivar resource: + :vartype resource: str + :ivar operation: + :vartype operation: str + :ivar description: + :vartype description: str """ _attribute_map = { @@ -268,6 +311,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword provider: + :paramtype provider: str + :keyword resource: + :paramtype resource: str + :keyword operation: + :paramtype operation: str + :keyword description: + :paramtype description: str + """ super(SerialConsoleOperationsValueItemDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -278,8 +331,8 @@ def __init__( class SerialConsoleStatus(msrest.serialization.Model): """Returns whether or not Serial Console is disabled. - :param disabled: Whether or not Serial Console is disabled. - :type disabled: bool + :ivar disabled: Whether or not Serial Console is disabled. + :vartype disabled: bool """ _attribute_map = { @@ -292,6 +345,10 @@ def __init__( disabled: Optional[bool] = None, **kwargs ): + """ + :keyword disabled: Whether or not Serial Console is disabled. + :paramtype disabled: bool + """ super(SerialConsoleStatus, self).__init__(**kwargs) self.disabled = disabled @@ -307,9 +364,9 @@ class SerialPort(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param state: Specifies whether the port is enabled for a serial console connection. Possible + :ivar 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 + :vartype state: str or ~azure.mgmt.serialconsole.models.SerialPortState """ _validation = { @@ -331,6 +388,11 @@ def __init__( state: Optional[Union[str, "SerialPortState"]] = None, **kwargs ): + """ + :keyword state: Specifies whether the port is enabled for a serial console connection. Possible + values include: "enabled", "disabled". + :paramtype state: str or ~azure.mgmt.serialconsole.models.SerialPortState + """ super(SerialPort, self).__init__(**kwargs) self.state = state @@ -338,8 +400,8 @@ def __init__( 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 + :ivar connection_string: Connection string to the serial port of the resource. + :vartype connection_string: str """ _attribute_map = { @@ -352,6 +414,10 @@ def __init__( connection_string: Optional[str] = None, **kwargs ): + """ + :keyword connection_string: Connection string to the serial port of the resource. + :paramtype connection_string: str + """ super(SerialPortConnectResult, self).__init__(**kwargs) self.connection_string = connection_string @@ -359,8 +425,8 @@ def __init__( 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] + :ivar value: The list of serial ports. + :vartype value: list[~azure.mgmt.serialconsole.models.SerialPort] """ _attribute_map = { @@ -373,5 +439,9 @@ def __init__( value: Optional[List["SerialPort"]] = None, **kwargs ): + """ + :keyword value: The list of serial ports. + :paramtype value: list[~azure.mgmt.serialconsole.models.SerialPort] + """ super(SerialPortListResult, self).__init__(**kwargs) self.value = value diff --git a/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/operations/_microsoft_serial_console_client_operations.py b/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/operations/_microsoft_serial_console_client_operations.py index e40f214e1823..ac8182f0072c 100644 --- a/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/operations/_microsoft_serial_console_client_operations.py +++ b/sdk/serialconsole/azure-mgmt-serialconsole/azure/mgmt/serialconsole/operations/_microsoft_serial_console_client_operations.py @@ -5,30 +5,156 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_operations_request( + **kwargs: Any +) -> HttpRequest: + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.SerialConsole/operations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_console_status_request( + subscription_id: str, + default: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.SerialConsole/consoleServices/{default}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "default": _SERIALIZER.url("default", default, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_disable_console_request( + subscription_id: str, + default: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.SerialConsole/consoleServices/{default}/disableConsole') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "default": _SERIALIZER.url("default", default, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_enable_console_request( + subscription_id: str, + default: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.SerialConsole/consoleServices/{default}/enableConsole') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "default": _SERIALIZER.url("default", default, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class MicrosoftSerialConsoleClientOperationsMixin(object): + @distributed_trace def list_operations( self, - **kwargs # type: Any - ): - # type: (...) -> "_models.SerialConsoleOperations" + **kwargs: Any + ) -> "_models.SerialConsoleOperations": """Gets a list of Serial Console API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -41,21 +167,14 @@ def list_operations( 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_operations.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 = build_list_operations_request( + template_url=self.list_operations.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # 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 @@ -69,14 +188,16 @@ def list_operations( return cls(pipeline_response, deserialized, {}) return deserialized + list_operations.metadata = {'url': '/providers/Microsoft.SerialConsole/operations'} # type: ignore + + @distributed_trace def get_console_status( self, - default, # type: str - **kwargs # type: Any - ): - # type: (...) -> Union["_models.SerialConsoleStatus", "_models.GetSerialConsoleSubscriptionNotFound"] + default: str, + **kwargs: Any + ) -> Union["_models.SerialConsoleStatus", "_models.GetSerialConsoleSubscriptionNotFound"]: """Get the disabled status for a subscription. Gets whether or not Serial Console is disabled for a given subscription. @@ -84,8 +205,10 @@ def get_console_status( :param default: Default parameter. Leave the value as "default". :type default: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SerialConsoleStatus or GetSerialConsoleSubscriptionNotFound, or the result of cls(response) - :rtype: ~azure.mgmt.serialconsole.models.SerialConsoleStatus or ~azure.mgmt.serialconsole.models.GetSerialConsoleSubscriptionNotFound + :return: SerialConsoleStatus or GetSerialConsoleSubscriptionNotFound, or the result of + cls(response) + :rtype: ~azure.mgmt.serialconsole.models.SerialConsoleStatus or + ~azure.mgmt.serialconsole.models.GetSerialConsoleSubscriptionNotFound :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.SerialConsoleStatus", "_models.GetSerialConsoleSubscriptionNotFound"]] @@ -93,26 +216,16 @@ def get_console_status( 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_console_status.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'default': self._serialize.url("default", default, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_console_status_request( + subscription_id=self._config.subscription_id, + default=default, + template_url=self.get_console_status.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # 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 @@ -130,14 +243,16 @@ def get_console_status( return cls(pipeline_response, deserialized, {}) return deserialized + get_console_status.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.SerialConsole/consoleServices/{default}'} # type: ignore + + @distributed_trace def disable_console( self, - default, # type: str - **kwargs # type: Any - ): - # type: (...) -> Union["_models.DisableSerialConsoleResult", "_models.GetSerialConsoleSubscriptionNotFound"] + default: str, + **kwargs: Any + ) -> Union["_models.DisableSerialConsoleResult", "_models.GetSerialConsoleSubscriptionNotFound"]: """Disable Serial Console for a subscription. Disables the Serial Console service for all VMs and VM scale sets in the provided subscription. @@ -145,8 +260,10 @@ def disable_console( :param default: Default parameter. Leave the value as "default". :type default: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DisableSerialConsoleResult or GetSerialConsoleSubscriptionNotFound, or the result of cls(response) - :rtype: ~azure.mgmt.serialconsole.models.DisableSerialConsoleResult or ~azure.mgmt.serialconsole.models.GetSerialConsoleSubscriptionNotFound + :return: DisableSerialConsoleResult or GetSerialConsoleSubscriptionNotFound, or the result of + cls(response) + :rtype: ~azure.mgmt.serialconsole.models.DisableSerialConsoleResult or + ~azure.mgmt.serialconsole.models.GetSerialConsoleSubscriptionNotFound :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.DisableSerialConsoleResult", "_models.GetSerialConsoleSubscriptionNotFound"]] @@ -154,26 +271,16 @@ def disable_console( 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.disable_console.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'default': self._serialize.url("default", default, '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 = build_disable_console_request( + subscription_id=self._config.subscription_id, + default=default, + template_url=self.disable_console.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -191,14 +298,16 @@ def disable_console( return cls(pipeline_response, deserialized, {}) return deserialized + disable_console.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.SerialConsole/consoleServices/{default}/disableConsole'} # type: ignore + + @distributed_trace def enable_console( self, - default, # type: str - **kwargs # type: Any - ): - # type: (...) -> Union["_models.EnableSerialConsoleResult", "_models.GetSerialConsoleSubscriptionNotFound"] + default: str, + **kwargs: Any + ) -> Union["_models.EnableSerialConsoleResult", "_models.GetSerialConsoleSubscriptionNotFound"]: """Enable Serial Console for a subscription. Enables the Serial Console service for all VMs and VM scale sets in the provided subscription. @@ -206,8 +315,10 @@ def enable_console( :param default: Default parameter. Leave the value as "default". :type default: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EnableSerialConsoleResult or GetSerialConsoleSubscriptionNotFound, or the result of cls(response) - :rtype: ~azure.mgmt.serialconsole.models.EnableSerialConsoleResult or ~azure.mgmt.serialconsole.models.GetSerialConsoleSubscriptionNotFound + :return: EnableSerialConsoleResult or GetSerialConsoleSubscriptionNotFound, or the result of + cls(response) + :rtype: ~azure.mgmt.serialconsole.models.EnableSerialConsoleResult or + ~azure.mgmt.serialconsole.models.GetSerialConsoleSubscriptionNotFound :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.EnableSerialConsoleResult", "_models.GetSerialConsoleSubscriptionNotFound"]] @@ -215,26 +326,16 @@ def enable_console( 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.enable_console.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'default': self._serialize.url("default", default, '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 = build_enable_console_request( + subscription_id=self._config.subscription_id, + default=default, + template_url=self.enable_console.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -252,4 +353,6 @@ def enable_console( return cls(pipeline_response, deserialized, {}) return deserialized + enable_console.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.SerialConsole/consoleServices/{default}/enableConsole'} # type: ignore + 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 index 20decfe90584..4f1414fb5804 100644 --- 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 @@ -5,22 +5,262 @@ # 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 functools +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 HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer 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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_type: str, + parent_resource: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourceType}/{parentResource}/providers/Microsoft.SerialConsole/serialPorts') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourceType": _SERIALIZER.url("parent_resource_type", parent_resource_type, 'str', skip_quote=True), + "parentResource": _SERIALIZER.url("parent_resource", parent_resource, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_type: str, + parent_resource: str, + serial_port: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourceType}/{parentResource}/providers/Microsoft.SerialConsole/serialPorts/{serialPort}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourceType": _SERIALIZER.url("parent_resource_type", parent_resource_type, 'str', skip_quote=True), + "parentResource": _SERIALIZER.url("parent_resource", parent_resource, 'str'), + "serialPort": _SERIALIZER.url("serial_port", serial_port, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_request( + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_type: str, + parent_resource: str, + serial_port: str, + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourceType}/{parentResource}/providers/Microsoft.SerialConsole/serialPorts/{serialPort}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourceType": _SERIALIZER.url("parent_resource_type", parent_resource_type, 'str', skip_quote=True), + "parentResource": _SERIALIZER.url("parent_resource", parent_resource, 'str'), + "serialPort": _SERIALIZER.url("serial_port", serial_port, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_type: str, + parent_resource: str, + serial_port: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourceType}/{parentResource}/providers/Microsoft.SerialConsole/serialPorts/{serialPort}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourceType": _SERIALIZER.url("parent_resource_type", parent_resource_type, 'str', skip_quote=True), + "parentResource": _SERIALIZER.url("parent_resource", parent_resource, 'str'), + "serialPort": _SERIALIZER.url("serial_port", serial_port, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_subscriptions_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.SerialConsole/serialPorts') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + headers=header_parameters, + **kwargs + ) + + +def build_connect_request( + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_type: str, + parent_resource: str, + serial_port: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-05-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourceType}/{parentResource}/providers/Microsoft.SerialConsole/serialPorts/{serialPort}/connect') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "resourceProviderNamespace": _SERIALIZER.url("resource_provider_namespace", resource_provider_namespace, 'str'), + "parentResourceType": _SERIALIZER.url("parent_resource_type", parent_resource_type, 'str', skip_quote=True), + "parentResource": _SERIALIZER.url("parent_resource", parent_resource, 'str'), + "serialPort": _SERIALIZER.url("serial_port", serial_port, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class SerialPortsOperations(object): """SerialPortsOperations operations. @@ -44,15 +284,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace 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" + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_type: str, + parent_resource: str, + **kwargs: Any + ) -> "_models.SerialPortListResult": """Lists all of the configured serial ports for a parent resource. :param resource_group_name: The name of the resource group. @@ -75,29 +315,19 @@ def list( 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 = build_list_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_type=parent_resource_type, + parent_resource=parent_resource, + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -111,18 +341,20 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourceType}/{parentResource}/providers/Microsoft.SerialConsole/serialPorts'} # type: ignore + + @distributed_trace 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" + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_type: str, + parent_resource: str, + serial_port: str, + **kwargs: Any + ) -> "_models.SerialPort": """Gets the configured settings for a serial port. :param resource_group_name: The name of the resource group. @@ -147,30 +379,20 @@ def get( 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') + + request = build_get_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_type=parent_resource_type, + parent_resource=parent_resource, + serial_port=serial_port, + subscription_id=self._config.subscription_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # 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 @@ -184,19 +406,21 @@ def get( 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 + + @distributed_trace 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" + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_type: str, + parent_resource: str, + serial_port: str, + parameters: "_models.SerialPort", + **kwargs: Any + ) -> "_models.SerialPort": """Creates or updates a serial port. :param resource_group_name: The name of the resource group. @@ -223,35 +447,25 @@ def create( 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SerialPort') - # 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') + request = build_create_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_type=parent_resource_type, + parent_resource=parent_resource, + serial_port=serial_port, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.create.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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 @@ -265,18 +479,20 @@ def create( 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 + + @distributed_trace 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 + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_type: str, + parent_resource: str, + serial_port: str, + **kwargs: Any + ) -> None: """Deletes a serial port. :param resource_group_name: The name of the resource group. @@ -301,30 +517,20 @@ def delete( 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') + + request = build_delete_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_type=parent_resource_type, + parent_resource=parent_resource, + serial_port=serial_port, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # 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 @@ -337,11 +543,12 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourceType}/{parentResource}/providers/Microsoft.SerialConsole/serialPorts/{serialPort}'} # type: ignore + + @distributed_trace def list_by_subscriptions( self, - **kwargs # type: Any - ): - # type: (...) -> "_models.SerialPortListResult" + **kwargs: Any + ) -> "_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 @@ -354,23 +561,15 @@ def list_by_subscriptions( 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 = build_list_by_subscriptions_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscriptions.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -384,18 +583,20 @@ def list_by_subscriptions( return cls(pipeline_response, deserialized, {}) return deserialized + list_by_subscriptions.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.SerialConsole/serialPorts'} # type: ignore + + @distributed_trace 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" + resource_group_name: str, + resource_provider_namespace: str, + parent_resource_type: str, + parent_resource: str, + serial_port: str, + **kwargs: Any + ) -> "_models.SerialPortConnectResult": """Connect to serial port of the target resource. :param resource_group_name: The name of the resource group. @@ -420,30 +621,20 @@ def connect( 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') + + request = build_connect_request( + resource_group_name=resource_group_name, + resource_provider_namespace=resource_provider_namespace, + parent_resource_type=parent_resource_type, + parent_resource=parent_resource, + serial_port=serial_port, + subscription_id=self._config.subscription_id, + template_url=self.connect.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # 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 @@ -457,4 +648,6 @@ def connect( 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 +