diff --git a/autorest/codegen/models/code_model.py b/autorest/codegen/models/code_model.py index f50ecb11f14..047e0250ca4 100644 --- a/autorest/codegen/models/code_model.py +++ b/autorest/codegen/models/code_model.py @@ -352,3 +352,9 @@ def has_lro_operations(self) -> bool: for operation_group in self.operation_groups for operation in operation_group.operations ]) + + @staticmethod + def base_url_method_signature(async_mode: bool) -> str: + if async_mode: + return "base_url: Optional[str] = None," + return "base_url=None, # type: Optional[str]" diff --git a/autorest/codegen/templates/metadata.json.jinja2 b/autorest/codegen/templates/metadata.json.jinja2 index 7585bd97bdb..4650c753af0 100644 --- a/autorest/codegen/templates/metadata.json.jinja2 +++ b/autorest/codegen/templates/metadata.json.jinja2 @@ -7,7 +7,7 @@ "name": {{ code_model.class_name | tojson }}, "filename": {{ ("_" + code_model.module_name) | tojson }}, "description": {{ code_model.description | tojson }}, - "base_url": {{ (keywords.escape_str(code_model.base_url) if base_url else None) | tojson }}, + "base_url": {{ (keywords.escape_str(code_model.base_url) if code_model.base_url else None) | tojson }}, "custom_base_url": {{ (keywords.escape_str(code_model.custom_base_url) if code_model.custom_base_url else None) | tojson }}, "azure_arm": {{ code_model.options["azure_arm"] | tojson }}, "has_lro_operations": {{ code_model.has_lro_operations | tojson }}, @@ -44,9 +44,15 @@ "call": {{ code_model.global_parameters.method | map(attribute="serialized_name") | join(', ') | tojson }}, "service_client_specific": { "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, {% if not code_model.custom_base_url %} "base_url": { - "signature": {{ code_model.base_url_parameter(False) | tojson }}, + "signature": {{ code_model.base_url_method_signature(False) | tojson }}, "description": "Service URL", "docstring_type": "str", "required": {{ code_model.required_base_url | tojson }} @@ -57,34 +63,28 @@ "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", "required": false - }, + } + }, + "async": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str] = None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", "required": false - } - }, - "async": { + }, {% if not code_model.custom_base_url %} "base_url": { - "signature": {{ code_model.base_url_parameter(True) | tojson }}, + "signature": {{ code_model.base_url_method_signature(True) | tojson }}, "description": "Service URL", "docstring_type": "str", "required": {{ code_model.required_base_url | tojson }} }, {% endif %} "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles = KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", "required": false - }, - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false } } } diff --git a/autorest/codegen/templates/service_client.py.jinja2 b/autorest/codegen/templates/service_client.py.jinja2 index 66df0692261..2ab1a160757 100644 --- a/autorest/codegen/templates/service_client.py.jinja2 +++ b/autorest/codegen/templates/service_client.py.jinja2 @@ -7,8 +7,8 @@ def __init__( {% for param_signature in code_model.global_parameters.async_method_signature %} {{ param_signature }}, {% endfor %} - {% if code_model.base_url or code_model.required_base_url %} - {{ code_model.base_url_parameter(True) }} + {% if not code_model.custom_base_url %} + {{ code_model.base_url_method_signature(True) }} {% endif %} **kwargs: Any {% else %} @@ -16,7 +16,7 @@ def __init__( {{ param_signature }} {% endfor %} {% if not code_model.custom_base_url %} - {{ code_model.base_url_parameter(False) }} + {{ code_model.base_url_method_signature(False) }} {% endif %} **kwargs # type: Any {% endif %} diff --git a/autorest/multiapi/models/code_model.py b/autorest/multiapi/models/code_model.py index c5f982f1b53..d8f8d39b2cc 100644 --- a/autorest/multiapi/models/code_model.py +++ b/autorest/multiapi/models/code_model.py @@ -37,7 +37,7 @@ def __init__( self.config = Config(default_version_metadata) self.operation_mixin_group = OperationMixinGroup(version_path_to_metadata, default_api_version) self.global_parameters = GlobalParameters( - default_version_metadata["global_parameters"], self.service_client + default_version_metadata["global_parameters"] ) self.user_specified_default_api = user_specified_default_api diff --git a/autorest/multiapi/models/global_parameters.py b/autorest/multiapi/models/global_parameters.py index dab16f196e6..0f28127eaa7 100644 --- a/autorest/multiapi/models/global_parameters.py +++ b/autorest/multiapi/models/global_parameters.py @@ -3,19 +3,28 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- -from typing import Any, Dict, List, Optional +from typing import Any, Dict, List from .global_parameter import GlobalParameter from .constant_global_parameter import ConstantGlobalParameter +def _convert_global_parameters(sync_metadata, async_metadata): + global_parameters = [ + GlobalParameter( + name=parameter_name, + global_parameter_metadata_sync=gp_sync, + global_parameter_metadata_async=async_metadata[parameter_name] + ) + for parameter_name, gp_sync in sync_metadata.items() + ] + return global_parameters + class GlobalParameters: def __init__( self, global_parameters_metadata: Dict[str, Any], - service_client, ): self.call = global_parameters_metadata["call"] self.global_parameters_metadata = global_parameters_metadata - self.service_client = service_client @property def service_client_specific_global_parameters(self) -> List[GlobalParameter]: @@ -25,7 +34,7 @@ def service_client_specific_global_parameters(self) -> List[GlobalParameter]: service_client_params_sync = self.global_parameters_metadata["service_client_specific"]["sync"] service_client_params_async = self.global_parameters_metadata["service_client_specific"]["async"] - return self._convert_global_parameters( + return _convert_global_parameters( service_client_params_sync, service_client_params_async ) @@ -35,22 +44,11 @@ def parameters(self) -> List[GlobalParameter]: global_parameters_metadata_sync = self.global_parameters_metadata["sync"] global_parameters_metadata_async = self.global_parameters_metadata["async"] - return self._convert_global_parameters( + return _convert_global_parameters( global_parameters_metadata_sync, global_parameters_metadata_async ) - def _convert_global_parameters(self, sync_metadata, async_metadata): - global_parameters = [ - GlobalParameter( - name=parameter_name, - global_parameter_metadata_sync=gp_sync, - global_parameter_metadata_async=async_metadata[parameter_name] - ) - for parameter_name, gp_sync in sync_metadata.items() - ] - return global_parameters - @property def constant_parameters(self) -> List[ConstantGlobalParameter]: return [ diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/_multiapi_service_client.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/_multiapi_service_client.py index c384468a23b..64c0e839758 100644 --- a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/_multiapi_service_client.py +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/_multiapi_service_client.py @@ -45,12 +45,12 @@ class MultiapiServiceClient(MultiapiServiceClientOperationsMixin, MultiApiClient :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential + :param api_version: API version to use if no profile is provided, or if missing in profile. + :type api_version: str :param base_url: Service URL :type base_url: str :param profile: A profile definition, from KnownProfiles to dict. :type profile: azure.profiles.KnownProfiles - :param api_version: API version to use if no profile is provided, or if missing in profile. - :type api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -69,11 +69,13 @@ class MultiapiServiceClient(MultiapiServiceClientOperationsMixin, MultiApiClient def __init__( self, credential, # type: "TokenCredential" + api_version=None, # type: Optional[str] base_url=None, # type: Optional[str] profile=KnownProfiles.default, # type: KnownProfiles - api_version=None, # type: Optional[str] **kwargs # type: Any ): + if not base_url: + base_url = 'http://localhost:3000' self._config = MultiapiServiceClientConfiguration(credential, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) super(MultiapiServiceClient, self).__init__( diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/aio/_multiapi_service_client.py b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/aio/_multiapi_service_client.py index 8f34a8507eb..fba5def7cef 100644 --- a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/aio/_multiapi_service_client.py +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/aio/_multiapi_service_client.py @@ -43,12 +43,12 @@ class MultiapiServiceClient(MultiapiServiceClientOperationsMixin, MultiApiClient :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param api_version: API version to use if no profile is provided, or if missing in profile. + :type api_version: str :param base_url: Service URL :type base_url: str :param profile: A profile definition, from KnownProfiles to dict. :type profile: azure.profiles.KnownProfiles - :param api_version: API version to use if no profile is provided, or if missing in profile. - :type api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -67,11 +67,13 @@ class MultiapiServiceClient(MultiapiServiceClientOperationsMixin, MultiApiClient def __init__( self, credential: "AsyncTokenCredential", - base_url: Optional[str] = None, - profile=KnownProfiles.default, # type: KnownProfiles api_version: Optional[str] = None, + base_url: Optional[str] = None, + profile: KnownProfiles = KnownProfiles.default, **kwargs # type: Any ) -> None: + if not base_url: + base_url = 'http://localhost:3000' self._config = MultiapiServiceClientConfiguration(credential, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) super(MultiapiServiceClient, self).__init__( diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_metadata.json b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_metadata.json index fc6e751c20c..5255ff98e91 100644 --- a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_metadata.json +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v1/_metadata.json @@ -5,7 +5,7 @@ "name": "MultiapiServiceClient", "filename": "_multiapi_service_client", "description": "Service client for multiapi client testing.", - "base_url": null, + "base_url": "\u0027http://localhost:3000\u0027", "custom_base_url": null, "azure_arm": true, "has_lro_operations": true, @@ -35,6 +35,12 @@ "call": "credential", "service_client_specific": { "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, "base_url": { "signature": "base_url=None, # type: Optional[str]", "description": "Service URL", @@ -46,15 +52,15 @@ "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", "required": false - }, + } + }, + "async": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str] = None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", "required": false - } - }, - "async": { + }, "base_url": { "signature": "base_url: Optional[str] = None,", "description": "Service URL", @@ -62,16 +68,10 @@ "required": false }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles = KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", "required": false - }, - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false } } } diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_metadata.json b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_metadata.json index 1559308d59c..bf39e335b32 100644 --- a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_metadata.json +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v2/_metadata.json @@ -5,7 +5,7 @@ "name": "MultiapiServiceClient", "filename": "_multiapi_service_client", "description": "Service client for multiapi client testing.", - "base_url": null, + "base_url": "\u0027http://localhost:3000\u0027", "custom_base_url": null, "azure_arm": true, "has_lro_operations": false, @@ -35,6 +35,12 @@ "call": "credential", "service_client_specific": { "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, "base_url": { "signature": "base_url=None, # type: Optional[str]", "description": "Service URL", @@ -46,15 +52,15 @@ "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", "required": false - }, + } + }, + "async": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str] = None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", "required": false - } - }, - "async": { + }, "base_url": { "signature": "base_url: Optional[str] = None,", "description": "Service URL", @@ -62,16 +68,10 @@ "required": false }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles = KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", "required": false - }, - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false } } } diff --git a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_metadata.json b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_metadata.json index b061f92ddc1..5907dc23b37 100644 --- a/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_metadata.json +++ b/docs/samples/specification/multiapi/generated/azure/multiapi/sample/v3/_metadata.json @@ -5,7 +5,7 @@ "name": "MultiapiServiceClient", "filename": "_multiapi_service_client", "description": "Service client for multiapi client testing.", - "base_url": null, + "base_url": "\u0027http://localhost:3000\u0027", "custom_base_url": null, "azure_arm": true, "has_lro_operations": false, @@ -35,6 +35,12 @@ "call": "credential", "service_client_specific": { "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, "base_url": { "signature": "base_url=None, # type: Optional[str]", "description": "Service URL", @@ -46,15 +52,15 @@ "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", "required": false - }, + } + }, + "async": { "api_version": { - "signature": "api_version=None, # type: Optional[str]", + "signature": "api_version: Optional[str] = None,", "description": "API version to use if no profile is provided, or if missing in profile.", "docstring_type": "str", "required": false - } - }, - "async": { + }, "base_url": { "signature": "base_url: Optional[str] = None,", "description": "Service URL", @@ -62,16 +68,10 @@ "required": false }, "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "signature": "profile: KnownProfiles = KnownProfiles.default,", "description": "A profile definition, from KnownProfiles to dict.", "docstring_type": "azure.profiles.KnownProfiles", "required": false - }, - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false } } } diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/_multiapi_service_client.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/_multiapi_service_client.py index 803c93344bd..0a4d67eed69 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/_multiapi_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/_multiapi_service_client.py @@ -70,7 +70,7 @@ def __init__( self, credential, # type: "TokenCredential" api_version=None, # type: Optional[str] - base_url=None, # type: Optional[str] + base_url=None, # type: Optional[str] profile=KnownProfiles.default, # type: KnownProfiles **kwargs # type: Any ): diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/_operations_mixin.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/_operations_mixin.py index ff2c491ec30..3a2656fd4d4 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/_operations_mixin.py +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/_operations_mixin.py @@ -94,6 +94,43 @@ def begin_test_lro_and_paging( mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) return mixin_instance.begin_test_lro_and_paging(client_request_id, test_lro_and_paging_options, **kwargs) + def test_different_calls( + self, + greeting_in_english, # type: str + greeting_in_chinese=None, # type: Optional[str] + greeting_in_french=None, # type: Optional[str] + **kwargs # type: Any + ): + """Has added parameters across the API versions. + + :param greeting_in_english: pass in 'hello' to pass test. + :type greeting_in_english: str + :param greeting_in_chinese: pass in 'nihao' to pass test. + :type greeting_in_chinese: str + :param greeting_in_french: pass in 'bonjour' to pass test. + :type greeting_in_french: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = self._get_api_version('test_different_calls') + if api_version == '1.0.0': + from .v1.operations import MultiapiServiceClientOperationsMixin as OperationClass + elif api_version == '2.0.0': + from .v2.operations import MultiapiServiceClientOperationsMixin as OperationClass + elif api_version == '3.0.0': + from .v3.operations import MultiapiServiceClientOperationsMixin as OperationClass + else: + raise ValueError("API version {} does not have operation 'test_different_calls'".format(api_version)) + mixin_instance = OperationClass() + mixin_instance._client = self._client + mixin_instance._config = self._config + mixin_instance._serialize = Serializer(self._models_dict(api_version)) + mixin_instance._serialize.client_side_validation = False + mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) + return mixin_instance.test_different_calls(greeting_in_english, greeting_in_chinese, greeting_in_french, **kwargs) + def test_one( self, id, # type: int diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/aio/_operations_mixin.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/aio/_operations_mixin.py index 9da82b4c68f..33e2d3b621a 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/aio/_operations_mixin.py +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/aio/_operations_mixin.py @@ -90,6 +90,43 @@ def begin_test_lro_and_paging( mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) return mixin_instance.begin_test_lro_and_paging(client_request_id, test_lro_and_paging_options, **kwargs) + async def test_different_calls( + self, + greeting_in_english: str, + greeting_in_chinese: Optional[str] = None, + greeting_in_french: Optional[str] = None, + **kwargs + ) -> None: + """Has added parameters across the API versions. + + :param greeting_in_english: pass in 'hello' to pass test. + :type greeting_in_english: str + :param greeting_in_chinese: pass in 'nihao' to pass test. + :type greeting_in_chinese: str + :param greeting_in_french: pass in 'bonjour' to pass test. + :type greeting_in_french: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = self._get_api_version('test_different_calls') + if api_version == '1.0.0': + from ..v1.aio.operations import MultiapiServiceClientOperationsMixin as OperationClass + elif api_version == '2.0.0': + from ..v2.aio.operations import MultiapiServiceClientOperationsMixin as OperationClass + elif api_version == '3.0.0': + from ..v3.aio.operations import MultiapiServiceClientOperationsMixin as OperationClass + else: + raise ValueError("API version {} does not have operation 'test_different_calls'".format(api_version)) + mixin_instance = OperationClass() + mixin_instance._client = self._client + mixin_instance._config = self._config + mixin_instance._serialize = Serializer(self._models_dict(api_version)) + mixin_instance._serialize.client_side_validation = False + mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) + return await mixin_instance.test_different_calls(greeting_in_english, greeting_in_chinese, greeting_in_french, **kwargs) + async def test_one( self, id: int, diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/_metadata.json b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/_metadata.json index 3399a9712f4..9f96612a882 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/_metadata.json +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/_metadata.json @@ -32,7 +32,49 @@ }, "constant": { }, - "call": "credential" + "call": "credential", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=None, # type: Optional[str]", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: Optional[str] = None,", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } }, "config": { "credential": true, @@ -109,6 +151,18 @@ "doc": "\"\"\"A long-running paging operation that includes a nextLink that has 10 pages.\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options: ~multiapi.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: Pass in True if you\u0027d like the AsyncARMPolling polling method,\n False for no polling, or your own initialized polling object for a personal polling strategy.\n:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.\n:return: An instance of AsyncLROPoller that returns an iterator like instance of either PagingResult or the result of cls(response)\n:rtype: ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~multiapi.v1.models.PagingResult]]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"" }, "call": "client_request_id, test_lro_and_paging_options" + }, + "test_different_calls" : { + "sync": { + "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n **kwargs # type: Any\n):\n", + "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "async": { + "coroutine": true, + "signature": "async def test_different_calls(\n self,\n greeting_in_english: str,\n **kwargs\n) -\u003e None:\n", + "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "call": "greeting_in_english" } } } diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/aio/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/aio/operations/_multiapi_service_client_operations.py index 3bd2e191904..641fff82f7e 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/aio/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/aio/operations/_multiapi_service_client_operations.py @@ -351,3 +351,51 @@ async def internal_get_next(next_link=None): else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) begin_test_lro_and_paging.metadata = {'url': '/multiapi/lroAndPaging'} # type: ignore + + async def test_different_calls( + self, + greeting_in_english: str, + **kwargs + ) -> None: + """Has added parameters across the API versions. + + :param greeting_in_english: pass in 'hello' to pass test. + :type greeting_in_english: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0.0" + accept = "application/json" + + # Construct URL + url = self.test_different_calls.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['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/operations/_multiapi_service_client_operations.py index eec5b2cf81e..4e31fc821a1 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/operations/_multiapi_service_client_operations.py @@ -360,3 +360,52 @@ def internal_get_next(next_link=None): else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) begin_test_lro_and_paging.metadata = {'url': '/multiapi/lroAndPaging'} # type: ignore + + def test_different_calls( + self, + greeting_in_english, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Has added parameters across the API versions. + + :param greeting_in_english: pass in 'hello' to pass test. + :type greeting_in_english: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0.0" + accept = "application/json" + + # Construct URL + url = self.test_different_calls.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['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/_metadata.json b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/_metadata.json index d31f059352f..15e7d8d6dc5 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/_metadata.json +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/_metadata.json @@ -32,7 +32,49 @@ }, "constant": { }, - "call": "credential" + "call": "credential", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=None, # type: Optional[str]", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: Optional[str] = None,", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } }, "config": { "credential": true, @@ -62,6 +104,18 @@ "doc": "\"\"\"TestOne should be in an SecondVersionOperationsMixin. Returns ModelTwo.\n\n:param id: An int parameter.\n:type id: int\n:param message: An optional string parameter.\n:type message: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: ModelTwo, or the result of cls(response)\n:rtype: ~multiapi.v2.models.ModelTwo\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "id, message" + }, + "test_different_calls" : { + "sync": { + "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n greeting_in_chinese=None, # type: Optional[str]\n **kwargs # type: Any\n):\n", + "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:param greeting_in_chinese: pass in \u0027nihao\u0027 to pass test.\n:type greeting_in_chinese: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "async": { + "coroutine": true, + "signature": "async def test_different_calls(\n self,\n greeting_in_english: str,\n greeting_in_chinese: Optional[str] = None,\n **kwargs\n) -\u003e None:\n", + "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:param greeting_in_chinese: pass in \u0027nihao\u0027 to pass test.\n:type greeting_in_chinese: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "call": "greeting_in_english, greeting_in_chinese" } } } diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/aio/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/aio/operations/_multiapi_service_client_operations.py index 7b58e2d72b6..9cab2e9371c 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/aio/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/aio/operations/_multiapi_service_client_operations.py @@ -75,3 +75,56 @@ async def test_one( return deserialized test_one.metadata = {'url': '/multiapi/testOneEndpoint'} # type: ignore + + async def test_different_calls( + self, + greeting_in_english: str, + greeting_in_chinese: Optional[str] = None, + **kwargs + ) -> None: + """Has added parameters across the API versions. + + :param greeting_in_english: pass in 'hello' to pass test. + :type greeting_in_english: str + :param greeting_in_chinese: pass in 'nihao' to pass test. + :type greeting_in_chinese: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2.0.0" + accept = "application/json" + + # Construct URL + url = self.test_different_calls.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['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') + if greeting_in_chinese is not None: + header_parameters['greetingInChinese'] = self._serialize.header("greeting_in_chinese", greeting_in_chinese, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/operations/_multiapi_service_client_operations.py index 0ecd976c20c..1433a3e3e50 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v2/operations/_multiapi_service_client_operations.py @@ -80,3 +80,57 @@ def test_one( return deserialized test_one.metadata = {'url': '/multiapi/testOneEndpoint'} # type: ignore + + def test_different_calls( + self, + greeting_in_english, # type: str + greeting_in_chinese=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + """Has added parameters across the API versions. + + :param greeting_in_english: pass in 'hello' to pass test. + :type greeting_in_english: str + :param greeting_in_chinese: pass in 'nihao' to pass test. + :type greeting_in_chinese: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2.0.0" + accept = "application/json" + + # Construct URL + url = self.test_different_calls.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['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') + if greeting_in_chinese is not None: + header_parameters['greetingInChinese'] = self._serialize.header("greeting_in_chinese", greeting_in_chinese, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/_metadata.json b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/_metadata.json index e14154944b8..83a5d7ceb76 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/_metadata.json +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/_metadata.json @@ -32,7 +32,49 @@ }, "constant": { }, - "call": "credential" + "call": "credential", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=None, # type: Optional[str]", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: Optional[str] = None,", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } }, "config": { "credential": true, @@ -62,6 +104,18 @@ "doc": "\"\"\"Returns ModelThree with optionalProperty \u0027paged\u0027.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either PagingResult or the result of cls(response)\n:rtype: ~azure.core.async_paging.AsyncItemPaged[~multiapi.v3.models.PagingResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "" + }, + "test_different_calls" : { + "sync": { + "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n greeting_in_chinese=None, # type: Optional[str]\n greeting_in_french=None, # type: Optional[str]\n **kwargs # type: Any\n):\n", + "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:param greeting_in_chinese: pass in \u0027nihao\u0027 to pass test.\n:type greeting_in_chinese: str\n:param greeting_in_french: pass in \u0027bonjour\u0027 to pass test.\n:type greeting_in_french: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "async": { + "coroutine": true, + "signature": "async def test_different_calls(\n self,\n greeting_in_english: str,\n greeting_in_chinese: Optional[str] = None,\n greeting_in_french: Optional[str] = None,\n **kwargs\n) -\u003e None:\n", + "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:param greeting_in_chinese: pass in \u0027nihao\u0027 to pass test.\n:type greeting_in_chinese: str\n:param greeting_in_french: pass in \u0027bonjour\u0027 to pass test.\n:type greeting_in_french: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "call": "greeting_in_english, greeting_in_chinese, greeting_in_french" } } } diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/aio/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/aio/operations/_multiapi_service_client_operations.py index fe2e29297be..030d258ccc0 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/aio/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/aio/operations/_multiapi_service_client_operations.py @@ -80,3 +80,61 @@ async def get_next(next_link=None): get_next, extract_data ) test_paging.metadata = {'url': '/multiapi/paging'} # type: ignore + + async def test_different_calls( + self, + greeting_in_english: str, + greeting_in_chinese: Optional[str] = None, + greeting_in_french: Optional[str] = None, + **kwargs + ) -> None: + """Has added parameters across the API versions. + + :param greeting_in_english: pass in 'hello' to pass test. + :type greeting_in_english: str + :param greeting_in_chinese: pass in 'nihao' to pass test. + :type greeting_in_chinese: str + :param greeting_in_french: pass in 'bonjour' to pass test. + :type greeting_in_french: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "3.0.0" + accept = "application/json" + + # Construct URL + url = self.test_different_calls.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['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') + if greeting_in_chinese is not None: + header_parameters['greetingInChinese'] = self._serialize.header("greeting_in_chinese", greeting_in_chinese, 'str') + if greeting_in_french is not None: + header_parameters['greetingInFrench'] = self._serialize.header("greeting_in_french", greeting_in_french, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/operations/_multiapi_service_client_operations.py index e7cbd128f2a..3d7c604d642 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v3/operations/_multiapi_service_client_operations.py @@ -85,3 +85,62 @@ def get_next(next_link=None): get_next, extract_data ) test_paging.metadata = {'url': '/multiapi/paging'} # type: ignore + + def test_different_calls( + self, + greeting_in_english, # type: str + greeting_in_chinese=None, # type: Optional[str] + greeting_in_french=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + """Has added parameters across the API versions. + + :param greeting_in_english: pass in 'hello' to pass test. + :type greeting_in_english: str + :param greeting_in_chinese: pass in 'nihao' to pass test. + :type greeting_in_chinese: str + :param greeting_in_french: pass in 'bonjour' to pass test. + :type greeting_in_french: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "3.0.0" + accept = "application/json" + + # Construct URL + url = self.test_different_calls.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['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') + if greeting_in_chinese is not None: + header_parameters['greetingInChinese'] = self._serialize.header("greeting_in_chinese", greeting_in_chinese, 'str') + if greeting_in_french is not None: + header_parameters['greetingInFrench'] = self._serialize.header("greeting_in_french", greeting_in_french, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/_multiapi_service_client.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/_multiapi_service_client.py index 4ef364bef06..9067086b7bd 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/_multiapi_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/_multiapi_service_client.py @@ -70,7 +70,7 @@ def __init__( self, credential, # type: AzureKeyCredential api_version=None, # type: Optional[str] - base_url=None, # type: Optional[str] + base_url=None, # type: Optional[str] profile=KnownProfiles.default, # type: KnownProfiles **kwargs # type: Any ): diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/_operations_mixin.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/_operations_mixin.py index b0fd55e530b..8d8a03e8476 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/_operations_mixin.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/_operations_mixin.py @@ -94,6 +94,43 @@ def begin_test_lro_and_paging( mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) return mixin_instance.begin_test_lro_and_paging(client_request_id, test_lro_and_paging_options, **kwargs) + def test_different_calls( + self, + greeting_in_english, # type: str + greeting_in_chinese=None, # type: Optional[str] + greeting_in_french=None, # type: Optional[str] + **kwargs # type: Any + ): + """Has added parameters across the API versions. + + :param greeting_in_english: pass in 'hello' to pass test. + :type greeting_in_english: str + :param greeting_in_chinese: pass in 'nihao' to pass test. + :type greeting_in_chinese: str + :param greeting_in_french: pass in 'bonjour' to pass test. + :type greeting_in_french: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = self._get_api_version('test_different_calls') + if api_version == '1.0.0': + from .v1.operations import MultiapiServiceClientOperationsMixin as OperationClass + elif api_version == '2.0.0': + from .v2.operations import MultiapiServiceClientOperationsMixin as OperationClass + elif api_version == '3.0.0': + from .v3.operations import MultiapiServiceClientOperationsMixin as OperationClass + else: + raise ValueError("API version {} does not have operation 'test_different_calls'".format(api_version)) + mixin_instance = OperationClass() + mixin_instance._client = self._client + mixin_instance._config = self._config + mixin_instance._serialize = Serializer(self._models_dict(api_version)) + mixin_instance._serialize.client_side_validation = False + mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) + return mixin_instance.test_different_calls(greeting_in_english, greeting_in_chinese, greeting_in_french, **kwargs) + def test_one( self, id, # type: int diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/aio/_operations_mixin.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/aio/_operations_mixin.py index 224a66a26a3..13396ccb87d 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/aio/_operations_mixin.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/aio/_operations_mixin.py @@ -90,6 +90,43 @@ def begin_test_lro_and_paging( mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) return mixin_instance.begin_test_lro_and_paging(client_request_id, test_lro_and_paging_options, **kwargs) + async def test_different_calls( + self, + greeting_in_english: str, + greeting_in_chinese: Optional[str] = None, + greeting_in_french: Optional[str] = None, + **kwargs + ) -> None: + """Has added parameters across the API versions. + + :param greeting_in_english: pass in 'hello' to pass test. + :type greeting_in_english: str + :param greeting_in_chinese: pass in 'nihao' to pass test. + :type greeting_in_chinese: str + :param greeting_in_french: pass in 'bonjour' to pass test. + :type greeting_in_french: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = self._get_api_version('test_different_calls') + if api_version == '1.0.0': + from ..v1.aio.operations import MultiapiServiceClientOperationsMixin as OperationClass + elif api_version == '2.0.0': + from ..v2.aio.operations import MultiapiServiceClientOperationsMixin as OperationClass + elif api_version == '3.0.0': + from ..v3.aio.operations import MultiapiServiceClientOperationsMixin as OperationClass + else: + raise ValueError("API version {} does not have operation 'test_different_calls'".format(api_version)) + mixin_instance = OperationClass() + mixin_instance._client = self._client + mixin_instance._config = self._config + mixin_instance._serialize = Serializer(self._models_dict(api_version)) + mixin_instance._serialize.client_side_validation = False + mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) + return await mixin_instance.test_different_calls(greeting_in_english, greeting_in_chinese, greeting_in_french, **kwargs) + async def test_one( self, id: int, diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/_metadata.json b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/_metadata.json index c89ca583608..274d0b7d505 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/_metadata.json +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/_metadata.json @@ -32,7 +32,49 @@ }, "constant": { }, - "call": "credential" + "call": "credential", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=None, # type: Optional[str]", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: Optional[str] = None,", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } }, "config": { "credential": true, @@ -109,6 +151,18 @@ "doc": "\"\"\"A long-running paging operation that includes a nextLink that has 10 pages.\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options: ~multiapicredentialdefaultpolicy.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: Pass in True if you\u0027d like the AsyncARMPolling polling method,\n False for no polling, or your own initialized polling object for a personal polling strategy.\n:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.\n:return: An instance of AsyncLROPoller that returns an iterator like instance of either PagingResult or the result of cls(response)\n:rtype: ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~multiapicredentialdefaultpolicy.v1.models.PagingResult]]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"" }, "call": "client_request_id, test_lro_and_paging_options" + }, + "test_different_calls" : { + "sync": { + "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n **kwargs # type: Any\n):\n", + "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "async": { + "coroutine": true, + "signature": "async def test_different_calls(\n self,\n greeting_in_english: str,\n **kwargs\n) -\u003e None:\n", + "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "call": "greeting_in_english" } } } diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/aio/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/aio/operations/_multiapi_service_client_operations.py index 128aacb683a..3b9613d4bcb 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/aio/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/aio/operations/_multiapi_service_client_operations.py @@ -351,3 +351,51 @@ async def internal_get_next(next_link=None): else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) begin_test_lro_and_paging.metadata = {'url': '/multiapi/lroAndPaging'} # type: ignore + + async def test_different_calls( + self, + greeting_in_english: str, + **kwargs + ) -> None: + """Has added parameters across the API versions. + + :param greeting_in_english: pass in 'hello' to pass test. + :type greeting_in_english: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0.0" + accept = "application/json" + + # Construct URL + url = self.test_different_calls.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['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/operations/_multiapi_service_client_operations.py index d2676255942..589a7f427d6 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v1/operations/_multiapi_service_client_operations.py @@ -360,3 +360,52 @@ def internal_get_next(next_link=None): else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) begin_test_lro_and_paging.metadata = {'url': '/multiapi/lroAndPaging'} # type: ignore + + def test_different_calls( + self, + greeting_in_english, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Has added parameters across the API versions. + + :param greeting_in_english: pass in 'hello' to pass test. + :type greeting_in_english: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0.0" + accept = "application/json" + + # Construct URL + url = self.test_different_calls.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['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/_metadata.json b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/_metadata.json index ed3b13a2ddb..a0c37792c6b 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/_metadata.json +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/_metadata.json @@ -32,7 +32,49 @@ }, "constant": { }, - "call": "credential" + "call": "credential", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=None, # type: Optional[str]", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: Optional[str] = None,", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } }, "config": { "credential": true, @@ -62,6 +104,18 @@ "doc": "\"\"\"TestOne should be in an SecondVersionOperationsMixin. Returns ModelTwo.\n\n:param id: An int parameter.\n:type id: int\n:param message: An optional string parameter.\n:type message: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: ModelTwo, or the result of cls(response)\n:rtype: ~multiapicredentialdefaultpolicy.v2.models.ModelTwo\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "id, message" + }, + "test_different_calls" : { + "sync": { + "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n greeting_in_chinese=None, # type: Optional[str]\n **kwargs # type: Any\n):\n", + "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:param greeting_in_chinese: pass in \u0027nihao\u0027 to pass test.\n:type greeting_in_chinese: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "async": { + "coroutine": true, + "signature": "async def test_different_calls(\n self,\n greeting_in_english: str,\n greeting_in_chinese: Optional[str] = None,\n **kwargs\n) -\u003e None:\n", + "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:param greeting_in_chinese: pass in \u0027nihao\u0027 to pass test.\n:type greeting_in_chinese: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "call": "greeting_in_english, greeting_in_chinese" } } } diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/aio/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/aio/operations/_multiapi_service_client_operations.py index 44adccdbf51..d10ef391baf 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/aio/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/aio/operations/_multiapi_service_client_operations.py @@ -75,3 +75,56 @@ async def test_one( return deserialized test_one.metadata = {'url': '/multiapi/testOneEndpoint'} # type: ignore + + async def test_different_calls( + self, + greeting_in_english: str, + greeting_in_chinese: Optional[str] = None, + **kwargs + ) -> None: + """Has added parameters across the API versions. + + :param greeting_in_english: pass in 'hello' to pass test. + :type greeting_in_english: str + :param greeting_in_chinese: pass in 'nihao' to pass test. + :type greeting_in_chinese: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2.0.0" + accept = "application/json" + + # Construct URL + url = self.test_different_calls.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['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') + if greeting_in_chinese is not None: + header_parameters['greetingInChinese'] = self._serialize.header("greeting_in_chinese", greeting_in_chinese, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/operations/_multiapi_service_client_operations.py index a539c5cdd57..332dd5f94de 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v2/operations/_multiapi_service_client_operations.py @@ -80,3 +80,57 @@ def test_one( return deserialized test_one.metadata = {'url': '/multiapi/testOneEndpoint'} # type: ignore + + def test_different_calls( + self, + greeting_in_english, # type: str + greeting_in_chinese=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + """Has added parameters across the API versions. + + :param greeting_in_english: pass in 'hello' to pass test. + :type greeting_in_english: str + :param greeting_in_chinese: pass in 'nihao' to pass test. + :type greeting_in_chinese: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2.0.0" + accept = "application/json" + + # Construct URL + url = self.test_different_calls.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['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') + if greeting_in_chinese is not None: + header_parameters['greetingInChinese'] = self._serialize.header("greeting_in_chinese", greeting_in_chinese, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/_metadata.json b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/_metadata.json index 2cf3b3af30d..13b8b57410d 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/_metadata.json +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/_metadata.json @@ -32,7 +32,49 @@ }, "constant": { }, - "call": "credential" + "call": "credential", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=None, # type: Optional[str]", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: Optional[str] = None,", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } }, "config": { "credential": true, @@ -62,6 +104,18 @@ "doc": "\"\"\"Returns ModelThree with optionalProperty \u0027paged\u0027.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either PagingResult or the result of cls(response)\n:rtype: ~azure.core.async_paging.AsyncItemPaged[~multiapicredentialdefaultpolicy.v3.models.PagingResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "" + }, + "test_different_calls" : { + "sync": { + "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n greeting_in_chinese=None, # type: Optional[str]\n greeting_in_french=None, # type: Optional[str]\n **kwargs # type: Any\n):\n", + "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:param greeting_in_chinese: pass in \u0027nihao\u0027 to pass test.\n:type greeting_in_chinese: str\n:param greeting_in_french: pass in \u0027bonjour\u0027 to pass test.\n:type greeting_in_french: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "async": { + "coroutine": true, + "signature": "async def test_different_calls(\n self,\n greeting_in_english: str,\n greeting_in_chinese: Optional[str] = None,\n greeting_in_french: Optional[str] = None,\n **kwargs\n) -\u003e None:\n", + "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:param greeting_in_chinese: pass in \u0027nihao\u0027 to pass test.\n:type greeting_in_chinese: str\n:param greeting_in_french: pass in \u0027bonjour\u0027 to pass test.\n:type greeting_in_french: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "call": "greeting_in_english, greeting_in_chinese, greeting_in_french" } } } diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/aio/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/aio/operations/_multiapi_service_client_operations.py index 22f084ab3ff..483b67993a2 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/aio/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/aio/operations/_multiapi_service_client_operations.py @@ -80,3 +80,61 @@ async def get_next(next_link=None): get_next, extract_data ) test_paging.metadata = {'url': '/multiapi/paging'} # type: ignore + + async def test_different_calls( + self, + greeting_in_english: str, + greeting_in_chinese: Optional[str] = None, + greeting_in_french: Optional[str] = None, + **kwargs + ) -> None: + """Has added parameters across the API versions. + + :param greeting_in_english: pass in 'hello' to pass test. + :type greeting_in_english: str + :param greeting_in_chinese: pass in 'nihao' to pass test. + :type greeting_in_chinese: str + :param greeting_in_french: pass in 'bonjour' to pass test. + :type greeting_in_french: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "3.0.0" + accept = "application/json" + + # Construct URL + url = self.test_different_calls.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['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') + if greeting_in_chinese is not None: + header_parameters['greetingInChinese'] = self._serialize.header("greeting_in_chinese", greeting_in_chinese, 'str') + if greeting_in_french is not None: + header_parameters['greetingInFrench'] = self._serialize.header("greeting_in_french", greeting_in_french, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/operations/_multiapi_service_client_operations.py index 916245a09fc..5ae5ca68fa1 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCredentialDefaultPolicy/multiapicredentialdefaultpolicy/v3/operations/_multiapi_service_client_operations.py @@ -85,3 +85,62 @@ def get_next(next_link=None): get_next, extract_data ) test_paging.metadata = {'url': '/multiapi/paging'} # type: ignore + + def test_different_calls( + self, + greeting_in_english, # type: str + greeting_in_chinese=None, # type: Optional[str] + greeting_in_french=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + """Has added parameters across the API versions. + + :param greeting_in_english: pass in 'hello' to pass test. + :type greeting_in_english: str + :param greeting_in_chinese: pass in 'nihao' to pass test. + :type greeting_in_chinese: str + :param greeting_in_french: pass in 'bonjour' to pass test. + :type greeting_in_french: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "3.0.0" + accept = "application/json" + + # Construct URL + url = self.test_different_calls.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['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') + if greeting_in_chinese is not None: + header_parameters['greetingInChinese'] = self._serialize.header("greeting_in_chinese", greeting_in_chinese, 'str') + if greeting_in_french is not None: + header_parameters['greetingInFrench'] = self._serialize.header("greeting_in_french", greeting_in_french, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/_multiapi_custom_base_url_service_client.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/_multiapi_custom_base_url_service_client.py index ed569f49245..7f5fd04fd55 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/_multiapi_custom_base_url_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/_multiapi_custom_base_url_service_client.py @@ -70,12 +70,6 @@ def __init__( profile=KnownProfiles.default, # type: KnownProfiles **kwargs # type: Any ): - if api_version == '1.0.0': - base_url = '{Endpoint}/multiapiCustomBaseUrl/v1' - elif api_version == '2.0.0': - base_url = '{Endpoint}/multiapiCustomBaseUrl/v2' - else: - raise ValueError("API version {} is not available".format(api_version)) self._config = MultiapiCustomBaseUrlServiceClientConfiguration(credential, endpoint, **kwargs) self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) super(MultiapiCustomBaseUrlServiceClient, self).__init__( diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/aio/_multiapi_custom_base_url_service_client.py b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/aio/_multiapi_custom_base_url_service_client.py index fea46f4a6df..e68c873be13 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/aio/_multiapi_custom_base_url_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/aio/_multiapi_custom_base_url_service_client.py @@ -68,12 +68,6 @@ def __init__( profile: KnownProfiles = KnownProfiles.default, **kwargs # type: Any ) -> None: - if api_version == '1.0.0': - base_url = '{Endpoint}/multiapiCustomBaseUrl/v1' - elif api_version == '2.0.0': - base_url = '{Endpoint}/multiapiCustomBaseUrl/v2' - else: - raise ValueError("API version {} is not available".format(api_version)) self._config = MultiapiCustomBaseUrlServiceClientConfiguration(credential, endpoint, **kwargs) self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) super(MultiapiCustomBaseUrlServiceClient, self).__init__( diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/_metadata.json b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/_metadata.json index 53e7a6081cc..60bc8d3394e 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/_metadata.json +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v1/_metadata.json @@ -44,7 +44,37 @@ }, "constant": { }, - "call": "credential, endpoint" + "call": "credential, endpoint", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } }, "config": { "credential": true, diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/_metadata.json b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/_metadata.json index 84708fa8bf7..9848b1c594c 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/_metadata.json +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiCustomBaseUrl/multiapicustombaseurl/v2/_metadata.json @@ -44,7 +44,37 @@ }, "constant": { }, - "call": "credential, endpoint" + "call": "credential, endpoint", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } }, "config": { "credential": true, diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/_multiapi_service_client.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/_multiapi_service_client.py index 02b924061b1..4a1f4671cc0 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/_multiapi_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/_multiapi_service_client.py @@ -70,7 +70,7 @@ def __init__( self, credential, # type: "TokenCredential" api_version=None, # type: Optional[str] - base_url=None, # type: Optional[str] + base_url=None, # type: Optional[str] profile=KnownProfiles.default, # type: KnownProfiles **kwargs # type: Any ): diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/_operations_mixin.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/_operations_mixin.py index 47f96a48822..f6f33152dc6 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/_operations_mixin.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/_operations_mixin.py @@ -93,6 +93,43 @@ def begin_test_lro_and_paging( mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) return mixin_instance.begin_test_lro_and_paging(client_request_id, test_lro_and_paging_options, **kwargs) + def test_different_calls( + self, + greeting_in_english, # type: str + greeting_in_chinese=None, # type: Optional[str] + greeting_in_french=None, # type: Optional[str] + **kwargs # type: Any + ): + """Has added parameters across the API versions. + + :param greeting_in_english: pass in 'hello' to pass test. + :type greeting_in_english: str + :param greeting_in_chinese: pass in 'nihao' to pass test. + :type greeting_in_chinese: str + :param greeting_in_french: pass in 'bonjour' to pass test. + :type greeting_in_french: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = self._get_api_version('test_different_calls') + if api_version == '1.0.0': + from .v1.operations import MultiapiServiceClientOperationsMixin as OperationClass + elif api_version == '2.0.0': + from .v2.operations import MultiapiServiceClientOperationsMixin as OperationClass + elif api_version == '3.0.0': + from .v3.operations import MultiapiServiceClientOperationsMixin as OperationClass + else: + raise ValueError("API version {} does not have operation 'test_different_calls'".format(api_version)) + mixin_instance = OperationClass() + mixin_instance._client = self._client + mixin_instance._config = self._config + mixin_instance._serialize = Serializer(self._models_dict(api_version)) + mixin_instance._serialize.client_side_validation = False + mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) + return mixin_instance.test_different_calls(greeting_in_english, greeting_in_chinese, greeting_in_french, **kwargs) + def test_one( self, id, # type: int diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/aio/_operations_mixin.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/aio/_operations_mixin.py index 3cb36aa06c6..93ec55dad49 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/aio/_operations_mixin.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/aio/_operations_mixin.py @@ -89,6 +89,43 @@ def begin_test_lro_and_paging( mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) return mixin_instance.begin_test_lro_and_paging(client_request_id, test_lro_and_paging_options, **kwargs) + async def test_different_calls( + self, + greeting_in_english: str, + greeting_in_chinese: Optional[str] = None, + greeting_in_french: Optional[str] = None, + **kwargs + ) -> None: + """Has added parameters across the API versions. + + :param greeting_in_english: pass in 'hello' to pass test. + :type greeting_in_english: str + :param greeting_in_chinese: pass in 'nihao' to pass test. + :type greeting_in_chinese: str + :param greeting_in_french: pass in 'bonjour' to pass test. + :type greeting_in_french: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = self._get_api_version('test_different_calls') + if api_version == '1.0.0': + from ..v1.aio.operations import MultiapiServiceClientOperationsMixin as OperationClass + elif api_version == '2.0.0': + from ..v2.aio.operations import MultiapiServiceClientOperationsMixin as OperationClass + elif api_version == '3.0.0': + from ..v3.aio.operations import MultiapiServiceClientOperationsMixin as OperationClass + else: + raise ValueError("API version {} does not have operation 'test_different_calls'".format(api_version)) + mixin_instance = OperationClass() + mixin_instance._client = self._client + mixin_instance._config = self._config + mixin_instance._serialize = Serializer(self._models_dict(api_version)) + mixin_instance._serialize.client_side_validation = False + mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) + return await mixin_instance.test_different_calls(greeting_in_english, greeting_in_chinese, greeting_in_french, **kwargs) + async def test_one( self, id: int, diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/_metadata.json b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/_metadata.json index cd95e40ecac..00ffc97900e 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/_metadata.json +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/_metadata.json @@ -32,7 +32,49 @@ }, "constant": { }, - "call": "credential" + "call": "credential", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=None, # type: Optional[str]", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: Optional[str] = None,", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } }, "config": { "credential": true, @@ -109,6 +151,18 @@ "doc": "\"\"\"A long-running paging operation that includes a nextLink that has 10 pages.\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options: ~multiapidataplane.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: Pass in True if you\u0027d like the AsyncLROBasePolling polling method,\n False for no polling, or your own initialized polling object for a personal polling strategy.\n:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.\n:return: An instance of AsyncLROPoller that returns an iterator like instance of either PagingResult or the result of cls(response)\n:rtype: ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~multiapidataplane.v1.models.PagingResult]]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"" }, "call": "client_request_id, test_lro_and_paging_options" + }, + "test_different_calls" : { + "sync": { + "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n **kwargs # type: Any\n):\n", + "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "async": { + "coroutine": true, + "signature": "async def test_different_calls(\n self,\n greeting_in_english: str,\n **kwargs\n) -\u003e None:\n", + "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "call": "greeting_in_english" } } } diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/aio/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/aio/operations/_multiapi_service_client_operations.py index 51ccbc668fc..58adf58feb8 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/aio/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/aio/operations/_multiapi_service_client_operations.py @@ -350,3 +350,51 @@ async def internal_get_next(next_link=None): else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) begin_test_lro_and_paging.metadata = {'url': '/multiapi/lroAndPaging'} # type: ignore + + async def test_different_calls( + self, + greeting_in_english: str, + **kwargs + ) -> None: + """Has added parameters across the API versions. + + :param greeting_in_english: pass in 'hello' to pass test. + :type greeting_in_english: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0.0" + accept = "application/json" + + # Construct URL + url = self.test_different_calls.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['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/operations/_multiapi_service_client_operations.py index cd680aa426f..43713bd712e 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v1/operations/_multiapi_service_client_operations.py @@ -359,3 +359,52 @@ def internal_get_next(next_link=None): else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) begin_test_lro_and_paging.metadata = {'url': '/multiapi/lroAndPaging'} # type: ignore + + def test_different_calls( + self, + greeting_in_english, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Has added parameters across the API versions. + + :param greeting_in_english: pass in 'hello' to pass test. + :type greeting_in_english: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0.0" + accept = "application/json" + + # Construct URL + url = self.test_different_calls.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['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/_metadata.json b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/_metadata.json index f04414efe22..135f8a43c1e 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/_metadata.json +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/_metadata.json @@ -32,7 +32,49 @@ }, "constant": { }, - "call": "credential" + "call": "credential", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=None, # type: Optional[str]", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: Optional[str] = None,", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } }, "config": { "credential": true, @@ -62,6 +104,18 @@ "doc": "\"\"\"TestOne should be in an SecondVersionOperationsMixin. Returns ModelTwo.\n\n:param id: An int parameter.\n:type id: int\n:param message: An optional string parameter.\n:type message: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: ModelTwo, or the result of cls(response)\n:rtype: ~multiapidataplane.v2.models.ModelTwo\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "id, message" + }, + "test_different_calls" : { + "sync": { + "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n greeting_in_chinese=None, # type: Optional[str]\n **kwargs # type: Any\n):\n", + "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:param greeting_in_chinese: pass in \u0027nihao\u0027 to pass test.\n:type greeting_in_chinese: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "async": { + "coroutine": true, + "signature": "async def test_different_calls(\n self,\n greeting_in_english: str,\n greeting_in_chinese: Optional[str] = None,\n **kwargs\n) -\u003e None:\n", + "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:param greeting_in_chinese: pass in \u0027nihao\u0027 to pass test.\n:type greeting_in_chinese: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "call": "greeting_in_english, greeting_in_chinese" } } } diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/aio/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/aio/operations/_multiapi_service_client_operations.py index b77ff5d5aed..5d3f452e204 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/aio/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/aio/operations/_multiapi_service_client_operations.py @@ -74,3 +74,56 @@ async def test_one( return deserialized test_one.metadata = {'url': '/multiapi/testOneEndpoint'} # type: ignore + + async def test_different_calls( + self, + greeting_in_english: str, + greeting_in_chinese: Optional[str] = None, + **kwargs + ) -> None: + """Has added parameters across the API versions. + + :param greeting_in_english: pass in 'hello' to pass test. + :type greeting_in_english: str + :param greeting_in_chinese: pass in 'nihao' to pass test. + :type greeting_in_chinese: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2.0.0" + accept = "application/json" + + # Construct URL + url = self.test_different_calls.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['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') + if greeting_in_chinese is not None: + header_parameters['greetingInChinese'] = self._serialize.header("greeting_in_chinese", greeting_in_chinese, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/operations/_multiapi_service_client_operations.py index 791aeded24e..b96f2b42094 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v2/operations/_multiapi_service_client_operations.py @@ -79,3 +79,57 @@ def test_one( return deserialized test_one.metadata = {'url': '/multiapi/testOneEndpoint'} # type: ignore + + def test_different_calls( + self, + greeting_in_english, # type: str + greeting_in_chinese=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + """Has added parameters across the API versions. + + :param greeting_in_english: pass in 'hello' to pass test. + :type greeting_in_english: str + :param greeting_in_chinese: pass in 'nihao' to pass test. + :type greeting_in_chinese: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2.0.0" + accept = "application/json" + + # Construct URL + url = self.test_different_calls.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['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') + if greeting_in_chinese is not None: + header_parameters['greetingInChinese'] = self._serialize.header("greeting_in_chinese", greeting_in_chinese, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/_metadata.json b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/_metadata.json index 960f8674482..218d0d4b6b8 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/_metadata.json +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/_metadata.json @@ -32,7 +32,49 @@ }, "constant": { }, - "call": "credential" + "call": "credential", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=None, # type: Optional[str]", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: Optional[str] = None,", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } }, "config": { "credential": true, @@ -62,6 +104,18 @@ "doc": "\"\"\"Returns ModelThree with optionalProperty \u0027paged\u0027.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either PagingResult or the result of cls(response)\n:rtype: ~azure.core.async_paging.AsyncItemPaged[~multiapidataplane.v3.models.PagingResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "" + }, + "test_different_calls" : { + "sync": { + "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n greeting_in_chinese=None, # type: Optional[str]\n greeting_in_french=None, # type: Optional[str]\n **kwargs # type: Any\n):\n", + "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:param greeting_in_chinese: pass in \u0027nihao\u0027 to pass test.\n:type greeting_in_chinese: str\n:param greeting_in_french: pass in \u0027bonjour\u0027 to pass test.\n:type greeting_in_french: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "async": { + "coroutine": true, + "signature": "async def test_different_calls(\n self,\n greeting_in_english: str,\n greeting_in_chinese: Optional[str] = None,\n greeting_in_french: Optional[str] = None,\n **kwargs\n) -\u003e None:\n", + "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:param greeting_in_chinese: pass in \u0027nihao\u0027 to pass test.\n:type greeting_in_chinese: str\n:param greeting_in_french: pass in \u0027bonjour\u0027 to pass test.\n:type greeting_in_french: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "call": "greeting_in_english, greeting_in_chinese, greeting_in_french" } } } diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/aio/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/aio/operations/_multiapi_service_client_operations.py index 5f2f9416e62..fee8756eadf 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/aio/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/aio/operations/_multiapi_service_client_operations.py @@ -79,3 +79,61 @@ async def get_next(next_link=None): get_next, extract_data ) test_paging.metadata = {'url': '/multiapi/paging'} # type: ignore + + async def test_different_calls( + self, + greeting_in_english: str, + greeting_in_chinese: Optional[str] = None, + greeting_in_french: Optional[str] = None, + **kwargs + ) -> None: + """Has added parameters across the API versions. + + :param greeting_in_english: pass in 'hello' to pass test. + :type greeting_in_english: str + :param greeting_in_chinese: pass in 'nihao' to pass test. + :type greeting_in_chinese: str + :param greeting_in_french: pass in 'bonjour' to pass test. + :type greeting_in_french: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "3.0.0" + accept = "application/json" + + # Construct URL + url = self.test_different_calls.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['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') + if greeting_in_chinese is not None: + header_parameters['greetingInChinese'] = self._serialize.header("greeting_in_chinese", greeting_in_chinese, 'str') + if greeting_in_french is not None: + header_parameters['greetingInFrench'] = self._serialize.header("greeting_in_french", greeting_in_french, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/operations/_multiapi_service_client_operations.py index 0763ecd9a9a..4e5eaadd522 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiDataPlane/multiapidataplane/v3/operations/_multiapi_service_client_operations.py @@ -84,3 +84,62 @@ def get_next(next_link=None): get_next, extract_data ) test_paging.metadata = {'url': '/multiapi/paging'} # type: ignore + + def test_different_calls( + self, + greeting_in_english, # type: str + greeting_in_chinese=None, # type: Optional[str] + greeting_in_french=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + """Has added parameters across the API versions. + + :param greeting_in_english: pass in 'hello' to pass test. + :type greeting_in_english: str + :param greeting_in_chinese: pass in 'nihao' to pass test. + :type greeting_in_chinese: str + :param greeting_in_french: pass in 'bonjour' to pass test. + :type greeting_in_french: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "3.0.0" + accept = "application/json" + + # Construct URL + url = self.test_different_calls.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['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') + if greeting_in_chinese is not None: + header_parameters['greetingInChinese'] = self._serialize.header("greeting_in_chinese", greeting_in_chinese, 'str') + if greeting_in_french is not None: + header_parameters['greetingInFrench'] = self._serialize.header("greeting_in_french", greeting_in_french, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) + + test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/_multiapi_service_client.py b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/_multiapi_service_client.py index 32e3361f585..62f41a83d96 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/_multiapi_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/_multiapi_service_client.py @@ -70,7 +70,7 @@ def __init__( self, credential, # type: "TokenCredential" api_version=None, # type: Optional[str] - base_url=None, # type: Optional[str] + base_url=None, # type: Optional[str] profile=KnownProfiles.default, # type: KnownProfiles **kwargs # type: Any ): diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/_operations_mixin.py b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/_operations_mixin.py index 07149fe8383..4b944a14624 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/_operations_mixin.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/_operations_mixin.py @@ -94,6 +94,43 @@ def begin_test_lro_and_paging( mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) return mixin_instance.begin_test_lro_and_paging(client_request_id, test_lro_and_paging_options, **kwargs) + def test_different_calls( + self, + greeting_in_english, # type: str + greeting_in_chinese=None, # type: Optional[str] + greeting_in_french=None, # type: Optional[str] + **kwargs # type: Any + ): + """Has added parameters across the API versions. + + :param greeting_in_english: pass in 'hello' to pass test. + :type greeting_in_english: str + :param greeting_in_chinese: pass in 'nihao' to pass test. + :type greeting_in_chinese: str + :param greeting_in_french: pass in 'bonjour' to pass test. + :type greeting_in_french: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = self._get_api_version('test_different_calls') + if api_version == '1.0.0': + from .v1.operations import MultiapiServiceClientOperationsMixin as OperationClass + elif api_version == '2.0.0': + from .v2.operations import MultiapiServiceClientOperationsMixin as OperationClass + elif api_version == '3.0.0': + from .v3.operations import MultiapiServiceClientOperationsMixin as OperationClass + else: + raise ValueError("API version {} does not have operation 'test_different_calls'".format(api_version)) + mixin_instance = OperationClass() + mixin_instance._client = self._client + mixin_instance._config = self._config + mixin_instance._serialize = Serializer(self._models_dict(api_version)) + mixin_instance._serialize.client_side_validation = False + mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) + return mixin_instance.test_different_calls(greeting_in_english, greeting_in_chinese, greeting_in_french, **kwargs) + def test_one( self, id, # type: int diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/_metadata.json b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/_metadata.json index 52d16bef6b8..c086e21c4a3 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/_metadata.json +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/_metadata.json @@ -32,7 +32,49 @@ }, "constant": { }, - "call": "credential" + "call": "credential", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=None, # type: Optional[str]", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: Optional[str] = None,", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } }, "config": { "credential": true, @@ -109,6 +151,18 @@ "doc": "\"\"\"A long-running paging operation that includes a nextLink that has 10 pages.\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options: ~multiapinoasync.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: Pass in True if you\u0027d like the AsyncARMPolling polling method,\n False for no polling, or your own initialized polling object for a personal polling strategy.\n:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.\n:return: An instance of AsyncLROPoller that returns an iterator like instance of either PagingResult or the result of cls(response)\n:rtype: ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~multiapinoasync.v1.models.PagingResult]]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"" }, "call": "client_request_id, test_lro_and_paging_options" + }, + "test_different_calls" : { + "sync": { + "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n **kwargs # type: Any\n):\n", + "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "async": { + "coroutine": true, + "signature": "async def test_different_calls(\n self,\n greeting_in_english: str,\n **kwargs\n) -\u003e None:\n", + "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "call": "greeting_in_english" } } } diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/operations/_multiapi_service_client_operations.py index 9da2920bb25..c6177935399 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/operations/_multiapi_service_client_operations.py @@ -360,3 +360,52 @@ def internal_get_next(next_link=None): else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) begin_test_lro_and_paging.metadata = {'url': '/multiapi/lroAndPaging'} # type: ignore + + def test_different_calls( + self, + greeting_in_english, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Has added parameters across the API versions. + + :param greeting_in_english: pass in 'hello' to pass test. + :type greeting_in_english: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0.0" + accept = "application/json" + + # Construct URL + url = self.test_different_calls.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['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/_metadata.json b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/_metadata.json index a93a254612f..efbb0a241a8 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/_metadata.json +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/_metadata.json @@ -32,7 +32,49 @@ }, "constant": { }, - "call": "credential" + "call": "credential", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=None, # type: Optional[str]", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: Optional[str] = None,", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } }, "config": { "credential": true, @@ -62,6 +104,18 @@ "doc": "\"\"\"TestOne should be in an SecondVersionOperationsMixin. Returns ModelTwo.\n\n:param id: An int parameter.\n:type id: int\n:param message: An optional string parameter.\n:type message: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: ModelTwo, or the result of cls(response)\n:rtype: ~multiapinoasync.v2.models.ModelTwo\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "id, message" + }, + "test_different_calls" : { + "sync": { + "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n greeting_in_chinese=None, # type: Optional[str]\n **kwargs # type: Any\n):\n", + "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:param greeting_in_chinese: pass in \u0027nihao\u0027 to pass test.\n:type greeting_in_chinese: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "async": { + "coroutine": true, + "signature": "async def test_different_calls(\n self,\n greeting_in_english: str,\n greeting_in_chinese: Optional[str] = None,\n **kwargs\n) -\u003e None:\n", + "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:param greeting_in_chinese: pass in \u0027nihao\u0027 to pass test.\n:type greeting_in_chinese: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "call": "greeting_in_english, greeting_in_chinese" } } } diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/operations/_multiapi_service_client_operations.py index 3183783f827..6479f115fec 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v2/operations/_multiapi_service_client_operations.py @@ -80,3 +80,57 @@ def test_one( return deserialized test_one.metadata = {'url': '/multiapi/testOneEndpoint'} # type: ignore + + def test_different_calls( + self, + greeting_in_english, # type: str + greeting_in_chinese=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + """Has added parameters across the API versions. + + :param greeting_in_english: pass in 'hello' to pass test. + :type greeting_in_english: str + :param greeting_in_chinese: pass in 'nihao' to pass test. + :type greeting_in_chinese: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2.0.0" + accept = "application/json" + + # Construct URL + url = self.test_different_calls.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['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') + if greeting_in_chinese is not None: + header_parameters['greetingInChinese'] = self._serialize.header("greeting_in_chinese", greeting_in_chinese, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/_metadata.json b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/_metadata.json index 4acdf0a48db..c6a3df252ff 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/_metadata.json +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/_metadata.json @@ -32,7 +32,49 @@ }, "constant": { }, - "call": "credential" + "call": "credential", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=None, # type: Optional[str]", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: Optional[str] = None,", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } }, "config": { "credential": true, @@ -62,6 +104,18 @@ "doc": "\"\"\"Returns ModelThree with optionalProperty \u0027paged\u0027.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either PagingResult or the result of cls(response)\n:rtype: ~azure.core.async_paging.AsyncItemPaged[~multiapinoasync.v3.models.PagingResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "" + }, + "test_different_calls" : { + "sync": { + "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n greeting_in_chinese=None, # type: Optional[str]\n greeting_in_french=None, # type: Optional[str]\n **kwargs # type: Any\n):\n", + "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:param greeting_in_chinese: pass in \u0027nihao\u0027 to pass test.\n:type greeting_in_chinese: str\n:param greeting_in_french: pass in \u0027bonjour\u0027 to pass test.\n:type greeting_in_french: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "async": { + "coroutine": true, + "signature": "async def test_different_calls(\n self,\n greeting_in_english: str,\n greeting_in_chinese: Optional[str] = None,\n greeting_in_french: Optional[str] = None,\n **kwargs\n) -\u003e None:\n", + "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:param greeting_in_chinese: pass in \u0027nihao\u0027 to pass test.\n:type greeting_in_chinese: str\n:param greeting_in_french: pass in \u0027bonjour\u0027 to pass test.\n:type greeting_in_french: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "call": "greeting_in_english, greeting_in_chinese, greeting_in_french" } } } diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/operations/_multiapi_service_client_operations.py index 243bee3c3ff..279abe65910 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v3/operations/_multiapi_service_client_operations.py @@ -85,3 +85,62 @@ def get_next(next_link=None): get_next, extract_data ) test_paging.metadata = {'url': '/multiapi/paging'} # type: ignore + + def test_different_calls( + self, + greeting_in_english, # type: str + greeting_in_chinese=None, # type: Optional[str] + greeting_in_french=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + """Has added parameters across the API versions. + + :param greeting_in_english: pass in 'hello' to pass test. + :type greeting_in_english: str + :param greeting_in_chinese: pass in 'nihao' to pass test. + :type greeting_in_chinese: str + :param greeting_in_french: pass in 'bonjour' to pass test. + :type greeting_in_french: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "3.0.0" + accept = "application/json" + + # Construct URL + url = self.test_different_calls.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['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') + if greeting_in_chinese is not None: + header_parameters['greetingInChinese'] = self._serialize.header("greeting_in_chinese", greeting_in_chinese, 'str') + if greeting_in_french is not None: + header_parameters['greetingInFrench'] = self._serialize.header("greeting_in_french", greeting_in_french, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/_multiapi_service_client.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/_multiapi_service_client.py index bbd8ad789d1..7c9affa6840 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/_multiapi_service_client.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/_multiapi_service_client.py @@ -70,7 +70,7 @@ def __init__( self, credential, # type: "TokenCredential" api_version=None, # type: Optional[str] - base_url=None, # type: Optional[str] + base_url=None, # type: Optional[str] profile=KnownProfiles.default, # type: KnownProfiles **kwargs # type: Any ): diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/_operations_mixin.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/_operations_mixin.py index 97f46e9809c..8bb7c0fef19 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/_operations_mixin.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/_operations_mixin.py @@ -94,6 +94,43 @@ def begin_test_lro_and_paging( mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) return mixin_instance.begin_test_lro_and_paging(client_request_id, test_lro_and_paging_options, **kwargs) + def test_different_calls( + self, + greeting_in_english, # type: str + greeting_in_chinese=None, # type: Optional[str] + greeting_in_french=None, # type: Optional[str] + **kwargs # type: Any + ): + """Has added parameters across the API versions. + + :param greeting_in_english: pass in 'hello' to pass test. + :type greeting_in_english: str + :param greeting_in_chinese: pass in 'nihao' to pass test. + :type greeting_in_chinese: str + :param greeting_in_french: pass in 'bonjour' to pass test. + :type greeting_in_french: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = self._get_api_version('test_different_calls') + if api_version == '1.0.0': + from .v1.operations import MultiapiServiceClientOperationsMixin as OperationClass + elif api_version == '2.0.0': + from .v2.operations import MultiapiServiceClientOperationsMixin as OperationClass + elif api_version == '3.0.0': + from .v3.operations import MultiapiServiceClientOperationsMixin as OperationClass + else: + raise ValueError("API version {} does not have operation 'test_different_calls'".format(api_version)) + mixin_instance = OperationClass() + mixin_instance._client = self._client + mixin_instance._config = self._config + mixin_instance._serialize = Serializer(self._models_dict(api_version)) + mixin_instance._serialize.client_side_validation = False + mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) + return mixin_instance.test_different_calls(greeting_in_english, greeting_in_chinese, greeting_in_french, **kwargs) + def test_one( self, id, # type: int diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/aio/_operations_mixin.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/aio/_operations_mixin.py index 9d7aae038a6..10d89e2f520 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/aio/_operations_mixin.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/aio/_operations_mixin.py @@ -90,6 +90,43 @@ def begin_test_lro_and_paging( mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) return mixin_instance.begin_test_lro_and_paging(client_request_id, test_lro_and_paging_options, **kwargs) + async def test_different_calls( + self, + greeting_in_english: str, + greeting_in_chinese: Optional[str] = None, + greeting_in_french: Optional[str] = None, + **kwargs + ) -> None: + """Has added parameters across the API versions. + + :param greeting_in_english: pass in 'hello' to pass test. + :type greeting_in_english: str + :param greeting_in_chinese: pass in 'nihao' to pass test. + :type greeting_in_chinese: str + :param greeting_in_french: pass in 'bonjour' to pass test. + :type greeting_in_french: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + api_version = self._get_api_version('test_different_calls') + if api_version == '1.0.0': + from ..v1.aio.operations import MultiapiServiceClientOperationsMixin as OperationClass + elif api_version == '2.0.0': + from ..v2.aio.operations import MultiapiServiceClientOperationsMixin as OperationClass + elif api_version == '3.0.0': + from ..v3.aio.operations import MultiapiServiceClientOperationsMixin as OperationClass + else: + raise ValueError("API version {} does not have operation 'test_different_calls'".format(api_version)) + mixin_instance = OperationClass() + mixin_instance._client = self._client + mixin_instance._config = self._config + mixin_instance._serialize = Serializer(self._models_dict(api_version)) + mixin_instance._serialize.client_side_validation = False + mixin_instance._deserialize = Deserializer(self._models_dict(api_version)) + return await mixin_instance.test_different_calls(greeting_in_english, greeting_in_chinese, greeting_in_french, **kwargs) + async def test_one( self, id: int, diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/_metadata.json b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/_metadata.json index 542d5542953..fc5abf89788 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/_metadata.json +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/_metadata.json @@ -32,7 +32,49 @@ }, "constant": { }, - "call": "credential" + "call": "credential", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=None, # type: Optional[str]", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: Optional[str] = None,", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } }, "config": { "credential": true, @@ -109,6 +151,18 @@ "doc": "\"\"\"A long-running paging operation that includes a nextLink that has 10 pages.\n\n:param client_request_id:\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group.\n:type test_lro_and_paging_options: ~multiapiwithsubmodule.submodule.v1.models.TestLroAndPagingOptions\n:keyword callable cls: A custom type or function that will be passed the direct response\n:keyword str continuation_token: A continuation token to restart a poller from a saved state.\n:keyword polling: Pass in True if you\u0027d like the AsyncARMPolling polling method,\n False for no polling, or your own initialized polling object for a personal polling strategy.\n:paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod\n:keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present.\n:return: An instance of AsyncLROPoller that returns an iterator like instance of either PagingResult or the result of cls(response)\n:rtype: ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~multiapiwithsubmodule.submodule.v1.models.PagingResult]]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"" }, "call": "client_request_id, test_lro_and_paging_options" + }, + "test_different_calls" : { + "sync": { + "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n **kwargs # type: Any\n):\n", + "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "async": { + "coroutine": true, + "signature": "async def test_different_calls(\n self,\n greeting_in_english: str,\n **kwargs\n) -\u003e None:\n", + "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "call": "greeting_in_english" } } } diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/aio/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/aio/operations/_multiapi_service_client_operations.py index ab7211c4baf..6b1801e76d5 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/aio/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/aio/operations/_multiapi_service_client_operations.py @@ -351,3 +351,51 @@ async def internal_get_next(next_link=None): else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) begin_test_lro_and_paging.metadata = {'url': '/multiapi/lroAndPaging'} # type: ignore + + async def test_different_calls( + self, + greeting_in_english: str, + **kwargs + ) -> None: + """Has added parameters across the API versions. + + :param greeting_in_english: pass in 'hello' to pass test. + :type greeting_in_english: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0.0" + accept = "application/json" + + # Construct URL + url = self.test_different_calls.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['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/operations/_multiapi_service_client_operations.py index 4546a5cca03..2d77366f757 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/operations/_multiapi_service_client_operations.py @@ -360,3 +360,52 @@ def internal_get_next(next_link=None): else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) begin_test_lro_and_paging.metadata = {'url': '/multiapi/lroAndPaging'} # type: ignore + + def test_different_calls( + self, + greeting_in_english, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + """Has added parameters across the API versions. + + :param greeting_in_english: pass in 'hello' to pass test. + :type greeting_in_english: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "1.0.0" + accept = "application/json" + + # Construct URL + url = self.test_different_calls.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['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/_metadata.json b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/_metadata.json index d74b4144718..00281e01554 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/_metadata.json +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/_metadata.json @@ -32,7 +32,49 @@ }, "constant": { }, - "call": "credential" + "call": "credential", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=None, # type: Optional[str]", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: Optional[str] = None,", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } }, "config": { "credential": true, @@ -62,6 +104,18 @@ "doc": "\"\"\"TestOne should be in an SecondVersionOperationsMixin. Returns ModelTwo.\n\n:param id: An int parameter.\n:type id: int\n:param message: An optional string parameter.\n:type message: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: ModelTwo, or the result of cls(response)\n:rtype: ~multiapiwithsubmodule.submodule.v2.models.ModelTwo\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "id, message" + }, + "test_different_calls" : { + "sync": { + "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n greeting_in_chinese=None, # type: Optional[str]\n **kwargs # type: Any\n):\n", + "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:param greeting_in_chinese: pass in \u0027nihao\u0027 to pass test.\n:type greeting_in_chinese: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "async": { + "coroutine": true, + "signature": "async def test_different_calls(\n self,\n greeting_in_english: str,\n greeting_in_chinese: Optional[str] = None,\n **kwargs\n) -\u003e None:\n", + "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:param greeting_in_chinese: pass in \u0027nihao\u0027 to pass test.\n:type greeting_in_chinese: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "call": "greeting_in_english, greeting_in_chinese" } } } diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/aio/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/aio/operations/_multiapi_service_client_operations.py index 8dd5d64f0b9..0f45c7c516e 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/aio/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/aio/operations/_multiapi_service_client_operations.py @@ -75,3 +75,56 @@ async def test_one( return deserialized test_one.metadata = {'url': '/multiapi/testOneEndpoint'} # type: ignore + + async def test_different_calls( + self, + greeting_in_english: str, + greeting_in_chinese: Optional[str] = None, + **kwargs + ) -> None: + """Has added parameters across the API versions. + + :param greeting_in_english: pass in 'hello' to pass test. + :type greeting_in_english: str + :param greeting_in_chinese: pass in 'nihao' to pass test. + :type greeting_in_chinese: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2.0.0" + accept = "application/json" + + # Construct URL + url = self.test_different_calls.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['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') + if greeting_in_chinese is not None: + header_parameters['greetingInChinese'] = self._serialize.header("greeting_in_chinese", greeting_in_chinese, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/operations/_multiapi_service_client_operations.py index 91049ff9180..b1896d7062b 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v2/operations/_multiapi_service_client_operations.py @@ -80,3 +80,57 @@ def test_one( return deserialized test_one.metadata = {'url': '/multiapi/testOneEndpoint'} # type: ignore + + def test_different_calls( + self, + greeting_in_english, # type: str + greeting_in_chinese=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + """Has added parameters across the API versions. + + :param greeting_in_english: pass in 'hello' to pass test. + :type greeting_in_english: str + :param greeting_in_chinese: pass in 'nihao' to pass test. + :type greeting_in_chinese: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2.0.0" + accept = "application/json" + + # Construct URL + url = self.test_different_calls.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['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') + if greeting_in_chinese is not None: + header_parameters['greetingInChinese'] = self._serialize.header("greeting_in_chinese", greeting_in_chinese, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/_metadata.json b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/_metadata.json index 86bbc1db040..247ac2647d9 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/_metadata.json +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/_metadata.json @@ -32,7 +32,49 @@ }, "constant": { }, - "call": "credential" + "call": "credential", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=None, # type: Optional[str]", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: Optional[str] = None,", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } }, "config": { "credential": true, @@ -62,6 +104,18 @@ "doc": "\"\"\"Returns ModelThree with optionalProperty \u0027paged\u0027.\n\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: An iterator like instance of either PagingResult or the result of cls(response)\n:rtype: ~azure.core.async_paging.AsyncItemPaged[~multiapiwithsubmodule.submodule.v3.models.PagingResult]\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" }, "call": "" + }, + "test_different_calls" : { + "sync": { + "signature": "def test_different_calls(\n self,\n greeting_in_english, # type: str\n greeting_in_chinese=None, # type: Optional[str]\n greeting_in_french=None, # type: Optional[str]\n **kwargs # type: Any\n):\n", + "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:param greeting_in_chinese: pass in \u0027nihao\u0027 to pass test.\n:type greeting_in_chinese: str\n:param greeting_in_french: pass in \u0027bonjour\u0027 to pass test.\n:type greeting_in_french: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "async": { + "coroutine": true, + "signature": "async def test_different_calls(\n self,\n greeting_in_english: str,\n greeting_in_chinese: Optional[str] = None,\n greeting_in_french: Optional[str] = None,\n **kwargs\n) -\u003e None:\n", + "doc": "\"\"\"Has added parameters across the API versions.\n\n:param greeting_in_english: pass in \u0027hello\u0027 to pass test.\n:type greeting_in_english: str\n:param greeting_in_chinese: pass in \u0027nihao\u0027 to pass test.\n:type greeting_in_chinese: str\n:param greeting_in_french: pass in \u0027bonjour\u0027 to pass test.\n:type greeting_in_french: str\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: None, or the result of cls(response)\n:rtype: None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"" + }, + "call": "greeting_in_english, greeting_in_chinese, greeting_in_french" } } } diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/aio/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/aio/operations/_multiapi_service_client_operations.py index 8ea551a3c08..b5de7e881fc 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/aio/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/aio/operations/_multiapi_service_client_operations.py @@ -80,3 +80,61 @@ async def get_next(next_link=None): get_next, extract_data ) test_paging.metadata = {'url': '/multiapi/paging'} # type: ignore + + async def test_different_calls( + self, + greeting_in_english: str, + greeting_in_chinese: Optional[str] = None, + greeting_in_french: Optional[str] = None, + **kwargs + ) -> None: + """Has added parameters across the API versions. + + :param greeting_in_english: pass in 'hello' to pass test. + :type greeting_in_english: str + :param greeting_in_chinese: pass in 'nihao' to pass test. + :type greeting_in_chinese: str + :param greeting_in_french: pass in 'bonjour' to pass test. + :type greeting_in_french: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "3.0.0" + accept = "application/json" + + # Construct URL + url = self.test_different_calls.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['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') + if greeting_in_chinese is not None: + header_parameters['greetingInChinese'] = self._serialize.header("greeting_in_chinese", greeting_in_chinese, 'str') + if greeting_in_french is not None: + header_parameters['greetingInFrench'] = self._serialize.header("greeting_in_french", greeting_in_french, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/operations/_multiapi_service_client_operations.py index b60d307eb41..3671fda546b 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v3/operations/_multiapi_service_client_operations.py @@ -85,3 +85,62 @@ def get_next(next_link=None): get_next, extract_data ) test_paging.metadata = {'url': '/multiapi/paging'} # type: ignore + + def test_different_calls( + self, + greeting_in_english, # type: str + greeting_in_chinese=None, # type: Optional[str] + greeting_in_french=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + """Has added parameters across the API versions. + + :param greeting_in_english: pass in 'hello' to pass test. + :type greeting_in_english: str + :param greeting_in_chinese: pass in 'nihao' to pass test. + :type greeting_in_chinese: str + :param greeting_in_french: pass in 'bonjour' to pass test. + :type greeting_in_french: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "3.0.0" + accept = "application/json" + + # Construct URL + url = self.test_different_calls.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['greetingInEnglish'] = self._serialize.header("greeting_in_english", greeting_in_english, 'str') + if greeting_in_chinese is not None: + header_parameters['greetingInChinese'] = self._serialize.header("greeting_in_chinese", greeting_in_chinese, 'str') + if greeting_in_french is not None: + header_parameters['greetingInFrench'] = self._serialize.header("greeting_in_french", greeting_in_french, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize(_models.Error, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + test_different_calls.metadata = {'url': '/multiapi/testDifferentCalls'} # type: ignore diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDictionary/bodydictionary/aio/operations/_dictionary_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyDictionary/bodydictionary/aio/operations/_dictionary_operations.py index a17474ea057..8cf62bb8325 100644 --- a/test/vanilla/Expected/AcceptanceTests/BodyDictionary/bodydictionary/aio/operations/_dictionary_operations.py +++ b/test/vanilla/Expected/AcceptanceTests/BodyDictionary/bodydictionary/aio/operations/_dictionary_operations.py @@ -2583,15 +2583,15 @@ async def put_array_valid(self, array_body: Dict[str, List[str]], **kwargs) -> N put_array_valid.metadata = {"url": "/dictionary/array/valid"} # type: ignore @distributed_trace_async - async def get_dictionary_null(self, **kwargs) -> Dict[str, object]: + async def get_dictionary_null(self, **kwargs) -> Dict[str, Dict[str, str]]: """Get an dictionaries of dictionaries with value null. :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to object, or the result of cls(response) - :rtype: dict[str, object] + :return: dict mapping str to dict mapping str to str, or the result of cls(response) + :rtype: dict[str, dict[str, str]] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, object]] + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, Dict[str, str]]] error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop("error_map", {})) accept = "application/json" @@ -2615,7 +2615,7 @@ async def get_dictionary_null(self, **kwargs) -> Dict[str, object]: error = self._deserialize(_models.Error, response) raise HttpResponseError(response=response, model=error) - deserialized = self._deserialize("{object}", pipeline_response) + deserialized = self._deserialize("{{str}}", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) @@ -2625,15 +2625,15 @@ async def get_dictionary_null(self, **kwargs) -> Dict[str, object]: get_dictionary_null.metadata = {"url": "/dictionary/dictionary/null"} # type: ignore @distributed_trace_async - async def get_dictionary_empty(self, **kwargs) -> Dict[str, object]: + async def get_dictionary_empty(self, **kwargs) -> Dict[str, Dict[str, str]]: """Get an dictionaries of dictionaries of type with value {}. :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to object, or the result of cls(response) - :rtype: dict[str, object] + :return: dict mapping str to dict mapping str to str, or the result of cls(response) + :rtype: dict[str, dict[str, str]] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, object]] + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, Dict[str, str]]] error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop("error_map", {})) accept = "application/json" @@ -2657,7 +2657,7 @@ async def get_dictionary_empty(self, **kwargs) -> Dict[str, object]: error = self._deserialize(_models.Error, response) raise HttpResponseError(response=response, model=error) - deserialized = self._deserialize("{object}", pipeline_response) + deserialized = self._deserialize("{{str}}", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) @@ -2667,16 +2667,16 @@ async def get_dictionary_empty(self, **kwargs) -> Dict[str, object]: get_dictionary_empty.metadata = {"url": "/dictionary/dictionary/empty"} # type: ignore @distributed_trace_async - async def get_dictionary_item_null(self, **kwargs) -> Dict[str, object]: + async def get_dictionary_item_null(self, **kwargs) -> Dict[str, Dict[str, str]]: """Get an dictionaries of dictionaries of type with value {"0": {"1": "one", "2": "two", "3": "three"}, "1": null, "2": {"7": "seven", "8": "eight", "9": "nine"}}. :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to object, or the result of cls(response) - :rtype: dict[str, object] + :return: dict mapping str to dict mapping str to str, or the result of cls(response) + :rtype: dict[str, dict[str, str]] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, object]] + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, Dict[str, str]]] error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop("error_map", {})) accept = "application/json" @@ -2700,7 +2700,7 @@ async def get_dictionary_item_null(self, **kwargs) -> Dict[str, object]: error = self._deserialize(_models.Error, response) raise HttpResponseError(response=response, model=error) - deserialized = self._deserialize("{object}", pipeline_response) + deserialized = self._deserialize("{{str}}", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) @@ -2710,16 +2710,16 @@ async def get_dictionary_item_null(self, **kwargs) -> Dict[str, object]: get_dictionary_item_null.metadata = {"url": "/dictionary/dictionary/itemnull"} # type: ignore @distributed_trace_async - async def get_dictionary_item_empty(self, **kwargs) -> Dict[str, object]: + async def get_dictionary_item_empty(self, **kwargs) -> Dict[str, Dict[str, str]]: """Get an dictionaries of dictionaries of type with value {"0": {"1": "one", "2": "two", "3": "three"}, "1": {}, "2": {"7": "seven", "8": "eight", "9": "nine"}}. :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to object, or the result of cls(response) - :rtype: dict[str, object] + :return: dict mapping str to dict mapping str to str, or the result of cls(response) + :rtype: dict[str, dict[str, str]] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, object]] + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, Dict[str, str]]] error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop("error_map", {})) accept = "application/json" @@ -2743,7 +2743,7 @@ async def get_dictionary_item_empty(self, **kwargs) -> Dict[str, object]: error = self._deserialize(_models.Error, response) raise HttpResponseError(response=response, model=error) - deserialized = self._deserialize("{object}", pipeline_response) + deserialized = self._deserialize("{{str}}", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) @@ -2753,17 +2753,17 @@ async def get_dictionary_item_empty(self, **kwargs) -> Dict[str, object]: get_dictionary_item_empty.metadata = {"url": "/dictionary/dictionary/itemempty"} # type: ignore @distributed_trace_async - async def get_dictionary_valid(self, **kwargs) -> Dict[str, object]: + async def get_dictionary_valid(self, **kwargs) -> Dict[str, Dict[str, str]]: """Get an dictionaries of dictionaries of type with value {"0": {"1": "one", "2": "two", "3": "three"}, "1": {"4": "four", "5": "five", "6": "six"}, "2": {"7": "seven", "8": "eight", "9": "nine"}}. :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to object, or the result of cls(response) - :rtype: dict[str, object] + :return: dict mapping str to dict mapping str to str, or the result of cls(response) + :rtype: dict[str, dict[str, str]] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, object]] + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, Dict[str, str]]] error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop("error_map", {})) accept = "application/json" @@ -2787,7 +2787,7 @@ async def get_dictionary_valid(self, **kwargs) -> Dict[str, object]: error = self._deserialize(_models.Error, response) raise HttpResponseError(response=response, model=error) - deserialized = self._deserialize("{object}", pipeline_response) + deserialized = self._deserialize("{{str}}", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) @@ -2797,13 +2797,13 @@ async def get_dictionary_valid(self, **kwargs) -> Dict[str, object]: get_dictionary_valid.metadata = {"url": "/dictionary/dictionary/valid"} # type: ignore @distributed_trace_async - async def put_dictionary_valid(self, array_body: Dict[str, object], **kwargs) -> None: + async def put_dictionary_valid(self, array_body: Dict[str, Dict[str, str]], **kwargs) -> None: """Get an dictionaries of dictionaries of type with value {"0": {"1": "one", "2": "two", "3": "three"}, "1": {"4": "four", "5": "five", "6": "six"}, "2": {"7": "seven", "8": "eight", "9": "nine"}}. :param array_body: - :type array_body: dict[str, object] + :type array_body: dict[str, dict[str, str]] :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -2827,7 +2827,7 @@ async def put_dictionary_valid(self, array_body: Dict[str, object], **kwargs) -> header_parameters["Accept"] = self._serialize.header("accept", accept, "str") body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "{object}") + body_content = self._serialize.body(array_body, "{{str}}") 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) diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDictionary/bodydictionary/operations/_dictionary_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyDictionary/bodydictionary/operations/_dictionary_operations.py index e0f89e68ae2..8b45cd26335 100644 --- a/test/vanilla/Expected/AcceptanceTests/BodyDictionary/bodydictionary/operations/_dictionary_operations.py +++ b/test/vanilla/Expected/AcceptanceTests/BodyDictionary/bodydictionary/operations/_dictionary_operations.py @@ -2795,15 +2795,15 @@ def put_array_valid( def get_dictionary_null( self, **kwargs # type: Any ): - # type: (...) -> Dict[str, object] + # type: (...) -> Dict[str, Dict[str, str]] """Get an dictionaries of dictionaries with value null. :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to object, or the result of cls(response) - :rtype: dict[str, object] + :return: dict mapping str to dict mapping str to str, or the result of cls(response) + :rtype: dict[str, dict[str, str]] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, object]] + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, Dict[str, str]]] error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop("error_map", {})) accept = "application/json" @@ -2827,7 +2827,7 @@ def get_dictionary_null( error = self._deserialize(_models.Error, response) raise HttpResponseError(response=response, model=error) - deserialized = self._deserialize("{object}", pipeline_response) + deserialized = self._deserialize("{{str}}", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) @@ -2840,15 +2840,15 @@ def get_dictionary_null( def get_dictionary_empty( self, **kwargs # type: Any ): - # type: (...) -> Dict[str, object] + # type: (...) -> Dict[str, Dict[str, str]] """Get an dictionaries of dictionaries of type with value {}. :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to object, or the result of cls(response) - :rtype: dict[str, object] + :return: dict mapping str to dict mapping str to str, or the result of cls(response) + :rtype: dict[str, dict[str, str]] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, object]] + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, Dict[str, str]]] error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop("error_map", {})) accept = "application/json" @@ -2872,7 +2872,7 @@ def get_dictionary_empty( error = self._deserialize(_models.Error, response) raise HttpResponseError(response=response, model=error) - deserialized = self._deserialize("{object}", pipeline_response) + deserialized = self._deserialize("{{str}}", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) @@ -2885,16 +2885,16 @@ def get_dictionary_empty( def get_dictionary_item_null( self, **kwargs # type: Any ): - # type: (...) -> Dict[str, object] + # type: (...) -> Dict[str, Dict[str, str]] """Get an dictionaries of dictionaries of type with value {"0": {"1": "one", "2": "two", "3": "three"}, "1": null, "2": {"7": "seven", "8": "eight", "9": "nine"}}. :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to object, or the result of cls(response) - :rtype: dict[str, object] + :return: dict mapping str to dict mapping str to str, or the result of cls(response) + :rtype: dict[str, dict[str, str]] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, object]] + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, Dict[str, str]]] error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop("error_map", {})) accept = "application/json" @@ -2918,7 +2918,7 @@ def get_dictionary_item_null( error = self._deserialize(_models.Error, response) raise HttpResponseError(response=response, model=error) - deserialized = self._deserialize("{object}", pipeline_response) + deserialized = self._deserialize("{{str}}", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) @@ -2931,16 +2931,16 @@ def get_dictionary_item_null( def get_dictionary_item_empty( self, **kwargs # type: Any ): - # type: (...) -> Dict[str, object] + # type: (...) -> Dict[str, Dict[str, str]] """Get an dictionaries of dictionaries of type with value {"0": {"1": "one", "2": "two", "3": "three"}, "1": {}, "2": {"7": "seven", "8": "eight", "9": "nine"}}. :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to object, or the result of cls(response) - :rtype: dict[str, object] + :return: dict mapping str to dict mapping str to str, or the result of cls(response) + :rtype: dict[str, dict[str, str]] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, object]] + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, Dict[str, str]]] error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop("error_map", {})) accept = "application/json" @@ -2964,7 +2964,7 @@ def get_dictionary_item_empty( error = self._deserialize(_models.Error, response) raise HttpResponseError(response=response, model=error) - deserialized = self._deserialize("{object}", pipeline_response) + deserialized = self._deserialize("{{str}}", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) @@ -2977,17 +2977,17 @@ def get_dictionary_item_empty( def get_dictionary_valid( self, **kwargs # type: Any ): - # type: (...) -> Dict[str, object] + # type: (...) -> Dict[str, Dict[str, str]] """Get an dictionaries of dictionaries of type with value {"0": {"1": "one", "2": "two", "3": "three"}, "1": {"4": "four", "5": "five", "6": "six"}, "2": {"7": "seven", "8": "eight", "9": "nine"}}. :keyword callable cls: A custom type or function that will be passed the direct response - :return: dict mapping str to object, or the result of cls(response) - :rtype: dict[str, object] + :return: dict mapping str to dict mapping str to str, or the result of cls(response) + :rtype: dict[str, dict[str, str]] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, object]] + cls = kwargs.pop("cls", None) # type: ClsType[Dict[str, Dict[str, str]]] error_map = {401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop("error_map", {})) accept = "application/json" @@ -3011,7 +3011,7 @@ def get_dictionary_valid( error = self._deserialize(_models.Error, response) raise HttpResponseError(response=response, model=error) - deserialized = self._deserialize("{object}", pipeline_response) + deserialized = self._deserialize("{{str}}", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) @@ -3023,7 +3023,7 @@ def get_dictionary_valid( @distributed_trace def put_dictionary_valid( self, - array_body, # type: Dict[str, object] + array_body, # type: Dict[str, Dict[str, str]] **kwargs # type: Any ): # type: (...) -> None @@ -3032,7 +3032,7 @@ def put_dictionary_valid( "eight", "9": "nine"}}. :param array_body: - :type array_body: dict[str, object] + :type array_body: dict[str, dict[str, str]] :keyword callable cls: A custom type or function that will be passed the direct response :return: None, or the result of cls(response) :rtype: None @@ -3056,7 +3056,7 @@ def put_dictionary_valid( header_parameters["Accept"] = self._serialize.header("accept", accept, "str") body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(array_body, "{object}") + body_content = self._serialize.body(array_body, "{{str}}") 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) diff --git a/test/vanilla/Expected/AcceptanceTests/NoHost/nohost/_no_host_service_client.py b/test/vanilla/Expected/AcceptanceTests/NoHost/nohost/_no_host_service_client.py index 917edff42fa..02f8fd54029 100644 --- a/test/vanilla/Expected/AcceptanceTests/NoHost/nohost/_no_host_service_client.py +++ b/test/vanilla/Expected/AcceptanceTests/NoHost/nohost/_no_host_service_client.py @@ -27,7 +27,7 @@ class NoHostServiceClient(NoHostServiceClientOperationsMixin): def __init__( self, - base_url, # type: str + base_url=None, # type: Optional[str] **kwargs # type: Any ): # type: (...) -> None diff --git a/test/vanilla/Expected/AcceptanceTests/NoHost/nohost/aio/_no_host_service_client.py b/test/vanilla/Expected/AcceptanceTests/NoHost/nohost/aio/_no_host_service_client.py index 54fa727e46e..cc57aef1af4 100644 --- a/test/vanilla/Expected/AcceptanceTests/NoHost/nohost/aio/_no_host_service_client.py +++ b/test/vanilla/Expected/AcceptanceTests/NoHost/nohost/aio/_no_host_service_client.py @@ -25,7 +25,7 @@ class NoHostServiceClient(NoHostServiceClientOperationsMixin): :param str base_url: Service URL """ - def __init__(self, base_url: str, **kwargs: Any) -> None: + def __init__(self, base_url: Optional[str] = None, **kwargs: Any) -> None: self._config = NoHostServiceClientConfiguration(**kwargs) self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs)